You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
To reproduce, the file is empty other than the function I've defined, including not having any import statements.
export async function Test(test, user) {
}
Whats weird is this:
if I tell it to infer parameter types, I get this:
export async function Test(test: any, user: any) {
}
Which is correct I guess.
But if the function contains just one line of code, I get this:
export async function getPlantMetric(test: any, user: import("../../../../../../../../../project/some/path//shared/models/User").User) {
if (!test) throw new Error('whatever!');
}
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.
Reacted by Andrew Branch and Titian Cernicova-Dragomir
Josh Pike (@jpike88) I can’t reproduce this with the info provided. I’m sure it must depend somewhat upon the file that exports some User type, and possibly upon project settings. Can you create or give me access to a repo that exhibits the issue, or describe more details about how to repro? Assume all details are relevant unless you can prove them otherwise.
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.
Activity
DanielRosenwasser commentedon Aug 15, 2019
We should always prefer an
importstatement at the top of the file.andrewbranch commentedon Aug 15, 2019
Josh Pike (@jpike88) can you share the contents of that file pre-“infer type from usage” command?
jpike88 commentedon Aug 20, 2019
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.
fatcerberus commentedon Aug 20, 2019
How is it even arriving at that type for
userif the only thing in the function is just an unconditionalthrow?andrewbranch commentedon Sep 16, 2019
Josh Pike (@jpike88) I can’t reproduce this with the info provided. I’m sure it must depend somewhat upon the file that exports some
Usertype, and possibly upon project settings. Can you create or give me access to a repo that exhibits the issue, or describe more details about how to repro? Assume all details are relevant unless you can prove them otherwise.jpike88 commentedon Sep 19, 2019
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.
andrewbranch commentedon Oct 4, 2019
Somewhere else in the project, something is calling that function with an argument of type
User. The code that triggers this issue isn’t shown.