@pkl-community/pkl-typescript
Advanced tools
@@ -24,2 +24,14 @@ /* This file was generated by `pkl-typescript` from Pkl module `04-withClass`. */ | ||
| overrideableStringType: string | ||
| overridableListing1: Array<string | number> | ||
| overridableListing2: Array<string | number> | ||
| overridableMap1: Map<string, string | number> | ||
| overridableMap2: Map<string, string | number> | ||
| overridableUnion1: number | string | Array<string> | ||
| overridableUnion2: number | string | ||
| } | ||
@@ -32,2 +44,14 @@ | ||
| overrideableStringType: "string literal type" | ||
| overridableListing1: Array<number | string> | ||
| overridableListing2: Array<string> | ||
| overridableMap1: Map<string, number | string> | ||
| overridableMap2: Map<string, string> | ||
| overridableUnion1: string | number | ||
| overridableUnion2: string | ||
| } | ||
@@ -34,0 +58,0 @@ |
+1
-1
| { | ||
| "name": "@pkl-community/pkl-typescript", | ||
| "description": "Typescript bindings for Pkl", | ||
| "version": "0.0.10", | ||
| "version": "0.0.11", | ||
| "main": "dist/src/index.js", | ||
@@ -6,0 +6,0 @@ "types": "dist/src/index.d.ts", |
+1
-1
@@ -68,3 +68,3 @@ > [!CAUTION] | ||
| - **Inlined imports**: Imported Pkl types are inlined into the output TypeScript file. For example, if `foo.pkl` has an import like `import "bar.pkl"`, and you run `pkl-gen-typescript foo.pkl`, the resulting `foo.pkl.ts` file will include all types defined in `foo.pkl` _as well as_ all types defined in `bar.pkl`. This means that the resulting TypeScript generated files (in a multi-file codegen) will match the set of input root files, not the file structure of the source Pkl files. This behaviour may create unintended name conflicts; these can be resolved using the `@typescript.Name { value = "..." }` annotation. It may also cause duplication (eg. if the same shared Pkl library file is imported in two schemas); TypeScript's structural typing (where equivalent type shapes can be used interchangeably) should mean that any duplicate types can be safely used as each other. | ||
| - **Subclass type overrides**: Pkl class definitions are generated as TypeScript interfaces in code generation; Pkl supports completely changing the type of a property in a child class, but this is not allowed in TypeScript extending interfaces. When a TypeScript interface `extends` a parent interface, overrides of the type of a property must be "compatible" with the parent type (eg. overriding a `string` type with a string-literal type). In TypeScript codegen, overriding a parent string-type property with a string literal type is allowed, and other compatible types may be allowed in the future (if you have an example of where this would be useful, please file a GitHub Issue). | ||
| - **Subclass type overrides**: Pkl class definitions are generated as TypeScript interfaces in code generation; Pkl supports completely changing the type of a property in a child class, but this is not allowed in TypeScript extending interfaces. When a TypeScript interface `extends` a parent interface, overrides of the type of a property must be "compatible" with the parent type (eg. overriding a `string` type with a string-literal type). TypeScript codegen currently has support for a few compatible types, and others may be allowed in the future (if you have an example of a compatible type that should work but fails in codegen, please file a GitHub Issue). | ||
| - **Regex deserialisation**: Pkl's `Regex` type will be decoded as a `pklTypescript.Regex` object, which contains a `.pattern` property. Pkl uses Java's regular expression syntax, which may not always be perfectly compatible with JavaScript's regular expression syntax. If you want to use your Pkl `Regex` as a JavaScript `RegExp`, and you are confident that the expression will behave the same way in JavaScript as in Pkl, you can instantiate a new `RegExp` using the `pklTypescript.Regex.pattern` property, eg. `const myConfigRegexp = new RegExp(myConfig.someRegex.pattern)`. | ||
@@ -71,0 +71,0 @@ - **IntSeq deserialisation**: Pkl's `IntSeq` type is intended to be used internally within a Pkl program to create a range loop. It is unlikely to be useful as a property type in JavaScript, and is therefore decoded into a custom `pklTypescript.IntSeq` type with signature `{ start: number; end: number: step: number }` - it is _not_ decoded into an array containing the ranged values. If you have a use-case to use `IntSeq` as an array of ranged values in a TypeScript program, please file a GitHub Issue. |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
325213
1.06%5279
0.23%