-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Consistently avoid module resolution errors when using getSymbolAtLocation
#58668
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
Consistently avoid module resolution errors when using getSymbolAtLocation
#58668
Conversation
src/compiler/checker.ts
Outdated
@@ -4521,17 +4521,17 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { | |||
const errorMessage = isClassic ? | |||
Diagnostics.Cannot_find_module_0_Did_you_mean_to_set_the_moduleResolution_option_to_nodenext_or_to_add_aliases_to_the_paths_option | |||
: Diagnostics.Cannot_find_module_0_or_its_corresponding_type_declarations; | |||
return resolveExternalModuleNameWorker(location, moduleReferenceExpression, ignoreErrors ? undefined : errorMessage); | |||
return resolveExternalModuleNameWorker(location, moduleReferenceExpression, ignoreErrors ? undefined : errorMessage, ignoreErrors); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the core of the fix. It propagates the ignoreErrors
and the intention to ignore them is highlighted in the comment here:
https://github.dev/microsoft/TypeScript/blob/af3a61fe4487a92d59f9479aa4249d897b91af14/src/compiler/checker.ts#L1654-L1658
@@ -114,4 +114,58 @@ describe("unittests:: tsc:: composite::", () => { | |||
}, | |||
], | |||
}); | |||
|
|||
verifyTsc({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
those are tests related to the referenced issue
"referencedMap": { | ||
"./main.ts": [ | ||
"./data.d.json.ts" | ||
] | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This feels like an improvement - even though there is a resolution error here, it still depends on this file so it should be reflected here. IIRC, there are other instances of something like this - when despite a resolution errors requested modules are listed here.
[96mb.ts[0m:[93m1[0m:[93m8[0m - [91merror[0m[90m TS5097: [0mAn import path can only end with a '.ts' extension when 'allowImportingTsExtensions' is enabled. | ||
|
||
[7m1[0m import "./a.ts"; | ||
[7m [0m [91m ~~~~~~~~[0m | ||
|
||
[[90mHH:MM:SS AM[0m] Found 1 error. Watching for file changes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this error should be reported but currently it was reported here accidentally. It's not consistent with a regular - non-incremental/composite executions. I raised an issue about it here: #58725
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FWIW resolving these would be #50394
fe293a5
to
039a66e
Compare
@typescript-bot test it |
Hey @jakebailey, I've packed this into an installable tgz. You can install it for testing by referencing it in your
and then running There is also a playground for this build and an npm module you can use via |
Hey @jakebailey, the results of running the DT tests are ready. Everything looks the same! |
@jakebailey Here are the results of running the user tests with tsc comparing Everything looks good! |
@jakebailey Here they are:
tscComparison Report - baseline..pr
System info unknown
Hosts
Scenarios
Developer Information: |
@jakebailey Here are the results of running the top 400 repos with tsc comparing Everything looks good! |
This appears to be out of date with main. |
fixes #58600
fixes #58791