Skip to content

Consistently avoid module resolution errors when using getSymbolAtLocation - #58668

Merged
Jake Bailey (jakebailey) merged 10 commits into
microsoft:mainfrom
Andarist:fix/crash-error-on-synthetic-import
Jun 24, 2024
Merged

Consistently avoid module resolution errors when using getSymbolAtLocation#58668
Jake Bailey (jakebailey) merged 10 commits into
microsoft:mainfrom
Andarist:fix/crash-error-on-synthetic-import

Conversation

@Andarist

@AndaristMateusz Burzyński (Andarist) commented May 27, 2024

Copy link
Copy Markdown
Contributor

fixes#58600
fixes#58791

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);

Copy link
Copy Markdown
ContributorAuthor

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

Comment threadsrc/compiler/checker.ts Outdated
Comment threadsrc/testRunner/unittests/programApi.ts Outdated
],
});

verifyTsc({

Copy link
Copy Markdown
ContributorAuthor

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

Comment threadtests/baselines/reference/moduleAugmentationGlobal5.js Outdated
Comment on lines +111 to +115
"referencedMap": {
"./main.ts": [
"./data.d.json.ts"
]
},

Copy link
Copy Markdown
ContributorAuthor

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.

Comment on lines -50 to -53
b.ts:1:8 - error TS5097: An import path can only end with a '.ts' extension when 'allowImportingTsExtensions' is enabled.

1 import "./a.ts";
   ~~~~~~~~

[HH:MM:SS AM] Found 1 error. Watching for file changes.

Copy link
Copy Markdown
ContributorAuthor

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

Copy link
Copy Markdown
Member

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

@Andarist
Mateusz Burzyński (Andarist)force-pushed the fix/crash-error-on-synthetic-import branch from fe293a5 to 039a66eCompareJune 7, 2024 07:20
@jakebailey

Copy link
Copy Markdown
Member

TypeScript Bot (@typescript-bot) test it
TypeScript Bot (@typescript-bot) pack this

@typescript-bot

TypeScript Bot (typescript-bot) commented Jun 7, 2024

Copy link
Copy Markdown
Contributor

Starting jobs; this comment will be updated as builds start and complete.

CommandStatusResults
test top400✅ Started✅ Results
user test this✅ Started✅ Results
run dt✅ Started✅ Results
perf test this faster✅ Started👀 Results
pack this✅ Started✅ Results

@typescript-bot

TypeScript Bot (typescript-bot) commented Jun 7, 2024

Copy link
Copy Markdown
Contributor

Hey Jake Bailey (@jakebailey), I've packed this into an installable tgz. You can install it for testing by referencing it in your package.json like so:

{
"devDependencies": {
"typescript": "https://typescript.visualstudio.com/cf7ac146-d525-443c-b23c-0d58337efebc/_apis/build/builds/162131/artifacts?artifactName=tgz&fileId=71D5E87C0254083AD9A25080B19F958EEA359780CCE198BDB12841AA1D3452D702&fileName=/typescript-5.6.0-insiders.20240607.tgz"
}
}

and then running npm install.


There is also a playground for this build and an npm module you can use via "typescript": "npm:@typescript-deploys/pr-build@5.6.0-pr-58668-2".;

@typescript-bot

Copy link
Copy Markdown
Contributor

Hey Jake Bailey (@jakebailey), the results of running the DT tests are ready.

Everything looks the same!

You can check the log here.

@typescript-bot

Copy link
Copy Markdown
Contributor

Jake Bailey (@jakebailey) Here are the results of running the user tests with tsc comparing main and refs/pull/58668/merge:

Everything looks good!

@typescript-bot

Copy link
Copy Markdown
Contributor

Jake Bailey (@jakebailey)
The results of the perf run you requested are in!

Here they are:

tsc

Comparison Report - baseline..pr
MetricbaselineprDeltaBestWorstp-value
Compiler-Unions - node (v18.15.0, x64)
Errors3030~~~p=1.000 n=6
Symbols62,15362,153~~~p=1.000 n=6
Types50,24250,242~~~p=1.000 n=6
Memory used192,948k (± 0.79%)193,600k (± 0.91%)~192,343k195,863kp=0.173 n=6
Parse Time1.30s (± 0.90%)1.30s (± 0.58%)~1.29s1.31sp=0.933 n=6
Bind Time0.72s0.72s~~~p=1.000 n=6
Check Time9.57s (± 0.21%)9.60s (± 0.47%)~9.53s9.65sp=0.164 n=6
Emit Time2.75s (± 0.82%)2.76s (± 1.04%)~2.73s2.80sp=0.685 n=6
Total Time14.34s (± 0.16%)14.38s (± 0.28%)~14.32s14.42sp=0.119 n=6
angular-1 - node (v18.15.0, x64)
Errors55~~~p=1.000 n=6
Symbols944,109944,109~~~p=1.000 n=6
Types407,049407,049~~~p=1.000 n=6
Memory used1,222,237k (± 0.01%)1,222,246k (± 0.00%)~1,222,198k1,222,341kp=0.936 n=6
Parse Time6.79s (± 0.57%)6.78s (± 0.57%)~6.72s6.83sp=0.687 n=6
Bind Time1.87s (± 0.40%)1.88s (± 0.22%)~1.87s1.88sp=0.100 n=6
Check Time31.29s (± 0.36%)31.25s (± 0.23%)~31.15s31.37sp=0.688 n=6
Emit Time15.22s (± 0.53%)15.24s (± 0.84%)~15.03s15.35sp=0.575 n=6
Total Time55.18s (± 0.31%)55.15s (± 0.30%)~54.94s55.38sp=0.688 n=6
mui-docs - node (v18.15.0, x64)
Errors55~~~p=1.000 n=6
Symbols2,063,4742,063,474~~~p=1.000 n=6
Types905,299905,299~~~p=1.000 n=6
Memory used2,072,777k (± 0.01%)2,072,760k (± 0.01%)~2,072,576k2,072,908kp=0.630 n=6
Parse Time8.10s (± 0.35%)8.11s (± 0.28%)~8.09s8.15sp=0.685 n=6
Bind Time2.76s (± 0.91%)2.75s (± 0.81%)~2.72s2.78sp=0.805 n=6
Check Time82.47s (± 0.40%)82.49s (± 0.56%)~82.08s83.13sp=0.810 n=6
Emit Time0.16s (± 3.16%)0.16s (± 3.16%)~0.16s0.17sp=1.000 n=6
Total Time93.50s (± 0.36%)93.52s (± 0.53%)~93.06s94.22sp=0.689 n=6
self-build-src - node (v18.15.0, x64)
Errors00~~~p=1.000 n=6
Symbols1,230,4241,230,497+73 (+ 0.01%)~~p=0.001 n=6
Types261,178261,204+26 (+ 0.01%)~~p=0.001 n=6
Memory used2,351,921k (± 0.04%)2,351,800k (± 0.04%)~2,350,729k2,353,077kp=0.936 n=6
Parse Time4.97s (± 0.95%)4.98s (± 0.91%)~4.95s5.07sp=0.810 n=6
Bind Time1.90s (± 0.40%)1.89s (± 0.67%)~1.87s1.90sp=0.301 n=6
Check Time34.15s (± 0.29%)34.03s (± 0.33%)~33.89s34.15sp=0.173 n=6
Emit Time2.61s (± 1.72%)2.62s (± 3.04%)~2.53s2.75sp=0.810 n=6
Total Time43.64s (± 0.17%)43.53s (± 0.39%)~43.38s43.84sp=0.093 n=6
self-build-src-public-api - node (v18.15.0, x64)
Errors00~~~p=1.000 n=6
Symbols1,230,4241,230,497+73 (+ 0.01%)~~p=0.001 n=6
Types261,178261,204+26 (+ 0.01%)~~p=0.001 n=6
Memory used2,427,402k (± 0.05%)2,427,814k (± 0.02%)~2,427,190k2,428,580kp=0.471 n=6
Parse Time5.20s (± 0.95%)5.19s (± 1.58%)~5.09s5.30sp=0.748 n=6
Bind Time1.69s (± 0.79%)1.68s (± 0.70%)~1.66s1.69sp=0.241 n=6
Check Time34.58s (± 0.13%)34.51s (± 0.39%)~34.33s34.69sp=0.378 n=6
Emit Time2.67s (± 3.04%)2.67s (± 0.64%)~2.65s2.70sp=1.000 n=6
Total Time44.15s (± 0.27%)44.06s (± 0.42%)~43.82s44.30sp=0.378 n=6
self-compiler - node (v18.15.0, x64)
Errors00~~~p=1.000 n=6
Symbols259,181259,182+1 (+ 0.00%)~~p=0.001 n=6
Types105,173105,173~~~p=1.000 n=6
Memory used428,839k (± 0.01%)428,815k (± 0.01%)~428,781k428,843kp=0.230 n=6
Parse Time4.10s (± 0.62%)4.06s (± 0.43%)-0.04s (- 0.85%)4.04s4.09sp=0.034 n=6
Bind Time1.63s (± 1.43%)1.63s (± 1.39%)~1.60s1.66sp=0.568 n=6
Check Time22.36s (± 0.35%)22.36s (± 0.35%)~22.27s22.46sp=0.872 n=6
Emit Time1.72s (± 1.68%)1.72s (± 1.74%)~1.68s1.76sp=0.871 n=6
Total Time29.80s (± 0.31%)29.77s (± 0.26%)~29.65s29.84sp=0.421 n=6
ts-pre-modules - node (v18.15.0, x64)
Errors3535~~~p=1.000 n=6
Symbols224,565224,565~~~p=1.000 n=6
Types93,73493,734~~~p=1.000 n=6
Memory used369,754k (± 0.02%)369,820k (± 0.03%)~369,637k369,925kp=0.298 n=6
Parse Time3.45s (± 0.81%)3.45s (± 0.68%)~3.42s3.49sp=0.570 n=6
Bind Time1.94s (± 0.98%)1.94s (± 0.84%)~1.92s1.96sp=0.744 n=6
Check Time19.35s (± 0.31%)19.42s (± 0.28%)~19.34s19.49sp=0.077 n=6
Emit Time0.00s0.00s~~~p=1.000 n=6
Total Time24.75s (± 0.35%)24.80s (± 0.25%)~24.75s24.89sp=0.335 n=6
vscode - node (v18.15.0, x64)
Errors00~~~p=1.000 n=6
Symbols2,851,2402,851,240~~~p=1.000 n=6
Types967,181967,181~~~p=1.000 n=6
Memory used3,023,304k (± 0.00%)3,023,299k (± 0.00%)~3,023,247k3,023,394kp=0.689 n=6
Parse Time13.96s (± 0.29%)13.92s (± 0.24%)~13.88s13.97sp=0.126 n=6
Bind Time4.17s (± 0.24%)4.16s (± 0.29%)~4.15s4.18sp=0.490 n=6
Check Time76.71s (± 2.67%)75.31s (± 2.46%)~73.80s77.73sp=0.230 n=6
Emit Time21.20s (± 8.72%)22.51s (± 8.25%)~20.11s24.01sp=0.093 n=6
Total Time116.03s (± 0.35%)115.90s (± 0.21%)~115.67s116.34sp=0.810 n=6
webpack - node (v18.15.0, x64)
Errors00~~~p=1.000 n=6
Symbols266,415266,415~~~p=1.000 n=6
Types108,580108,580~~~p=1.000 n=6
Memory used411,445k (± 0.01%)411,426k (± 0.01%)~411,371k411,474kp=0.689 n=6
Parse Time3.87s (± 0.67%)3.84s (± 0.77%)~3.80s3.87sp=0.106 n=6
Bind Time1.67s (± 1.03%)1.67s (± 0.72%)~1.66s1.69sp=0.934 n=6
Check Time17.08s (± 0.27%)17.06s (± 0.21%)~17.03s17.12sp=0.296 n=6
Emit Time0.00s0.00s~~~p=1.000 n=6
Total Time22.62s (± 0.28%)22.57s (± 0.15%)~22.53s22.62sp=0.146 n=6
xstate-main - node (v18.15.0, x64)
Errors00~~~p=1.000 n=6
Symbols526,436526,436~~~p=1.000 n=6
Types179,425179,425~~~p=1.000 n=6
Memory used464,208k (± 0.04%)464,080k (± 0.08%)~463,585k464,453kp=0.810 n=6
Parse Time3.13s (± 0.77%)3.15s (± 0.58%)~3.13s3.17sp=0.252 n=6
Bind Time1.18s (± 0.46%)1.19s (± 0.82%)~1.18s1.21sp=0.201 n=6
Check Time18.10s (± 0.60%)18.08s (± 0.53%)~17.89s18.14sp=0.470 n=6
Emit Time0.00s0.00s (±244.70%)~0.00s0.01sp=0.405 n=6
Total Time22.42s (± 0.42%)22.42s (± 0.39%)~22.25s22.49sp=1.000 n=6
System info unknown
Hosts
  • node (v18.15.0, x64)
Scenarios
  • Compiler-Unions - node (v18.15.0, x64)
  • angular-1 - node (v18.15.0, x64)
  • mui-docs - node (v18.15.0, x64)
  • self-build-src - node (v18.15.0, x64)
  • self-build-src-public-api - node (v18.15.0, x64)
  • self-compiler - node (v18.15.0, x64)
  • ts-pre-modules - node (v18.15.0, x64)
  • vscode - node (v18.15.0, x64)
  • webpack - node (v18.15.0, x64)
  • xstate-main - node (v18.15.0, x64)
BenchmarkNameIterations
Currentpr6
Baselinebaseline6

Developer Information:

Download Benchmarks

@typescript-bot

Copy link
Copy Markdown
Contributor

Jake Bailey (@jakebailey) Here are the results of running the top 400 repos with tsc comparing main and refs/pull/58668/merge:

Everything looks good!

@jakebailey

Copy link
Copy Markdown
Member

This appears to be out of date with main.

@jakebailey
Jake Bailey (jakebailey) merged commit 3743fbc into microsoft:mainJun 24, 2024
@microsoftMicrosoft (microsoft) locked as resolved and limited conversation to collaborators Oct 16, 2025
Sign up for freeto subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

For Milestone BugPRs that fix a bug with a specific milestone

Projects

None yet

7 participants

@Andarist@jakebailey@typescript-bot@fatcerberus@sheetalkamat@ehoogeveen-medweb@iisaduan