Skip to content
This repository was archived by the owner on Dec 15, 2022. It is now read-only.

Linting Types is Overstepping #19

Closed
wldcordeiro opened this issue Sep 12, 2017 · 12 comments
Closed

Linting Types is Overstepping #19

wldcordeiro opened this issue Sep 12, 2017 · 12 comments

Comments

@wldcordeiro
Copy link

I'm using this server to get just the JavaScript features and have the flow server installed as well. I'm getting errors about defining flow types in my JS files. There should be some better detection of typescript before it applies the linting rule.

@damieng
Copy link
Contributor

damieng commented Sep 12, 2017

Can you provide a screen-shot?

@wldcordeiro
Copy link
Author

screen shot 2017-09-12 at 4 22 16 pm 2
screen shot 2017-09-12 at 4 22 37 pm

@damieng
Copy link
Contributor

damieng commented Sep 12, 2017

I see.

The underlying TypeScript language server isn't capable of ignoring Flow annotations unfortunately. It can treat files as plain JS or as TypeScript but not Flow.

You are best off using ide-flow if you are editing flow code. If you also want ide-typescript installed for typescript files you can turn off JS entirely for it from the Atom Settings page under ide-typescript.

@wldcordeiro
Copy link
Author

But in a project that isn't using Typescript it shouldn't complain about type annotations in JS files.

@damieng
Copy link
Contributor

damieng commented Sep 12, 2017

The problem is a javascript file with flow type annotations isn't plain javascript.

@damieng
Copy link
Contributor

damieng commented Sep 13, 2017

I should clarify - if this was easy to achieve we would still do it. Unfortunately it's a limitation of the underlying language server that does all the hard work (Microsoft's TypeScript server)

@wldcordeiro
Copy link
Author

There's no way to enable the JS portions of the server without the TypeScript portions? You have the checkbox in the settings for JS.

@damieng
Copy link
Contributor

damieng commented Sep 14, 2017

No.

@Arcanemagus
Copy link

@wldcordeiro The reason that can't be done is there are no "JS portions of the server". The LSP treats all code as TypeScript, it just happens to somewhat work for JS as TypeScript is for the most part a superset of JS. Where it fails is when you start using parts of JS (or non-JS like Flow) that TypeScript doesn't support.

@skylize
Copy link

skylize commented Jan 27, 2018

I should clarify - if this was easy to achieve we would still do it.

Flow files should be annotated with // @flow or /* @flow */ at the top of the file. This makes them incredibly simple to identify. If typescript server finds a flow annotation at the top of the file, just don't process it any further, or silence any results. What is hard about that?

@damieng
Copy link
Contributor

damieng commented Jan 27, 2018

@skylize The 'hard' part about that is we don't own the typescript server - Microsoft does. They'll need to support it.

@skylize
Copy link

skylize commented Jan 27, 2018

Ah, I see. And looking at your code I don't see anywhere the text content passes through for you to check it.

Worth recording here that this has been raised already upstream.
sourcegraph/javascript-typescript-langserver#352

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants