Sublime 3 JS Snippets to Typescript

661 views Asked by At

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

1

There are 1 answers

2
Needpoule On BEST ANSWER

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>