microsoft / rushstack

Monorepo for tools developed by the Rush Stack community
https://rushstack.io/
Other
5.95k stars 602 forks source link

[api-extractor] Unable to determine semantic information for declaration #3674

Open weidezhong-msft opened 2 years ago

weidezhong-msft commented 2 years ago

I am hitting ERROR: Internal Error: Unable to determine semantic information for declaration: when running api-extractor The bolded code [name, value] seems to be causing the problem. const diagnosticSeverityOverrides = pythonAnalysisSection.diagnosticSeverityOverrides; if (diagnosticSeverityOverrides) { for (const [name, value] of Object.entries(diagnosticSeverityOverrides)) { const ruleName = this.getDiagnosticRuleName(name); const severity = this.getSeverityOverrides(value as string); if (ruleName && severity) { serverSettings.diagnosticSeverityOverrides![ruleName] = severity!; } } }

Repro steps

Expected result:

Actual result: Internal Error: Unable to determine semantic information for declaration: when running api-extractor

InternalError (d:\repos\rushstack\libraries\node-core-library\src\InternalError.ts:49) getSymbolForDeclaration (d:\repos\rushstack\apps\api-extractor\src\analyzer\TypeScriptHelpers.ts:119) _fetchAstDeclaration (d:\repos\rushstack\apps\api-extractor\src\analyzer\AstSymbolTable.ts:510) _analyzeChildTree (d:\repos\rushstack\apps\api-extractor\src\analyzer\AstSymbolTable.ts:467) _analyzeChildTree (d:\repos\rushstack\apps\api-extractor\src\analyzer\AstSymbolTable.ts:473) _analyzeChildTree (d:\repos\rushstack\apps\api-extractor\src\analyzer\AstSymbolTable.ts:473) _analyzeChildTree (d:\repos\rushstack\apps\api-extractor\src\analyzer\AstSymbolTable.ts:473) _analyzeChildTree (d:\repos\rushstack\apps\api-extractor\src\analyzer\AstSymbolTable.ts:473) _analyzeChildTree (d:\repos\rushstack\apps\api-extractor\src\analyzer\AstSymbolTable.ts:473) _analyzeChildTree (d:\repos\rushstack\apps\api-extractor\src\analyzer\AstSymbolTable.ts:473) _analyzeChildTree (d:\repos\rushstack\apps\api-extractor\src\analyzer\AstSymbolTable.ts:473) _analyzeChildTree (d:\repos\rushstack\apps\api-extractor\src\analyzer\AstSymbolTable.ts:473) _analyzeChildTree (d:\repos\rushstack\apps\api-extractor\src\analyzer\AstSymbolTable.ts:473) _analyzeChildTree (d:\repos\rushstack\apps\api-extractor\src\analyzer\AstSymbolTable.ts:473) _analyzeChildTree (d:\repos\rushstack\apps\api-extractor\src\analyzer\AstSymbolTable.ts:473) _analyzeChildTree (d:\repos\rushstack\apps\api-extractor\src\analyzer\AstSymbolTable.ts:473) _analyzeChildTree (d:\repos\rushstack\apps\api-extractor\src\analyzer\AstSymbolTable.ts:473) _analyzeChildTree (d:\repos\rushstack\apps\api-extractor\src\analyzer\AstSymbolTable.ts:473) _analyzeChildTree (d:\repos\rushstack\apps\api-extractor\src\analyzer\AstSymbolTable.ts:473) _analyzeChildTree (d:\repos\rushstack\apps\api-extractor\src\analyzer\AstSymbolTable.ts:473) _analyzeChildTree (d:\repos\rushstack\apps\api-extractor\src\analyzer\AstSymbolTable.ts:473) _analyzeAstSymbol (d:\repos\rushstack\apps\api-extractor\src\analyzer\AstSymbolTable.ts:312)

