Fixed typescript build
This commit is contained in:
parent
1c4557b638
commit
078534f7c8
|
@ -120,77 +120,86 @@ function createTsExport(
|
||||||
x: expressionValue,
|
x: expressionValue,
|
||||||
environment: environment
|
environment: environment
|
||||||
): squiggleExpression {
|
): squiggleExpression {
|
||||||
switch (x.tag) {
|
switch (x) {
|
||||||
case "EvArray":
|
case "EvVoid":
|
||||||
// genType doesn't convert anything more than 2 layers down into {tag: x, value: x}
|
return tag("void", "");
|
||||||
// format, leaving it as the raw values. This converts the raw values
|
default: {
|
||||||
// directly into typescript values.
|
switch (x.tag) {
|
||||||
//
|
case "EvArray":
|
||||||
// The casting here is because genType is about the types of the returned
|
// genType doesn't convert anything more than 2 layers down into {tag: x, value: x}
|
||||||
// values, claiming they are fully recursive when that's not actually the
|
// format, leaving it as the raw values. This converts the raw values
|
||||||
// case
|
// directly into typescript values.
|
||||||
return tag(
|
//
|
||||||
"array",
|
// The casting here is because genType is about the types of the returned
|
||||||
x.value.map(
|
// values, claiming they are fully recursive when that's not actually the
|
||||||
(arrayItem): squiggleExpression =>
|
// case
|
||||||
convertRawToTypescript(
|
return tag(
|
||||||
arrayItem as unknown as rescriptExport,
|
"array",
|
||||||
environment
|
x.value.map(
|
||||||
|
(arrayItem): squiggleExpression =>
|
||||||
|
convertRawToTypescript(
|
||||||
|
arrayItem as unknown as rescriptExport,
|
||||||
|
environment
|
||||||
|
)
|
||||||
)
|
)
|
||||||
)
|
);
|
||||||
);
|
case "EvArrayString":
|
||||||
case "EvArrayString":
|
return tag("arraystring", x.value);
|
||||||
return tag("arraystring", x.value);
|
case "EvBool":
|
||||||
case "EvBool":
|
return tag("boolean", x.value);
|
||||||
return tag("boolean", x.value);
|
case "EvCall":
|
||||||
case "EvCall":
|
return tag("call", x.value);
|
||||||
return tag("call", x.value);
|
case "EvLambda":
|
||||||
case "EvLambda":
|
return tag("lambda", x.value);
|
||||||
return tag("lambda", x.value);
|
case "EvDistribution":
|
||||||
case "EvDistribution":
|
return tag("distribution", new Distribution(x.value, environment));
|
||||||
return tag("distribution", new Distribution(x.value, environment));
|
case "EvNumber":
|
||||||
case "EvNumber":
|
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 }> =
|
||||||
let result: tagged<"record", { [key: string]: squiggleExpression }> = tag(
|
tag(
|
||||||
"record",
|
"record",
|
||||||
_.mapValues(x.value, (x: unknown) =>
|
_.mapValues(x.value, (x: unknown) =>
|
||||||
convertRawToTypescript(x as rescriptExport, environment)
|
convertRawToTypescript(x as rescriptExport, environment)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
return result;
|
return result;
|
||||||
case "EvString":
|
case "EvString":
|
||||||
return tag("string", x.value);
|
return tag("string", x.value);
|
||||||
case "EvSymbol":
|
case "EvSymbol":
|
||||||
return tag("symbol", x.value);
|
return tag("symbol", x.value);
|
||||||
case "EvDate":
|
case "EvDate":
|
||||||
return tag("date", x.value);
|
return tag("date", x.value);
|
||||||
case "EvTimeDuration":
|
case "EvTimeDuration":
|
||||||
return tag("timeDuration", x.value);
|
return tag("timeDuration", x.value);
|
||||||
case "EvDeclaration":
|
case "EvDeclaration":
|
||||||
return tag("lambdaDeclaration", x.value);
|
return tag("lambdaDeclaration", x.value);
|
||||||
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",
|
||||||
"type",
|
{ [key: string]: squiggleExpression }
|
||||||
_.mapValues(x.value, (x: unknown) =>
|
> = tag(
|
||||||
convertRawToTypescript(x as rescriptExport, environment)
|
"type",
|
||||||
)
|
_.mapValues(x.value, (x: unknown) =>
|
||||||
);
|
convertRawToTypescript(x as rescriptExport, environment)
|
||||||
return typeResult;
|
)
|
||||||
case "EvModule":
|
);
|
||||||
let moduleResult: tagged<
|
return typeResult;
|
||||||
"module",
|
case "EvModule":
|
||||||
{ [key: string]: squiggleExpression }
|
let moduleResult: tagged<
|
||||||
> = tag(
|
"module",
|
||||||
"module",
|
{ [key: string]: squiggleExpression }
|
||||||
_.mapValues(x.value, (x: unknown) =>
|
> = tag(
|
||||||
convertRawToTypescript(x as rescriptExport, environment)
|
"module",
|
||||||
)
|
_.mapValues(x.value, (x: unknown) =>
|
||||||
);
|
convertRawToTypescript(x as rescriptExport, environment)
|
||||||
return moduleResult;
|
)
|
||||||
|
);
|
||||||
|
return moduleResult;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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 };
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user