@tsonic/frontend 0.0.62 → 0.0.64
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/dependency-graph.d.ts +1 -1
- package/dist/dependency-graph.d.ts.map +1 -1
- package/dist/dependency-graph.js +1 -1
- package/dist/dependency-graph.js.map +1 -1
- package/dist/dotnet-metadata.d.ts +0 -12
- package/dist/dotnet-metadata.d.ts.map +1 -1
- package/dist/dotnet-metadata.js +0 -24
- package/dist/dotnet-metadata.js.map +1 -1
- package/dist/generic-function-values.d.ts +11 -0
- package/dist/generic-function-values.d.ts.map +1 -0
- package/dist/generic-function-values.js +243 -0
- package/dist/generic-function-values.js.map +1 -0
- package/dist/generic-function-values.test.d.ts +2 -0
- package/dist/generic-function-values.test.d.ts.map +1 -0
- package/dist/generic-function-values.test.js +256 -0
- package/dist/generic-function-values.test.js.map +1 -0
- package/dist/graph/extraction/imports.d.ts +5 -0
- package/dist/graph/extraction/imports.d.ts.map +1 -1
- package/dist/graph/extraction/imports.js +39 -1
- package/dist/graph/extraction/imports.js.map +1 -1
- package/dist/graph/extraction/index.d.ts +1 -1
- package/dist/graph/extraction/index.d.ts.map +1 -1
- package/dist/graph/extraction/index.js +1 -1
- package/dist/graph/extraction/index.js.map +1 -1
- package/dist/graph/extraction/orchestrator.d.ts.map +1 -1
- package/dist/graph/extraction/orchestrator.js +16 -2
- package/dist/graph/extraction/orchestrator.js.map +1 -1
- package/dist/graph/extraction.d.ts +1 -1
- package/dist/graph/extraction.d.ts.map +1 -1
- package/dist/graph/extraction.js +1 -1
- package/dist/graph/extraction.js.map +1 -1
- package/dist/ir/binding/binding-factory.d.ts +17 -0
- package/dist/ir/binding/binding-factory.d.ts.map +1 -0
- package/dist/ir/binding/binding-factory.js +765 -0
- package/dist/ir/binding/binding-factory.js.map +1 -0
- package/dist/ir/binding/binding-helpers.d.ts +90 -0
- package/dist/ir/binding/binding-helpers.d.ts.map +1 -0
- package/dist/ir/binding/binding-helpers.js +387 -0
- package/dist/ir/binding/binding-helpers.js.map +1 -0
- package/dist/ir/binding/binding-types.d.ts +203 -0
- package/dist/ir/binding/binding-types.d.ts.map +1 -0
- package/dist/ir/binding/binding-types.js +9 -0
- package/dist/ir/binding/binding-types.js.map +1 -0
- package/dist/ir/binding/index.d.ts +4 -158
- package/dist/ir/binding/index.d.ts.map +1 -1
- package/dist/ir/binding/index.js +3 -1134
- package/dist/ir/binding/index.js.map +1 -1
- package/dist/ir/binding-resolution.test.js +248 -0
- package/dist/ir/binding-resolution.test.js.map +1 -1
- package/dist/ir/builder/imports.d.ts.map +1 -1
- package/dist/ir/builder/imports.js +8 -1
- package/dist/ir/builder/imports.js.map +1 -1
- package/dist/ir/builder.test.js +360 -0
- package/dist/ir/builder.test.js.map +1 -1
- package/dist/ir/converters/anonymous-synthesis.d.ts +3 -3
- package/dist/ir/converters/anonymous-synthesis.d.ts.map +1 -1
- package/dist/ir/converters/anonymous-synthesis.js +45 -8
- package/dist/ir/converters/anonymous-synthesis.js.map +1 -1
- package/dist/ir/converters/expressions/access/access-converter.d.ts +14 -0
- package/dist/ir/converters/expressions/access/access-converter.d.ts.map +1 -0
- package/dist/ir/converters/expressions/access/access-converter.js +141 -0
- package/dist/ir/converters/expressions/access/access-converter.js.map +1 -0
- package/dist/ir/converters/expressions/access/binding-resolution.d.ts +35 -0
- package/dist/ir/converters/expressions/access/binding-resolution.d.ts.map +1 -0
- package/dist/ir/converters/expressions/access/binding-resolution.js +447 -0
- package/dist/ir/converters/expressions/access/binding-resolution.js.map +1 -0
- package/dist/ir/converters/expressions/access/member-resolution.d.ts +67 -0
- package/dist/ir/converters/expressions/access/member-resolution.d.ts.map +1 -0
- package/dist/ir/converters/expressions/access/member-resolution.js +262 -0
- package/dist/ir/converters/expressions/access/member-resolution.js.map +1 -0
- package/dist/ir/converters/expressions/access.d.ts +1 -7
- package/dist/ir/converters/expressions/access.d.ts.map +1 -1
- package/dist/ir/converters/expressions/access.js +1 -720
- package/dist/ir/converters/expressions/access.js.map +1 -1
- package/dist/ir/converters/expressions/calls/call-converter.d.ts +23 -0
- package/dist/ir/converters/expressions/calls/call-converter.d.ts.map +1 -0
- package/dist/ir/converters/expressions/calls/call-converter.js +526 -0
- package/dist/ir/converters/expressions/calls/call-converter.js.map +1 -0
- package/dist/ir/converters/expressions/calls/call-site-analysis.d.ts +53 -0
- package/dist/ir/converters/expressions/calls/call-site-analysis.d.ts.map +1 -0
- package/dist/ir/converters/expressions/calls/call-site-analysis.js +554 -0
- package/dist/ir/converters/expressions/calls/call-site-analysis.js.map +1 -0
- package/dist/ir/converters/expressions/calls/new-converter.d.ts +21 -0
- package/dist/ir/converters/expressions/calls/new-converter.d.ts.map +1 -0
- package/dist/ir/converters/expressions/calls/new-converter.js +182 -0
- package/dist/ir/converters/expressions/calls/new-converter.js.map +1 -0
- package/dist/ir/converters/expressions/calls.d.ts +2 -28
- package/dist/ir/converters/expressions/calls.d.ts.map +1 -1
- package/dist/ir/converters/expressions/calls.js +2 -1344
- package/dist/ir/converters/expressions/calls.js.map +1 -1
- package/dist/ir/converters/expressions/collections.d.ts.map +1 -1
- package/dist/ir/converters/expressions/collections.js +37 -6
- package/dist/ir/converters/expressions/collections.js.map +1 -1
- package/dist/ir/converters/expressions/functions.js +1 -1
- package/dist/ir/converters/expressions/functions.js.map +1 -1
- package/dist/ir/converters/expressions/helpers.d.ts.map +1 -1
- package/dist/ir/converters/expressions/helpers.js +1 -0
- package/dist/ir/converters/expressions/helpers.js.map +1 -1
- package/dist/ir/converters/expressions/other.d.ts.map +1 -1
- package/dist/ir/converters/expressions/other.js +3 -2
- package/dist/ir/converters/expressions/other.js.map +1 -1
- package/dist/ir/converters/flow-narrowing.d.ts.map +1 -1
- package/dist/ir/converters/flow-narrowing.js +3 -2
- package/dist/ir/converters/flow-narrowing.js.map +1 -1
- package/dist/ir/converters/statements/declarations/classes/methods.js +1 -1
- package/dist/ir/converters/statements/declarations/classes/methods.js.map +1 -1
- package/dist/ir/converters/statements/declarations/type-aliases.js +1 -1
- package/dist/ir/converters/statements/declarations/type-aliases.js.map +1 -1
- package/dist/ir/converters/statements/declarations/variables.d.ts +2 -2
- package/dist/ir/converters/statements/declarations/variables.d.ts.map +1 -1
- package/dist/ir/converters/statements/declarations/variables.js +289 -2
- package/dist/ir/converters/statements/declarations/variables.js.map +1 -1
- package/dist/ir/expression-converter.d.ts +0 -1
- package/dist/ir/expression-converter.d.ts.map +1 -1
- package/dist/ir/expression-converter.js +0 -2
- package/dist/ir/expression-converter.js.map +1 -1
- package/dist/ir/generic-function-value-lowering.test.d.ts +2 -0
- package/dist/ir/generic-function-value-lowering.test.d.ts.map +1 -0
- package/dist/ir/generic-function-value-lowering.test.js +312 -0
- package/dist/ir/generic-function-value-lowering.test.js.map +1 -0
- package/dist/ir/generic-validator.d.ts +3 -4
- package/dist/ir/generic-validator.d.ts.map +1 -1
- package/dist/ir/generic-validator.js +3 -35
- package/dist/ir/generic-validator.js.map +1 -1
- package/dist/ir/program-context.d.ts +12 -0
- package/dist/ir/program-context.d.ts.map +1 -1
- package/dist/ir/program-context.js +2 -0
- package/dist/ir/program-context.js.map +1 -1
- package/dist/ir/statement-converter.d.ts +0 -2
- package/dist/ir/statement-converter.d.ts.map +1 -1
- package/dist/ir/statement-converter.js +0 -3
- package/dist/ir/statement-converter.js.map +1 -1
- package/dist/ir/type-system/internal/handle-types.d.ts +16 -16
- package/dist/ir/type-system/internal/handle-types.d.ts.map +1 -1
- package/dist/ir/type-system/internal/nominal-env.d.ts +0 -2
- package/dist/ir/type-system/internal/nominal-env.d.ts.map +1 -1
- package/dist/ir/type-system/internal/nominal-env.js +2 -6
- package/dist/ir/type-system/internal/nominal-env.js.map +1 -1
- package/dist/ir/type-system/internal/type-converter/converter.d.ts +3 -1
- package/dist/ir/type-system/internal/type-converter/converter.d.ts.map +1 -1
- package/dist/ir/type-system/internal/type-converter/converter.js +3 -1
- package/dist/ir/type-system/internal/type-converter/converter.js.map +1 -1
- package/dist/ir/type-system/internal/type-converter/objects.js +7 -1
- package/dist/ir/type-system/internal/type-converter/objects.js.map +1 -1
- package/dist/ir/type-system/internal/type-converter/orchestrator.d.ts +0 -2
- package/dist/ir/type-system/internal/type-converter/orchestrator.d.ts.map +1 -1
- package/dist/ir/type-system/internal/type-converter/orchestrator.js +322 -23
- package/dist/ir/type-system/internal/type-converter/orchestrator.js.map +1 -1
- package/dist/ir/type-system/internal/type-converter/orchestrator.test.d.ts +2 -0
- package/dist/ir/type-system/internal/type-converter/orchestrator.test.d.ts.map +1 -0
- package/dist/ir/type-system/internal/type-converter/orchestrator.test.js +265 -0
- package/dist/ir/type-system/internal/type-converter/orchestrator.test.js.map +1 -0
- package/dist/ir/type-system/internal/type-converter/primitives.d.ts.map +1 -1
- package/dist/ir/type-system/internal/type-converter/primitives.js +5 -0
- package/dist/ir/type-system/internal/type-converter/primitives.js.map +1 -1
- package/dist/ir/type-system/internal/type-converter/references.d.ts.map +1 -1
- package/dist/ir/type-system/internal/type-converter/references.js +67 -29
- package/dist/ir/type-system/internal/type-converter/references.js.map +1 -1
- package/dist/ir/type-system/internal/type-converter/utility-types.d.ts.map +1 -1
- package/dist/ir/type-system/internal/type-converter/utility-types.js +145 -0
- package/dist/ir/type-system/internal/type-converter/utility-types.js.map +1 -1
- package/dist/ir/type-system/internal/type-converter/utility-types.test.js +91 -1
- package/dist/ir/type-system/internal/type-converter/utility-types.test.js.map +1 -1
- package/dist/ir/type-system/internal/type-registry.d.ts +1 -1
- package/dist/ir/type-system/internal/type-registry.js +7 -7
- package/dist/ir/type-system/internal/type-registry.js.map +1 -1
- package/dist/ir/type-system/internal/universe/alias-table.d.ts +0 -14
- package/dist/ir/type-system/internal/universe/alias-table.d.ts.map +1 -1
- package/dist/ir/type-system/internal/universe/alias-table.js +0 -17
- package/dist/ir/type-system/internal/universe/alias-table.js.map +1 -1
- package/dist/ir/type-system/internal/universe/clr-catalog.d.ts +3 -0
- package/dist/ir/type-system/internal/universe/clr-catalog.d.ts.map +1 -1
- package/dist/ir/type-system/internal/universe/clr-catalog.js +4 -1044
- package/dist/ir/type-system/internal/universe/clr-catalog.js.map +1 -1
- package/dist/ir/type-system/internal/universe/clr-entry-converter.d.ts +51 -0
- package/dist/ir/type-system/internal/universe/clr-entry-converter.d.ts.map +1 -0
- package/dist/ir/type-system/internal/universe/clr-entry-converter.js +657 -0
- package/dist/ir/type-system/internal/universe/clr-entry-converter.js.map +1 -0
- package/dist/ir/type-system/internal/universe/clr-type-parser.d.ts +52 -0
- package/dist/ir/type-system/internal/universe/clr-type-parser.d.ts.map +1 -0
- package/dist/ir/type-system/internal/universe/clr-type-parser.js +481 -0
- package/dist/ir/type-system/internal/universe/clr-type-parser.js.map +1 -0
- package/dist/ir/type-system/internal/universe/clr-type-parser.test.d.ts +2 -0
- package/dist/ir/type-system/internal/universe/clr-type-parser.test.d.ts.map +1 -0
- package/dist/ir/type-system/internal/universe/clr-type-parser.test.js +55 -0
- package/dist/ir/type-system/internal/universe/clr-type-parser.test.js.map +1 -0
- package/dist/ir/type-system/internal/universe/index.d.ts +1 -1
- package/dist/ir/type-system/internal/universe/index.d.ts.map +1 -1
- package/dist/ir/type-system/internal/universe/index.js +1 -3
- package/dist/ir/type-system/internal/universe/index.js.map +1 -1
- package/dist/ir/type-system/internal/universe/unified-universe.test.js +2 -0
- package/dist/ir/type-system/internal/universe/unified-universe.test.js.map +1 -1
- package/dist/ir/type-system/type-system-call-resolution.d.ts +69 -0
- package/dist/ir/type-system/type-system-call-resolution.d.ts.map +1 -0
- package/dist/ir/type-system/type-system-call-resolution.js +1121 -0
- package/dist/ir/type-system/type-system-call-resolution.js.map +1 -0
- package/dist/ir/type-system/type-system-inference.d.ts +98 -0
- package/dist/ir/type-system/type-system-inference.d.ts.map +1 -0
- package/dist/ir/type-system/type-system-inference.js +1121 -0
- package/dist/ir/type-system/type-system-inference.js.map +1 -0
- package/dist/ir/type-system/type-system-relations.d.ts +15 -0
- package/dist/ir/type-system/type-system-relations.d.ts.map +1 -0
- package/dist/ir/type-system/type-system-relations.js +152 -0
- package/dist/ir/type-system/type-system-relations.js.map +1 -0
- package/dist/ir/type-system/type-system-state.d.ts +436 -0
- package/dist/ir/type-system/type-system-state.d.ts.map +1 -0
- package/dist/ir/type-system/type-system-state.js +212 -0
- package/dist/ir/type-system/type-system-state.js.map +1 -0
- package/dist/ir/type-system/type-system-utilities.d.ts +56 -0
- package/dist/ir/type-system/type-system-utilities.d.ts.map +1 -0
- package/dist/ir/type-system/type-system-utilities.js +373 -0
- package/dist/ir/type-system/type-system-utilities.js.map +1 -0
- package/dist/ir/type-system/type-system.d.ts +17 -358
- package/dist/ir/type-system/type-system.d.ts.map +1 -1
- package/dist/ir/type-system/type-system.js +67 -2945
- package/dist/ir/type-system/type-system.js.map +1 -1
- package/dist/ir/types/index.d.ts +1 -0
- 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-substitution.js +1 -1
- package/dist/ir/types/ir-substitution.js.map +1 -1
- package/dist/ir/types/statements.d.ts +1 -1
- package/dist/ir/types/type-ops.d.ts +9 -0
- package/dist/ir/types/type-ops.d.ts.map +1 -0
- package/dist/ir/types/type-ops.js +134 -0
- package/dist/ir/types/type-ops.js.map +1 -0
- package/dist/ir/types/type-ops.test.d.ts +2 -0
- package/dist/ir/types/type-ops.test.d.ts.map +1 -0
- package/dist/ir/types/type-ops.test.js +73 -0
- package/dist/ir/types/type-ops.test.js.map +1 -0
- package/dist/ir/validation/anonymous-type-lowering-pass.d.ts.map +1 -1
- package/dist/ir/validation/anonymous-type-lowering-pass.js +34 -0
- package/dist/ir/validation/anonymous-type-lowering-pass.js.map +1 -1
- package/dist/ir/validation/anonymous-type-lowering-regressions.test.d.ts +2 -0
- package/dist/ir/validation/anonymous-type-lowering-regressions.test.d.ts.map +1 -0
- package/dist/ir/validation/anonymous-type-lowering-regressions.test.js +121 -0
- package/dist/ir/validation/anonymous-type-lowering-regressions.test.js.map +1 -0
- package/dist/ir/validation/attribute-collection/arg-extractor.d.ts +58 -0
- package/dist/ir/validation/attribute-collection/arg-extractor.d.ts.map +1 -0
- package/dist/ir/validation/attribute-collection/arg-extractor.js +284 -0
- package/dist/ir/validation/attribute-collection/arg-extractor.js.map +1 -0
- package/dist/ir/validation/attribute-collection/marker-parser.d.ts +28 -0
- package/dist/ir/validation/attribute-collection/marker-parser.d.ts.map +1 -0
- package/dist/ir/validation/attribute-collection/marker-parser.js +404 -0
- package/dist/ir/validation/attribute-collection/marker-parser.js.map +1 -0
- package/dist/ir/validation/attribute-collection/orchestrator.d.ts +28 -0
- package/dist/ir/validation/attribute-collection/orchestrator.d.ts.map +1 -0
- package/dist/ir/validation/attribute-collection/orchestrator.js +332 -0
- package/dist/ir/validation/attribute-collection/orchestrator.js.map +1 -0
- package/dist/ir/validation/attribute-collection-pass.d.ts +1 -23
- package/dist/ir/validation/attribute-collection-pass.d.ts.map +1 -1
- package/dist/ir/validation/attribute-collection-pass.js +1 -961
- package/dist/ir/validation/attribute-collection-pass.js.map +1 -1
- package/dist/ir/validation/attribute-collection-pass.test.js +12 -6
- package/dist/ir/validation/attribute-collection-pass.test.js.map +1 -1
- package/dist/ir/validation/numeric-invariants.test.js +29 -0
- package/dist/ir/validation/numeric-invariants.test.js.map +1 -1
- package/dist/ir/validation/numeric-proof-pass.d.ts.map +1 -1
- package/dist/ir/validation/numeric-proof-pass.js +21 -0
- package/dist/ir/validation/numeric-proof-pass.js.map +1 -1
- package/dist/ir/validation/soundness-gate.d.ts.map +1 -1
- package/dist/ir/validation/soundness-gate.js +2 -1
- package/dist/ir/validation/soundness-gate.js.map +1 -1
- package/dist/ir/validation/soundness-gate.test.js +69 -0
- package/dist/ir/validation/soundness-gate.test.js.map +1 -1
- package/dist/ir/validation/yield-lowering-pass.d.ts +11 -5
- package/dist/ir/validation/yield-lowering-pass.d.ts.map +1 -1
- package/dist/ir/validation/yield-lowering-pass.js +942 -48
- package/dist/ir/validation/yield-lowering-pass.js.map +1 -1
- package/dist/ir/validation/yield-lowering-pass.test.js +1333 -127
- package/dist/ir/validation/yield-lowering-pass.test.js.map +1 -1
- package/dist/program/binding-loader.d.ts +37 -0
- package/dist/program/binding-loader.d.ts.map +1 -0
- package/dist/program/binding-loader.js +155 -0
- package/dist/program/binding-loader.js.map +1 -0
- package/dist/program/binding-registry.d.ts +106 -0
- package/dist/program/binding-registry.d.ts.map +1 -0
- package/dist/program/binding-registry.js +590 -0
- package/dist/program/binding-registry.js.map +1 -0
- package/dist/program/binding-types.d.ts +166 -0
- package/dist/program/binding-types.d.ts.map +1 -0
- package/dist/program/binding-types.js +57 -0
- package/dist/program/binding-types.js.map +1 -0
- package/dist/program/bindings.d.ts +6 -271
- package/dist/program/bindings.d.ts.map +1 -1
- package/dist/program/bindings.js +7 -781
- package/dist/program/bindings.js.map +1 -1
- package/dist/program/creation.d.ts.map +1 -1
- package/dist/program/creation.js +104 -13
- package/dist/program/creation.js.map +1 -1
- package/dist/program/creation.test.js +133 -1
- package/dist/program/creation.test.js.map +1 -1
- package/dist/program/diagnostics.d.ts +1 -1
- package/dist/program/diagnostics.d.ts.map +1 -1
- package/dist/program/diagnostics.js +47 -2
- package/dist/program/diagnostics.js.map +1 -1
- package/dist/program/diagnostics.test.d.ts +2 -0
- package/dist/program/diagnostics.test.d.ts.map +1 -0
- package/dist/program/diagnostics.test.js +58 -0
- package/dist/program/diagnostics.test.js.map +1 -0
- package/dist/program/types.d.ts +2 -0
- package/dist/program/types.d.ts.map +1 -1
- package/dist/resolver/clr-bindings-resolver.d.ts +0 -1
- package/dist/resolver/clr-bindings-resolver.d.ts.map +1 -1
- package/dist/resolver/clr-bindings-resolver.js +22 -32
- package/dist/resolver/clr-bindings-resolver.js.map +1 -1
- package/dist/resolver/clr-bindings-resolver.test.js +0 -27
- package/dist/resolver/clr-bindings-resolver.test.js.map +1 -1
- package/dist/resolver/import-resolution.d.ts +3 -1
- package/dist/resolver/import-resolution.d.ts.map +1 -1
- package/dist/resolver/import-resolution.js +14 -11
- package/dist/resolver/import-resolution.js.map +1 -1
- package/dist/resolver/naming.d.ts.map +1 -1
- package/dist/resolver/naming.js +1 -0
- package/dist/resolver/naming.js.map +1 -1
- package/dist/resolver/node-module-aliases.d.ts +6 -0
- package/dist/resolver/node-module-aliases.d.ts.map +1 -0
- package/dist/resolver/node-module-aliases.js +164 -0
- package/dist/resolver/node-module-aliases.js.map +1 -0
- package/dist/resolver/node-module-aliases.test.d.ts +2 -0
- package/dist/resolver/node-module-aliases.test.d.ts.map +1 -0
- package/dist/resolver/node-module-aliases.test.js +64 -0
- package/dist/resolver/node-module-aliases.test.js.map +1 -0
- package/dist/resolver.test.js +103 -0
- package/dist/resolver.test.js.map +1 -1
- package/dist/surface/js-surface-shims.d.ts +3 -0
- package/dist/surface/js-surface-shims.d.ts.map +1 -0
- package/dist/surface/js-surface-shims.js +332 -0
- package/dist/surface/js-surface-shims.js.map +1 -0
- package/dist/surface/js-surface-shims.test.d.ts +2 -0
- package/dist/surface/js-surface-shims.test.d.ts.map +1 -0
- package/dist/surface/js-surface-shims.test.js +53 -0
- package/dist/surface/js-surface-shims.test.js.map +1 -0
- package/dist/surface/profiles.d.ts +10 -0
- package/dist/surface/profiles.d.ts.map +1 -0
- package/dist/surface/profiles.js +65 -0
- package/dist/surface/profiles.js.map +1 -0
- package/dist/surface/profiles.test.d.ts +2 -0
- package/dist/surface/profiles.test.d.ts.map +1 -0
- package/dist/surface/profiles.test.js +44 -0
- package/dist/surface/profiles.test.js.map +1 -0
- 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/features.d.ts.map +1 -1
- package/dist/validation/features.js +38 -13
- package/dist/validation/features.js.map +1 -1
- package/dist/validation/features.test.d.ts +2 -0
- package/dist/validation/features.test.d.ts.map +1 -0
- package/dist/validation/features.test.js +273 -0
- package/dist/validation/features.test.js.map +1 -0
- package/dist/validation/generics.d.ts +1 -1
- package/dist/validation/generics.d.ts.map +1 -1
- package/dist/validation/generics.js +2 -26
- package/dist/validation/generics.js.map +1 -1
- package/dist/validation/imports.d.ts.map +1 -1
- package/dist/validation/imports.js +29 -5
- package/dist/validation/imports.js.map +1 -1
- package/dist/validation/imports.test.d.ts +2 -0
- package/dist/validation/imports.test.d.ts.map +1 -0
- package/dist/validation/imports.test.js +211 -0
- package/dist/validation/imports.test.js.map +1 -0
- package/dist/validation/static-safety.d.ts +6 -6
- package/dist/validation/static-safety.d.ts.map +1 -1
- package/dist/validation/static-safety.js +163 -109
- package/dist/validation/static-safety.js.map +1 -1
- package/dist/validation/unsupported-utility-types.d.ts +3 -3
- package/dist/validation/unsupported-utility-types.d.ts.map +1 -1
- package/dist/validation/unsupported-utility-types.js +4 -7
- package/dist/validation/unsupported-utility-types.js.map +1 -1
- package/dist/validator.maximus.test.d.ts +2 -0
- package/dist/validator.maximus.test.d.ts.map +1 -0
- package/dist/validator.maximus.test.js +1214 -0
- package/dist/validator.maximus.test.js.map +1 -0
- package/dist/validator.test.js +152 -18
- package/dist/validator.test.js.map +1 -1
- package/package.json +1 -1
- package/dist/ir/converters/statements/declarations/registry.d.ts +0 -96
- package/dist/ir/converters/statements/declarations/registry.d.ts.map +0 -1
- package/dist/ir/converters/statements/declarations/registry.js +0 -130
- package/dist/ir/converters/statements/declarations/registry.js.map +0 -1
- package/dist/ir/this-parameter-inference.test.d.ts +0 -13
- package/dist/ir/this-parameter-inference.test.d.ts.map +0 -1
- package/dist/ir/this-parameter-inference.test.js +0 -165
- package/dist/ir/this-parameter-inference.test.js.map +0 -1
- package/dist/metadata/bindings-loader.d.ts +0 -41
- package/dist/metadata/bindings-loader.d.ts.map +0 -1
- package/dist/metadata/bindings-loader.js +0 -308
- package/dist/metadata/bindings-loader.js.map +0 -1
- package/dist/metadata/bindings-loader.test.d.ts +0 -5
- package/dist/metadata/bindings-loader.test.d.ts.map +0 -1
- package/dist/metadata/bindings-loader.test.js +0 -117
- package/dist/metadata/bindings-loader.test.js.map +0 -1
- package/dist/metadata/index.d.ts +0 -8
- package/dist/metadata/index.d.ts.map +0 -1
- package/dist/metadata/index.js +0 -7
- package/dist/metadata/index.js.map +0 -1
- package/dist/metadata/library-loader.d.ts +0 -42
- package/dist/metadata/library-loader.d.ts.map +0 -1
- package/dist/metadata/library-loader.js +0 -126
- package/dist/metadata/library-loader.js.map +0 -1
- package/dist/metadata/loader.d.ts +0 -26
- package/dist/metadata/loader.d.ts.map +0 -1
- package/dist/metadata/loader.js +0 -333
- package/dist/metadata/loader.js.map +0 -1
- package/dist/metadata/loader.test.d.ts +0 -5
- package/dist/metadata/loader.test.d.ts.map +0 -1
- package/dist/metadata/loader.test.js +0 -119
- package/dist/metadata/loader.test.js.map +0 -1
- package/dist/resolver/naming-policy.d.ts +0 -20
- package/dist/resolver/naming-policy.d.ts.map +0 -1
- package/dist/resolver/naming-policy.js +0 -40
- package/dist/resolver/naming-policy.js.map +0 -1
- package/dist/types/bindings.d.ts +0 -153
- package/dist/types/bindings.d.ts.map +0 -1
- package/dist/types/bindings.js +0 -14
- package/dist/types/bindings.js.map +0 -1
- package/dist/types/metadata.d.ts +0 -196
- package/dist/types/metadata.d.ts.map +0 -1
- package/dist/types/metadata.js +0 -10
- package/dist/types/metadata.js.map +0 -1
- package/dist/types/nested-types.d.ts +0 -111
- package/dist/types/nested-types.d.ts.map +0 -1
- package/dist/types/nested-types.js +0 -176
- package/dist/types/nested-types.js.map +0 -1
- package/dist/types/nested-types.test.d.ts +0 -5
- package/dist/types/nested-types.test.d.ts.map +0 -1
- package/dist/types/nested-types.test.js +0 -135
- package/dist/types/nested-types.test.js.map +0 -1
- package/dist/types/ref-parameters.d.ts +0 -123
- package/dist/types/ref-parameters.d.ts.map +0 -1
- package/dist/types/ref-parameters.js +0 -203
- package/dist/types/ref-parameters.js.map +0 -1
- package/dist/types/ref-parameters.test.d.ts +0 -5
- package/dist/types/ref-parameters.test.d.ts.map +0 -1
- package/dist/types/ref-parameters.test.js +0 -147
- package/dist/types/ref-parameters.test.js.map +0 -1
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
import { describe, it } from "mocha";
|
|
2
|
+
import { expect } from "chai";
|
|
3
|
+
import * as ts from "typescript";
|
|
4
|
+
import * as fs from "node:fs";
|
|
5
|
+
import * as os from "node:os";
|
|
6
|
+
import * as path from "node:path";
|
|
7
|
+
import { validateImports } from "./imports.js";
|
|
8
|
+
import { createDiagnosticsCollector } from "../types/diagnostic.js";
|
|
9
|
+
import { DotnetMetadataRegistry } from "../dotnet-metadata.js";
|
|
10
|
+
import { BindingRegistry } from "../program/bindings.js";
|
|
11
|
+
import { createClrBindingsResolver } from "../resolver/clr-bindings-resolver.js";
|
|
12
|
+
import { createBinding } from "../ir/binding/index.js";
|
|
13
|
+
const createTestProgram = (source, fileName = "/test/test.ts", sourceRoot = "/test", options) => {
|
|
14
|
+
const sourceFile = ts.createSourceFile(fileName, source, ts.ScriptTarget.Latest, true, ts.ScriptKind.TS);
|
|
15
|
+
const compilerOptions = {
|
|
16
|
+
target: ts.ScriptTarget.ES2022,
|
|
17
|
+
module: ts.ModuleKind.NodeNext,
|
|
18
|
+
strict: true,
|
|
19
|
+
noEmit: true,
|
|
20
|
+
skipLibCheck: true,
|
|
21
|
+
};
|
|
22
|
+
const host = ts.createCompilerHost(compilerOptions);
|
|
23
|
+
const originalGetSourceFile = host.getSourceFile;
|
|
24
|
+
host.getSourceFile = (name, languageVersionOrOptions, onError, shouldCreateNewSourceFile) => {
|
|
25
|
+
if (name === fileName) {
|
|
26
|
+
return sourceFile;
|
|
27
|
+
}
|
|
28
|
+
return originalGetSourceFile.call(host, name, languageVersionOrOptions, onError, shouldCreateNewSourceFile);
|
|
29
|
+
};
|
|
30
|
+
const program = ts.createProgram([fileName], compilerOptions, host);
|
|
31
|
+
const checker = program.getTypeChecker();
|
|
32
|
+
return {
|
|
33
|
+
program,
|
|
34
|
+
checker,
|
|
35
|
+
options: {
|
|
36
|
+
projectRoot: sourceRoot,
|
|
37
|
+
sourceRoot,
|
|
38
|
+
rootNamespace: "Test",
|
|
39
|
+
surface: options?.surface,
|
|
40
|
+
},
|
|
41
|
+
sourceFiles: [sourceFile],
|
|
42
|
+
declarationSourceFiles: [],
|
|
43
|
+
metadata: new DotnetMetadataRegistry(),
|
|
44
|
+
bindings: new BindingRegistry(),
|
|
45
|
+
clrResolver: createClrBindingsResolver(sourceRoot),
|
|
46
|
+
binding: createBinding(checker),
|
|
47
|
+
sourceFile,
|
|
48
|
+
};
|
|
49
|
+
};
|
|
50
|
+
const runValidation = (sourceText, fileName, sourceRoot, options) => {
|
|
51
|
+
const testProgram = createTestProgram(sourceText, fileName, sourceRoot, options);
|
|
52
|
+
return validateImports(testProgram.sourceFile, testProgram, createDiagnosticsCollector());
|
|
53
|
+
};
|
|
54
|
+
const codes = (result) => result.diagnostics.map((diag) => diag.code);
|
|
55
|
+
describe("validateImports", () => {
|
|
56
|
+
it("allows import type declarations from @tsonic/core modules", () => {
|
|
57
|
+
const result = runValidation(`
|
|
58
|
+
import type { int } from "@tsonic/core/types.js";
|
|
59
|
+
const x: int | undefined = undefined;
|
|
60
|
+
void x;
|
|
61
|
+
`);
|
|
62
|
+
expect(result.hasErrors).to.equal(false);
|
|
63
|
+
expect(codes(result)).to.deep.equal([]);
|
|
64
|
+
});
|
|
65
|
+
it("allows inline import type queries", () => {
|
|
66
|
+
const result = runValidation(`
|
|
67
|
+
type StackAlloc = import("@tsonic/core/lang.js").stackalloc;
|
|
68
|
+
const f: StackAlloc | undefined = undefined;
|
|
69
|
+
void f;
|
|
70
|
+
`);
|
|
71
|
+
expect(result.hasErrors).to.equal(false);
|
|
72
|
+
expect(codes(result)).to.deep.equal([]);
|
|
73
|
+
});
|
|
74
|
+
it("allows runtime imports from @tsonic/core modules", () => {
|
|
75
|
+
const result = runValidation(`
|
|
76
|
+
import { stackalloc } from "@tsonic/core/lang.js";
|
|
77
|
+
void stackalloc;
|
|
78
|
+
`);
|
|
79
|
+
expect(result.hasErrors).to.equal(false);
|
|
80
|
+
expect(codes(result)).to.deep.equal([]);
|
|
81
|
+
});
|
|
82
|
+
it("reports unsupported module imports with TSN1004", () => {
|
|
83
|
+
const result = runValidation(`
|
|
84
|
+
import { x } from "leftpad";
|
|
85
|
+
void x;
|
|
86
|
+
`);
|
|
87
|
+
expect(result.hasErrors).to.equal(true);
|
|
88
|
+
expect(codes(result).includes("TSN1004")).to.equal(true);
|
|
89
|
+
});
|
|
90
|
+
it("warns on default imports from local modules", () => {
|
|
91
|
+
const tempRoot = fs.mkdtempSync(path.join(os.tmpdir(), "tsonic-imports-"));
|
|
92
|
+
const sourceDir = path.join(tempRoot, "src");
|
|
93
|
+
const sourceFile = path.join(sourceDir, "main.ts");
|
|
94
|
+
const importedModule = path.join(sourceDir, "module.ts");
|
|
95
|
+
fs.mkdirSync(sourceDir, { recursive: true });
|
|
96
|
+
fs.writeFileSync(importedModule, "export const value = 1;\n", "utf-8");
|
|
97
|
+
try {
|
|
98
|
+
const result = runValidation(`
|
|
99
|
+
import value from "./module.js";
|
|
100
|
+
void value;
|
|
101
|
+
`, sourceFile, tempRoot);
|
|
102
|
+
expect(result.hasErrors).to.equal(false);
|
|
103
|
+
const warningCodes = result.diagnostics
|
|
104
|
+
.filter((diag) => diag.severity === "warning")
|
|
105
|
+
.map((diag) => diag.code);
|
|
106
|
+
expect(warningCodes.includes("TSN2001")).to.equal(true);
|
|
107
|
+
}
|
|
108
|
+
finally {
|
|
109
|
+
fs.rmSync(tempRoot, { recursive: true, force: true });
|
|
110
|
+
}
|
|
111
|
+
});
|
|
112
|
+
it("allows canonical node module named imports in nodejs surface", () => {
|
|
113
|
+
const testProgram = createTestProgram(`
|
|
114
|
+
import { fs } from "node:fs";
|
|
115
|
+
void fs;
|
|
116
|
+
`, "/test/node-valid.ts", "/test", { surface: "nodejs" });
|
|
117
|
+
testProgram.bindings.addBindings("/test/node-bindings.json", {
|
|
118
|
+
bindings: {
|
|
119
|
+
"@tsonic/nodejs/index.js": {
|
|
120
|
+
kind: "module",
|
|
121
|
+
assembly: "nodejs",
|
|
122
|
+
type: "nodejs.fs$instance",
|
|
123
|
+
},
|
|
124
|
+
},
|
|
125
|
+
});
|
|
126
|
+
const result = validateImports(testProgram.sourceFile, testProgram, createDiagnosticsCollector());
|
|
127
|
+
expect(result.hasErrors).to.equal(false);
|
|
128
|
+
expect(codes(result)).to.deep.equal([]);
|
|
129
|
+
});
|
|
130
|
+
it("rejects unsupported named member imports from node aliases with TSN1004", () => {
|
|
131
|
+
const testProgram = createTestProgram(`
|
|
132
|
+
import { readFileSync } from "node:fs";
|
|
133
|
+
void readFileSync;
|
|
134
|
+
`, "/test/node-invalid-member.ts", "/test", { surface: "nodejs" });
|
|
135
|
+
testProgram.bindings.addBindings("/test/node-bindings.json", {
|
|
136
|
+
bindings: {
|
|
137
|
+
"@tsonic/nodejs/index.js": {
|
|
138
|
+
kind: "module",
|
|
139
|
+
assembly: "nodejs",
|
|
140
|
+
type: "nodejs.fs$instance",
|
|
141
|
+
},
|
|
142
|
+
},
|
|
143
|
+
});
|
|
144
|
+
const result = validateImports(testProgram.sourceFile, testProgram, createDiagnosticsCollector());
|
|
145
|
+
expect(result.hasErrors).to.equal(true);
|
|
146
|
+
expect(codes(result)).to.include("TSN1004");
|
|
147
|
+
expect(result.diagnostics[0]?.message).to.include("Unsupported member import");
|
|
148
|
+
});
|
|
149
|
+
it("rejects default imports from node aliases with TSN1004", () => {
|
|
150
|
+
const testProgram = createTestProgram(`
|
|
151
|
+
import fs from "node:fs";
|
|
152
|
+
void fs;
|
|
153
|
+
`, "/test/node-default-import.ts", "/test", { surface: "nodejs" });
|
|
154
|
+
testProgram.bindings.addBindings("/test/node-bindings.json", {
|
|
155
|
+
bindings: {
|
|
156
|
+
"@tsonic/nodejs/index.js": {
|
|
157
|
+
kind: "module",
|
|
158
|
+
assembly: "nodejs",
|
|
159
|
+
type: "nodejs.fs$instance",
|
|
160
|
+
},
|
|
161
|
+
},
|
|
162
|
+
});
|
|
163
|
+
const result = validateImports(testProgram.sourceFile, testProgram, createDiagnosticsCollector());
|
|
164
|
+
expect(result.hasErrors).to.equal(true);
|
|
165
|
+
expect(codes(result)).to.include("TSN1004");
|
|
166
|
+
expect(result.diagnostics[0]?.message).to.include("Default import is not supported");
|
|
167
|
+
});
|
|
168
|
+
it("rejects unsupported named member imports from bare node aliases with TSN1004", () => {
|
|
169
|
+
const testProgram = createTestProgram(`
|
|
170
|
+
import { join } from "path";
|
|
171
|
+
void join;
|
|
172
|
+
`, "/test/node-bare-invalid-member.ts", "/test", { surface: "nodejs" });
|
|
173
|
+
testProgram.bindings.addBindings("/test/node-bindings.json", {
|
|
174
|
+
bindings: {
|
|
175
|
+
"@tsonic/nodejs/index.js": {
|
|
176
|
+
kind: "module",
|
|
177
|
+
assembly: "nodejs",
|
|
178
|
+
type: "nodejs.path$instance",
|
|
179
|
+
},
|
|
180
|
+
},
|
|
181
|
+
});
|
|
182
|
+
const result = validateImports(testProgram.sourceFile, testProgram, createDiagnosticsCollector());
|
|
183
|
+
expect(result.hasErrors).to.equal(true);
|
|
184
|
+
expect(codes(result)).to.include("TSN1004");
|
|
185
|
+
expect(result.diagnostics[0]?.message).to.include("Unsupported member import");
|
|
186
|
+
});
|
|
187
|
+
it("reports multiple node import diagnostics in one pass", () => {
|
|
188
|
+
const testProgram = createTestProgram(`
|
|
189
|
+
import { readFileSync } from "node:fs";
|
|
190
|
+
import badPath from "node:path";
|
|
191
|
+
void readFileSync;
|
|
192
|
+
void badPath;
|
|
193
|
+
`, "/test/node-multi-diagnostics.ts", "/test", { surface: "nodejs" });
|
|
194
|
+
testProgram.bindings.addBindings("/test/node-bindings.json", {
|
|
195
|
+
bindings: {
|
|
196
|
+
"@tsonic/nodejs/index.js": {
|
|
197
|
+
kind: "module",
|
|
198
|
+
assembly: "nodejs",
|
|
199
|
+
type: "nodejs.fs$instance",
|
|
200
|
+
},
|
|
201
|
+
},
|
|
202
|
+
});
|
|
203
|
+
const result = validateImports(testProgram.sourceFile, testProgram, createDiagnosticsCollector());
|
|
204
|
+
expect(result.hasErrors).to.equal(true);
|
|
205
|
+
expect(codes(result).filter((code) => code === "TSN1004").length).to.equal(2);
|
|
206
|
+
const messages = result.diagnostics.map((diag) => diag.message);
|
|
207
|
+
expect(messages.some((message) => message.includes("Unsupported member import"))).to.equal(true);
|
|
208
|
+
expect(messages.some((message) => message.includes("Default import is not supported"))).to.equal(true);
|
|
209
|
+
});
|
|
210
|
+
});
|
|
211
|
+
//# sourceMappingURL=imports.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"imports.test.js","sourceRoot":"","sources":["../../src/validation/imports.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;AACrC,OAAO,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAC9B,OAAO,KAAK,EAAE,MAAM,YAAY,CAAC;AACjC,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,EAAE,0BAA0B,EAAE,MAAM,wBAAwB,CAAC;AAEpE,OAAO,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AAC/D,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,yBAAyB,EAAE,MAAM,sCAAsC,CAAC;AACjF,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AASvD,MAAM,iBAAiB,GAAG,CACxB,MAAc,EACd,QAAQ,GAAG,eAAe,EAC1B,UAAU,GAAG,OAAO,EACpB,OAA4B,EAC4B,EAAE;IAC1D,MAAM,UAAU,GAAG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CAAC,OAAO,EAAE,EAAE,CACxB,OAAO,CAAC,QAAQ,CAAC,iCAAiC,CAAC,CACpD,CACF,CAAC,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IACnB,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -5,12 +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
|
-
* - 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
|
|
8
|
+
* - TSN7406: Mapped types not supported (retired)
|
|
9
|
+
* - TSN7407: Conditional types not supported (retired)
|
|
10
|
+
* - TSN7408: Mixed variadic tuples not supported (retired)
|
|
11
|
+
* - TSN7409: 'infer' keyword not supported (retired)
|
|
12
|
+
* - TSN7410: Intersection types not supported (retired)
|
|
13
|
+
* - TSN7413: Dictionary key must be string, number, or symbol
|
|
14
14
|
* - TSN7430: Arrow function requires explicit types (escape hatch)
|
|
15
15
|
*
|
|
16
16
|
* This ensures NativeAOT-compatible, predictable-performance output.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"static-safety.d.ts","sourceRoot":"","sources":["../../src/validation/static-safety.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,KAAK,EAAE,MAAM,YAAY,CAAC;AACjC,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,EACL,oBAAoB,EAGrB,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"static-safety.d.ts","sourceRoot":"","sources":["../../src/validation/static-safety.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,KAAK,EAAE,MAAM,YAAY,CAAC;AACjC,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,EACL,oBAAoB,EAGrB,MAAM,wBAAwB,CAAC;AAyZhC;;GAEG;AACH,eAAO,MAAM,oBAAoB,GAC/B,YAAY,EAAE,CAAC,UAAU,EACzB,SAAS,aAAa,EACtB,WAAW,oBAAoB,KAC9B,oBAkUF,CAAC"}
|
|
@@ -5,12 +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
|
-
* - 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
|
|
8
|
+
* - TSN7406: Mapped types not supported (retired)
|
|
9
|
+
* - TSN7407: Conditional types not supported (retired)
|
|
10
|
+
* - TSN7408: Mixed variadic tuples not supported (retired)
|
|
11
|
+
* - TSN7409: 'infer' keyword not supported (retired)
|
|
12
|
+
* - TSN7410: Intersection types not supported (retired)
|
|
13
|
+
* - TSN7413: Dictionary key must be string, number, or symbol
|
|
14
14
|
* - TSN7430: Arrow function requires explicit types (escape hatch)
|
|
15
15
|
*
|
|
16
16
|
* This ensures NativeAOT-compatible, predictable-performance output.
|
|
@@ -22,17 +22,35 @@
|
|
|
22
22
|
import * as ts from "typescript";
|
|
23
23
|
import { addDiagnostic, createDiagnostic, } from "../types/diagnostic.js";
|
|
24
24
|
import { getNodeLocation } from "./helpers.js";
|
|
25
|
-
import {
|
|
25
|
+
import { collectWrittenSymbols, collectSupportedGenericFunctionValueSymbols, getSupportedGenericFunctionDeclarationSymbol, getSupportedGenericFunctionValueSymbol, isGenericFunctionDeclarationNode, isGenericFunctionValueNode, } from "../generic-function-values.js";
|
|
26
26
|
/**
|
|
27
27
|
* Check basic structural eligibility for object literal synthesis.
|
|
28
28
|
*
|
|
29
29
|
* This is a simplified check that doesn't require TypeSystem access.
|
|
30
|
-
* It validates structural constraints (no computed keys, no method shorthand, etc.)
|
|
30
|
+
* It validates structural constraints (no computed keys, no dynamic receiver method shorthand, etc.)
|
|
31
31
|
* but does NOT validate spread type annotations (that requires TypeSystem).
|
|
32
32
|
*
|
|
33
33
|
* Full eligibility check happens during IR conversion.
|
|
34
34
|
*/
|
|
35
35
|
const checkBasicSynthesisEligibility = (node) => {
|
|
36
|
+
const usesDynamicReceiverSemantics = (method) => {
|
|
37
|
+
let found = false;
|
|
38
|
+
const visit = (current) => {
|
|
39
|
+
if (found)
|
|
40
|
+
return;
|
|
41
|
+
if (current.kind === ts.SyntaxKind.ThisKeyword ||
|
|
42
|
+
current.kind === ts.SyntaxKind.SuperKeyword ||
|
|
43
|
+
(ts.isIdentifier(current) && current.text === "arguments")) {
|
|
44
|
+
found = true;
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
ts.forEachChild(current, visit);
|
|
48
|
+
};
|
|
49
|
+
if (method.body) {
|
|
50
|
+
visit(method.body);
|
|
51
|
+
}
|
|
52
|
+
return found;
|
|
53
|
+
};
|
|
36
54
|
for (const prop of node.properties) {
|
|
37
55
|
// Property assignment: check key type
|
|
38
56
|
if (ts.isPropertyAssignment(prop)) {
|
|
@@ -69,12 +87,31 @@ const checkBasicSynthesisEligibility = (node) => {
|
|
|
69
87
|
}
|
|
70
88
|
continue;
|
|
71
89
|
}
|
|
72
|
-
// Method
|
|
90
|
+
// Method declarations are valid only when they can be represented as
|
|
91
|
+
// function-valued properties without dynamic receiver semantics.
|
|
73
92
|
if (ts.isMethodDeclaration(prop)) {
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
93
|
+
if (ts.isComputedPropertyName(prop.name)) {
|
|
94
|
+
const expr = prop.name.expression;
|
|
95
|
+
if (!ts.isStringLiteral(expr)) {
|
|
96
|
+
return {
|
|
97
|
+
eligible: false,
|
|
98
|
+
reason: `Computed property key is not a string literal`,
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
if (ts.isPrivateIdentifier(prop.name)) {
|
|
103
|
+
return {
|
|
104
|
+
eligible: false,
|
|
105
|
+
reason: `Private identifier (symbol) keys are not supported`,
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
if (usesDynamicReceiverSemantics(prop)) {
|
|
109
|
+
return {
|
|
110
|
+
eligible: false,
|
|
111
|
+
reason: "Method shorthand cannot reference this/super/arguments in synthesized types",
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
continue;
|
|
78
115
|
}
|
|
79
116
|
// Getter/setter: reject
|
|
80
117
|
if (ts.isGetAccessorDeclaration(prop) ||
|
|
@@ -186,16 +223,6 @@ const findContainingFunction = (node) => {
|
|
|
186
223
|
}
|
|
187
224
|
return undefined;
|
|
188
225
|
};
|
|
189
|
-
const isArrayLikeType = (checker, type) => {
|
|
190
|
-
if (!type)
|
|
191
|
-
return false;
|
|
192
|
-
if (checker.isArrayType(type) || checker.isTupleType(type))
|
|
193
|
-
return true;
|
|
194
|
-
if (type.isUnion()) {
|
|
195
|
-
return type.types.every((t) => isArrayLikeType(checker, t));
|
|
196
|
-
}
|
|
197
|
-
return false;
|
|
198
|
-
};
|
|
199
226
|
/**
|
|
200
227
|
* DETERMINISTIC IR TYPING (INV-0 compliant):
|
|
201
228
|
* Check if an object literal is in a position where expected types are available.
|
|
@@ -261,10 +288,74 @@ const objectLiteralHasContextualType = (node) => {
|
|
|
261
288
|
}
|
|
262
289
|
return false;
|
|
263
290
|
};
|
|
291
|
+
const isAllowedGenericFunctionValueIdentifierUse = (node, checker) => {
|
|
292
|
+
const parent = node.parent;
|
|
293
|
+
if (ts.isFunctionDeclaration(parent) && parent.name === node)
|
|
294
|
+
return true;
|
|
295
|
+
if (ts.isVariableDeclaration(parent) && parent.name === node)
|
|
296
|
+
return true;
|
|
297
|
+
if (ts.isImportSpecifier(parent) && parent.name === node)
|
|
298
|
+
return true;
|
|
299
|
+
if (ts.isVariableDeclaration(parent) &&
|
|
300
|
+
parent.initializer === node &&
|
|
301
|
+
ts.isIdentifier(parent.name)) {
|
|
302
|
+
const declarationList = parent.parent;
|
|
303
|
+
if (ts.isVariableDeclarationList(declarationList)) {
|
|
304
|
+
const isConst = (declarationList.flags & ts.NodeFlags.Const) !== 0;
|
|
305
|
+
const isLet = (declarationList.flags & ts.NodeFlags.Let) !== 0;
|
|
306
|
+
if (isConst || isLet)
|
|
307
|
+
return true;
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
if (ts.isCallExpression(parent) && parent.expression === node)
|
|
311
|
+
return true;
|
|
312
|
+
if (ts.isTypeQueryNode(parent) && parent.exprName === node)
|
|
313
|
+
return true;
|
|
314
|
+
if (ts.isExportSpecifier(parent))
|
|
315
|
+
return true;
|
|
316
|
+
if (ts.isExportAssignment(parent) && parent.expression === node)
|
|
317
|
+
return true;
|
|
318
|
+
const contextualType = checker.getContextualType(node);
|
|
319
|
+
if (contextualType) {
|
|
320
|
+
const isNullishOnly = (type) => {
|
|
321
|
+
const flags = type.getFlags();
|
|
322
|
+
return ((flags &
|
|
323
|
+
(ts.TypeFlags.Null |
|
|
324
|
+
ts.TypeFlags.Undefined |
|
|
325
|
+
ts.TypeFlags.Void |
|
|
326
|
+
ts.TypeFlags.Never)) !==
|
|
327
|
+
0);
|
|
328
|
+
};
|
|
329
|
+
const isMonomorphicCallableType = (type) => {
|
|
330
|
+
if (type.isUnion()) {
|
|
331
|
+
return type.types.every((member) => isNullishOnly(member) || isMonomorphicCallableType(member));
|
|
332
|
+
}
|
|
333
|
+
if (type.isIntersection()) {
|
|
334
|
+
return type.types.every((member) => isMonomorphicCallableType(member));
|
|
335
|
+
}
|
|
336
|
+
const signatures = checker.getSignaturesOfType(type, ts.SignatureKind.Call);
|
|
337
|
+
if (signatures.length === 0)
|
|
338
|
+
return false;
|
|
339
|
+
return signatures.every((sig) => !sig.typeParameters || sig.typeParameters.length === 0);
|
|
340
|
+
};
|
|
341
|
+
if (isMonomorphicCallableType(contextualType))
|
|
342
|
+
return true;
|
|
343
|
+
}
|
|
344
|
+
return false;
|
|
345
|
+
};
|
|
346
|
+
const getReferencedIdentifierSymbol = (checker, node) => {
|
|
347
|
+
const parent = node.parent;
|
|
348
|
+
if (ts.isShorthandPropertyAssignment(parent) && parent.name === node) {
|
|
349
|
+
return checker.getShorthandAssignmentValueSymbol(parent) ?? undefined;
|
|
350
|
+
}
|
|
351
|
+
return checker.getSymbolAtLocation(node);
|
|
352
|
+
};
|
|
264
353
|
/**
|
|
265
354
|
* Validate a source file for static safety violations.
|
|
266
355
|
*/
|
|
267
356
|
export const validateStaticSafety = (sourceFile, program, collector) => {
|
|
357
|
+
const writtenSymbols = collectWrittenSymbols(sourceFile, program.checker);
|
|
358
|
+
const supportedGenericFunctionValueSymbols = collectSupportedGenericFunctionValueSymbols(sourceFile, program.checker, writtenSymbols);
|
|
268
359
|
const visitor = (node, accCollector) => {
|
|
269
360
|
let currentCollector = accCollector;
|
|
270
361
|
// TSN7401: Check for explicit 'any' type annotations
|
|
@@ -350,111 +441,73 @@ export const validateStaticSafety = (sourceFile, program, collector) => {
|
|
|
350
441
|
node.typeArguments?.some((a) => a.kind === ts.SyntaxKind.NeverKeyword)) {
|
|
351
442
|
currentCollector = addDiagnostic(currentCollector, createDiagnostic("TSN7419", "error", "'never' cannot be used as a generic type argument.", getNodeLocation(sourceFile, node), "Rewrite the type to avoid never. For Result-like types, model explicit variants (Ok<T> | Err<E>) and have helpers return the specific variant type."));
|
|
352
443
|
}
|
|
353
|
-
// TSN7406: Mapped-type utility types (these expand to mapped types internally)
|
|
354
|
-
// Only check when type arguments are present to avoid false positives for
|
|
355
|
-
// user-defined types named "Partial", etc.
|
|
356
|
-
if (hasTypeArgs && UNSUPPORTED_MAPPED_UTILITY_TYPES.has(name)) {
|
|
357
|
-
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.`));
|
|
358
|
-
}
|
|
359
|
-
// TSN7407: Conditional-type utility types (these expand to conditional types internally)
|
|
360
|
-
// Only check when type arguments are present
|
|
361
|
-
if (hasTypeArgs && UNSUPPORTED_CONDITIONAL_UTILITY_TYPES.has(name)) {
|
|
362
|
-
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.`));
|
|
363
|
-
}
|
|
364
444
|
// TSN7413: Record<K, V> where K is not an allowed key type
|
|
365
445
|
if (name === "Record") {
|
|
366
446
|
const typeArgs = node.typeArguments;
|
|
367
447
|
const keyTypeNode = typeArgs?.[0];
|
|
368
448
|
if (keyTypeNode !== undefined) {
|
|
369
449
|
if (!isAllowedKeyType(keyTypeNode)) {
|
|
370
|
-
currentCollector = addDiagnostic(currentCollector, createDiagnostic("TSN7413", "error", "Dictionary key type must be 'string' or '
|
|
450
|
+
currentCollector = addDiagnostic(currentCollector, createDiagnostic("TSN7413", "error", "Dictionary key type must be 'string', 'number', or 'symbol'. Other key types are not supported.", getNodeLocation(sourceFile, keyTypeNode), "Use Record<string, V>, Record<number, V>, or Record<symbol, V>."));
|
|
371
451
|
}
|
|
372
452
|
}
|
|
373
453
|
}
|
|
374
454
|
}
|
|
375
455
|
}
|
|
376
456
|
// TSN7413: Check for unsupported index signature key types
|
|
377
|
-
//
|
|
457
|
+
// string, number, and symbol are allowed (matches TypeScript's PropertyKey constraint)
|
|
378
458
|
if (ts.isIndexSignatureDeclaration(node)) {
|
|
379
459
|
const keyParam = node.parameters[0];
|
|
380
460
|
if (keyParam?.type && !isAllowedKeyType(keyParam.type)) {
|
|
381
|
-
currentCollector = addDiagnostic(currentCollector, createDiagnostic("TSN7413", "error", "Index signature key type must be 'string' or '
|
|
461
|
+
currentCollector = addDiagnostic(currentCollector, createDiagnostic("TSN7413", "error", "Index signature key type must be 'string', 'number', or 'symbol'. Other key types are not supported.", getNodeLocation(sourceFile, keyParam.type), "Use { [key: string]: V }, { [key: number]: V }, or { [key: symbol]: V }."));
|
|
382
462
|
}
|
|
383
463
|
}
|
|
384
|
-
// TSN7406
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
//
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
//
|
|
393
|
-
//
|
|
394
|
-
//
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
464
|
+
// TSN7406 retired:
|
|
465
|
+
// Mapped types are handled by type conversion + specialization.
|
|
466
|
+
// TSN7407 retired:
|
|
467
|
+
// Conditional types are handled by utility expansion and type conversion.
|
|
468
|
+
// TSN7408 retired:
|
|
469
|
+
// Mixed variadic tuples are now lowered to array types in the converter.
|
|
470
|
+
// TSN7409 retired:
|
|
471
|
+
// infer clauses are handled by conditional/type evaluator paths.
|
|
472
|
+
// TSN7410 retired:
|
|
473
|
+
// Intersection types are lowered by the type emitter.
|
|
474
|
+
// TSN7416 retired:
|
|
475
|
+
// new Array() without explicit type argument is lowered by the emitter.
|
|
476
|
+
// TSN7417 retired:
|
|
477
|
+
// Empty arrays are inferred/erased deterministically by array conversion rules.
|
|
478
|
+
// TSN7432:
|
|
479
|
+
// Generic function values are supported for deterministic declaration/alias
|
|
480
|
+
// forms that can be lowered to C# generic method declarations:
|
|
481
|
+
// - direct generic function value declarations (`const` + never-reassigned `let`)
|
|
482
|
+
// - direct generic function declarations (`function f<T>(...) { ... }`)
|
|
483
|
+
// - deterministic alias declarations that point at supported symbols
|
|
484
|
+
// (`const` aliases + never-reassigned `let` aliases).
|
|
485
|
+
// Non-deterministic or non-transpilable value-level usages remain hard errors.
|
|
486
|
+
if (isGenericFunctionValueNode(node)) {
|
|
487
|
+
const symbol = getSupportedGenericFunctionValueSymbol(node, program.checker, writtenSymbols);
|
|
488
|
+
const isSupported = symbol !== undefined &&
|
|
489
|
+
supportedGenericFunctionValueSymbols.has(symbol);
|
|
490
|
+
if (!isSupported) {
|
|
491
|
+
currentCollector = addDiagnostic(currentCollector, createDiagnostic("TSN7432", "error", "Generic function values are only supported in deterministic declaration/alias forms that can lower to C# generic methods.", getNodeLocation(sourceFile, node), "Use `const f = <T>(...) => ...`, `let f = <T>(...) => ...` with no reassignments, or deterministic aliases like `const g = f`."));
|
|
400
492
|
}
|
|
401
493
|
}
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
const isTypeParamConstraint = ts.isTypeParameterDeclaration(node.parent) &&
|
|
409
|
-
node.parent.constraint === node;
|
|
410
|
-
// Intersection constraints are representable as multiple C# generic constraints:
|
|
411
|
-
// `T extends A & B` -> `where T : A, B`.
|
|
412
|
-
if (!isTypeParamConstraint) {
|
|
413
|
-
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."));
|
|
494
|
+
if (isGenericFunctionDeclarationNode(node)) {
|
|
495
|
+
const symbol = getSupportedGenericFunctionDeclarationSymbol(node, program.checker);
|
|
496
|
+
const isSupported = symbol !== undefined &&
|
|
497
|
+
supportedGenericFunctionValueSymbols.has(symbol);
|
|
498
|
+
if (!isSupported) {
|
|
499
|
+
currentCollector = addDiagnostic(currentCollector, createDiagnostic("TSN7432", "error", "Generic function declarations are only supported when their symbol remains deterministic in value positions and lowers to a C# generic method.", getNodeLocation(sourceFile, node), "Use a direct generic call (e.g., `f<T>(...)`) or deterministic const/never-reassigned let aliases."));
|
|
414
500
|
}
|
|
415
501
|
}
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
const
|
|
422
|
-
|
|
423
|
-
currentCollector = addDiagnostic(currentCollector, createDiagnostic("TSN7416", "error", "'new Array()' requires an explicit type argument. Use 'new Array<T>(size)' instead.", getNodeLocation(sourceFile, node), "Add a type argument: new Array<int>(10), new Array<string>(5), etc."));
|
|
424
|
-
}
|
|
502
|
+
if (ts.isIdentifier(node)) {
|
|
503
|
+
const symbol = getReferencedIdentifierSymbol(program.checker, node);
|
|
504
|
+
if (symbol &&
|
|
505
|
+
supportedGenericFunctionValueSymbols.has(symbol) &&
|
|
506
|
+
!isAllowedGenericFunctionValueIdentifierUse(node, program.checker)) {
|
|
507
|
+
const name = node.text;
|
|
508
|
+
currentCollector = addDiagnostic(currentCollector, createDiagnostic("TSN7432", "error", `Generic function value '${name}' is only supported in direct call or monomorphic callable-context position where lowering is deterministic.`, getNodeLocation(sourceFile, node), "Call the function directly (e.g., `name<T>(...)`), or use it where a concrete callable type is contextually known (e.g., function argument typed as `(x: number) => number`)."));
|
|
425
509
|
}
|
|
426
510
|
}
|
|
427
|
-
// TSN7417: Check for empty array literal without type annotation
|
|
428
|
-
// const x = [] is invalid, const x: T[] = [] is valid
|
|
429
|
-
if (ts.isArrayLiteralExpression(node) && node.elements.length === 0) {
|
|
430
|
-
const hasContextualType = program.checker.getContextualType(node) !== undefined;
|
|
431
|
-
const parent = node.parent;
|
|
432
|
-
const hasConditionalArrayContext = ts.isConditionalExpression(parent) &&
|
|
433
|
-
isArrayLikeType(program.checker, program.checker.getTypeAtLocation(parent));
|
|
434
|
-
// Check if parent provides type context
|
|
435
|
-
const hasTypeAnnotation = (ts.isVariableDeclaration(parent) && parent.type !== undefined) ||
|
|
436
|
-
(ts.isPropertyDeclaration(parent) && parent.type !== undefined) ||
|
|
437
|
-
(ts.isParameter(parent) && parent.type !== undefined) ||
|
|
438
|
-
ts.isReturnStatement(parent) || // return type from function
|
|
439
|
-
ts.isCallExpression(parent) || // passed as argument (has contextual type)
|
|
440
|
-
ts.isPropertyAssignment(parent) || // object property (has contextual type)
|
|
441
|
-
hasConditionalArrayContext ||
|
|
442
|
-
hasContextualType;
|
|
443
|
-
if (!hasTypeAnnotation) {
|
|
444
|
-
currentCollector = addDiagnostic(currentCollector, createDiagnostic("TSN7417", "error", "Empty array literal requires a type annotation. Use 'const x: T[] = []' instead.", getNodeLocation(sourceFile, node), "Add a type annotation: const x: number[] = []; or const x: string[] = [];"));
|
|
445
|
-
}
|
|
446
|
-
}
|
|
447
|
-
// TSN7432: Generic function values are not supported.
|
|
448
|
-
//
|
|
449
|
-
// Generic methods exist in CLR, but generic functions as first-class values do not.
|
|
450
|
-
// For airplane-grade emission, we require generic functions to be declared as
|
|
451
|
-
// named function declarations (which become CLR methods), not arrow/function
|
|
452
|
-
// expressions assigned to values.
|
|
453
|
-
if ((ts.isArrowFunction(node) || ts.isFunctionExpression(node)) &&
|
|
454
|
-
node.typeParameters &&
|
|
455
|
-
node.typeParameters.length > 0) {
|
|
456
|
-
currentCollector = addDiagnostic(currentCollector, createDiagnostic("TSN7432", "error", "Generic arrow/functions are not supported as values. Use a named function declaration instead.", getNodeLocation(sourceFile, node), "Rewrite: `export function f<T>(x: T): ... { ... }`"));
|
|
457
|
-
}
|
|
458
511
|
// TSN7430: Arrow function escape hatch validation
|
|
459
512
|
// Non-simple arrows must have explicit type annotations
|
|
460
513
|
if (ts.isArrowFunction(node)) {
|
|
@@ -470,15 +523,16 @@ export const validateStaticSafety = (sourceFile, program, collector) => {
|
|
|
470
523
|
};
|
|
471
524
|
/**
|
|
472
525
|
* Check if a type node represents an allowed dictionary key type.
|
|
473
|
-
* Allowed: string, number (matches TypeScript's PropertyKey constraint)
|
|
526
|
+
* Allowed: string, number, symbol (matches TypeScript's PropertyKey constraint)
|
|
474
527
|
*
|
|
475
528
|
* Note: TypeScript's Record<K, V> only allows K extends keyof any (string | number | symbol).
|
|
476
|
-
* We support
|
|
529
|
+
* We support all three PropertyKey primitives.
|
|
477
530
|
*/
|
|
478
531
|
const isAllowedKeyType = (typeNode) => {
|
|
479
532
|
// Direct keywords
|
|
480
533
|
if (typeNode.kind === ts.SyntaxKind.StringKeyword ||
|
|
481
|
-
typeNode.kind === ts.SyntaxKind.NumberKeyword
|
|
534
|
+
typeNode.kind === ts.SyntaxKind.NumberKeyword ||
|
|
535
|
+
typeNode.kind === ts.SyntaxKind.SymbolKeyword) {
|
|
482
536
|
return true;
|
|
483
537
|
}
|
|
484
538
|
// String literal types (e.g., "a", "b")
|
|
@@ -499,7 +553,7 @@ const isAllowedKeyType = (typeNode) => {
|
|
|
499
553
|
const typeName = typeNode.typeName;
|
|
500
554
|
if (ts.isIdentifier(typeName)) {
|
|
501
555
|
const name = typeName.text;
|
|
502
|
-
if (name === "string" || name === "number") {
|
|
556
|
+
if (name === "string" || name === "number" || name === "symbol") {
|
|
503
557
|
return true;
|
|
504
558
|
}
|
|
505
559
|
}
|