(d:\repos\rushstack\apps\api-extractor\src\analyzer\AstSymbolTable.ts:326) forEachDeclarationRecursive (d:\repos\rushstack\apps\api-extractor\src\analyzer\AstDeclaration.ts:204) forEachDeclarationRecursive (d:\repos\rushstack\apps\api-extractor\src\analyzer\AstSymbol.ts:179) _analyzeAstSymbol (d:\repos\rushstack\apps\api-extractor\src\analyzer\AstSymbolTable.ts:321) analyze (d:\repos\rushstack\apps\api-extractor\src\analyzer\AstSymbolTable.ts:154) (d:\repos\rushstack\apps\api-extractor\src\analyzer\ExportAnalyzer.ts:338) _collectAllExportsRecursive (d:\repos\rushstack\apps\api-extractor\src\analyzer\ExportAnalyzer.ts:326) fetchAstModuleExportInfo (d:\repos\rushstack\apps\api-extractor\src\analyzer\ExportAnalyzer.ts:247) fetchAstModuleExportInfo (d:\repos\rushstack\apps\api-extractor\src\analyzer\AstSymbolTable.ts:128) analyze (d:\repos\rushstack\apps\api-extractor\src\collector\Collector.ts:251) invoke (d:\repos\rushstack\apps\api-extractor\src\api\Extractor.ts:256) onExecute (d:\repos\rushstack\apps\api-extractor\src\cli\RunAction.ts:137) _execute (d:\repos\rushstack\libraries\ts-command-line\src\providers\CommandLineAction.ts:104) onExecute (d:\repos\rushstack\libraries\ts-command-line\src\providers\CommandLineParser.ts:277) onExecute (d:\repos\rushstack\apps\api-extractor\src\cli\ApiExtractorCommandLine.ts:44) executeWithoutErrorHandling (d:\repos\rushstack\libraries\ts-command-line\src\providers\CommandLineParser.ts:230) execute (d:\repos\rushstack\libraries\ts-command-line\src\providers\CommandLineParser.ts:152) (d:\repos\rushstack\apps\api-extractor\src\start.ts:17) Module._compile (internal/modules/cjs/loader:1105) Module._extensions..js (internal/modules/cjs/loader:1159) Module.load (internal/modules/cjs/loader:981) Module._load (internal/modules/cjs/loader:822) Module.require (internal/modules/cjs/loader:1005) require (internal/modules/cjs/helpers:102) (d:\repos\rushstack\apps\api-extractor\bin\api-extractor:2) Module._compile (internal/modules/cjs/loader:1105) Module._extensions..js (internal/modules/cjs/loader:1159) Module.load (internal/modules/cjs/loader:981) Module._load (internal/modules/cjs/loader:822) executeUserEntryPoint (internal/modules/run_main:77) (internal/main/run_main_module:17) ## Details ## Standard questions Please answer these questions to help us investigate your issue more quickly: | Question | Answer | | -------- | -------- | | `@microsoft/api-extractor` version? | latest built from the rush repo | | Operating system? | Windows 11 | | API Extractor scenario? | rollups (.d.ts) | | Would you consider contributing a PR? | Yes | | TypeScript compiler version? | 4.4.4 | | Node.js version (`node -v`)? | 16.16.0 |
zelliott commented 2 years ago

Is the code that you shared above (i.e. const diagnosticSeverityOverrides...) within your codebase (I think so)? If so, then the issue may be that API Extractor is running on .ts files in your codebase (as the code you shared looks like its from a .ts file). API Extractor expects to process .d.ts files, not .ts files. If you invoke API Extractor with the --diagnostics flag (https://api-extractor.com/pages/setup/invoking/), then it should print out the list of files that it's processing, and you can validate if there are any .ts files in that list.

Additionally, if you're able to share the repo that you're running API Extractor on as well as steps to run API Extractor in that repo, that would help me diagnose what's going on.

weidezhong-msft commented 2 years ago

Thanks for the quick response. I have since changed the code to reduce the number of exports. I am no longer getting the “Unable to determine semantic information for declaration” error, but I am getting a new error. See the attached log for details. I did find some .ts files in the list. I have also attached api-extractor.json and the entry file pylanceServerWrapper.d.ts.

Error: D:/repos/pyrx-officepy/packages/pyright/packages/pyright-internal/src/common/core.ts:1:1 - (ae-wrong-input-file-type) Incorrect file type; API Extractor expects to analyze compiler outputs with the .d.ts file extension. Troubleshooting tips: https://api-extractor.com/link/dts-error

The repo is internal to Microsoft. I can only share it within Microsoft.

From: Zack Elliott @.> Sent: Thursday, October 6, 2022 7:49 AM To: microsoft/rushstack @.> Cc: Weide Zhong @.>; Author @.> Subject: Re: [microsoft/rushstack] [api-extractor] Unable to determine semantic information for declaration (Issue #3674)

Is the code that you referenced above (i.e. const diagnosticSeverityOverrides...) within your codebase (I think so)? If so, then the issue may be that API Extractor is running on .ts files in your codebase. API Extractor expects to process .d.ts files, not .ts files. If you invoke API Extractor with the --diagnostics flag (https://api-extractor.com/pages/setup/invoking/), then it should print out the list of files that it's processing, and you can validate if there are any .ts files in that list.

Additionally, if you're able to share the repo that you're running API Extractor on as well as steps to run API Extractor in that repo, that would help me diagnose what's going on.

— Reply to this email directly, view it on GitHubhttps://github.com/microsoft/rushstack/issues/3674#issuecomment-1270195083, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ATJ2NHHR4TP7LPKZQAMUXPDWB3RELANCNFSM6AAAAAAQ5ZIUGM. You are receiving this because you authored the thread.Message ID: @.**@.>>

weidezhong-msft commented 2 years ago

I think the problem is due to my tsconfig.json repathing child package reference to the output folder, because pyright-internal is a child package, and it is locally built.

The source code is here. This is what api-extractor knows about the location. D:/repos/pyrx-officepy/packages/pyright/packages/pyright-internal/src/common/core.ts

The d.ts file is actually here. D:\repos\pyrx-officepy\packages\pylance-officepy\out\pyright\packages\pyright-internal\src\common\core.d.ts

How can api-extractor be configured to use the compiler’s path mapping?

"compilerOptions": {
    "sourceMap": true,
    "declaration": true,
    "declarationMap": true,
    "lib": ["es2017"],
    "outDir": "./out",
    "paths": {
        "pylance-internal/*": ["../pylance-internal/src/*"],
        "pyright-internal/*": ["../pyright/packages/pyright-internal/src/*"],
        "pylance-officepy/*": ["../pylance-officepy/src/*"]
    }
},

From: Weide Zhong Sent: Thursday, October 6, 2022 9:52 AM To: microsoft/rushstack @.>; microsoft/rushstack @.> Cc: Author @.***> Subject: RE: [microsoft/rushstack] [api-extractor] Unable to determine semantic information for declaration (Issue #3674)

Thanks for the quick response. I have since changed the code to reduce the number of exports. I am no longer getting the “Unable to determine semantic information for declaration” error, but I am getting a new error. See the attached log for details. I did find some .ts files in the list. I have also attached api-extractor.json and the entry file pylanceServerWrapper.d.ts.

Error: D:/repos/pyrx-officepy/packages/pyright/packages/pyright-internal/src/common/core.ts:1:1 - (ae-wrong-input-file-type) Incorrect file type; API Extractor expects to analyze compiler outputs with the .d.ts file extension. Troubleshooting tips: https://api-extractor.com/link/dts-error

The repo is internal to Microsoft. I can only share it within Microsoft.

From: Zack Elliott @.**@.>> Sent: Thursday, October 6, 2022 7:49 AM To: microsoft/rushstack @.**@.>> Cc: Weide Zhong @.**@.>>; Author @.**@.>> Subject: Re: [microsoft/rushstack] [api-extractor] Unable to determine semantic information for declaration (Issue #3674)

Is the code that you referenced above (i.e. const diagnosticSeverityOverrides...) within your codebase (I think so)? If so, then the issue may be that API Extractor is running on .ts files in your codebase. API Extractor expects to process .d.ts files, not .ts files. If you invoke API Extractor with the --diagnostics flag (https://api-extractor.com/pages/setup/invoking/), then it should print out the list of files that it's processing, and you can validate if there are any .ts files in that list.

Additionally, if you're able to share the repo that you're running API Extractor on as well as steps to run API Extractor in that repo, that would help me diagnose what's going on.

— Reply to this email directly, view it on GitHubhttps://github.com/microsoft/rushstack/issues/3674#issuecomment-1270195083, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ATJ2NHHR4TP7LPKZQAMUXPDWB3RELANCNFSM6AAAAAAQ5ZIUGM. You are receiving this because you authored the thread.Message ID: @.**@.>>

zelliott commented 2 years ago

I think you're probably running into the same issue as https://github.com/microsoft/rushstack/issues/3510.

weidezhong-msft commented 2 years ago

It does appear to be the same issue, but I have to use path mapping in my repo. If I want to temporarily workaround the issue, where should I look at in api-extractor?