@tsonic/frontend 0.0.4 → 0.0.11
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/.tsbuildinfo +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/ir/builder/exports.d.ts.map +1 -1
- package/dist/ir/builder/exports.js +8 -6
- package/dist/ir/builder/exports.js.map +1 -1
- package/dist/ir/builder/imports.d.ts.map +1 -1
- package/dist/ir/builder/imports.js +6 -6
- package/dist/ir/builder/imports.js.map +1 -1
- package/dist/ir/builder/statements.d.ts +7 -1
- package/dist/ir/builder/statements.d.ts.map +1 -1
- package/dist/ir/builder/statements.js +18 -5
- package/dist/ir/builder/statements.js.map +1 -1
- package/dist/ir/builder.test.js +70 -5
- package/dist/ir/builder.test.js.map +1 -1
- package/dist/ir/converters/anonymous-synthesis.d.ts +76 -0
- package/dist/ir/converters/anonymous-synthesis.d.ts.map +1 -0
- package/dist/ir/converters/anonymous-synthesis.js +307 -0
- package/dist/ir/converters/anonymous-synthesis.js.map +1 -0
- package/dist/ir/converters/expressions/access.d.ts.map +1 -1
- package/dist/ir/converters/expressions/access.js +65 -2
- package/dist/ir/converters/expressions/access.js.map +1 -1
- package/dist/ir/converters/expressions/calls.d.ts.map +1 -1
- package/dist/ir/converters/expressions/calls.js +96 -1
- package/dist/ir/converters/expressions/calls.js.map +1 -1
- package/dist/ir/converters/expressions/collections.d.ts +3 -0
- package/dist/ir/converters/expressions/collections.d.ts.map +1 -1
- package/dist/ir/converters/expressions/collections.js +43 -2
- package/dist/ir/converters/expressions/collections.js.map +1 -1
- package/dist/ir/converters/expressions/functions.d.ts.map +1 -1
- package/dist/ir/converters/expressions/functions.js +52 -5
- package/dist/ir/converters/expressions/functions.js.map +1 -1
- package/dist/ir/converters/expressions/helpers.d.ts +10 -0
- package/dist/ir/converters/expressions/helpers.d.ts.map +1 -1
- package/dist/ir/converters/expressions/helpers.js +173 -7
- package/dist/ir/converters/expressions/helpers.js.map +1 -1
- package/dist/ir/converters/expressions/index.d.ts +1 -1
- package/dist/ir/converters/expressions/index.d.ts.map +1 -1
- package/dist/ir/converters/expressions/index.js +1 -1
- package/dist/ir/converters/expressions/index.js.map +1 -1
- package/dist/ir/converters/expressions/literals.d.ts.map +1 -1
- package/dist/ir/converters/expressions/literals.js +2 -1
- package/dist/ir/converters/expressions/literals.js.map +1 -1
- package/dist/ir/converters/expressions/numeric-recovery.test.d.ts +14 -0
- package/dist/ir/converters/expressions/numeric-recovery.test.d.ts.map +1 -0
- package/dist/ir/converters/expressions/numeric-recovery.test.js +286 -0
- package/dist/ir/converters/expressions/numeric-recovery.test.js.map +1 -0
- package/dist/ir/converters/expressions/operators.d.ts.map +1 -1
- package/dist/ir/converters/expressions/operators.js +16 -2
- package/dist/ir/converters/expressions/operators.js.map +1 -1
- package/dist/ir/converters/expressions/other.d.ts.map +1 -1
- package/dist/ir/converters/expressions/other.js +4 -1
- package/dist/ir/converters/expressions/other.js.map +1 -1
- package/dist/ir/converters/statements/control/conditionals.d.ts.map +1 -1
- package/dist/ir/converters/statements/control/conditionals.js +4 -6
- package/dist/ir/converters/statements/control/conditionals.js.map +1 -1
- package/dist/ir/converters/statements/control/loops.d.ts.map +1 -1
- package/dist/ir/converters/statements/control/loops.js +6 -5
- package/dist/ir/converters/statements/control/loops.js.map +1 -1
- package/dist/ir/converters/statements/declarations/interfaces.d.ts +4 -3
- package/dist/ir/converters/statements/declarations/interfaces.d.ts.map +1 -1
- package/dist/ir/converters/statements/declarations/interfaces.js +55 -1
- package/dist/ir/converters/statements/declarations/interfaces.js.map +1 -1
- package/dist/ir/converters/statements/declarations/type-aliases.d.ts +8 -3
- package/dist/ir/converters/statements/declarations/type-aliases.d.ts.map +1 -1
- package/dist/ir/converters/statements/declarations/type-aliases.js +12 -2
- package/dist/ir/converters/statements/declarations/type-aliases.js.map +1 -1
- package/dist/ir/converters/synthetic-types.d.ts +38 -0
- package/dist/ir/converters/synthetic-types.d.ts.map +1 -0
- package/dist/ir/converters/synthetic-types.js +123 -0
- package/dist/ir/converters/synthetic-types.js.map +1 -0
- package/dist/ir/expression-converter.d.ts.map +1 -1
- package/dist/ir/expression-converter.js +81 -9
- package/dist/ir/expression-converter.js.map +1 -1
- package/dist/ir/statement-converter.d.ts +16 -1
- package/dist/ir/statement-converter.d.ts.map +1 -1
- package/dist/ir/statement-converter.js +32 -0
- package/dist/ir/statement-converter.js.map +1 -1
- package/dist/ir/type-converter/arrays.d.ts.map +1 -1
- package/dist/ir/type-converter/arrays.js +1 -0
- package/dist/ir/type-converter/arrays.js.map +1 -1
- package/dist/ir/type-converter/index.d.ts +1 -1
- package/dist/ir/type-converter/index.d.ts.map +1 -1
- package/dist/ir/type-converter/index.js +1 -1
- package/dist/ir/type-converter/index.js.map +1 -1
- package/dist/ir/type-converter/inference.d.ts +12 -0
- package/dist/ir/type-converter/inference.d.ts.map +1 -1
- package/dist/ir/type-converter/inference.js +172 -23
- package/dist/ir/type-converter/inference.js.map +1 -1
- package/dist/ir/type-converter/literals.d.ts.map +1 -1
- package/dist/ir/type-converter/literals.js +2 -1
- package/dist/ir/type-converter/literals.js.map +1 -1
- package/dist/ir/type-converter/objects.d.ts.map +1 -1
- package/dist/ir/type-converter/objects.js +2 -1
- package/dist/ir/type-converter/objects.js.map +1 -1
- package/dist/ir/type-converter/orchestrator.d.ts +2 -2
- package/dist/ir/type-converter/orchestrator.d.ts.map +1 -1
- package/dist/ir/type-converter/orchestrator.js +55 -1
- package/dist/ir/type-converter/orchestrator.js.map +1 -1
- package/dist/ir/type-converter/references.d.ts.map +1 -1
- package/dist/ir/type-converter/references.js +14 -18
- package/dist/ir/type-converter/references.js.map +1 -1
- package/dist/ir/type-converter.d.ts +1 -1
- package/dist/ir/type-converter.d.ts.map +1 -1
- package/dist/ir/type-converter.js +1 -1
- package/dist/ir/type-converter.js.map +1 -1
- package/dist/ir/types/expressions.d.ts +110 -1
- package/dist/ir/types/expressions.d.ts.map +1 -1
- package/dist/ir/types/guards.d.ts.map +1 -1
- package/dist/ir/types/guards.js +2 -0
- package/dist/ir/types/guards.js.map +1 -1
- package/dist/ir/types/index.d.ts +5 -3
- package/dist/ir/types/index.d.ts.map +1 -1
- package/dist/ir/types/index.js +1 -0
- package/dist/ir/types/index.js.map +1 -1
- package/dist/ir/types/ir-types.d.ts +33 -1
- package/dist/ir/types/ir-types.d.ts.map +1 -1
- package/dist/ir/types/numeric-kind.d.ts +68 -0
- package/dist/ir/types/numeric-kind.d.ts.map +1 -0
- package/dist/ir/types/numeric-kind.js +170 -0
- package/dist/ir/types/numeric-kind.js.map +1 -0
- package/dist/ir/types/statements.d.ts +38 -1
- package/dist/ir/types/statements.d.ts.map +1 -1
- package/dist/ir/types.d.ts +2 -1
- package/dist/ir/types.d.ts.map +1 -1
- package/dist/ir/types.js +2 -0
- package/dist/ir/types.js.map +1 -1
- package/dist/ir/validation/index.d.ts +7 -0
- package/dist/ir/validation/index.d.ts.map +1 -0
- package/dist/ir/validation/index.js +7 -0
- package/dist/ir/validation/index.js.map +1 -0
- package/dist/ir/validation/numeric-invariants.test.d.ts +15 -0
- package/dist/ir/validation/numeric-invariants.test.d.ts.map +1 -0
- package/dist/ir/validation/numeric-invariants.test.js +598 -0
- package/dist/ir/validation/numeric-invariants.test.js.map +1 -0
- package/dist/ir/validation/numeric-proof-pass.d.ts +37 -0
- package/dist/ir/validation/numeric-proof-pass.d.ts.map +1 -0
- package/dist/ir/validation/numeric-proof-pass.js +889 -0
- package/dist/ir/validation/numeric-proof-pass.js.map +1 -0
- package/dist/ir/validation/soundness-gate.d.ts +26 -0
- package/dist/ir/validation/soundness-gate.d.ts.map +1 -0
- package/dist/ir/validation/soundness-gate.js +551 -0
- package/dist/ir/validation/soundness-gate.js.map +1 -0
- package/dist/ir/validation/soundness-gate.test.d.ts +13 -0
- package/dist/ir/validation/soundness-gate.test.d.ts.map +1 -0
- package/dist/ir/validation/soundness-gate.test.js +315 -0
- package/dist/ir/validation/soundness-gate.test.js.map +1 -0
- package/dist/ir/validation/yield-lowering-pass.d.ts +40 -0
- package/dist/ir/validation/yield-lowering-pass.d.ts.map +1 -0
- package/dist/ir/validation/yield-lowering-pass.js +548 -0
- package/dist/ir/validation/yield-lowering-pass.js.map +1 -0
- package/dist/ir/validation/yield-lowering-pass.test.d.ts +12 -0
- package/dist/ir/validation/yield-lowering-pass.test.d.ts.map +1 -0
- package/dist/ir/validation/yield-lowering-pass.test.js +761 -0
- package/dist/ir/validation/yield-lowering-pass.test.js.map +1 -0
- package/dist/program/bindings.d.ts +5 -0
- package/dist/program/bindings.d.ts.map +1 -1
- package/dist/program/bindings.js +12 -1
- package/dist/program/bindings.js.map +1 -1
- package/dist/program/dependency-graph.d.ts +3 -0
- package/dist/program/dependency-graph.d.ts.map +1 -1
- package/dist/program/dependency-graph.js +28 -4
- package/dist/program/dependency-graph.js.map +1 -1
- package/dist/program/index.d.ts +1 -1
- package/dist/program/index.d.ts.map +1 -1
- package/dist/program/index.js.map +1 -1
- package/dist/program.d.ts +1 -0
- package/dist/program.d.ts.map +1 -1
- package/dist/program.js.map +1 -1
- package/dist/resolver/clr-bindings-resolver.d.ts +9 -0
- package/dist/resolver/clr-bindings-resolver.d.ts.map +1 -1
- package/dist/resolver/clr-bindings-resolver.js +52 -3
- package/dist/resolver/clr-bindings-resolver.js.map +1 -1
- package/dist/types/diagnostic.d.ts +1 -1
- package/dist/types/diagnostic.d.ts.map +1 -1
- package/dist/types/diagnostic.js.map +1 -1
- package/dist/validation/static-safety.d.ts +6 -1
- package/dist/validation/static-safety.d.ts.map +1 -1
- package/dist/validation/static-safety.js +144 -36
- package/dist/validation/static-safety.js.map +1 -1
- package/dist/validation/unsupported-utility-types.d.ts +38 -0
- package/dist/validation/unsupported-utility-types.d.ts.map +1 -0
- package/dist/validation/unsupported-utility-types.js +53 -0
- package/dist/validation/unsupported-utility-types.js.map +1 -0
- package/dist/validator.test.js +304 -14
- package/dist/validator.test.js.map +1 -1
- package/package.json +1 -1
- package/dist/types/parameter-modifiers.d.ts +0 -55
- package/dist/types/parameter-modifiers.d.ts.map +0 -1
- package/dist/types/parameter-modifiers.js +0 -148
- package/dist/types/parameter-modifiers.js.map +0 -1
|
@@ -5,7 +5,12 @@
|
|
|
5
5
|
* - TSN7401: 'any' type usage
|
|
6
6
|
* - TSN7403: Object literal without contextual nominal type
|
|
7
7
|
* - TSN7405: Untyped function/arrow/lambda parameter
|
|
8
|
-
* -
|
|
8
|
+
* - TSN7406: Mapped types not supported
|
|
9
|
+
* - TSN7407: Conditional types not supported
|
|
10
|
+
* - TSN7408: Mixed variadic tuples not supported
|
|
11
|
+
* - TSN7409: 'infer' keyword not supported
|
|
12
|
+
* - TSN7410: Intersection types not supported
|
|
13
|
+
* - TSN7413: Dictionary key must be string or number
|
|
9
14
|
*
|
|
10
15
|
* This ensures NativeAOT-compatible, predictable-performance output.
|
|
11
16
|
*
|
|
@@ -16,6 +21,9 @@
|
|
|
16
21
|
import * as ts from "typescript";
|
|
17
22
|
import { addDiagnostic, createDiagnostic, } from "../types/diagnostic.js";
|
|
18
23
|
import { getNodeLocation } from "./helpers.js";
|
|
24
|
+
import { inferLambdaParamTypes } from "../ir/type-converter/index.js";
|
|
25
|
+
import { UNSUPPORTED_MAPPED_UTILITY_TYPES, UNSUPPORTED_CONDITIONAL_UTILITY_TYPES, } from "./unsupported-utility-types.js";
|
|
26
|
+
import { checkSynthesisEligibility } from "../ir/converters/anonymous-synthesis.js";
|
|
19
27
|
/**
|
|
20
28
|
* Validate a source file for static safety violations.
|
|
21
29
|
*/
|
|
@@ -36,49 +44,122 @@ export const validateStaticSafety = (sourceFile, program, collector) => {
|
|
|
36
44
|
// Covers: function declarations, methods, constructors, arrow functions, function expressions
|
|
37
45
|
if (ts.isParameter(node) && !node.type) {
|
|
38
46
|
const parent = node.parent;
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
47
|
+
// For lambdas (arrow functions and function expressions), allow inference from context
|
|
48
|
+
const isLambda = ts.isArrowFunction(parent) || ts.isFunctionExpression(parent);
|
|
49
|
+
if (isLambda) {
|
|
50
|
+
// Try contextual signature inference
|
|
51
|
+
const inference = inferLambdaParamTypes(parent, checker);
|
|
52
|
+
const paramIndex = parent.parameters.indexOf(node);
|
|
53
|
+
// If inference succeeded for this parameter, don't emit TSN7405
|
|
54
|
+
if (inference && inference.paramTypes[paramIndex] !== undefined) {
|
|
55
|
+
// Inference succeeded - no error needed
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
// Inference failed - emit TSN7405
|
|
59
|
+
const paramName = ts.isIdentifier(node.name)
|
|
60
|
+
? node.name.text
|
|
61
|
+
: "param";
|
|
62
|
+
currentCollector = addDiagnostic(currentCollector, createDiagnostic("TSN7405", "error", `Parameter '${paramName}' must have an explicit type annotation.`, getNodeLocation(sourceFile, node), "Add a type annotation to this parameter, or use the lambda in a context that provides type inference (e.g., array.sort, array.map)."));
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
// For non-lambdas (function declarations, methods, constructors, accessors),
|
|
67
|
+
// always require explicit type annotations
|
|
68
|
+
const isFunctionLike = ts.isFunctionDeclaration(parent) ||
|
|
69
|
+
ts.isMethodDeclaration(parent) ||
|
|
70
|
+
ts.isConstructorDeclaration(parent) ||
|
|
71
|
+
ts.isGetAccessorDeclaration(parent) ||
|
|
72
|
+
ts.isSetAccessorDeclaration(parent);
|
|
73
|
+
if (isFunctionLike) {
|
|
74
|
+
const paramName = ts.isIdentifier(node.name)
|
|
75
|
+
? node.name.text
|
|
76
|
+
: "param";
|
|
77
|
+
currentCollector = addDiagnostic(currentCollector, createDiagnostic("TSN7405", "error", `Parameter '${paramName}' must have an explicit type annotation.`, getNodeLocation(sourceFile, node), "Add a type annotation to this parameter."));
|
|
78
|
+
}
|
|
49
79
|
}
|
|
50
80
|
}
|
|
51
81
|
// TSN7403: Check for object literals without contextual nominal type
|
|
82
|
+
// Now supports auto-synthesis for eligible object literals (spreads, arrow props)
|
|
52
83
|
if (ts.isObjectLiteralExpression(node)) {
|
|
53
84
|
const contextualType = checker.getContextualType(node);
|
|
54
|
-
//
|
|
55
|
-
if (
|
|
56
|
-
|
|
57
|
-
|
|
85
|
+
// If there's a contextual nominal type, we're good
|
|
86
|
+
if (contextualType &&
|
|
87
|
+
isNominalOrDictionaryType(contextualType, checker)) {
|
|
88
|
+
// Has contextual type - no synthesis needed
|
|
89
|
+
}
|
|
90
|
+
else {
|
|
91
|
+
// No contextual type - check if eligible for synthesis
|
|
92
|
+
const eligibility = checkSynthesisEligibility(node, checker);
|
|
93
|
+
if (!eligibility.eligible) {
|
|
94
|
+
// Not eligible for synthesis - emit diagnostic with specific reason
|
|
95
|
+
currentCollector = addDiagnostic(currentCollector, createDiagnostic("TSN7403", "error", `Object literal cannot be synthesized: ${eligibility.reason}`, getNodeLocation(sourceFile, node), "Use an explicit type annotation, or restructure to use only identifier keys and arrow functions."));
|
|
96
|
+
}
|
|
97
|
+
// If eligible, synthesis will happen during IR conversion
|
|
58
98
|
}
|
|
59
99
|
}
|
|
60
|
-
//
|
|
61
|
-
// Record<K, V> where K is not string
|
|
100
|
+
// Check TypeReferenceNode for utility types and dictionary keys
|
|
62
101
|
if (ts.isTypeReferenceNode(node)) {
|
|
63
102
|
const typeName = node.typeName;
|
|
64
|
-
if (ts.isIdentifier(typeName)
|
|
65
|
-
const
|
|
66
|
-
const
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
103
|
+
if (ts.isIdentifier(typeName)) {
|
|
104
|
+
const name = typeName.text;
|
|
105
|
+
const hasTypeArgs = node.typeArguments && node.typeArguments.length > 0;
|
|
106
|
+
// TSN7406: Mapped-type utility types (these expand to mapped types internally)
|
|
107
|
+
// Only check when type arguments are present to avoid false positives for
|
|
108
|
+
// user-defined types named "Partial", etc.
|
|
109
|
+
if (hasTypeArgs && UNSUPPORTED_MAPPED_UTILITY_TYPES.has(name)) {
|
|
110
|
+
currentCollector = addDiagnostic(currentCollector, createDiagnostic("TSN7406", "error", `Utility type '${name}' is not supported (it uses mapped types internally).`, getNodeLocation(sourceFile, node), `Replace '${name}' with an explicit interface that has the desired properties.`));
|
|
111
|
+
}
|
|
112
|
+
// TSN7407: Conditional-type utility types (these expand to conditional types internally)
|
|
113
|
+
// Only check when type arguments are present
|
|
114
|
+
if (hasTypeArgs && UNSUPPORTED_CONDITIONAL_UTILITY_TYPES.has(name)) {
|
|
115
|
+
currentCollector = addDiagnostic(currentCollector, createDiagnostic("TSN7407", "error", `Utility type '${name}' is not supported (it uses conditional types internally).`, getNodeLocation(sourceFile, node), `Replace '${name}' with an explicit type definition.`));
|
|
116
|
+
}
|
|
117
|
+
// TSN7413: Record<K, V> where K is not an allowed key type
|
|
118
|
+
if (name === "Record") {
|
|
119
|
+
const typeArgs = node.typeArguments;
|
|
120
|
+
const keyTypeNode = typeArgs?.[0];
|
|
121
|
+
if (keyTypeNode !== undefined) {
|
|
122
|
+
if (!isAllowedKeyType(keyTypeNode)) {
|
|
123
|
+
currentCollector = addDiagnostic(currentCollector, createDiagnostic("TSN7413", "error", "Dictionary key type must be 'string' or 'number'. Other key types are not supported.", getNodeLocation(sourceFile, keyTypeNode), "Use Record<string, V> or Record<number, V>."));
|
|
124
|
+
}
|
|
70
125
|
}
|
|
71
126
|
}
|
|
72
127
|
}
|
|
73
128
|
}
|
|
74
|
-
// TSN7413: Check for
|
|
75
|
-
//
|
|
129
|
+
// TSN7413: Check for unsupported index signature key types
|
|
130
|
+
// Only string and number are allowed (matches TypeScript's index signature constraints)
|
|
76
131
|
if (ts.isIndexSignatureDeclaration(node)) {
|
|
77
132
|
const keyParam = node.parameters[0];
|
|
78
|
-
if (keyParam?.type && !
|
|
79
|
-
currentCollector = addDiagnostic(currentCollector, createDiagnostic("TSN7413", "error", "Index signature key type must be 'string'.
|
|
133
|
+
if (keyParam?.type && !isAllowedKeyType(keyParam.type)) {
|
|
134
|
+
currentCollector = addDiagnostic(currentCollector, createDiagnostic("TSN7413", "error", "Index signature key type must be 'string' or 'number'. Other key types are not supported.", getNodeLocation(sourceFile, keyParam.type), "Use { [key: string]: V } or { [key: number]: V }."));
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
// TSN7406: Check for mapped types (e.g., { [P in keyof T]: ... })
|
|
138
|
+
if (ts.isMappedTypeNode(node)) {
|
|
139
|
+
currentCollector = addDiagnostic(currentCollector, createDiagnostic("TSN7406", "error", "Mapped types are not supported. Write an explicit interface or class instead.", getNodeLocation(sourceFile, node), "Replace mapped types like Partial<T>, Required<T>, or { [P in keyof T]: ... } with explicit interface definitions."));
|
|
140
|
+
}
|
|
141
|
+
// TSN7407: Check for conditional types (e.g., T extends U ? X : Y)
|
|
142
|
+
if (ts.isConditionalTypeNode(node)) {
|
|
143
|
+
currentCollector = addDiagnostic(currentCollector, createDiagnostic("TSN7407", "error", "Conditional types are not supported. Use explicit union types or overloads instead.", getNodeLocation(sourceFile, node), "Replace conditional types like Extract<T, U> or T extends X ? Y : Z with explicit type definitions."));
|
|
144
|
+
}
|
|
145
|
+
// TSN7408: Check for variadic tuple types with mixed elements (e.g., [string, ...number[]])
|
|
146
|
+
// Pure variadic tuples like [...T[]] are OK (converted to arrays), fixed tuples are OK
|
|
147
|
+
// Mixed tuples with both fixed and rest elements are not supported
|
|
148
|
+
if (ts.isTupleTypeNode(node)) {
|
|
149
|
+
const hasRest = node.elements.some((el) => ts.isRestTypeNode(el));
|
|
150
|
+
const hasFixed = node.elements.some((el) => !ts.isRestTypeNode(el));
|
|
151
|
+
if (hasRest && hasFixed) {
|
|
152
|
+
currentCollector = addDiagnostic(currentCollector, createDiagnostic("TSN7408", "error", "Variadic tuple types with mixed fixed and rest elements are not supported.", getNodeLocation(sourceFile, node), "Use a fixed-length tuple like [T1, T2] or an array like T[] instead."));
|
|
80
153
|
}
|
|
81
154
|
}
|
|
155
|
+
// TSN7409: Check for 'infer' keyword in conditional types
|
|
156
|
+
if (ts.isInferTypeNode(node)) {
|
|
157
|
+
currentCollector = addDiagnostic(currentCollector, createDiagnostic("TSN7409", "error", "The 'infer' keyword is not supported. Use explicit type parameters instead.", getNodeLocation(sourceFile, node), "Replace infer patterns with explicit generic type parameters."));
|
|
158
|
+
}
|
|
159
|
+
// TSN7410: Check for intersection types (e.g., A & B)
|
|
160
|
+
if (ts.isIntersectionTypeNode(node)) {
|
|
161
|
+
currentCollector = addDiagnostic(currentCollector, createDiagnostic("TSN7410", "error", "Intersection types (A & B) are not supported. Use a nominal type that explicitly includes all required members.", getNodeLocation(sourceFile, node), "Replace the intersection with an interface or class that combines the members, or a type alias to an object type with explicit members."));
|
|
162
|
+
}
|
|
82
163
|
// Continue visiting children
|
|
83
164
|
ts.forEachChild(node, (child) => {
|
|
84
165
|
currentCollector = visitor(child, currentCollector);
|
|
@@ -92,14 +173,26 @@ export const validateStaticSafety = (sourceFile, program, collector) => {
|
|
|
92
173
|
* or a dictionary type that we can emit.
|
|
93
174
|
*
|
|
94
175
|
* Returns false for anonymous object types like `{ x: number }` without a name.
|
|
176
|
+
*
|
|
177
|
+
* Special case: Union types defined via type aliases (e.g., Result<T, E> = { ok: true; value: T } | {...})
|
|
178
|
+
* are considered nominal because we generate synthetic interfaces for them during IR building.
|
|
95
179
|
*/
|
|
96
180
|
const isNominalOrDictionaryType = (type, checker) => {
|
|
97
181
|
// Check if it's a dictionary type (Record<K,V> or index signature)
|
|
98
182
|
if (isTsDictionaryType(type)) {
|
|
99
183
|
return true;
|
|
100
184
|
}
|
|
185
|
+
// Check if the type has an aliasSymbol (used via a type alias)
|
|
186
|
+
// This catches: type Result = { ok: true } | { ok: false }
|
|
187
|
+
// where the union was defined via a type alias
|
|
188
|
+
if (type.aliasSymbol) {
|
|
189
|
+
const aliasDecl = type.aliasSymbol.getDeclarations()?.[0];
|
|
190
|
+
if (aliasDecl && ts.isTypeAliasDeclaration(aliasDecl)) {
|
|
191
|
+
return true;
|
|
192
|
+
}
|
|
193
|
+
}
|
|
101
194
|
// Check if the type has a symbol with a declaration (named type)
|
|
102
|
-
const symbol = type.getSymbol()
|
|
195
|
+
const symbol = type.getSymbol();
|
|
103
196
|
if (symbol) {
|
|
104
197
|
const declarations = symbol.getDeclarations();
|
|
105
198
|
const decl = declarations?.[0];
|
|
@@ -112,6 +205,14 @@ const isNominalOrDictionaryType = (type, checker) => {
|
|
|
112
205
|
}
|
|
113
206
|
}
|
|
114
207
|
}
|
|
208
|
+
// Check for union types with aliasSymbol (discriminated unions via type alias)
|
|
209
|
+
// This handles: return { ok: true, value } where return type is Result<T,E>
|
|
210
|
+
if (type.isUnion()) {
|
|
211
|
+
// Check if this union was created from a type alias
|
|
212
|
+
if (type.aliasSymbol) {
|
|
213
|
+
return true;
|
|
214
|
+
}
|
|
215
|
+
}
|
|
115
216
|
// Check for primitive types (allowed)
|
|
116
217
|
if (type.flags & ts.TypeFlags.String ||
|
|
117
218
|
type.flags & ts.TypeFlags.Number ||
|
|
@@ -145,19 +246,26 @@ const isTsDictionaryType = (type) => {
|
|
|
145
246
|
return !!(stringIndexType || numberIndexType);
|
|
146
247
|
};
|
|
147
248
|
/**
|
|
148
|
-
* Check if a type node represents
|
|
149
|
-
*
|
|
249
|
+
* Check if a type node represents an allowed dictionary key type.
|
|
250
|
+
* Allowed: string, number (matches TypeScript's PropertyKey constraint)
|
|
251
|
+
*
|
|
252
|
+
* Note: TypeScript's Record<K, V> only allows K extends keyof any (string | number | symbol).
|
|
253
|
+
* We support string and number. Symbol is rejected via TSN7203.
|
|
150
254
|
*/
|
|
151
|
-
const
|
|
152
|
-
// Direct
|
|
153
|
-
if (typeNode.kind === ts.SyntaxKind.StringKeyword
|
|
255
|
+
const isAllowedKeyType = (typeNode) => {
|
|
256
|
+
// Direct keywords
|
|
257
|
+
if (typeNode.kind === ts.SyntaxKind.StringKeyword ||
|
|
258
|
+
typeNode.kind === ts.SyntaxKind.NumberKeyword) {
|
|
154
259
|
return true;
|
|
155
260
|
}
|
|
156
|
-
// Type reference to
|
|
261
|
+
// Type reference to allowed types
|
|
157
262
|
if (ts.isTypeReferenceNode(typeNode)) {
|
|
158
263
|
const typeName = typeNode.typeName;
|
|
159
|
-
if (ts.isIdentifier(typeName)
|
|
160
|
-
|
|
264
|
+
if (ts.isIdentifier(typeName)) {
|
|
265
|
+
const name = typeName.text;
|
|
266
|
+
if (name === "string" || name === "number") {
|
|
267
|
+
return true;
|
|
268
|
+
}
|
|
161
269
|
}
|
|
162
270
|
}
|
|
163
271
|
return false;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"static-safety.js","sourceRoot":"","sources":["../../src/validation/static-safety.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"static-safety.js","sourceRoot":"","sources":["../../src/validation/static-safety.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,KAAK,EAAE,MAAM,YAAY,CAAC;AAEjC,OAAO,EAEL,aAAa,EACb,gBAAgB,GACjB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AACtE,OAAO,EACL,gCAAgC,EAChC,qCAAqC,GACtC,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAE,yBAAyB,EAAE,MAAM,yCAAyC,CAAC;AAEpF;;GAEG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAClC,UAAyB,EACzB,OAAsB,EACtB,SAA+B,EACT,EAAE;IACxB,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;IAEhC,MAAM,OAAO,GAAG,CACd,IAAa,EACb,YAAkC,EACZ,EAAE;QACxB,IAAI,gBAAgB,GAAG,YAAY,CAAC;QAEpC,qDAAqD;QACrD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MG;AACH,MAAM,kBAAkB,GAAG,CAAC,IAAa,EAAW,EAAE;IACpD,qCAAqC;IACrC,IAAI,IAAI,CAAC,WAAW,EAAE,IAAI,KAAK,QAAQ,EAAE,CAAC;QACxC,OAAO,IAAI,CAAC;IACd,CAAC;IAED,yDAAyD;IACzD,MAAM,eAAe,GAAG,IAAI,CAAC,kBAAkB,EAAE,CAAC;IAClD,MAAM,eAAe,GAAG,IAAI,CAAC,kBAAkB,EAAE,CAAC;IAElD,OAAO,CAAC,CAAC,CAAC,eAAe,IAAI,eAAe,CAAC,CAAC;AAChD,CAAC,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,gBAAgB,GAAG,CAAC,QAAqB,EAAW,EAAE;IAC1D,kBAAkB;IAClB,IACE,QAAQ,CAAC,IAAI,KAAK,EAAE,CAAC,UAAU,CAAC,aAAa;QAC7C,QAAQ,CAAC,IAAI,KAAK,EAAE,CAAC,UAAU,CAAC,aAAa,EAC7C,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IAED,kCAAkC;IAClC,IAAI,EAAE,CAAC,mBAAmB,CAAC,QAAQ,CAAC,EAAE,CAAC;QACrC,MAAM,QAAQ,GAAG,QAAQ,CAAC,QAAQ,CAAC;QACnC,IAAI,EAAE,CAAC,YAAY,CAAC,QAAQ,CAAC,EAAE,CAAC;YAC9B,MAAM,IAAI,GAAG,QAAQ,CAAC,IAAI,CAAC;YAC3B,IAAI,IAAI,KAAK,QAAQ,IAAI,IAAI,KAAK,QAAQ,EAAE,CAAC;gBAC3C,OAAO,IAAI,CAAC;YACd,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC,CAAC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Centralized list of unsupported TypeScript utility types
|
|
3
|
+
*
|
|
4
|
+
* These utility types internally use mapped or conditional types which are not
|
|
5
|
+
* supported in Tsonic. They are detected by name in TypeReferenceNode validation.
|
|
6
|
+
*
|
|
7
|
+
* Note: This only applies to the built-in utility types from TypeScript's lib.
|
|
8
|
+
* User-defined types with these names (without type arguments) are allowed.
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* Mapped-type utility types (TSN7406)
|
|
12
|
+
*
|
|
13
|
+
* These expand to mapped types internally:
|
|
14
|
+
* - Partial<T> → { [P in keyof T]?: T[P] }
|
|
15
|
+
* - Required<T> → { [P in keyof T]-?: T[P] }
|
|
16
|
+
* - Readonly<T> → { readonly [P in keyof T]: T[P] }
|
|
17
|
+
* - Pick<T, K> → { [P in K]: T[P] }
|
|
18
|
+
* - Omit<T, K> → { [P in Exclude<keyof T, K>]: T[P] }
|
|
19
|
+
*
|
|
20
|
+
* Note: Record<K, V> is handled separately (allowed when K is string, TSN7413 otherwise)
|
|
21
|
+
* Note: ReadonlyArray<T> is NOT a mapped type - it maps to IReadOnlyList<T> and is supported
|
|
22
|
+
*/
|
|
23
|
+
export declare const UNSUPPORTED_MAPPED_UTILITY_TYPES: Set<string>;
|
|
24
|
+
/**
|
|
25
|
+
* Conditional-type utility types (TSN7407)
|
|
26
|
+
*
|
|
27
|
+
* These expand to conditional types internally:
|
|
28
|
+
* - Extract<T, U> → T extends U ? T : never
|
|
29
|
+
* - Exclude<T, U> → T extends U ? never : T
|
|
30
|
+
* - NonNullable<T> → T & {} (or T extends null | undefined ? never : T)
|
|
31
|
+
* - ReturnType<T> → T extends (...args: any) => infer R ? R : any
|
|
32
|
+
* - Parameters<T> → T extends (...args: infer P) => any ? P : never
|
|
33
|
+
* - ConstructorParameters → ConstructorType extends abstract new (...args: infer P) => any ? P : never
|
|
34
|
+
* - InstanceType<T> → T extends abstract new (...args: any) => infer R ? R : any
|
|
35
|
+
* - Awaited<T> → T extends PromiseLike<infer U> ? Awaited<U> : T
|
|
36
|
+
*/
|
|
37
|
+
export declare const UNSUPPORTED_CONDITIONAL_UTILITY_TYPES: Set<string>;
|
|
38
|
+
//# sourceMappingURL=unsupported-utility-types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"unsupported-utility-types.d.ts","sourceRoot":"","sources":["../../src/validation/unsupported-utility-types.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,gCAAgC,aAM3C,CAAC;AAEH;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,qCAAqC,aAShD,CAAC"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Centralized list of unsupported TypeScript utility types
|
|
3
|
+
*
|
|
4
|
+
* These utility types internally use mapped or conditional types which are not
|
|
5
|
+
* supported in Tsonic. They are detected by name in TypeReferenceNode validation.
|
|
6
|
+
*
|
|
7
|
+
* Note: This only applies to the built-in utility types from TypeScript's lib.
|
|
8
|
+
* User-defined types with these names (without type arguments) are allowed.
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* Mapped-type utility types (TSN7406)
|
|
12
|
+
*
|
|
13
|
+
* These expand to mapped types internally:
|
|
14
|
+
* - Partial<T> → { [P in keyof T]?: T[P] }
|
|
15
|
+
* - Required<T> → { [P in keyof T]-?: T[P] }
|
|
16
|
+
* - Readonly<T> → { readonly [P in keyof T]: T[P] }
|
|
17
|
+
* - Pick<T, K> → { [P in K]: T[P] }
|
|
18
|
+
* - Omit<T, K> → { [P in Exclude<keyof T, K>]: T[P] }
|
|
19
|
+
*
|
|
20
|
+
* Note: Record<K, V> is handled separately (allowed when K is string, TSN7413 otherwise)
|
|
21
|
+
* Note: ReadonlyArray<T> is NOT a mapped type - it maps to IReadOnlyList<T> and is supported
|
|
22
|
+
*/
|
|
23
|
+
export const UNSUPPORTED_MAPPED_UTILITY_TYPES = new Set([
|
|
24
|
+
"Partial",
|
|
25
|
+
"Required",
|
|
26
|
+
"Readonly",
|
|
27
|
+
"Pick",
|
|
28
|
+
"Omit",
|
|
29
|
+
]);
|
|
30
|
+
/**
|
|
31
|
+
* Conditional-type utility types (TSN7407)
|
|
32
|
+
*
|
|
33
|
+
* These expand to conditional types internally:
|
|
34
|
+
* - Extract<T, U> → T extends U ? T : never
|
|
35
|
+
* - Exclude<T, U> → T extends U ? never : T
|
|
36
|
+
* - NonNullable<T> → T & {} (or T extends null | undefined ? never : T)
|
|
37
|
+
* - ReturnType<T> → T extends (...args: any) => infer R ? R : any
|
|
38
|
+
* - Parameters<T> → T extends (...args: infer P) => any ? P : never
|
|
39
|
+
* - ConstructorParameters → ConstructorType extends abstract new (...args: infer P) => any ? P : never
|
|
40
|
+
* - InstanceType<T> → T extends abstract new (...args: any) => infer R ? R : any
|
|
41
|
+
* - Awaited<T> → T extends PromiseLike<infer U> ? Awaited<U> : T
|
|
42
|
+
*/
|
|
43
|
+
export const UNSUPPORTED_CONDITIONAL_UTILITY_TYPES = new Set([
|
|
44
|
+
"Extract",
|
|
45
|
+
"Exclude",
|
|
46
|
+
"NonNullable",
|
|
47
|
+
"ReturnType",
|
|
48
|
+
"Parameters",
|
|
49
|
+
"ConstructorParameters",
|
|
50
|
+
"InstanceType",
|
|
51
|
+
"Awaited",
|
|
52
|
+
]);
|
|
53
|
+
//# sourceMappingURL=unsupported-utility-types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"unsupported-utility-types.js","sourceRoot":"","sources":["../../src/validation/unsupported-utility-types.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,MAAM,gCAAgC,GAAG,IAAI,GAAG,CAAC;IACtD,SAAS;IACT,UAAU;IACV,UAAU;IACV,MAAM;IACN,MAAM;CACP,CAAC,CAAC;AAEH;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,MAAM,qCAAqC,GAAG,IAAI,GAAG,CAAC;IAC3D,SAAS;IACT,SAAS;IACT,aAAa;IACb,YAAY;IACZ,YAAY;IACZ,uBAAuB;IACvB,cAAc;IACd,SAAS;CACV,CAAC,CAAC"}
|