TypeStrong / atom-typescript

The only TypeScript package you will ever need
https://atom.io/packages/atom-typescript
MIT License
1.13k stars 205 forks source link

Support JavaScript by default #1551

Closed aminya closed 3 years ago

aminya commented 4 years ago

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

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

aminya commented 4 years ago

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

lierdakil commented 4 years ago

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.

aminya commented 4 years ago

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.

lierdakil commented 4 years ago

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.

aminya commented 4 years ago

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:

lierdakil commented 4 years ago

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.

aminya commented 4 years ago

@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).

lierdakil commented 4 years ago

The last release makes the following settings grammar-scoped:

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

Refer to package.json for descriptions: https://github.com/TypeStrong/atom-typescript/blob/2a131cae505f65903610656702194291cd212d48/package.json#L156-L196 https://github.com/TypeStrong/atom-typescript/blob/2a131cae505f65903610656702194291cd212d48/package.json#L30-L36

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)

github-actions[bot] commented 3 years ago

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