qmhc/vite-plugin-dts

Win11 - Internal Error with Vite and TypeScript - "Unable to follow symbol for 'Promise'" Description

Closed this issue · 2 comments

Describe the bug

Note: Linux/Debian works (Docker tested) only Win11 has a problem.

I encountered an internal error while using Vite with TypeScript. The error message is as follows:

typescript - terminal message

[vite:dts] Internal Error: Unable to follow symbol for "Promise"

This issue occurs when attempting to initialize a promise within a function. The relevant code snippet is:

typescript - code

1

exampleFunction(input: Input, config: Config): Promise<ExampleClass> {
    
    let initConfig = extend(DEFAULTCONFIG, config);
    
    return new Promise<ExampleClass>((resolve, reject): void => {
    
        // some logic here
    });
}

2

exampleFunction(input: Input, config: Config): Promise<any> {
    
    let initConfig = extend(DEFAULTCONFIG, config);
    
    return new Promise<any>((resolve, reject): void => {
    
        // some logic here
    });
}

The error seems to originate from Vite's handling of TypeScript type declarations, particularly when dealing with the Promise type.

Reproduction

https://stackblitz.com/edit/stackblitz-starters-bmmh1n?file=api.ts

Steps to reproduce

Steps to Reproduce

Create a TypeScript project with Vite.
Implement a method that returns a Promise as shown in the code snippet above.
Run the Vite build or development server.

Expected Behavior

Vite should correctly process the TypeScript types without throwing an internal error related to the Promise symbol.
Actual Behavior

Vite throws an internal error, stating it is unable to follow the symbol for Promise.

System Info

## System:
    OS: Windows 11 10.0.22631
    CPU: (16) x64 AMD Ryzen 7 3700X 8-Core Processor             
    Memory: 29.95 GB / 63.92 GB
  Binaries:
    Node: 20.9.0 - C:\Program Files\nodejs\node.EXE
    npm: 10.8.2 - C:\Program Files\nodejs\npm.CMD
  Browsers:
    Edge: Chromium (127.0.2651.74)
    Internet Explorer: 11.0.22621.3527

## Environment:

    Vite Version: 5.2.12
    TypeScript Version: 5.4.5
    Operating System: Win11
    Node Version: 20.9.0

Validations

Appears to be related to rollupTypes: true. Without it, it does work.

Extra info: we found that this was only an issue on Windows, not Mac or Linux. It also only seems to be broken starting from version 4 of this library.

Extra error info:

Analysis will use the bundled TypeScript version 5.4.2
*** The target project appears to use TypeScript 5.5.4 which is newer than the bundled compiler engine; consider upgrading API Extractor.
x Build failed in 18.79s
error during build:
[vite:dts] Internal Error: Unable to follow symbol for "Promise"

You have encountered a software defect. Please consider reporting the issue to the maintainers of this application.
    at AstSymbolTable._analyzeChildTree (C:\project\node_modules\.pnpm\@microsoft+api-extractor@7.47.4_@types+node@18.19.41\node_modules\@microsoft\api-extractor\lib\analyzer\AstSymbolTable.js:328:43)
    at AstSymbolTable._analyzeChildTree (C:\project\node_modules\.pnpm\@microsoft+api-extractor@7.47.4_@types+node@18.19.41\node_modules\@microsoft\api-extractor\lib\analyzer\AstSymbolTable.js:377:18)
    at AstSymbolTable._analyzeChildTree (C:\project\node_modules\.pnpm\@microsoft+api-extractor@7.47.4_@types+node@18.19.41\node_modules\@microsoft\api-extractor\lib\analyzer\AstSymbolTable.js:377:18)
    at AstSymbolTable._analyzeChildTree (C:\project\node_modules\.pnpm\@microsoft+api-extractor@7.47.4_@types+node@18.19.41\node_modules\@microsoft\api-extractor\lib\analyzer\AstSymbolTable.js:377:18)
    at AstSymbolTable._analyzeAstSymbol (C:\project\node_modules\.pnpm\@microsoft+api-extractor@7.47.4_@types+node@18.19.41\node_modules\@microsoft\api-extractor\lib\analyzer\AstSymbolTable.js:247:18)
    at C:\project\node_modules\.pnpm\@microsoft+api-extractor@7.47.4_@types+node@18.19.41\node_modules\@microsoft\api-extractor\lib\analyzer\AstSymbolTable.js:259:34
    at AstDeclaration.forEachDeclarationRecursive (C:\project\node_modules\.pnpm\@microsoft+api-extractor@7.47.4_@types+node@18.19.41\node_modules\@microsoft\api-extractor\lib\analyzer\AstDeclaration.js:168:9)
    at AstSymbol.forEachDeclarationRecursive (C:\project\node_modules\.pnpm\@microsoft+api-extractor@7.47.4_@types+node@18.19.41\node_modules\@microsoft\api-extractor\lib\analyzer\AstSymbol.js:103:28)
    at AstSymbolTable._analyzeAstSymbol (C:\project\node_modules\.pnpm\@microsoft+api-extractor@7.47.4_@types+node@18.19.41\node_modules\@microsoft\api-extractor\lib\analyzer\AstSymbolTable.js:254:27)
    at AstSymbolTable.analyze (C:\project\node_modules\.pnpm\@microsoft+api-extractor@7.47.4_@types+node@18.19.41\node_modules\@microsoft\api-extractor\lib\analyzer\AstSymbolTable.js:113:25)
 ELIFECYCLE  Command failed with exit code 1.