TypeStrong / atom-typescript

The only TypeScript package you will ever need

Home Page:https://atom.io/packages/atom-typescript

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Support JavaScript by default

aminya opened this issue · comments

Could you change the settings to support JavaScript by default? For doing so:

  • Adding activation hooks for JavaScript
  • Setting the related config.

In many other IDEs, TypeScript services are used for JavaScript by default.

Not sure if related to this, but I have difficulty with mjs files
image

I'm reluctant to enable javascript by default because this would probably interfere with other javascript packages. I'm inclined to leave it as opt-in. An argument could be made that actual "opt-in" is a bit of a hassle, but since the end-users are implied to be developers who hopefully know what they're doing, it's less of an issue I think.

For mjs, it's not recognized as js file extension. You can add it to Atom-TypeScript settings manually (the change won't take effect until Atom restart/reload):
image

Probably a good idea to add mjs and cjs to the defaults though.

I'm reluctant to enable javascript by default because this would probably interfere with other javascript packages.

I don't this happens. There is no JavaScript IDE for Atom and non of the features that atom-typescript provides are offered anywhere else. There will not be any interference. TypeScript service can work in combination with other packages. As an example, Eslint and TS can both offer listing features.

Especially since I plan to include atom-typescirpt in atom-community builds, I would love to see atom-typescript support JS by default. I plan to give an out of the box experience to the users. Those who like tinkering with settings can use the bare bone atom instead.

Well, feel free to patch your bundled version then, it's really not that hard (add language-javascript:grammar-used to activation hooks and change allowJS default to true -- easy enough with a script).

I am a tinkerer and I hate packages that overstep their bounds. I'm pretty sure there are plenty of users who don't want to deal with TypeScript in their JS code, and are perfectly happy with ESLint. Those people won't appreciate it if Atom-TypeScript starts suddenly activating on JavaScript files and showing hundreds of useless warnings like "could not find declaration for module" etc.

If you feel like that, I can make a synchronized fork instead that chooses some default settings. I will only apply minimal changes for the sake of out of the box experience. Mostly:

  • activation hook for JavaScript
  • Setting that config to true

Sure, that would be fine.

Side note: if you're going to bundle Atom-TypeScript with Atom, you'll probably want to include it into the snapshot which as far as I understand would make activation hooks irrelevant.

@lierdakil I created the package. Instead of patching atom-typescript, I decided to make a proper atom-ide-javascript, and use typescript through the services, etc.
https://github.com/atom-ide-community/atom-ide-javascript

BTW, thanks for the activate command in the last version. Now, here is the function:
https://github.com/atom-ide-community/atom-ide-javascript/blob/master/src/typescript.js

Can we set up service or config that I can turn off some of the typescript linter messages inside atom-ide-javscript? Things like "missing declaration file", or "you can only use type annotation in typescript files" (while flow also allows that).

The last release makes the following settings grammar-scoped:

- suppressAllDiagnostics
- ignoredDiagnosticCodes
- ignoreUnusedSuggestionDiagnostics
- ignoredSuggestionDiagnostics
- ignoreNonSuggestionSuggestionDiagnostics
- unusedAsInfo

Refer to package.json for descriptions:

"ignoredDiagnosticCodes": {
"title": "Ignore diagnostics",
"description": "List of diagnostic codes to ignore, comma-separated. Refer to [diagnosticMessages.json](https://github.com/Microsoft/TypeScript/blob/master/src/compiler/diagnosticMessages.json) for diagnostic codes",
"type": "array",
"items": {
"type": "string"
},
"default": [],
"order": 80
},
"ignoreUnusedSuggestionDiagnostics": {
"title": "Ignore 'unused parameter/variable/etc' suggestion diagnostics",
"description": "When `noUnusedLocals` etc are disabled, TypeScript 2.9 and above still report this as 'suggestions'. This option will filter these out",
"type": "boolean",
"default": "false",
"order": 100
},
"ignoreNonSuggestionSuggestionDiagnostics": {
"title": "Ignore suggestion diagnostics that are not actionable suggestions",
"description": "TypeScript server reports some error-type diagnostics on the suggestion channel. Enabling this option will suppress those",
"type": "boolean",
"default": "false",
"order": 105
},
"ignoredSuggestionDiagnostics": {
"title": "Ignore suggestion diagnostics",
"description": "List of suggestion-type diagnostic codes to ignore, comma-separated. Refer to [diagnosticMessages.json](https://github.com/Microsoft/TypeScript/blob/master/src/compiler/diagnosticMessages.json) for diagnostic codes",
"type": "array",
"items": {
"type": "string"
},
"default": [],
"order": 110
},
"suppressAllDiagnostics": {
"title": "Suppress all diagnostics",
"description": "The package will not report any problems with TypeScript. Use only if you know what you are doing",
"type": "boolean",
"default": "false",
"order": 120
},

"unusedAsInfo": {
"title": "Show unused values with severity info",
"description": "Show unused values with severity 'info' instead of 'error'",
"type": "boolean",
"default": true,
"order": 90
},

You can override those specifically for source.js scope (for instance), e.g.

atom.config.set("atom-typescript.suppressAllDiagnostics", true, {scopeSelector: ".source.js"})

You're probably most interested in ignoredDiagnosticCodes. Refer to https://github.com/Microsoft/TypeScript/blob/master/src/compiler/diagnosticMessages.json for codes (codes are stable, unlike messages, which can be affected by version, locale, etc)

This issue has been marked as stale because it did not have any activity for the last 90 days or more. Remove the stale label or comment or this will be closed in 14 days