-
Notifications
You must be signed in to change notification settings - Fork 73
Only Lint in TypeScript Projects? #352
Comments
Hmm, this server will work with whatever is configured to be included in the tsconfig and sent through didOpen/didChange etc. Not sure how TS is supposed to know what files you want it to run on and which not other than that? |
@felixfbecker if there is no tsconfig at all should the server still do type hinting in a |
Yes, if there is no tsconfig detected a default is used because JS devs usually don't have a tsconfig. This matches what VS Code does. To understand the problem better, let me repeat my question: How would you want TS to know what files you want it to run on and which not other than that? |
@felixfbecker I think we're talking about different things? The server has TS only features and JS features. I think the TS only features should only run in the presence of a tsconfig the other features should run in any JS file. Does that clarify? |
Not sure what TS only features / JS features you mean? The feature set is the same, it's the same language service running as TS is just a superset of JS. It simply parses the JS as TS. The parser can't handle Flow syntax of course, because that is not valid JS |
@wldcordeiro I might have similar issues as yours. Quick confirmation here.
// foo.js
// @flow
type SetAuthState = (?string) => object
// ~~~~~~~~~~~~
// RED LINE LINT ERROR HERE
const setAuthState: SetAuthState = (publicKey) => ({
payload: { publicKey }
})
|
@liuderchi that's precisely it! I'm seeing the TS linting in a JS codebase that has no tsconfig and Flow typed code. That kind of warning should only appear when the codebase has a tsconfig so the tool can be used in concert with others and not degrade user experience. |
The errors you are seeing are not a linting feature (that would be ts-lint). This exact problem has come up for VS Code here and here. |
It might be reasonable for the TS parser to ignore JS files that have the Have you tried creating a tsconfig.json with |
@tomv564 thanks for clarifying that it's not linting related. I've edited my comment. @wldcordeiro maybe it's better to edit the issue title to avoid confusion if you are using vscode there is solution of setting project config in your project looks like currently only babel with flow plugin can parse js code with flow type, but too bad we're not using it. @felixfbecker I tried adding following {
"exclude": [
"foo.js"
]
} |
I think the real problem here is flow typed files are not valid plain JavaScript despite the file extension. For this to ever work properly the TypeScript Server team would need to bake knowledge of flow into their server so they can 'ignore' the annotations. Given they are competing technologies I personally think that is unlikely. |
News about this? |
Given the simplicity of checking for |
@skylize The package that reads the text is the Microsoft TypeScript server itself - two packages upstream. |
Throwing my opinion in the ring here and saying that it's been super frustrating to working with a set of projects, some javascript/typescript and some flow. I'm with @skylize here that a simple check for |
This question is related to the new Atom IDE Typescript server. But I've noticed that this is the tool behind it and that there isn't much they can do to enable this type of thing. But is there a way to get the server to only do the TS linting in TS Projects? I have both the TS IDE server and Flow-type as I work on projects using both and it becomes unbearable to see all the red but I really like what this server does for plain JS. If it is something that is already possible could I be pointed to how? I'll PR the Atom plugin with the fix. 😄
The text was updated successfully, but these errors were encountered: