-
Notifications
You must be signed in to change notification settings - Fork 12.6k
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
Cannot find name 'require' and 'module' when @ts-check is on #21933
Comments
So two things:
|
If we resolve the name If this is a .ts file we should error like we do today, with an explanation If this is in a .js file, we should not, since we already treat these in a special way. |
We should also special-case the built-in node modules and give an even better error message, like "Can not find module "fs". Did you forget to install |
We have the list of built-in node modules in https://github.com/Microsoft/TypeScript/blob/master/src/services/jsTyping.ts#L34. we should use that in giving ppl better error message, and enabling a quick fix to install the app for you. |
We spoke about this with @mjbvz a few months ago.
When tossing
checkJs
or// @ts-check
into a project, users almost immediately get feedback likeCannot find name 'require'
which is frustrating because we specifically understand howrequire
works.I understand that we want users to have more actionable feedback when they require a Node built-in, but the current behavior is not ideal.
The text was updated successfully, but these errors were encountered: