-
Notifications
You must be signed in to change notification settings - Fork 616
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
[api-extractor] Internal Error: Unable to follow symbol for "const" on first api-extractor run #3875
Comments
I also tried with node v16.19.0, and a completely clean install. Same error. |
I have the same issue in my project. It seems that API extractor is be unable to parse |
Also encountered this error. In my case, the cause was due to imports of type As requested in AstSymbolTable.ts, I have tagged the commit in my Github repository where this error occurs. Tag is api-extractor-error. This error can be reproduced by:
This should generate the error. The subsequent commit removes the relevant |
Sorry nobody looked at this until now. I was able to confirm the repro from this issue's description. (I haven't tried @pbklink's repro yet.) The problem is caused by the {
"extends": "@tsconfig/node16-strictest/tsconfig.json",
"compilerOptions": {
"outDir": "./dist/",
"noImplicitAny": true,
"strict": true,
"rootDir": "./src",
"baseUrl": "src", 👈👈👈 This setting enables the following sort of import: api-extractor-issue/src/boundaries/index.ts
Normally the module resolver would interpret The The problem is that these remappings exist in tsconfig.json for your library project, but are generally NOT visible to the tsconfig.json used to build other projects that consume your library. (There is a proper way to define mappings in package.json, but that is a separate topic, with its own pitfalls.) Now, API Extractor does actually consult your tsconfig.json when analyzing your project, but by design it tries to analyze your project as an external consumer would. In other words, it analyzes And so the bug is that So while we would probably NOT want to support
In short, this repo's tsconfig.json is using an compiler configuration that is nonstandard and cannot generalize to the professional library development situations that API Extractor focuses on, so my recommendation is to fix the tsconfig.json to use standard imports, and then the crash will go away. |
Aha! Thanks for the explanation. I thought I had fixed the exports so that external consumers can use it appropriately, but perhaps I didn't. I remember looking in to that problem at length.
This definitely wasn't clear to me! I really like your three improvement steps. |
Update: It turns out I fixed it by removing that |
I'm experiencing the same problem in my repository FacilMap/facilmap. How to reproduce: Check out the repository at tag After some investigation, I found the cause to be one specific |
@octogonz We use alias paths in our tsconfig, like example below, to help avoid with the {
...
"compilerOptions": {
...
"paths": {
"@/*": [ "./assets/*" ],
"~/*": [ "./src/*" ]
},
}
} import * as utils from '~/utilities'
... |
This took a long time to find, thank you @octogonz for the clear explanation! |
@octogonz any thoughts on my question? |
@johnwc I think your question is already answered- as far as I understand, |
@TimothyJones you're going to have to explain further, as I don't know what you're referring to with My question is how can we use aliases with import statements and still have api-extractor work with rolling up the declarations into single file? Using aliases in import statements is very common. |
I'm running into a similar issue, but I'm not sure if it's the same:
I'm using vite-plugin-dts to build a UX library. Part of that library includes subclassing the DateFns adapter here: My code:
Basically, I'm hoping someone can confirm to me that this is indeed the same issue and I should sit tight and wait for this bug to be addressed. |
I fixed this problem by changing line in vite.config.ts to And also I have changed in package.json to The problem was related to vite-plugin-dts with enabled rollupTypes, and it was too difficult to fix the bug, so I just decided to disable rollupTypes |
You didn't fix the error, you disabled the feature that has the error. That is what most have to do to get it to work, but we are wanting to rollup all of the types into one file. |
This topic ranks top 1 on Google for many queries related to "Internal Error: Unable to follow symbol for." I spent 2 days trying to solve my issue with the incorrect behavior of the API extractor, went through a ton of threads online. And it was a revelation for me that in my case, I could simply disable rollupTypes. If someone had mentioned this in this thread earlier, I would have saved 2 days of my life. It is not obvious for many non experts in typescript, that they could just disable rollupTypes, and this would solve lots of theis problems. |
Summary
When following the setup steps here, I encountered:
Repro steps
Because this happened on my first ever use of this tool, I haven't tried to make a minimal repro. However, I can point you at the repository that has this error.
Check out the
api-extractor-issue
branch of this repository, donpm install && npm run build
and then run eithernpm run api-extractor
, ornpx api-extractor run --local --diagnostics
Expected result: No errors.
Actual result: as above. The end of the error message with
--diagnostics
is:As instructed, I am reporting it 😎
Details
api-extractor init
is not right - for example, I had to change the/lib/
to/dist/
. It would be awesome if the init would parse the tsconfig and set that setting (and any others) appropriately. I had a skim read of the settings, but couldn't see anything obviously wrong.Standard questions
Please answer these questions to help us investigate your issue more quickly:
@microsoft/api-extractor
version?node -v
)?The text was updated successfully, but these errors were encountered: