Skip to content
This repository has been archived by the owner on Apr 21, 2022. It is now read-only.

[plugin-bundle-types] combined type file references removed files #87

Closed
phryneas opened this issue Sep 12, 2019 · 2 comments
Closed

[plugin-bundle-types] combined type file references removed files #87

phryneas opened this issue Sep 12, 2019 · 2 comments

Comments

@phryneas
Copy link

This came up while trying to convert react-async to TS. (See async-library/react-async#105 ).

We are trying to get a single-file-.d.ts. Unfortunately, using the plugin-bundle-types, it seems like the generated file in part references files that are being inlined.
See line 220 here: https://gist.github.com/phryneas/d101e7e0b8070f6dc8b44540825c87cd#file-index-d-ts-L220

@FredKSchott could you take a look please?

This was build by running yarn build:packages from this branch: https://github.com/phryneas/react-async/tree/switch-to-ts

@FredKSchott
Copy link
Owner

Bah, this looks like a @microsoft/api-extractor bug. That definitely shouldn't be happening, but I can still reproduce if I run @microsoft/api-extractor directly.

It looks like you all are doing some pretty complicated typing stuff with generics, and it looks like the bug only occurs when the type is referenced as a generic argument:

  • When AbstractState is referenced on its own it's properly bundled
  • When AbstractState is referenced as an argument generic like AsyncState<T, AbstractState<T>>, it includes the broken import('./Async').

Unfortunately I can't find a simple reproduction case, and I don't know enough about the library to know where to start pulling/commenting things out until I don't see it any more. But I'd recommend getting as simple a reproduction case as you can, and then filing an issue here: https://github.com/microsoft/web-build-tools

Since the type does actually exist in the file, a hacky short-term workaround would be to add this after your build to remove the zombie type import: sed -i "" -e "s/import(\".\/Async\").//g" pkg/dist-types/index.d.ts

Wish I had better news! Let me know if you end up filing that bug with microsoft and I'd be happy to jump in there to help as well.

@phryneas
Copy link
Author

I've brought it up with them and we've found a workaround for now :)

Thanks for helping investigate this!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants