Any recommended patterns for sharing types across ...
# typescript
Any recommended patterns for sharing types across pulumi projects? (I'm new to TS, so maybe the answer is "the regular ts way!", but just thought I'd ask). Also is it an anti-pattern to be exporting complex objects from stacks? Or generally fine?
Hi there John, We use custom types and interfaces across a number of projects, that we're referencing using relative paths (I come from the python world so I couldn't say how idiomatic our approach is).
Copy code
|_ components
   |_ kubernetes
   |_ DB
|_ models (this is where our types live)
As for exports, my team and I are rather parsimonious so to speak: we're exporting outputs required to provision resources that are somehow related. Though it is possible to export complex objects, I would rather export simply strings, thereby preventing users from gaining access to protected/confidential resources. Does that make sense?
It's usually best to stay away from exporting types with constructors that have side effects. If you exporting simple JSON objects, you're fine.
👍 1