pkl-community / pkl-typescript

TypeScript language bindings for the Pkl programming language
https://www.npmjs.com/package/@pkl-community/pkl-typescript
Apache License 2.0
104 stars 1 forks source link

Support type imports from other packages, instead of re-generating well-known types #9

Open jasongwartz opened 9 months ago

jasongwartz commented 9 months ago

via @bioball on Discord:

something to think about WRT codegen: sometimes, you might import a Pkl module that comes from some external library. in that case, maybe the generated code should import that library, instead of genearting new code

And then from @jackkleeman:

its a similar problem as in the crd generation where we added a converters field to allow saying that the object at this path should be treated as this external pkl library type lets say there is a well known typescript library for k8s types, and i have pkl code that refers to k8s types. i might want to set those objects as being the k8s typescript library instead of generating typescript types for the pkl types

TLDR: when a Pkl property is of a type that has an existing TypeScript definition (like a k8s type), we could provide a way (an option during codegen) to use an import of the TypeScript type, instead of doing codegen of the equivalent Pkl type.