简体   繁体   中英

TSLint on javascript files

I spent many hour getting this to work, still without success...

The question is: How to use the TSLint on .js file?

Why? I'm trying to have best possible IDE for writing many JavaScript scripts, used in our internal SW.

My vision:

  • I have well documented TypeScript definitions of functions and want to use them in .js.
  • I want to import .js file and see the errors on it. TSLint is capable to do type control on .ts, according to .d.ts files. But on .js file, JSHint/ESLint can only see the function names and parametres from .d.ts files. Ok, but it's not enough. There is no type control in .js, which I'm missing.
  • Use JSHint/ESLint with TSLint in the same time. Using only few functions from both, but making great combo in the end. (TSLint for types, JSHint/ESLint for the rest)
  • Do not allow to use TypeScript keywords in JavaScript.
  • Autocomplete in .js from .d.ts. Ok, this is working.

I can code in VSCode, Sublime, NetBeans.

Thank you for an ideas!

There is some good documentation on this topic in vscode docs: https://code.visualstudio.com/docs/languages/javascript

You can use https://github.com/typings/typings to install any type definitions. https://code.visualstudio.com/docs/languages/javascript#_intellisense-support

You can also add a jsconfig.json to your project similar to tsconfig.json and set module loader to commonJS and target to ES6 if you are using ES2015 syntax in your javascript files. https://code.visualstudio.com/docs/languages/javascript#_javascript-projects-jsconfigjson

In addition you can install ESLint or JSHint extensions. https://code.visualstudio.com/docs/languages/javascript#_javascript-linters-eslint-jshint

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM