Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Build] Support IDE Intellisense #4690

Closed
unlikelyzero opened this issue Jan 7, 2022 · 3 comments · Fixed by #4643
Closed

[Build] Support IDE Intellisense #4690

unlikelyzero opened this issue Jan 7, 2022 · 3 comments · Fixed by #4643
Labels
type:maintenance tests, chores, or project maintenance
Milestone

Comments

@unlikelyzero
Copy link
Contributor

unlikelyzero commented Jan 7, 2022

Summary

Let's summarize what all is needed for IDE Intellisense support and maybe some links to how it works

Note: Added a Github Discussion for this Typescript topics: #4693

@unlikelyzero unlikelyzero added the type:maintenance tests, chores, or project maintenance label Jan 7, 2022
@unlikelyzero unlikelyzero linked a pull request Jan 7, 2022 that will close this issue
8 tasks
@trusktr
Copy link
Contributor

trusktr commented Jan 7, 2022

By default nothing is needed in VS Code and it will start automatically type checking things. This is why in a plain .js file, you can hover on a variable you declared, f.e. const foo = 123, and you will see that it tells you it is type number. VS Code does this with TypeScript.

However, if one adds a tsconfig.json file (the same config file that TypeScript would use if we were to compile typescript code to JS) to a project, then VS Code will use this to configure it internal TypeScript instance.

In the config file I added in #4643 specifies for VS Code to check plain JS files (i.e. actually show errors) due to the checkJs and allowJs options. These two options (along with the supplemental other ones like strict: true to enforce strict type checking), cause VS Code to actually show red squigglies on type errors.

Without allowJs/checkJs, no red squigglies will be shown by VS Code.

To test this out, you can write the following snippet in any file (while on that #4643 branch which isn't merged yet, and after all dependencies are installed) then you'll see a type error and you can hover on the variable names to see more information:

/* @type {number} */
const foo = 123

/* @type {string} */
let bar = foo // type error: number is not assignable to string

Although this error is displayed by VS Code, it has nothing to do with our build system and that continues to work as-is. It is purely a cosmetic feature that we see in the editor for dev convenience (converting files to .ts would be a different effort that would require build changes).

It's more like a lint feature that doesn't require code changes. If we want to, we can set strict to false which will make TypeScript automatically assign the type any to many variable, and will reduce the number of type errors at the loss of type safety (we have no type safety to begin with since we have a lot of plain JS without TS being able to infer types anyway), but this at least allows us to begin to write code that type checks, preventing some errors, and we can modify improve thing here or there little by little.

@unlikelyzero unlikelyzero added this to the Target: 1.8.4 milestone Jan 7, 2022
@unlikelyzero unlikelyzero added the needs:test instructions Missing testing notes label Jan 7, 2022
@unlikelyzero unlikelyzero added unverified and removed needs:test instructions Missing testing notes labels Jan 24, 2022
@unlikelyzero
Copy link
Contributor Author

Verified Fixed

@nikhilmandlik
Copy link
Contributor

Verified Fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:maintenance tests, chores, or project maintenance
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants