Skip to content
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

Debug failure at resolveExternalModule after allowArbitraryExtensions #52182

Closed
jakebailey opened this issue Jan 10, 2023 · 4 comments · Fixed by #52189
Closed

Debug failure at resolveExternalModule after allowArbitraryExtensions #52182

jakebailey opened this issue Jan 10, 2023 · 4 comments · Fixed by #52189
Assignees
Labels
Bug A bug in TypeScript

Comments

@jakebailey
Copy link
Member

jakebailey commented Jan 10, 2023

As of 89e928e (#51435), the perf runner is Debug asserting: https://typescript.visualstudio.com/TypeScript/_build/results?buildId=142178&view=logs&j=fd490c07-0b22-5182-fac9-6d67fe1e939b

>> /home/setup/vsts-agent/_work/7/s/built/local/tsc.js:109755
>>       throw e;
>>       ^
>> 
>> Error: Debug Failure.
>>     at resolveExternalModule (/home/setup/vsts-agent/_work/7/s/built/local/tsc.js:44740:35)
>>     at resolveExternalModuleNameWorker (/home/setup/vsts-agent/_work/7/s/built/local/tsc.js:44702:61)
>>     at resolveExternalModuleName (/home/setup/vsts-agent/_work/7/s/built/local/tsc.js:44699:12)
>>     at checkImportDeclaration (/home/setup/vsts-agent/_work/7/s/built/local/tsc.js:76954:35)
>>     at checkSourceElementWorker (/home/setup/vsts-agent/_work/7/s/built/local/tsc.js:77425:16)
>>     at checkSourceElement (/home/setup/vsts-agent/_work/7/s/built/local/tsc.js:77244:7)
>>     at forEach (/home/setup/vsts-agent/_work/7/s/built/local/tsc.js:37:22)
>>     at checkSourceFileWorker (/home/setup/vsts-agent/_work/7/s/built/local/tsc.js:77608:7)
>>     at checkSourceFile (/home/setup/vsts-agent/_work/7/s/built/local/tsc.js:77575:5)
>>     at checkSourceFileWithEagerDiagnostics (/home/setup/vsts-agent/_work/7/s/built/local/tsc.js:77669:5

This seems to be carried through to PRs too (like https://typescript.visualstudio.com/TypeScript/_build/results?buildId=142192&view=logs&j=fd490c07-0b22-5182-fac9-6d67fe1e939b&t=fb1961db-d514-5215-fe81-a42cdc309f86 😢)

cc @weswigham

@RyanCavanaugh RyanCavanaugh added the Bug A bug in TypeScript label Jan 10, 2023
@jakebailey
Copy link
Member Author

jakebailey commented Jan 10, 2023

This checkDefined is what's failing:

else if (resolvedModule.resolvedUsingTsExtension && !shouldAllowImportingTsExtension(compilerOptions, currentSourceFile.fileName)) {
    const tsExtension = Debug.checkDefined(tryExtractTSExtension(moduleReference));
    error(errorNode, Diagnostics.An_import_path_can_only_end_with_a_0_extension_when_allowImportingTsExtensions_is_enabled, tsExtension);
}

@jakebailey
Copy link
Member Author

And moduleReference is '@angular/core', yet it was resolved using a TS extension?

@jakebailey
Copy link
Member Author

jakebailey commented Jan 10, 2023

Minimal repro:

// @filename: tsconfig.json
{
    "compilerOptions": {
        "paths": {
            "@angular/*": ["./@angular/*"]
        }
    }
}

// @filename: @angular/core/package.json
{
    "name": "@angular/core",
    "typings": "index.d.ts"
}

// @filename: @angular/core/index.ts
export {};

// @filename: @angular/core/testing/test.ts
import "@angular/core";

@jakebailey
Copy link
Member Author

The general pattern seems to be:

  • loadNodeModuleFromDirectory finds index.d.ts, then calls loadNodeModuleFromDirectoryWorker with tests/cases/@angular/core/index.d.ts
  • nodeLoadModuleByRelativeName is then called on tests/cases/@angular/core/index.d.ts, which then eventually calls loadModuleFromFileNoImplicitExtensions, which used to return undefined, but now returns a result that says "I found a match and it was resolved using a ts extension"
  • Things fall apart because a non-file import was resolved using a ts extension.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in TypeScript
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants