prostgles-types 4.0.280 → 4.0.282
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/files.d.ts +3 -0
- package/dist/files.d.ts.map +1 -1
- package/dist/files.js +3 -0
- package/dist/files.js.map +1 -1
- package/dist/index.d.ts +32 -13
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index_umd.js +1 -1
- package/dist/insertTypes.d.ts +22 -0
- package/dist/insertTypes.d.ts.map +1 -0
- package/dist/insertTypes.js +3 -0
- package/dist/insertTypes.js.map +1 -0
- package/dist/joinHelpers.d.ts +3 -1
- package/dist/joinHelpers.d.ts.map +1 -1
- package/dist/joinHelpers.js +4 -1
- package/dist/joinHelpers.js.map +1 -1
- package/lib/files.ts +3 -0
- package/lib/index.ts +47 -15
- package/lib/insertTypes.ts +32 -0
- package/lib/joinHelpers.ts +4 -1
- package/package.json +8 -2
- package/.vscode/settings.json +0 -12
- package/scripts/check-type-instantiations.mjs +0 -40
- package/trace/trace.json +0 -1975
- package/trace/types.json +0 -24427
- package/tsconfig.browser.json +0 -9
- package/tsconfig.json +0 -30
- package/webpack.prod.js +0 -34
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"insertTypes.d.ts","sourceRoot":"","sources":["../lib/insertTypes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,QAAQ,EAAE,oBAAoB,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAE7F,MAAM,MAAM,2BAA2B,CACrC,EAAE,SAAS,SAAS,EACpB,CAAC,SAAS,QAAQ,GAAG,IAAI,EACzB,KAAK,SAAS,WAAW,IAEzB;IAAC,KAAK;CAAC,SAAS,CAAC,KAAK,CAAC,GAAG,kBAAkB,CAAC,EAAE,CAAC,GAC9C,gBAAgB,CAAC,CAAC,EAAE,KAAK,CAAC,SAAS,MAAM,IAAI,GAC7C;IAAC,IAAI;CAAC,SAAS,CAAC,KAAK,CAAC,GACpB,kBAAkB,CAAC,EAAE,CAAC,GACtB;KACG,CAAC,IAAI,MAAM,EAAE,GACV,kBAAkB,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,GACzB,CAAC,IAAI,SAAS;QAAE,OAAO,EAAE,SAAS,MAAM,EAAE,CAAC;QAAC,IAAI,EAAE,MAAM,IAAI,CAAA;KAAE,GAC5D,CAAC,SAAS,IAAI,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC,GAC/B,IAAI,GACJ,KAAK,GACP,KAAK,CAAC;CACb,GACH,KAAK,CAAC;AAEV,KAAK,gBAAgB,CAAC,CAAC,SAAS,QAAQ,GAAG,IAAI,EAAE,KAAK,SAAS,WAAW,IAAI;KAC3E,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,CAC3B;QACE,OAAO,EAAE,MAAM,IAAI,SAAS,SAAS,CAAC;QACtC,YAAY,EAAE,MAAM,CAAC,KAAK,EAAE,MAAM,OAAO,CAAC,CAAC;KAC5C,CACF,GACC;QAAE,OAAO,EAAE,OAAO,CAAC;QAAC,IAAI,EAAE,oBAAoB,CAAC,IAAI,EAAE,CAAC,EAAE,CAAC,CAAC,CAAA;KAAE,GAC5D,KAAK;CACR,CAAC,MAAM,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"insertTypes.js","sourceRoot":"","sources":["../lib/insertTypes.ts"],"names":[],"mappings":""}
|
package/dist/joinHelpers.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import type { JoinMaker } from "./index";
|
|
1
|
+
import type { DetailedJoinSelect, JoinMaker } from "./index";
|
|
2
|
+
/** Preserve literal table names and selections for joined return type inference. */
|
|
3
|
+
export declare const defineJoin: <const J extends DetailedJoinSelect>(join: J) => J;
|
|
2
4
|
export declare const innerJoin: JoinMaker;
|
|
3
5
|
export declare const leftJoin: JoinMaker;
|
|
4
6
|
//# sourceMappingURL=joinHelpers.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"joinHelpers.d.ts","sourceRoot":"","sources":["../lib/joinHelpers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAa,SAAS,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"joinHelpers.d.ts","sourceRoot":"","sources":["../lib/joinHelpers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAa,kBAAkB,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAGxE,oFAAoF;AACpF,eAAO,MAAM,UAAU,GAAI,KAAK,CAAC,CAAC,SAAS,kBAAkB,EAAE,MAAM,CAAC,KAAG,CAAS,CAAC;AAmBnF,eAAO,MAAM,SAAS,WAA4B,CAAC;AACnD,eAAO,MAAM,QAAQ,WAA2B,CAAC"}
|
package/dist/joinHelpers.js
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.leftJoin = exports.innerJoin = void 0;
|
|
3
|
+
exports.leftJoin = exports.innerJoin = exports.defineJoin = void 0;
|
|
4
4
|
const util_1 = require("./util");
|
|
5
|
+
/** Preserve literal table names and selections for joined return type inference. */
|
|
6
|
+
const defineJoin = (join) => join;
|
|
7
|
+
exports.defineJoin = defineJoin;
|
|
5
8
|
const getJoinFunc = (joinType = "$leftJoin") => {
|
|
6
9
|
const joinMaker = (tableName, filter, select, options = {}) => {
|
|
7
10
|
return {
|
package/dist/joinHelpers.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"joinHelpers.js","sourceRoot":"","sources":["../lib/joinHelpers.ts"],"names":[],"mappings":";;;AACA,iCAAkC;AAElC,MAAM,WAAW,GAAG,CAAC,WAAuC,WAAW,EAAE,EAAE;IACzE,MAAM,SAAS,GAAc,CAC3B,SAA8C,EAC9C,MAA2C,EAC3C,MAA2C,EAC3C,UAA+C,EAAE,EACjD,EAAE;QACF,OAAO;YACL,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC,IAAI,IAAI,SAAS;YACrC,MAAM;YACN,GAAG,IAAA,eAAQ,EAAC,OAAO,EAAE,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;YACxC,MAAM;SACP,CAAC;IACJ,CAAC,CAAC;IACF,OAAO,SAAS,CAAC;AACnB,CAAC,CAAC;AAEW,QAAA,SAAS,GAAG,WAAW,CAAC,YAAY,CAAC,CAAC;AACtC,QAAA,QAAQ,GAAG,WAAW,CAAC,WAAW,CAAC,CAAC"}
|
|
1
|
+
{"version":3,"file":"joinHelpers.js","sourceRoot":"","sources":["../lib/joinHelpers.ts"],"names":[],"mappings":";;;AACA,iCAAkC;AAElC,oFAAoF;AAC7E,MAAM,UAAU,GAAG,CAAqC,IAAO,EAAK,EAAE,CAAC,IAAI,CAAC;AAAtE,QAAA,UAAU,cAA4D;AAEnF,MAAM,WAAW,GAAG,CAAC,WAAuC,WAAW,EAAE,EAAE;IACzE,MAAM,SAAS,GAAc,CAC3B,SAA8C,EAC9C,MAA2C,EAC3C,MAA2C,EAC3C,UAA+C,EAAE,EACjD,EAAE;QACF,OAAO;YACL,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC,IAAI,IAAI,SAAS;YACrC,MAAM;YACN,GAAG,IAAA,eAAQ,EAAC,OAAO,EAAE,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;YACxC,MAAM;SACP,CAAC;IACJ,CAAC,CAAC;IACF,OAAO,SAAS,CAAC;AACnB,CAAC,CAAC;AAEW,QAAA,SAAS,GAAG,WAAW,CAAC,YAAY,CAAC,CAAC;AACtC,QAAA,QAAQ,GAAG,WAAW,CAAC,WAAW,CAAC,CAAC"}
|
package/lib/files.ts
CHANGED
|
@@ -8,6 +8,7 @@ export const CONTENT_TYPE_TO_EXT = {
|
|
|
8
8
|
"text/xml": ["xml"],
|
|
9
9
|
"text/mathml": ["mml"],
|
|
10
10
|
"text/plain": ["txt"],
|
|
11
|
+
"text/markdown": ["md", "markdown"],
|
|
11
12
|
"text/vnd.sun.j2me.app-descriptor": ["jad"],
|
|
12
13
|
"text/vnd.wap.wml": ["wml"],
|
|
13
14
|
"text/x-component": ["htc"],
|
|
@@ -22,6 +23,8 @@ export const CONTENT_TYPE_TO_EXT = {
|
|
|
22
23
|
"image/svg+xml": ["svg"],
|
|
23
24
|
"image/webp": ["webp"],
|
|
24
25
|
"application/sql": ["sql"],
|
|
26
|
+
"application/json": ["json"],
|
|
27
|
+
"application/geo+json": ["geojson"],
|
|
25
28
|
"application/x-javascript": ["js"],
|
|
26
29
|
"application/atom+xml": ["atom"],
|
|
27
30
|
"application/rss+xml": ["rss"],
|
package/lib/index.ts
CHANGED
|
@@ -5,6 +5,7 @@ import { JSONB } from "./JSONBSchemaValidation/JSONBSchema";
|
|
|
5
5
|
import { getKeys, isDefined } from "./util";
|
|
6
6
|
import { includes } from "./utilFuncs/includes";
|
|
7
7
|
import type { SyncTableInfo } from "./WAL";
|
|
8
|
+
import type { InsertColumnsWithReferences } from "./insertTypes";
|
|
8
9
|
export const _PG_strings = [
|
|
9
10
|
"bpchar",
|
|
10
11
|
"char",
|
|
@@ -581,7 +582,7 @@ type InclusiveSelect = true | 1 | FunctionSelect | JoinSelect;
|
|
|
581
582
|
type SelectWithFunctions<T extends AnyObject = AnyObject, IsTyped = false> =
|
|
582
583
|
| ({ [K in keyof Partial<T>]: InclusiveSelect } & Record<
|
|
583
584
|
string,
|
|
584
|
-
IsTyped extends true ? FunctionFull : InclusiveSelect
|
|
585
|
+
IsTyped extends true ? FunctionFull | DetailedJoinSelect : InclusiveSelect
|
|
585
586
|
>)
|
|
586
587
|
| FunctionAliasedSelect
|
|
587
588
|
| { [K in keyof Partial<T>]: true | 1 | string }
|
|
@@ -756,31 +757,61 @@ export type NormalizedRow<T extends Record<string, unknown>> = Required<{
|
|
|
756
757
|
[K in keyof T]: CollapseNumberIfStringPresent<T[K]>;
|
|
757
758
|
}>;
|
|
758
759
|
|
|
760
|
+
type JoinTarget<P> =
|
|
761
|
+
P extends string ? P
|
|
762
|
+
: P extends readonly [...unknown[], infer Last] ?
|
|
763
|
+
Last extends string ? Last
|
|
764
|
+
: Last extends { table: infer T } ? T
|
|
765
|
+
: never
|
|
766
|
+
: never;
|
|
767
|
+
|
|
768
|
+
type ExplicitJoinResult<J, S extends DBSchema | void, P> =
|
|
769
|
+
[JoinTarget<P>] extends [never] ? any[]
|
|
770
|
+
: S extends DBSchema ?
|
|
771
|
+
JoinTarget<P> extends infer T extends keyof S ?
|
|
772
|
+
J extends { select: infer Sel extends Select } ?
|
|
773
|
+
SelectDataType<S, { select: Sel }, S[T]["columns"]>[]
|
|
774
|
+
: any[]
|
|
775
|
+
: any[]
|
|
776
|
+
: any[];
|
|
777
|
+
|
|
759
778
|
type JoinedSelect = Record<string, Select>;
|
|
760
779
|
export type SelectFunction = Record<string, any[]>;
|
|
761
780
|
type ParseSelect<
|
|
762
781
|
Select extends SelectParams<TD>["select"],
|
|
763
782
|
TD extends AnyObject,
|
|
783
|
+
S extends DBSchema | void,
|
|
764
784
|
> = (Select extends { "*": 1 } ? NormalizedRow<TD> : {}) & {
|
|
765
|
-
[Key in keyof Omit<Select, "*"> & string]: Select[Key] extends 1 ? NormalizedRow<TD>[Key]
|
|
785
|
+
[Key in keyof Omit<Select, "*"> & string]: Select[Key] extends 1 | true ? NormalizedRow<TD>[Key]
|
|
786
|
+
: Select[Key] extends (
|
|
787
|
+
{
|
|
788
|
+
$leftJoin: infer P extends RawJoinPath;
|
|
789
|
+
select: unknown;
|
|
790
|
+
}
|
|
791
|
+
) ?
|
|
792
|
+
ExplicitJoinResult<Select[Key], S, P>
|
|
793
|
+
: Select[Key] extends (
|
|
794
|
+
{
|
|
795
|
+
$innerJoin: infer P extends RawJoinPath;
|
|
796
|
+
select: unknown;
|
|
797
|
+
}
|
|
798
|
+
) ?
|
|
799
|
+
ExplicitJoinResult<Select[Key], S, P>
|
|
766
800
|
: Select[Key] extends SelectFunction ? any
|
|
767
801
|
: Select[Key] extends JoinedSelect ? any[]
|
|
768
802
|
: any;
|
|
769
803
|
};
|
|
770
804
|
|
|
771
|
-
type SelectDataType<
|
|
772
|
-
S extends DBSchema | void,
|
|
773
|
-
O extends SelectParams<TD, S>,
|
|
774
|
-
TD extends AnyObject,
|
|
775
|
-
> =
|
|
805
|
+
type SelectDataType<S extends DBSchema | void, O, TD extends AnyObject> =
|
|
776
806
|
O extends { returnType: "value" } ? any
|
|
777
807
|
: O extends { returnType: "values"; select: Record<string, 1> } ?
|
|
778
808
|
ValueOf<Pick<NormalizedRow<TD>, keyof O["select"]>>
|
|
779
809
|
: O extends { returnType: "values" } ? any
|
|
780
810
|
: O extends { select: "*" } ? NormalizedRow<TD>
|
|
781
811
|
: O extends { select: "" } ? Record<string, never>
|
|
782
|
-
: O extends { select:
|
|
783
|
-
: O extends { select: Record<string,
|
|
812
|
+
: O extends { select: readonly (keyof TD)[] } ? Pick<NormalizedRow<TD>, O["select"][number]>
|
|
813
|
+
: O extends { select: Record<string, 0 | false> } ? Omit<NormalizedRow<TD>, keyof O["select"]>
|
|
814
|
+
: O extends { select: Record<string, any> } ? ParseSelect<O["select"], NormalizedRow<TD>, S>
|
|
784
815
|
: NormalizedRow<TD>;
|
|
785
816
|
|
|
786
817
|
export type SelectReturnType<
|
|
@@ -899,12 +930,13 @@ export type DeleteParams<T extends AnyObject | void = void, S extends DBSchema |
|
|
|
899
930
|
export type InsertDataWithNested<
|
|
900
931
|
TD extends AnyObject,
|
|
901
932
|
S extends DBSchema | void,
|
|
902
|
-
|
|
933
|
+
TName extends PropertyKey = never,
|
|
934
|
+
> = InsertColumnsWithReferences<TD, S, TName> &
|
|
903
935
|
(S extends DBSchema ?
|
|
904
936
|
string extends keyof S ?
|
|
905
937
|
{} // collapse to void-like behavior for untyped/dynamic schema
|
|
906
938
|
: {
|
|
907
|
-
[TableName in keyof S]?: Partial<InsertDataWithNested<S[TableName]["columns"], S>>[];
|
|
939
|
+
[TableName in keyof S]?: Partial<InsertDataWithNested<S[TableName]["columns"], S, TableName>>[];
|
|
908
940
|
}
|
|
909
941
|
: {});
|
|
910
942
|
|
|
@@ -915,7 +947,7 @@ export type InsertDataWithNested<
|
|
|
915
947
|
export type TableHandler<
|
|
916
948
|
TD extends AnyObject = AnyObject,
|
|
917
949
|
S extends DBSchema | void = void,
|
|
918
|
-
TName extends
|
|
950
|
+
TName extends PropertyKey = never,
|
|
919
951
|
> = {
|
|
920
952
|
/**
|
|
921
953
|
* Retrieves the table/view info
|
|
@@ -1045,7 +1077,7 @@ export type TableHandler<
|
|
|
1045
1077
|
* Inserts a new record into the table.
|
|
1046
1078
|
*/
|
|
1047
1079
|
insert<P extends InsertParams<TD, S>>(
|
|
1048
|
-
data: InsertDataWithNested<TD, S>,
|
|
1080
|
+
data: InsertDataWithNested<TD, S, TName>,
|
|
1049
1081
|
params?: P,
|
|
1050
1082
|
): Promise<GetReturningReturnType<P, TD, S>>;
|
|
1051
1083
|
|
|
@@ -1053,7 +1085,7 @@ export type TableHandler<
|
|
|
1053
1085
|
* Inserts new records into the table.
|
|
1054
1086
|
*/
|
|
1055
1087
|
insertMany<P extends InsertParams<TD, S>>(
|
|
1056
|
-
data: InsertDataWithNested<TD, S>[],
|
|
1088
|
+
data: InsertDataWithNested<TD, S, TName>[],
|
|
1057
1089
|
params?: P,
|
|
1058
1090
|
): Promise<GetReturningReturnType<P, TD, S>[]>;
|
|
1059
1091
|
|
|
@@ -1213,7 +1245,7 @@ export type ValidatedMethods<T extends DBTableSchema> =
|
|
|
1213
1245
|
export type DBHandler<S = void> =
|
|
1214
1246
|
S extends DBSchema ?
|
|
1215
1247
|
{
|
|
1216
|
-
[k in keyof S]: Pick<TableHandler<S[k]["columns"], S>, ValidatedMethods<S[k]>>;
|
|
1248
|
+
[k in keyof S]: Pick<TableHandler<S[k]["columns"], S, k>, ValidatedMethods<S[k]>>;
|
|
1217
1249
|
}
|
|
1218
1250
|
: {
|
|
1219
1251
|
[key: string]: Partial<TableHandler>;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { AnyObject, DBSchema, InsertDataWithNested, UpsertDataToPGCast } from "./index";
|
|
2
|
+
|
|
3
|
+
export type InsertColumnsWithReferences<
|
|
4
|
+
TD extends AnyObject,
|
|
5
|
+
S extends DBSchema | void,
|
|
6
|
+
TName extends PropertyKey,
|
|
7
|
+
> =
|
|
8
|
+
[TName] extends [never] ? UpsertDataToPGCast<TD>
|
|
9
|
+
: ColumnReferences<S, TName> extends infer Refs ?
|
|
10
|
+
[Refs] extends [never] ?
|
|
11
|
+
UpsertDataToPGCast<TD>
|
|
12
|
+
: {
|
|
13
|
+
[K in keyof TD]:
|
|
14
|
+
| UpsertDataToPGCast<TD>[K]
|
|
15
|
+
| (Refs extends { columns: readonly string[]; data: infer Data } ?
|
|
16
|
+
K extends Refs["columns"][number] ?
|
|
17
|
+
Data
|
|
18
|
+
: never
|
|
19
|
+
: never);
|
|
20
|
+
}
|
|
21
|
+
: never;
|
|
22
|
+
|
|
23
|
+
type ColumnReferences<S extends DBSchema | void, TName extends PropertyKey> = {
|
|
24
|
+
[F in keyof S]: S[F] extends (
|
|
25
|
+
{
|
|
26
|
+
columns: infer Data extends AnyObject;
|
|
27
|
+
referencedBy: Record<TName, infer Columns>;
|
|
28
|
+
}
|
|
29
|
+
) ?
|
|
30
|
+
{ columns: Columns; data: InsertDataWithNested<Data, S, F> }
|
|
31
|
+
: never;
|
|
32
|
+
}[keyof S];
|
package/lib/joinHelpers.ts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
import type { AnyObject, JoinMaker } from "./index";
|
|
1
|
+
import type { AnyObject, DetailedJoinSelect, JoinMaker } from "./index";
|
|
2
2
|
import { omitKeys } from "./util";
|
|
3
3
|
|
|
4
|
+
/** Preserve literal table names and selections for joined return type inference. */
|
|
5
|
+
export const defineJoin = <const J extends DetailedJoinSelect>(join: J): J => join;
|
|
6
|
+
|
|
4
7
|
const getJoinFunc = (joinType: "$leftJoin" | "$innerJoin" = "$leftJoin") => {
|
|
5
8
|
const joinMaker: JoinMaker = (
|
|
6
9
|
tableName: Parameters<JoinMaker<AnyObject>>[0],
|
package/package.json
CHANGED
|
@@ -1,16 +1,22 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "prostgles-types",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.282",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/index_umd.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
7
|
+
"files": [
|
|
8
|
+
"dist",
|
|
9
|
+
"lib",
|
|
10
|
+
"!**/*.spec.*"
|
|
11
|
+
],
|
|
7
12
|
"directories": {},
|
|
8
13
|
"scripts": {
|
|
9
14
|
"start": "tsc --watch",
|
|
10
15
|
"test": "npm run build && npm run test:type-instantiations && node --test dist/*.spec.js dist/**/*.spec.js",
|
|
11
16
|
"test:type-instantiations": "node scripts/check-type-instantiations.mjs",
|
|
12
|
-
"build": "
|
|
17
|
+
"build": "rm -rf ./dist/* && tsc && webpack --config webpack.prod.js",
|
|
13
18
|
"prebuild": "tsc --noEmit -p tsconfig.browser.json",
|
|
19
|
+
"prepack": "npm run build",
|
|
14
20
|
"perf": "tsc --extendedDiagnostics 2>&1 | grep -E \"Instantiations|Check time\"",
|
|
15
21
|
"pushpublish": "npm version patch --git-tag-version false && git push && npm publish"
|
|
16
22
|
},
|
package/.vscode/settings.json
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"typescript.tsdk": "node_modules/typescript/lib",
|
|
3
|
-
"editor.formatOnSave": true,
|
|
4
|
-
"prettier.experimentalTernaries": true,
|
|
5
|
-
"[javascript]": {
|
|
6
|
-
"editor.defaultFormatter": "esbenp.prettier-vscode"
|
|
7
|
-
},
|
|
8
|
-
"[typescript]": {
|
|
9
|
-
"editor.defaultFormatter": "esbenp.prettier-vscode"
|
|
10
|
-
},
|
|
11
|
-
"prettier.printWidth": 100
|
|
12
|
-
}
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { spawnSync } from "node:child_process";
|
|
2
|
-
import { fileURLToPath } from "node:url";
|
|
3
|
-
|
|
4
|
-
// Baseline: 108,997. The small margin avoids hiding meaningful inference regressions.
|
|
5
|
-
const MAX_INSTANTIATIONS = 105_000;
|
|
6
|
-
const tscPath = fileURLToPath(new URL("../node_modules/typescript/bin/tsc", import.meta.url));
|
|
7
|
-
const result = spawnSync(
|
|
8
|
-
process.execPath,
|
|
9
|
-
[tscPath, "--noEmit", "--extendedDiagnostics", "--pretty", "false"],
|
|
10
|
-
{ encoding: "utf8" },
|
|
11
|
-
);
|
|
12
|
-
|
|
13
|
-
if (result.error) {
|
|
14
|
-
throw result.error;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
if (result.status !== 0) {
|
|
18
|
-
process.stdout.write(result.stdout);
|
|
19
|
-
process.stderr.write(result.stderr);
|
|
20
|
-
process.exit(result.status ?? 1);
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
const output = result.stdout + result.stderr;
|
|
24
|
-
const label = "Instantiations:";
|
|
25
|
-
const line = output.split("\n").find((outputLine) => outputLine.startsWith(label));
|
|
26
|
-
const instantiations = Number(line?.slice(label.length).trim());
|
|
27
|
-
|
|
28
|
-
if (!Number.isFinite(instantiations)) {
|
|
29
|
-
throw new Error(`Could not read type instantiations from tsc output:\n${output}`);
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
if (instantiations > MAX_INSTANTIATIONS) {
|
|
33
|
-
throw new Error(
|
|
34
|
-
`Type instantiations increased to ${instantiations.toLocaleString()} (maximum: ${MAX_INSTANTIATIONS.toLocaleString()}).`,
|
|
35
|
-
);
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
console.log(
|
|
39
|
-
`Type instantiations: ${instantiations.toLocaleString()} / ${MAX_INSTANTIATIONS.toLocaleString()}`,
|
|
40
|
-
);
|