Skip to content
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

Fix: "Got unexpected undefined" error when using a re-exported type #7424

Merged
merged 8 commits into from Dec 19, 2021

Conversation

Shinyaigeek
Copy link
Contributor

↪️ Pull Request

Fixes: #7360

Hi all 👋

When I investigated # 7360, I think that this bug may have occurred because the resolveExports of TSModuleGraph, which resolves the dependency of TypeScript type import/export, is returned even if it is undefined in this part (https://github.com/parcel-bundler/parcel/blob/v2/packages/transformers/typescript-types/src/TSModuleGraph.js#L146-L149). Originally, resolveExports should return only when it is not undefined, as getAllExports does (https://github.com/parcel-bundler/parcel/blob/v2/packages/transformers/typescript-types/src/TSModuleGraph.js#L167-L169).

The # 7360 issue can be resolved by changing the export order as follows, which also seems to support the above considerations.

before src/types/index.ts

export * from './basic';
export * from './props';

after src/types/index.ts

export * from './props';
export * from './basic';

if there is something I missed, please be free to point it out 🙇

💻 Examples

Bug repo: https://github.com/jakeboone02/parcel-basic-test

🚨 Test instructions

I made an integration test to check if parcel-bundler could handle a source that is shown in #7360 correctly.

✔️ PR Todo

  • Added/updated unit tests for this change
  • Filled out test instructions (In case there aren't any unit tests)
  • Included links to related issues/PRs

@height
Copy link

height bot commented Dec 9, 2021

Link Height tasks by mentioning a task ID in the pull request title or commit messages, or description and comments with the keyword link (e.g. "Link T-123").

💡Tip: You can also use "Close T-X" to automatically close a task when the pull request is merged.

@Shinyaigeek
Copy link
Contributor Author

Oh, I commited dummy data but I forgot to commit test code 🤣

@boaz-codota
Copy link

I had just tried to migrate to parcel from rollup, and I'd bumped into this issue although using the latest version 2.4.1. I also tried nightly, but nothing works. Could the issues regarding this PR be re-opened?

@devongovett
Copy link
Member

Please make a new issue with a reproduction.

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

Successfully merging this pull request may close these issues.

@parcel/transformer-typescript-types throws a "Got unexpected undefined" error when using a re-exported type
4 participants