Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Export generic load() function, and generate type-only .d.ts files #51

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions codegen/snippet-tests/output/01_primitive_types.pkl.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/* This file was generated by `pkl-typescript` from Pkl module `01-primitiveTypes`. */
/* DO NOT EDIT! */
/* istanbul ignore file */
/* eslint-disable */
import * as pklTypescript from "@pkl-community/pkl-typescript"

// Ref: Module root.
export interface N01PrimitiveTypes {
str: string

int: number

int8: number

uint: number

float: number

bool: boolean

nullType: null

anyType: pklTypescript.Any

nothingType: never
}
40 changes: 0 additions & 40 deletions codegen/snippet-tests/output/01_primitive_types.pkl.ts

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,3 @@ export interface N02Collections {

setInt: Set<number>
}

// LoadFromPath loads the pkl module at the given path and evaluates it into a N02Collections
export const loadFromPath = async (path: string): Promise<N02Collections> => {
const evaluator = await pklTypescript.newEvaluator(pklTypescript.PreconfiguredOptions);
try {
const result = await load(evaluator, pklTypescript.FileSource(path));
return result
} finally {
evaluator.close()
}
};

export const load = (evaluator: pklTypescript.Evaluator, source: pklTypescript.ModuleSource): Promise<N02Collections> =>
evaluator.evaluateModule(source) as Promise<N02Collections>;
16 changes: 16 additions & 0 deletions codegen/snippet-tests/output/03_nullables.pkl.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/* This file was generated by `pkl-typescript` from Pkl module `03-nullables`. */
/* DO NOT EDIT! */
/* istanbul ignore file */
/* eslint-disable */
import * as pklTypescript from "@pkl-community/pkl-typescript"

// Ref: Module root.
export interface N03Nullables {
nullableString: string|null

nullableInt: number|null

nullableListingOfStrings: Array<string>|null

listingOfNullableStrings: Array<string|null>
}
30 changes: 0 additions & 30 deletions codegen/snippet-tests/output/03_nullables.pkl.ts

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -53,17 +53,3 @@ export interface MyConcreteClass extends MyAbstractClass {

overridableUnion2: string
}

// LoadFromPath loads the pkl module at the given path and evaluates it into a N04WithClass
export const loadFromPath = async (path: string): Promise<N04WithClass> => {
const evaluator = await pklTypescript.newEvaluator(pklTypescript.PreconfiguredOptions);
try {
const result = await load(evaluator, pklTypescript.FileSource(path));
return result
} finally {
evaluator.close()
}
};

export const load = (evaluator: pklTypescript.Evaluator, source: pklTypescript.ModuleSource): Promise<N04WithClass> =>
evaluator.evaluateModule(source) as Promise<N04WithClass>;
10 changes: 10 additions & 0 deletions codegen/snippet-tests/output/05_with_pair.pkl.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/* This file was generated by `pkl-typescript` from Pkl module `05-withPair`. */
/* DO NOT EDIT! */
/* istanbul ignore file */
/* eslint-disable */
import * as pklTypescript from "@pkl-community/pkl-typescript"

// Ref: Module root.
export interface N05WithPair {
x: pklTypescript.Pair<string, number>
}
24 changes: 0 additions & 24 deletions codegen/snippet-tests/output/05_with_pair.pkl.ts

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,3 @@ type MyStringAlias = string

// Ref: Pkl type `06-withTypeAlias.MyAliasedClass`.
type MyAliasedClass = MyClassToBeAliased

// LoadFromPath loads the pkl module at the given path and evaluates it into a N06WithTypeAlias
export const loadFromPath = async (path: string): Promise<N06WithTypeAlias> => {
const evaluator = await pklTypescript.newEvaluator(pklTypescript.PreconfiguredOptions);
try {
const result = await load(evaluator, pklTypescript.FileSource(path));
return result
} finally {
evaluator.close()
}
};

export const load = (evaluator: pklTypescript.Evaluator, source: pklTypescript.ModuleSource): Promise<N06WithTypeAlias> =>
evaluator.evaluateModule(source) as Promise<N06WithTypeAlias>;
12 changes: 12 additions & 0 deletions codegen/snippet-tests/output/07_literal_types.pkl.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/* This file was generated by `pkl-typescript` from Pkl module `07-literalTypes`. */
/* DO NOT EDIT! */
/* istanbul ignore file */
/* eslint-disable */
import * as pklTypescript from "@pkl-community/pkl-typescript"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these imports arent needed now right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They are if we use custom types like pklTypescript.Any


// Ref: Module root.
export interface N07LiteralTypes {
x: "one"

y: "two"
}
26 changes: 0 additions & 26 deletions codegen/snippet-tests/output/07_literal_types.pkl.ts

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -54,17 +54,3 @@ type PersonName = string

// Ref: Pkl type `08-withUnion.PersonAge`.
type PersonAge = number

// LoadFromPath loads the pkl module at the given path and evaluates it into a N08WithUnion
export const loadFromPath = async (path: string): Promise<N08WithUnion> => {
const evaluator = await pklTypescript.newEvaluator(pklTypescript.PreconfiguredOptions);
try {
const result = await load(evaluator, pklTypescript.FileSource(path));
return result
} finally {
evaluator.close()
}
};

export const load = (evaluator: pklTypescript.Evaluator, source: pklTypescript.ModuleSource): Promise<N08WithUnion> =>
evaluator.evaluateModule(source) as Promise<N08WithUnion>;
24 changes: 24 additions & 0 deletions codegen/snippet-tests/output/09_custom_types.pkl.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/* This file was generated by `pkl-typescript` from Pkl module `09-customTypes`. */
/* DO NOT EDIT! */
/* istanbul ignore file */
/* eslint-disable */
import * as pklTypescript from "@pkl-community/pkl-typescript"

// Ref: Module root.
export interface N09CustomTypes {
varAny: pklTypescript.Any

varDymaic: pklTypescript.Dynamic

varDataSizeUnit: pklTypescript.DataSizeUnit

varDataSize: pklTypescript.DataSize

varDuration: pklTypescript.Duration

varIntSeq: pklTypescript.IntSeq

varRegex: pklTypescript.Regex

varPair: pklTypescript.Pair<string, number>
}
38 changes: 0 additions & 38 deletions codegen/snippet-tests/output/09_custom_types.pkl.ts

This file was deleted.

21 changes: 21 additions & 0 deletions codegen/snippet-tests/output/11_with_import.pkl.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/* This file was generated by `pkl-typescript` from Pkl module `11-withImport`. */
/* DO NOT EDIT! */
/* istanbul ignore file */
/* eslint-disable */
import * as pklTypescript from "@pkl-community/pkl-typescript"

// Ref: Module root.
export interface N11WithImport {
value: ExampleClass
}

// Ref: Pkl class `moduleWithClass.ExampleClass`.
export interface ExampleClass {
x: string

y: number
}

// Ref: Module root.
export interface ModuleWithClass {
}
35 changes: 0 additions & 35 deletions codegen/snippet-tests/output/11_with_import.pkl.ts

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/* This file was generated by `pkl-typescript` from Pkl module `n10.pkl.typescript.tests.namedModule`. */
/* DO NOT EDIT! */
/* istanbul ignore file */
/* eslint-disable */
import * as pklTypescript from "@pkl-community/pkl-typescript"

// Ref: Module root.
export interface NamedModule {
x: string
}
Loading
Loading