-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Infering type from usage does silly import #32910
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
Comments
We should always prefer an |
@jpike88 can you share the contents of that file pre-“infer type from usage” command? |
To reproduce, the file is empty other than the function I've defined, including not having any import statements.
Whats weird is this: if I tell it to infer parameter types, I get this:
Which is correct I guess. But if the function contains just one line of code, I get this:
The second argument attempts to get at an import, but in doing so incorrectly inlines an import() function instead of pulling it in at the top. |
How is it even arriving at that type for |
@jpike88 I can’t reproduce this with the info provided. I’m sure it must depend somewhat upon the file that exports some |
Sorry don't have the time, and I guess is an edge case. But I think that there should be a VSCode setting that disables the import() function from being used at all when these sorts of judgements are being made. |
Somewhere else in the project, something is calling that function with an argument of type |
TypeScript Version: [email protected]
myInterfaceFile.ts
another file, when using 'infer type from usage' option in VSCode
An 'import' function shouldn't be called.
The text was updated successfully, but these errors were encountered: