@ts-typed/compiler 0.0.1 → 0.1.1
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/CHANGELOG.md +51 -0
- package/dist/cli/cli.d.ts.map +1 -1
- package/dist/cli/cli.js +14 -0
- package/dist/cli/cli.js.map +1 -1
- package/dist/compiler/analysis/analyze-project.d.ts.map +1 -1
- package/dist/compiler/analysis/analyze-project.js +21 -4
- package/dist/compiler/analysis/analyze-project.js.map +1 -1
- package/dist/compiler/analysis/type-schema-resolver.d.ts +44 -1
- package/dist/compiler/analysis/type-schema-resolver.d.ts.map +1 -1
- package/dist/compiler/analysis/type-schema-resolver.js +189 -2
- package/dist/compiler/analysis/type-schema-resolver.js.map +1 -1
- package/dist/compiler/build/build-project.d.ts.map +1 -1
- package/dist/compiler/build/build-project.js +19 -1
- package/dist/compiler/build/build-project.js.map +1 -1
- package/dist/compiler/transform/create-contract-transformer.d.ts.map +1 -1
- package/dist/compiler/transform/create-contract-transformer.js +308 -16
- package/dist/compiler/transform/create-contract-transformer.js.map +1 -1
- package/dist/compiler/transform/schema-expression.d.ts.map +1 -1
- package/dist/compiler/transform/schema-expression.js +5 -0
- package/dist/compiler/transform/schema-expression.js.map +1 -1
- package/dist/runtime/assert-value.js +39 -0
- package/dist/runtime/assert-value.js.map +1 -1
- package/dist/runtime/guards/guards.d.ts +14 -0
- package/dist/runtime/guards/guards.d.ts.map +1 -1
- package/dist/runtime/guards/guards.js +52 -5
- package/dist/runtime/guards/guards.js.map +1 -1
- package/dist/runtime/guards/index.d.ts +1 -1
- package/dist/runtime/guards/index.d.ts.map +1 -1
- package/dist/runtime/guards/index.js +2 -1
- package/dist/runtime/guards/index.js.map +1 -1
- package/dist/runtime/index.d.ts +1 -1
- package/dist/runtime/index.d.ts.map +1 -1
- package/dist/runtime/index.js +2 -1
- package/dist/runtime/index.js.map +1 -1
- package/dist/runtime/schema.interface.d.ts +11 -0
- package/dist/runtime/schema.interface.d.ts.map +1 -1
- package/dist/runtime/schema.type.d.ts +2 -2
- package/dist/runtime/schema.type.d.ts.map +1 -1
- package/package.json +3 -2
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,57 @@ All notable changes to `@ts-typed/compiler` are documented in this file.
|
|
|
4
4
|
|
|
5
5
|
The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to [Semantic Versioning](https://semver.org/).
|
|
6
6
|
|
|
7
|
+
## [0.1.1] - 2026-10-17
|
|
8
|
+
|
|
9
|
+
A real NestJS + TypeORM project was upgraded to 0.1.0 and its full test suite rerun, surfacing two bugs in the coverage this release had just added.
|
|
10
|
+
|
|
11
|
+
### Fixed
|
|
12
|
+
|
|
13
|
+
- `installFieldGuard` silently gave up — installing no guard at all — for any field that keeps its `PropertyDeclaration` in the output (every decorated field, to preserve decorator emission) and has no inline initializer: native class fields (target ES2022+) pre-define such a field as `undefined` before the constructor body runs, and that pre-defined, still-uninitialized placeholder was mistaken for "something else already initialized this field, leave it alone." In practice this left every field of a typical `class CreateUserDto { @IsString() name: string; constructor(data) { this.name = data.name; } }` — the common pattern of assigning fields inside the constructor body rather than inline — completely unguarded, decorated or not.
|
|
14
|
+
- A class field whose own type is a pure function (e.g. `class WithHandler { onClick: () => void = () => {}; }`) never had a guard installed at all: the `function` leaf added in 0.1.0 was only wired into the path used when a property is resolved as part of its *containing object's* structural shape, not into the general resolution path a field's own top-level contract candidate goes through to build its `installFieldGuard` call. A property/interface member with a callback type (fixed in 0.1.0) was unaffected; only a *class field's own* candidate took the unpatched path.
|
|
15
|
+
|
|
16
|
+
## [0.1.0] - 2026-10-17
|
|
17
|
+
|
|
18
|
+
A pass over real NestJS + TypeORM + SQLite usage found that the single highest-impact gap was coverage, not any individual bug: class methods, constructors and decorated fields were never instrumented at all, and several common type shapes (`Date`, callback-typed properties) made their whole containing contract silently `unsupported`. This release closes those gaps and fixes twelve runtime-breaking or silently-incorrect bugs found along the way.
|
|
19
|
+
|
|
20
|
+
### Added
|
|
21
|
+
|
|
22
|
+
- Class methods, getters, setters and constructors are now instrumented (parameters and return values), closing the largest coverage gap: a NestJS controller/service/repository method is now protected the same way a free function always was.
|
|
23
|
+
- Decorated class fields and parameters (`class-validator`, `@nestjs/swagger`, TypeORM `@Column`/`@OneToMany`, etc.) are resolved by their own type instead of being unconditionally marked `unsupported`.
|
|
24
|
+
- `Date` is supported as a first-class runtime contract, including explicitly rejecting `Invalid Date` with a `StrictTypeError` instead of letting it surface later as an unrelated `RangeError`.
|
|
25
|
+
- A property or parameter typed as a plain function (a callback field, an interface method signature) is validated as `typeof value === 'function'` instead of making its whole containing object type `unsupported`.
|
|
26
|
+
- Template literal types (`` `${number}px` ``, `` `user_${string}` ``, `` `${boolean}-flag` ``, etc.) are converted to an anchored regular expression at compile time and validated against it.
|
|
27
|
+
- `yield` inside a generator function is validated against its declared/inferred yielded type; `AsyncGenerator`/`Iterable`/`IterableIterator` are supported the same way. (`yield*` delegation is left unprotected — validating a whole delegated iterable up front is a different, larger problem.)
|
|
28
|
+
- A required class field (no `?`) can no longer be removed with `delete` or have its guard replaced via `Object.defineProperty`, bypassing validation entirely. The lock is deferred to the most-derived class's own constructor (checked via `new.target`), so a subclass that legitimately redeclares the same field is unaffected.
|
|
29
|
+
- Compound assignment on a guarded variable (`+=`, `-=`, `*=`, `/=`, `%=`, `**=`, shifts, bitwise) is now rewritten into a validated assignment instead of running unguarded. `&&=`, `||=` and `??=` are left exactly as before — rewriting them would change short-circuit evaluation — and keep warning as unsupported.
|
|
30
|
+
- Every coverage-affecting diagnostic computed during analysis (not just the ones a transform happens to touch) now reaches the build's coverage report and `compiler.onUnsupported: "error"`'s failure message, which now names the offending contract and reason instead of only a count.
|
|
31
|
+
- `diagnostics.reportFile` actually writes the coverage report to disk, as JSON, creating parent directories as needed; a write failure fails the build instead of being silently swallowed.
|
|
32
|
+
- `strictNullChecks` (directly, or via `strict: true`) is now a hard requirement, checked before any analysis runs, per the original spec — a project without it now fails fast with a clear diagnostic instead of building successfully on a checker view that is already too lossy to protect against.
|
|
33
|
+
- A project configuring `paths` aliases in `tsconfig.json` now fails the build with a clear diagnostic, in both the bundled and the unbundled output: TypeScript never rewrites aliases in its own emitted JavaScript, and `@vercel/ncc` does not read tsconfig `paths` either, so either path previously reported success while producing a "Cannot find module" failure at runtime.
|
|
34
|
+
- The package's `exports` map now exposes `./package.json`, so `require.resolve('@ts-typed/compiler/package.json')` and similar version-probing patterns work.
|
|
35
|
+
|
|
36
|
+
### Fixed
|
|
37
|
+
|
|
38
|
+
- A type assertion or cast used directly as an assignment target (`(x as T) = v`, `(x as T) += 1`, `(x as any)++`/`--`) produced invalid JavaScript (`Invalid left-hand side in assignment`) instead of being erased the way `tsc` itself erases a cast. Casting the *object* of a member assignment (`(a as T).b = v`) is unaffected and continues to validate `a` as a read.
|
|
39
|
+
- `compiler.enforcePrivate` (the default) broke construction of any class with a plain `private` field: the structural schema still required the field under its pre-`#private` name after the transformer had already converted it to a real `#private` accessor. The field is now correctly excluded from the structural schema instead of marking the whole class `unsupported`.
|
|
40
|
+
- A branded/tagged primitive type (`string & { readonly __brand: 'Id' }`, the standard TypeScript nominal-typing idiom) rejected every value, because the phantom `object` member of the intersection was validated against primitive values that can never carry it. It is now ignored when the value being checked is a primitive; an intersection applied to a real object value is unaffected and still enforces every member.
|
|
41
|
+
- A project compiling to native ESM (`module` resolving to an ES module kind) got a `require(...)` call injected into the generated ES module, crashing immediately with `ReferenceError: require is not defined`. The injected runtime reference is now an `import` declaration when the target module format is ESM, and unchanged (`require`) for CommonJS.
|
|
42
|
+
- A comparison against a guarded variable (`port >= MIN`, `x === y`, …) emitted a false "compound assignment" coverage warning, because every non-`=` binary operator was treated as an assignment attempt regardless of whether it actually was one.
|
|
43
|
+
- `compiler.onUnsupported: "error"` could fail a build without ever saying which contract caused it.
|
|
44
|
+
|
|
45
|
+
### Fixed (`@ts-typed/nestjs`-relevant, surfaced through NestJS testing)
|
|
46
|
+
|
|
47
|
+
- See `@ts-typed/nestjs`'s own changelog for the HTTP exception filter fix (`StrictTypeError` from a return-value violation now maps to 500, not 400).
|
|
48
|
+
|
|
49
|
+
### Known limits (new, in addition to the ones already listed below)
|
|
50
|
+
|
|
51
|
+
- Generic type parameters still have no concrete runtime contract inside a generic function's own body (`identity<User>(x)` validates nothing extra inside `identity`): the type is erased before any single call site's concrete argument is known to the instrumented body.
|
|
52
|
+
- `Map`/`Set` contents, `static` class fields, and reflective mutation of a validated array (`push`/`splice`/index assignment/`length`) are still unprotected.
|
|
53
|
+
- A destructuring binding (`const { age }: T = value`) still does not validate `value` against `T` before destructuring.
|
|
54
|
+
- A user-authored type predicate (`x is T`) or assertion function (`asserts x is T`) is trusted as-is; a predicate that lies is not caught.
|
|
55
|
+
- `readonly` on an interface or type-alias member (as opposed to a class field) is not enforced — the value is still writable through that property.
|
|
56
|
+
- Extra properties or `symbol`-keyed properties added directly to a class instance after construction are not rejected (property-level extras on a *nested* plain object already were, and remain, rejected by default).
|
|
57
|
+
|
|
7
58
|
## [0.0.1] - 2026-10-16
|
|
8
59
|
|
|
9
60
|
Initial release.
|
package/dist/cli/cli.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../../src/cli/cli.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../../src/cli/cli.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAwBxD,MAAM,WAAW,aAAa;IAC5B,2EAA2E;IAC3E,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;CAC3D;AAED,wBAAsB,MAAM,CAC1B,IAAI,EAAE,SAAS,MAAM,EAAE,EACvB,OAAO,GAAE,aAAkB,GAC1B,OAAO,CAAC,SAAS,CAAC,CAoBpB"}
|
package/dist/cli/cli.js
CHANGED
|
@@ -128,12 +128,26 @@ async function runBuild(args) {
|
|
|
128
128
|
`Build succeeded: ${report.outDir}${report.bundled ? ' (bundled)' : ''}`,
|
|
129
129
|
(0, report_1.formatCoverageReport)(coverage, (0, node_path_1.resolve)(config.tsconfig, '..')),
|
|
130
130
|
].filter((line) => line.length > 0);
|
|
131
|
+
const reportFile = config.diagnostics.reportFile;
|
|
132
|
+
if (reportFile !== null) {
|
|
133
|
+
await writeDiagnosticsReport(reportFile, coverage);
|
|
134
|
+
stdout.push(`Diagnostics report written to ${reportFile}`);
|
|
135
|
+
}
|
|
131
136
|
return { exitCode: EXIT_SUCCESS, stdout, stderr: [] };
|
|
132
137
|
}
|
|
133
138
|
catch (error) {
|
|
134
139
|
return { exitCode: EXIT_FAILURE, stdout: [], stderr: [describeError(error)] };
|
|
135
140
|
}
|
|
136
141
|
}
|
|
142
|
+
async function writeDiagnosticsReport(filePath, coverage) {
|
|
143
|
+
try {
|
|
144
|
+
await (0, promises_1.mkdir)((0, node_path_1.dirname)(filePath), { recursive: true });
|
|
145
|
+
await (0, promises_1.writeFile)(filePath, `${JSON.stringify(coverage, null, 2)}\n`, 'utf8');
|
|
146
|
+
}
|
|
147
|
+
catch (error) {
|
|
148
|
+
throw new Error(`Could not write diagnostics report to ${filePath}: ${describeError(error)}`);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
137
151
|
function parseInitArgs(args) {
|
|
138
152
|
let root = process.cwd();
|
|
139
153
|
for (let index = 0; index < args.length; index += 1) {
|
package/dist/cli/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../../src/cli/cli.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../../src/cli/cli.ts"],"names":[],"mappings":";;AAsCA,wBAuBC;AA7DD,+CAA8D;AAC9D,yCAAmD;AAEnD,6CAAiD;AAEjD,+CAAgF;AAEhF,s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AAI,KAAK,YAAY,oBAAW,EAAE,CAAC;QACjC,OAAO,wBAAwB,KAAK,CAAC,OAAO,EAAE,CAAC;IACjD,CAAC;IACD,OAAO,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,eAAe,CAAC;AAClE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"analyze-project.d.ts","sourceRoot":"","sources":["../../../src/compiler/analysis/analyze-project.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EACV,cAAc,EACd,qBAAqB,EAEtB,MAAM,6BAA6B,CAAC;AAuBrC,wBAAgB,cAAc,CAAC,OAAO,EAAE,qBAAqB,GAAG,cAAc,
|
|
1
|
+
{"version":3,"file":"analyze-project.d.ts","sourceRoot":"","sources":["../../../src/compiler/analysis/analyze-project.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EACV,cAAc,EACd,qBAAqB,EAEtB,MAAM,6BAA6B,CAAC;AAuBrC,wBAAgB,cAAc,CAAC,OAAO,EAAE,qBAAqB,GAAG,cAAc,CA2G7E"}
|
|
@@ -14,15 +14,29 @@ function analyzeProject(context) {
|
|
|
14
14
|
throw new Error(formatDiagnostic(typescript, configFile.error));
|
|
15
15
|
}
|
|
16
16
|
const parsedConfig = typescript.parseJsonConfigFileContent(configFile.config, typescript.sys, (0, node_path_1.dirname)(tsconfigPath), undefined, tsconfigPath);
|
|
17
|
+
const compilerOptions = {
|
|
18
|
+
...parsedConfig.options,
|
|
19
|
+
...context.compilerOptions,
|
|
20
|
+
};
|
|
21
|
+
// strictNullChecks is what lets a runtime contract tell `null`/`undefined`
|
|
22
|
+
// apart from every other value; without it the type information the
|
|
23
|
+
// transformer reads from the checker is already too lossy to protect
|
|
24
|
+
// against, so this is a hard requirement per the project spec rather than
|
|
25
|
+
// a per-contract coverage limit.
|
|
26
|
+
const effectiveStrictNullChecks = compilerOptions.strictNullChecks ?? compilerOptions.strict ?? false;
|
|
27
|
+
if (effectiveStrictNullChecks !== true) {
|
|
28
|
+
throw new Error(`ts-typed requires "strictNullChecks": true (directly, or via "strict": true) in ${tsconfigPath}. ` +
|
|
29
|
+
'Without it, null and undefined cannot be reliably distinguished from other values when building runtime contracts.');
|
|
30
|
+
}
|
|
17
31
|
const program = typescript.createProgram({
|
|
18
32
|
rootNames: parsedConfig.fileNames,
|
|
19
|
-
options:
|
|
33
|
+
options: compilerOptions,
|
|
20
34
|
projectReferences: parsedConfig.projectReferences,
|
|
21
35
|
});
|
|
22
36
|
const checker = program.getTypeChecker();
|
|
23
37
|
const projectLoadMs = performance.now() - projectLoadStart;
|
|
24
38
|
const typeAnalysisStart = performance.now();
|
|
25
|
-
const resolver = new type_schema_resolver_1.TypeSchemaResolver(typescript, checker);
|
|
39
|
+
const resolver = new type_schema_resolver_1.TypeSchemaResolver(typescript, checker, context.enforcePrivate === true);
|
|
26
40
|
const contracts = new Map();
|
|
27
41
|
const coverage = [];
|
|
28
42
|
const diagnostics = [];
|
|
@@ -260,8 +274,11 @@ function getUnsupportedMemberReason(typescript, node, enforcePrivate) {
|
|
|
260
274
|
!(enforcePrivate && isOnlyPrivate)) {
|
|
261
275
|
return 'Private, protected, and static members require class-specific instrumentation.';
|
|
262
276
|
}
|
|
263
|
-
|
|
264
|
-
|
|
277
|
+
// enforcePrivate rewrites a private field into a `#name` accessor pair, which
|
|
278
|
+
// drops the field's decorators (a decorator cannot target a `#` accessor).
|
|
279
|
+
// Keep such a member unsupported so its decorator is not silently lost.
|
|
280
|
+
if (isOnlyPrivate && (typescript.getDecorators(node)?.length ?? 0) > 0) {
|
|
281
|
+
return 'Decorated private members cannot keep their decorators under enforcePrivate.';
|
|
265
282
|
}
|
|
266
283
|
return undefined;
|
|
267
284
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"analyze-project.js","sourceRoot":"","sources":["../../../src/compiler/analysis/analyze-project.ts"],"names":[],"mappings":";;AAgCA,wCA2FC;AA3HD,6C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AI,UAAU,CAAC,MAAM,KAAK,aAAa,EAAE,CAAC;QAC3E,OAAO,SAAS,CAAC;IACnB,CAAC;IACD,MAAM,IAAI,GACR,aAAa,IAAI,CAAC,UAAU,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,kBAAkB,CAAC,CAAC,CAAC,qBAAqB,CAAC,CAAC;IAClG,MAAM,MAAM,GAAG,UAAU,CAAC,MAAM,IAAI,wDAAwD,CAAC;IAC7F,OAAO;QACL,IAAI;QACJ,QAAQ,EAAE,SAAS;QACnB,IAAI,EAAE,UAAU,CAAC,IAAI;QACrB,IAAI,EAAE,UAAU,CAAC,IAAI;QACrB,MAAM,EAAE,UAAU,CAAC,MAAM;QACzB,IAAI,EAAE,UAAU,CAAC,IAAI;QACrB,IAAI,EAAE,UAAU,CAAC,IAAI;QACrB,MAAM,EAAE,UAAU,CAAC,MAAM;QACzB,OAAO,EAAE,GAAG,MAAM,aAAa,UAAU,CAAC,IAAI,OAAO,UAAU,CAAC,MAAM,GAAG;KAC1E,CAAC;AACJ,CAAC"}
|
|
@@ -4,13 +4,14 @@ import type { SchemaResolution } from './schema-resolution.interface';
|
|
|
4
4
|
export declare class TypeSchemaResolver {
|
|
5
5
|
private readonly _typescript;
|
|
6
6
|
private readonly _checker;
|
|
7
|
+
private readonly _enforcePrivate;
|
|
7
8
|
private readonly _definitions;
|
|
8
9
|
private readonly _definitionNames;
|
|
9
10
|
private readonly _definitionResolutions;
|
|
10
11
|
private readonly _definitionTypes;
|
|
11
12
|
private readonly _resolvingDefinitions;
|
|
12
13
|
private readonly _classSymbolsByDefinitionName;
|
|
13
|
-
constructor(_typescript: typeof import('typescript'), _checker: ts.TypeChecker);
|
|
14
|
+
constructor(_typescript: typeof import('typescript'), _checker: ts.TypeChecker, _enforcePrivate?: boolean);
|
|
14
15
|
resolve(type: ts.Type, node: ts.Node): SchemaResolution;
|
|
15
16
|
getDefinitions(): Readonly<Record<string, Schema>>;
|
|
16
17
|
/**
|
|
@@ -22,12 +23,54 @@ export declare class TypeSchemaResolver {
|
|
|
22
23
|
getClassSymbol(definitionName: string): ts.Symbol | undefined;
|
|
23
24
|
private _resolveType;
|
|
24
25
|
private _resolveDirectType;
|
|
26
|
+
/**
|
|
27
|
+
* Open template literal types (`${number}px`, `user_${string}`) are leaves
|
|
28
|
+
* validated by a regex compiled from their texts and placeholders. Finite
|
|
29
|
+
* interpolations (`${'a' | 'b'}`) never reach here: TypeScript already
|
|
30
|
+
* expands them into a union of string literals.
|
|
31
|
+
*/
|
|
32
|
+
private _resolveTemplateLiteral;
|
|
33
|
+
private _templateLiteralPattern;
|
|
34
|
+
private _placeholderPattern;
|
|
35
|
+
/**
|
|
36
|
+
* Heuristic: the built-in `Date` interface is declared in a TypeScript lib
|
|
37
|
+
* file, which carries `/// <reference no-default-lib="true"/>` and therefore
|
|
38
|
+
* `hasNoDefaultLib === true`. A user-declared class/interface named `Date`
|
|
39
|
+
* lives in an ordinary module and is not matched.
|
|
40
|
+
*/
|
|
41
|
+
/**
|
|
42
|
+
* Resolves the type of an object property. A property whose type is purely a
|
|
43
|
+
* function (or such a function optionally widened with `undefined`/`null`, as
|
|
44
|
+
* in `onClick?: () => void`) is an opaque `function` leaf, so one callback field
|
|
45
|
+
* does not make the whole containing object unsupported. Any other shape goes
|
|
46
|
+
* through the general resolution unchanged.
|
|
47
|
+
*/
|
|
48
|
+
private _resolvePropertyType;
|
|
49
|
+
private _isClassMethod;
|
|
50
|
+
/**
|
|
51
|
+
* Heuristic: a type is "purely a function" when it has call signatures, no
|
|
52
|
+
* construct signatures, and no own members at all. `getPropertiesOfType` does
|
|
53
|
+
* not include the members inherited from the global `Function` interface
|
|
54
|
+
* (`call`, `apply`, `bind`, `name`, ...), which are reached through the apparent
|
|
55
|
+
* type, so an empty property list means no user-declared extras. Index
|
|
56
|
+
* signatures are checked too, since they are also extra structure. Anything
|
|
57
|
+
* with extra members (`{ (): void; extra: string }`) stays unsupported.
|
|
58
|
+
*/
|
|
59
|
+
private _isPureFunction;
|
|
60
|
+
private _isGlobalDate;
|
|
25
61
|
private _resolveDefinitionOrCompound;
|
|
26
62
|
private _resolveComposite;
|
|
27
63
|
private _expandIntersectionObjectReference;
|
|
28
64
|
private _resolveTuple;
|
|
29
65
|
private _resolveArray;
|
|
30
66
|
private _resolveObject;
|
|
67
|
+
/**
|
|
68
|
+
* Mirrors the transformer's `isOnlyPrivateField` rule: with enforcePrivate,
|
|
69
|
+
* a plain `private` PropertyDeclaration with an identifier name (not
|
|
70
|
+
* protected, not static) is converted to a real `#private` field. Parameter
|
|
71
|
+
* properties are not converted and remain part of the schema.
|
|
72
|
+
*/
|
|
73
|
+
private _isConvertedToHashPrivate;
|
|
31
74
|
private _getDefinitionName;
|
|
32
75
|
private _hasDefiniteAssignmentAssertion;
|
|
33
76
|
private _getClassSymbol;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"type-schema-resolver.d.ts","sourceRoot":"","sources":["../../../src/compiler/analysis/type-schema-resolver.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,YAAY,CAAC;AAEjC,OAAO,KAAK,EAAwB,MAAM,EAAE,MAAM,eAAe,CAAC;AAClE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;
|
|
1
|
+
{"version":3,"file":"type-schema-resolver.d.ts","sourceRoot":"","sources":["../../../src/compiler/analysis/type-schema-resolver.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,YAAY,CAAC;AAEjC,OAAO,KAAK,EAAwB,MAAM,EAAE,MAAM,eAAe,CAAC;AAClE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AAetE,qBAAa,kBAAkB;IAS3B,OAAO,CAAC,QAAQ,CAAC,WAAW;IAC5B,OAAO,CAAC,QAAQ,CAAC,QAAQ;IACzB,OAAO,CAAC,QAAQ,CAAC,eAAe;IAVlC,OAAO,CAAC,QAAQ,CAAC,YAAY,C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C,YAAY;CAGrB"}
|
|
@@ -2,18 +2,23 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.TypeSchemaResolver = void 0;
|
|
4
4
|
const ALIAS_LIMIT_REASON = 'The value is validated at the typed boundary, but mutations through external aliases can escape.';
|
|
5
|
+
function escapeRegExp(text) {
|
|
6
|
+
return text.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
7
|
+
}
|
|
5
8
|
class TypeSchemaResolver {
|
|
6
9
|
_typescript;
|
|
7
10
|
_checker;
|
|
11
|
+
_enforcePrivate;
|
|
8
12
|
_definitions = new Map();
|
|
9
13
|
_definitionNames = new Map();
|
|
10
14
|
_definitionResolutions = new Map();
|
|
11
15
|
_definitionTypes = new Map();
|
|
12
16
|
_resolvingDefinitions = new Set();
|
|
13
17
|
_classSymbolsByDefinitionName = new Map();
|
|
14
|
-
constructor(_typescript, _checker) {
|
|
18
|
+
constructor(_typescript, _checker, _enforcePrivate = false) {
|
|
15
19
|
this._typescript = _typescript;
|
|
16
20
|
this._checker = _checker;
|
|
21
|
+
this._enforcePrivate = _enforcePrivate;
|
|
17
22
|
}
|
|
18
23
|
resolve(type, node) {
|
|
19
24
|
return this._resolveType(type, node, true);
|
|
@@ -35,6 +40,20 @@ class TypeSchemaResolver {
|
|
|
35
40
|
if (directResolution !== undefined) {
|
|
36
41
|
return directResolution;
|
|
37
42
|
}
|
|
43
|
+
// A pure function type is an opaque leaf (see _isPureFunction) regardless
|
|
44
|
+
// of WHERE it is being resolved from. _resolvePropertyType special-cases
|
|
45
|
+
// this for a property being resolved as part of its containing object's
|
|
46
|
+
// structural shape, but a function-typed value can also be its own
|
|
47
|
+
// top-level contract — a class field's own candidate, a variable, a
|
|
48
|
+
// parameter, a return — which reaches this general path directly, not
|
|
49
|
+
// through _resolvePropertyType. Handling it here, before the Union
|
|
50
|
+
// branch below, also means a union member that is a pure function (e.g.
|
|
51
|
+
// `(() => void) | undefined`) gets the same leaf treatment through the
|
|
52
|
+
// ordinary recursive _resolveComposite call, with no separate union
|
|
53
|
+
// handling needed on this path.
|
|
54
|
+
if (this._isPureFunction(type)) {
|
|
55
|
+
return { status: 'protected', schema: { kind: 'function' } };
|
|
56
|
+
}
|
|
38
57
|
if (type.isUnion()) {
|
|
39
58
|
return this._resolveDefinitionOrCompound(type, node, canCreateDefinition, () => this._resolveComposite(type.types, node, 'union'));
|
|
40
59
|
}
|
|
@@ -112,8 +131,142 @@ class TypeSchemaResolver {
|
|
|
112
131
|
if ((flags & typeFlags.NonPrimitive) !== 0) {
|
|
113
132
|
return { status: 'protected', schema: { kind: 'primitive', name: 'object' } };
|
|
114
133
|
}
|
|
134
|
+
if (this._isGlobalDate(type)) {
|
|
135
|
+
// Date is an opaque leaf: its methods are never enumerated (they are
|
|
136
|
+
// callable and would otherwise poison the whole object contract).
|
|
137
|
+
return { status: 'protected', schema: { kind: 'date' } };
|
|
138
|
+
}
|
|
139
|
+
if ((flags & typeFlags.TemplateLiteral) !== 0) {
|
|
140
|
+
return this._resolveTemplateLiteral(type);
|
|
141
|
+
}
|
|
142
|
+
return undefined;
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Open template literal types (`${number}px`, `user_${string}`) are leaves
|
|
146
|
+
* validated by a regex compiled from their texts and placeholders. Finite
|
|
147
|
+
* interpolations (`${'a' | 'b'}`) never reach here: TypeScript already
|
|
148
|
+
* expands them into a union of string literals.
|
|
149
|
+
*/
|
|
150
|
+
_resolveTemplateLiteral(type) {
|
|
151
|
+
const pattern = this._templateLiteralPattern(type);
|
|
152
|
+
if (pattern === undefined) {
|
|
153
|
+
return this._unsupported(`Template literal type ${this._checker.typeToString(type)} has a placeholder with no runtime pattern.`);
|
|
154
|
+
}
|
|
155
|
+
return { status: 'protected', schema: { kind: 'templateLiteral', pattern } };
|
|
156
|
+
}
|
|
157
|
+
_templateLiteralPattern(type) {
|
|
158
|
+
const placeholderPatterns = [];
|
|
159
|
+
for (const placeholder of type.types) {
|
|
160
|
+
const placeholderPattern = this._placeholderPattern(placeholder);
|
|
161
|
+
if (placeholderPattern === undefined) {
|
|
162
|
+
return undefined;
|
|
163
|
+
}
|
|
164
|
+
placeholderPatterns.push(placeholderPattern);
|
|
165
|
+
}
|
|
166
|
+
let pattern = '^';
|
|
167
|
+
type.texts.forEach((text, index) => {
|
|
168
|
+
pattern += escapeRegExp(text);
|
|
169
|
+
if (index < placeholderPatterns.length) {
|
|
170
|
+
pattern += placeholderPatterns[index];
|
|
171
|
+
}
|
|
172
|
+
});
|
|
173
|
+
return `${pattern}$`;
|
|
174
|
+
}
|
|
175
|
+
_placeholderPattern(placeholder) {
|
|
176
|
+
const typeFlags = this._typescript.TypeFlags;
|
|
177
|
+
if ((placeholder.flags & typeFlags.String) !== 0) {
|
|
178
|
+
// Any string, including the empty one. `[\s\S]` also matches newlines.
|
|
179
|
+
return '[\\s\\S]*';
|
|
180
|
+
}
|
|
181
|
+
if ((placeholder.flags & typeFlags.Number) !== 0) {
|
|
182
|
+
// Integers and plain decimals only; exponent notation, `Infinity` and
|
|
183
|
+
// `NaN` are not covered (documented limitation).
|
|
184
|
+
return '-?\\d+(?:\\.\\d+)?';
|
|
185
|
+
}
|
|
186
|
+
if ((placeholder.flags & typeFlags.BigInt) !== 0) {
|
|
187
|
+
return '-?\\d+';
|
|
188
|
+
}
|
|
189
|
+
if ((placeholder.flags & typeFlags.Boolean) !== 0) {
|
|
190
|
+
return '(?:true|false)';
|
|
191
|
+
}
|
|
192
|
+
if (placeholder.isStringLiteral() || placeholder.isNumberLiteral()) {
|
|
193
|
+
return escapeRegExp(String(placeholder.value));
|
|
194
|
+
}
|
|
195
|
+
if (placeholder.isUnion()) {
|
|
196
|
+
const alternatives = placeholder.types.map((member) => this._placeholderPattern(member));
|
|
197
|
+
if (alternatives.some((alternative) => alternative === undefined)) {
|
|
198
|
+
return undefined;
|
|
199
|
+
}
|
|
200
|
+
return `(?:${alternatives.join('|')})`;
|
|
201
|
+
}
|
|
115
202
|
return undefined;
|
|
116
203
|
}
|
|
204
|
+
/**
|
|
205
|
+
* Heuristic: the built-in `Date` interface is declared in a TypeScript lib
|
|
206
|
+
* file, which carries `/// <reference no-default-lib="true"/>` and therefore
|
|
207
|
+
* `hasNoDefaultLib === true`. A user-declared class/interface named `Date`
|
|
208
|
+
* lives in an ordinary module and is not matched.
|
|
209
|
+
*/
|
|
210
|
+
/**
|
|
211
|
+
* Resolves the type of an object property. A property whose type is purely a
|
|
212
|
+
* function (or such a function optionally widened with `undefined`/`null`, as
|
|
213
|
+
* in `onClick?: () => void`) is an opaque `function` leaf, so one callback field
|
|
214
|
+
* does not make the whole containing object unsupported. Any other shape goes
|
|
215
|
+
* through the general resolution unchanged.
|
|
216
|
+
*/
|
|
217
|
+
_resolvePropertyType(type, declaration) {
|
|
218
|
+
const members = type.isUnion() ? type.types : [type];
|
|
219
|
+
const functionMembers = members.filter((member) => this._isPureFunction(member));
|
|
220
|
+
if (functionMembers.length === 0) {
|
|
221
|
+
return this._resolveType(type, declaration, true);
|
|
222
|
+
}
|
|
223
|
+
const typeFlags = this._typescript.TypeFlags;
|
|
224
|
+
const schemas = [];
|
|
225
|
+
for (const member of members) {
|
|
226
|
+
if (this._isPureFunction(member)) {
|
|
227
|
+
schemas.push({ kind: 'function' });
|
|
228
|
+
}
|
|
229
|
+
else if ((member.flags & typeFlags.Undefined) !== 0) {
|
|
230
|
+
schemas.push({ kind: 'literal', value: undefined });
|
|
231
|
+
}
|
|
232
|
+
else if ((member.flags & typeFlags.Null) !== 0) {
|
|
233
|
+
schemas.push({ kind: 'literal', value: null });
|
|
234
|
+
}
|
|
235
|
+
else {
|
|
236
|
+
// Mixed with a non-function member: not a pure function leaf.
|
|
237
|
+
return this._resolveType(type, declaration, true);
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
return {
|
|
241
|
+
status: 'protected',
|
|
242
|
+
schema: schemas.length === 1 ? schemas[0] : { kind: 'union', schemas },
|
|
243
|
+
};
|
|
244
|
+
}
|
|
245
|
+
_isClassMethod(property) {
|
|
246
|
+
return (property.declarations ?? []).some((declaration) => this._typescript.isMethodDeclaration(declaration) && this._typescript.isClassLike(declaration.parent));
|
|
247
|
+
}
|
|
248
|
+
/**
|
|
249
|
+
* Heuristic: a type is "purely a function" when it has call signatures, no
|
|
250
|
+
* construct signatures, and no own members at all. `getPropertiesOfType` does
|
|
251
|
+
* not include the members inherited from the global `Function` interface
|
|
252
|
+
* (`call`, `apply`, `bind`, `name`, ...), which are reached through the apparent
|
|
253
|
+
* type, so an empty property list means no user-declared extras. Index
|
|
254
|
+
* signatures are checked too, since they are also extra structure. Anything
|
|
255
|
+
* with extra members (`{ (): void; extra: string }`) stays unsupported.
|
|
256
|
+
*/
|
|
257
|
+
_isPureFunction(type) {
|
|
258
|
+
return (type.getCallSignatures().length > 0 &&
|
|
259
|
+
type.getConstructSignatures().length === 0 &&
|
|
260
|
+
this._checker.getPropertiesOfType(type).length === 0 &&
|
|
261
|
+
this._checker.getIndexInfosOfType(type).length === 0);
|
|
262
|
+
}
|
|
263
|
+
_isGlobalDate(type) {
|
|
264
|
+
const symbol = type.getSymbol();
|
|
265
|
+
if (symbol === undefined || symbol.getName() !== 'Date') {
|
|
266
|
+
return false;
|
|
267
|
+
}
|
|
268
|
+
return (symbol.getDeclarations() ?? []).some((declaration) => declaration.getSourceFile().hasNoDefaultLib);
|
|
269
|
+
}
|
|
117
270
|
_resolveDefinitionOrCompound(type, node, canCreateDefinition, resolveCompound) {
|
|
118
271
|
const definitionName = canCreateDefinition ? this._getDefinitionName(type, node) : undefined;
|
|
119
272
|
if (definitionName === undefined) {
|
|
@@ -236,9 +389,22 @@ class TypeSchemaResolver {
|
|
|
236
389
|
if (propertyName.startsWith('#')) {
|
|
237
390
|
return this._unsupported('True #private class fields have no reflective runtime access and cannot be represented by the runtime schema model.');
|
|
238
391
|
}
|
|
392
|
+
if (this._isConvertedToHashPrivate(property)) {
|
|
393
|
+
// With enforcePrivate, the transformer rewrites this field into a real
|
|
394
|
+
// `#private` field, so it has no reflective property at runtime and
|
|
395
|
+
// must not be required by the structural schema. Only this member is
|
|
396
|
+
// omitted; the rest of the class stays validated.
|
|
397
|
+
continue;
|
|
398
|
+
}
|
|
399
|
+
if (this._isClassMethod(property)) {
|
|
400
|
+
// Class methods keep the established contract: a class with a method is
|
|
401
|
+
// not represented structurally. Only non-method members (fields holding
|
|
402
|
+
// callbacks, interface method signatures) become function leaves.
|
|
403
|
+
return this._unsupported(`Property ${propertyName} is unsupported: Callable and constructable contracts are not represented by object schemas.`);
|
|
404
|
+
}
|
|
239
405
|
const declaration = property.valueDeclaration ?? property.declarations?.[0] ?? node;
|
|
240
406
|
const propertyType = this._checker.getTypeOfSymbolAtLocation(property, declaration);
|
|
241
|
-
const propertyResolution = this.
|
|
407
|
+
const propertyResolution = this._resolvePropertyType(propertyType, declaration);
|
|
242
408
|
if (propertyResolution.schema === undefined) {
|
|
243
409
|
return this._unsupported(`Property ${propertyName} is unsupported: ${propertyResolution.reason ?? 'unknown type limit'}`);
|
|
244
410
|
}
|
|
@@ -276,6 +442,27 @@ class TypeSchemaResolver {
|
|
|
276
442
|
: ALIAS_LIMIT_REASON,
|
|
277
443
|
};
|
|
278
444
|
}
|
|
445
|
+
/**
|
|
446
|
+
* Mirrors the transformer's `isOnlyPrivateField` rule: with enforcePrivate,
|
|
447
|
+
* a plain `private` PropertyDeclaration with an identifier name (not
|
|
448
|
+
* protected, not static) is converted to a real `#private` field. Parameter
|
|
449
|
+
* properties are not converted and remain part of the schema.
|
|
450
|
+
*/
|
|
451
|
+
_isConvertedToHashPrivate(property) {
|
|
452
|
+
if (!this._enforcePrivate) {
|
|
453
|
+
return false;
|
|
454
|
+
}
|
|
455
|
+
const declaration = property.valueDeclaration ?? property.declarations?.[0];
|
|
456
|
+
if (declaration === undefined || !this._typescript.isPropertyDeclaration(declaration)) {
|
|
457
|
+
return false;
|
|
458
|
+
}
|
|
459
|
+
if (!this._typescript.isIdentifier(declaration.name)) {
|
|
460
|
+
return false;
|
|
461
|
+
}
|
|
462
|
+
const flags = this._typescript.getCombinedModifierFlags(declaration);
|
|
463
|
+
return (flags & this._typescript.ModifierFlags.Private) !== 0 &&
|
|
464
|
+
(flags & (this._typescript.ModifierFlags.Protected | this._typescript.ModifierFlags.Static)) === 0;
|
|
465
|
+
}
|
|
279
466
|
_getDefinitionName(type, node) {
|
|
280
467
|
const existingName = this._definitionNames.get(type);
|
|
281
468
|
if (existingName !== undefined) {
|