Closed jasongwartz closed 8 months ago
Pkl supports string type literals, ie x: "asdf", where the string value of x can only be "asdf". https://pkl-lang.org/main/current/language-reference/index.html#string-literal-types
x: "asdf"
x
"asdf"
TypeScript also supports type literals: https://www.typescriptlang.org/docs/handbook/2/everyday-types.html#literal-types
To get better type inference in TypeScript, when it can be inferred that the value can only be that of the type literal, pkl-gen-typescript should create a TypeScript type literal that matches the Pkl type literal.
pkl-gen-typescript
Pkl supports string type literals, ie
x: "asdf"
, where the string value ofx
can only be"asdf"
. https://pkl-lang.org/main/current/language-reference/index.html#string-literal-typesTypeScript also supports type literals: https://www.typescriptlang.org/docs/handbook/2/everyday-types.html#literal-types
To get better type inference in TypeScript, when it can be inferred that the value can only be that of the type literal,
pkl-gen-typescript
should create a TypeScript type literal that matches the Pkl type literal.