Typescript: Enable JavaScript specific warning behavior

Created on 2 Feb 2016  路  3Comments  路  Source: microsoft/TypeScript

See #6658 for background.

Currently for JavaScript files we provide a very limited set of errors, mostly for syntax errors. There are a number of grammatical and type errors that would be useful to display also.

Brief notes from ad hoc discussion in the team room include:

  • Move the code that flags TypeScript syntax in JavaScript files for better error handling
  • Add a distinction between errors and warnings to avoid "valid" JavaScript containing errors
  • Make the warnings user configurable as part of the project (i.e. may enable/disable certain warnings)

More detailed design to come...

Committed JavaScript Suggestion VS Code Tracked

Most helpful comment

Hey TS team, there is currently a somewhat relevant discussion to this in #9694. (A flow-style system of allowing fully checked type annotations in comments in .js files). It seems already a little bit contentious and there is a bit of noise in that issue (sorry!)
I have started work on a basic PR to demonstrate this functionality and am willing to do up a proper proposal and even implementation if the team would be open to that. Would this functionality ever be considered?

All 3 comments

From our own usage for Salsa for editing JS, we miss a warning about undefined variables. In eslint:

{
    "rules": {
        "no-undef": 2,
        "no-unused-vars": 1
    }
}

The other warning we got used is the one about unused local variables.

From #9132, it is clear that point 2 and 3 are valid for these type of issues. When importing just for emitting purposes (e.g. import 'foo.js';) some developers would like to be warned that that file is not resolvable, but many others would be expressly importing something that is only resolvable at run-time. So the ability to a) only have it be a warning and b) allow that warning to be turn off.

Hey TS team, there is currently a somewhat relevant discussion to this in #9694. (A flow-style system of allowing fully checked type annotations in comments in .js files). It seems already a little bit contentious and there is a bit of noise in that issue (sorry!)
I have started work on a basic PR to demonstrate this functionality and am willing to do up a proper proposal and even implementation if the team would be open to that. Would this functionality ever be considered?

Was this page helpful?
0 / 5 - 0 ratings