Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sublime 3 JS Snippets to Typescript

I have a lot of useful snippets on JS. Like cl for console.log(); or

fn for

function methodName (arguments) {
    // body...
}

However I can't use them on *.ts files.

How can manage the snippets and complation for js to ts also.

Thanks

like image 857
engincancan Avatar asked Jun 18 '15 11:06

engincancan


People also ask

Does Sublime Text support TypeScript?

TypeScript Plugin for Sublime Text. The plugin uses an IO wrapper around the TypeScript language services to provide an enhanced Sublime Text experience when working with TypeScript code.

How do I run a TypeScript file in Sublime Text 3?

Open the typescript file -that you need to run- on sublime text 3. Click on Tools tab, then Build System , then New Build System . A new file will open.. override its content with the following JSON object. The cmd parameter uses ts-node based on the suggestion of @idleberg.

How do I edit a sublime snippet?

How to edit built-in snippets in Sublime Text [Quick Guide][Super Easy Method] Tools — >Command Palette — >Package Control: Install Package. Step 2: Search for the PackageResourceViewer in the Package Control and install it.


1 Answers

You have to add a typescript source to your snippets scope.

<scope>source.js, source.ts</scope>

There is a exemple of snippet that you can find in the TypeScript package:

<snippet>
    <content><![CDATA[
class ${2:ClassName}${3: extends ${4:AnotherClass}} {
    $5
    ${6:constructor}(${7:argument}) {
        ${0:// code...}
    }
}
]]></content>
    <tabTrigger>class</tabTrigger>
    <scope>source.ts</scope>
    <description>class …</description>
</snippet>
like image 184
Needpoule Avatar answered Oct 20 '22 00:10

Needpoule