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

Declaration content differs using watch vs build #1003

Closed
phippg opened this issue Sep 25, 2022 · 1 comment
Closed

Declaration content differs using watch vs build #1003

phippg opened this issue Sep 25, 2022 · 1 comment

Comments

@phippg
Copy link

phippg commented Sep 25, 2022

In one of my experimentation projects I am using Zod to validate data requested from a 3rd party API. In particular there is one part where I am using z.discriminatedUnion with a type field and want to be able to narrow down a second field (say data) at the call site in the consumers of my library. This works locally in that project.

Running microbundle watch the object in the generated declaration file (which the other projects rely on) includes the type field but is missing the other field. Running a regular microbundle the declaration file includes both type and the data field and I can narrow the data type based on the type property.

Running microbundle watch --target node leads to a correctly generated declaration file, running microbundle --target <anything> has no effect on the declaration output. Additionally, it seems the change is limited to the declaration since the Zod schema for validating the API responses are not stripped from the runtime code.

EDIT: Just tested running tsc --emitDeclarationOnly directly and that generates okay as well.

@phippg
Copy link
Author

phippg commented Sep 25, 2022

After some more looking around this issue ezolenko/rollup-plugin-typescript2#228 prompted me to empty the cache in node_modules/.cache/ containing a couple .rts2-... folders. The watch build works just fine, seems to be an upstream issue.

@phippg phippg closed this as completed Sep 25, 2022
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

No branches or pull requests

1 participant