Closed phippg closed 1 year ago
After some more looking around this issue https://github.com/ezolenko/rollup-plugin-typescript2/issues/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.
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 atype
field and want to be able to narrow down a second field (saydata
) 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 thetype
field but is missing the other field. Running a regularmicrobundle
the declaration file includes bothtype
and thedata
field and I can narrow thedata
type based on thetype
property.Running
microbundle watch --target node
leads to a correctly generated declaration file, runningmicrobundle --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.