Making js snippets work in typescript files


#1

There are some great snippet packages like standardjs-snippets and best-js-snippets, the problem is that they don’t work inside typescript files. Is it possible to change this by configuration, and if so, how?

Thanks.


#2

It’s not possible to configure the packages, because snippet scopes are hard-coded in the package files. You’ll have to do one of the following things:

  1. Use a JavaScript grammar instead of TypeScript. This might cause errors if you’re also using a linter at the same time, but your snippets will go in easily.
  2. Copy the specific snippets you want to snippets.cson and change the scope name to .source.ts.
  3. Navigate to your projects folder and use git clone to clone each of the repos, then use apm link inside each of them to create symbolic links from .atom/packages/. Finally, go through the repos and change each of the scope names to read .source.js, .source.ts so that the snippets will all work for both languages.