TSUP advice - typescript behaving differently after build
I have little experience with building my typescript code into packages that I can then publish and subsequently then download from the npm registry - however that is exactly what I am trying to do right now.
After doing some research it seems TSUP is a favourable tool to use to bundle ts into a package. I followed this video from Matt Pocock https://www.youtube.com/watch?v=eh89VE3Mk5g
However, when I import my class from the generated dist folder, typescript is not able to infer types correctly. This occurs when I call one of my factory methods, which generates a method that accepts an argument of a type dependant on the argument provided to the factory method.
It is hard to explain without an example, so here is a simple one:
Here is the project repo, this behaviour should be very easily re-creatable if you clone the project and run the build script, and then use the example provided above.
https://github.com/FlynnHillier/ws-schema/tree/lib
Could anyone advise on why typescript is behaving differently post build? I am nowhere near familiar enough with tsup or publishing in general to know where to start in resolving this - any suggestions are appreciated 🙂
0 Replies