- Notifications
You must be signed in to change notification settings - Fork 658
Description
Summary
In microsoft/TypeScript#49517 I reported a TS bug and was given a workaround which, unfortunately seems to break api-extractor 😢
My .d.ts file:
declareclassFoo{protectedfoo: number;}declareclassBar{protectedfoo: number;}declaretypeNothing<VextendsFoo>=void;/** * @internal */exportdeclaretypeBroken<VextendsArray<Foo|Bar>>={readonly[PinkeyofV]: V[P]extends(infer TextendsFoo) ? Nothing<T> : never;};export{};//# sourceMappingURL=index.d.ts.mapRunning api-extractor, I get the error:
ERROR: Internal Error: Unable to follow symbol for "" You have encountered a software defect. Please consider reporting the issue to the maintainers of this application. I assume it is on the (infer T extends Foo) pattern that it breaks, given that it used to work fine on older version of the code that was just using V[P] instead.
Additionally, it seems that prettier also breaks because it expects a ? after the inner extends, so my guess it that api-extractor has a similar problem 🤔
Repro steps
Creating a fresh TS project, install api-extractor with default config (api-extractor init). Use the following TS file:
classFoo{protectedfoo=0;}classBar{protectedfoo=0;}typeNothing<VextendsFoo>=void;/** * @internal */exportdeclaretypeBroken<VextendsArray<Foo|Bar>>={// breaks TS, see https://github.com/microsoft/TypeScript/issues/49517// readonly [P in keyof V]: V[P] extends Foo ? Nothing<V[P]> : never;// workaround, breaks API extractorreadonly[PinkeyofV]: V[P]extends(infer TextendsFoo) ? Nothing<T> : never;};Run api-extractor --local
Expected result: API is successfully extracted
Actual result:
ERROR: Internal Error: Unable to follow symbol for "" You have encountered a software defect. Please consider reporting the issue to the maintainers of this application. Details
Diagnostic:
diagnostic.txt
Standard questions
Please answer these questions to help us investigate your issue more quickly:
| Question | Answer |
|---|---|
@microsoft/api-extractor version? | 7.25.2 |
| Operating system? | Windows |
| API Extractor scenario? | |
| Would you consider contributing a PR? | No |
| TypeScript compiler version? | 4.7.4 |
Node.js version (node -v)? | 16.14.2 |