Fixed typescript build

This commit is contained in:
Ozzie Gooen 2022-07-20 08:27:57 -07:00
parent 1c4557b638
commit 078534f7c8
2 changed files with 82 additions and 72 deletions

View File

@ -120,6 +120,10 @@ function createTsExport(
x: expressionValue, x: expressionValue,
environment: environment environment: environment
): squiggleExpression { ): squiggleExpression {
switch (x) {
case "EvVoid":
return tag("void", "");
default: {
switch (x.tag) { switch (x.tag) {
case "EvArray": case "EvArray":
// genType doesn't convert anything more than 2 layers down into {tag: x, value: x} // genType doesn't convert anything more than 2 layers down into {tag: x, value: x}
@ -153,7 +157,8 @@ function createTsExport(
return tag("number", x.value); return tag("number", x.value);
case "EvRecord": case "EvRecord":
// genType doesn't support records, so we have to do the raw conversion ourself // genType doesn't support records, so we have to do the raw conversion ourself
let result: tagged<"record", { [key: string]: squiggleExpression }> = tag( let result: tagged<"record", { [key: string]: squiggleExpression }> =
tag(
"record", "record",
_.mapValues(x.value, (x: unknown) => _.mapValues(x.value, (x: unknown) =>
convertRawToTypescript(x as rescriptExport, environment) convertRawToTypescript(x as rescriptExport, environment)
@ -173,8 +178,10 @@ function createTsExport(
case "EvTypeIdentifier": case "EvTypeIdentifier":
return tag("typeIdentifier", x.value); return tag("typeIdentifier", x.value);
case "EvType": case "EvType":
let typeResult: tagged<"type", { [key: string]: squiggleExpression }> = let typeResult: tagged<
tag( "type",
{ [key: string]: squiggleExpression }
> = tag(
"type", "type",
_.mapValues(x.value, (x: unknown) => _.mapValues(x.value, (x: unknown) =>
convertRawToTypescript(x as rescriptExport, environment) convertRawToTypescript(x as rescriptExport, environment)
@ -194,3 +201,5 @@ function createTsExport(
return moduleResult; return moduleResult;
} }
} }
}
}

View File

@ -131,7 +131,8 @@ export type squiggleExpression =
| tagged<"record", { [key: string]: squiggleExpression }> | tagged<"record", { [key: string]: squiggleExpression }>
| tagged<"type", { [key: string]: squiggleExpression }> | tagged<"type", { [key: string]: squiggleExpression }>
| tagged<"typeIdentifier", string> | tagged<"typeIdentifier", string>
| tagged<"module", { [key: string]: squiggleExpression }>; | tagged<"module", { [key: string]: squiggleExpression }>
| tagged<"void", string>;
export { lambdaValue }; export { lambdaValue };