typia 13.0.0-dev.20260501 → 13.0.0-dev.20260506
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/lib/executable/generate/ttsc.js.map +1 -1
- package/lib/executable/setup/PluginConfigurator.js.map +1 -1
- package/lib/internal/_randomInteger.js.map +1 -1
- package/lib/internal/_validateReport.js.map +1 -1
- package/lib/transform.js.map +1 -1
- package/native/adapter/adapter.go +128 -128
- package/native/adapter/cleanup.go +155 -155
- package/native/adapter/imports.go +80 -80
- package/native/adapter/visit.go +142 -142
- package/native/cmd/ttsc-typia/build.go +223 -223
- package/native/cmd/ttsc-typia/main.go +57 -57
- package/native/cmd/ttsc-typia/transform.go +393 -385
- package/native/cmd/ttsc-typia/transform_test.go +40 -0
- package/native/core/context/IProgrammerProps.go +7 -7
- package/native/core/context/ITransformOptions.go +5 -5
- package/native/core/context/ITypiaContext.go +13 -13
- package/native/core/context/TransformerError.go +81 -81
- package/native/core/factories/CommentFactory.go +9 -9
- package/native/core/factories/ExpressionFactory.go +254 -254
- package/native/core/factories/FormatCheatSheet.go +23 -23
- package/native/core/factories/IdentifierFactory.go +130 -130
- package/native/core/factories/JsonMetadataFactory.go +129 -129
- package/native/core/factories/LiteralFactory.go +192 -192
- package/native/core/factories/MetadataCommentTagFactory.go +379 -379
- package/native/core/factories/MetadataFactory.go +462 -462
- package/native/core/factories/MetadataTypeTagFactory.go +498 -498
- package/native/core/factories/MetadataTypeTagSchemaFactory.go +102 -102
- package/native/core/factories/NumericRangeFactory.go +84 -84
- package/native/core/factories/ProtobufFactory.go +933 -933
- package/native/core/factories/StatementFactory.go +72 -72
- package/native/core/factories/TemplateFactory.go +57 -57
- package/native/core/factories/TypeFactory.go +125 -125
- package/native/core/factories/ValueFactory.go +12 -12
- package/native/core/factories/internal/metadata/IMetadataIteratorProps.go +35 -35
- package/native/core/factories/internal/metadata/MetadataHelper.go +176 -176
- package/native/core/factories/internal/metadata/emend_metadata_atomics.go +69 -69
- package/native/core/factories/internal/metadata/emplace_metadata_alias.go +27 -27
- package/native/core/factories/internal/metadata/emplace_metadata_array_type.go +33 -33
- package/native/core/factories/internal/metadata/emplace_metadata_object.go +209 -209
- package/native/core/factories/internal/metadata/emplace_metadata_tuple.go +50 -50
- package/native/core/factories/internal/metadata/explore_metadata.go +29 -29
- package/native/core/factories/internal/metadata/iterate_metadata.go +46 -46
- package/native/core/factories/internal/metadata/iterate_metadata_alias.go +25 -25
- package/native/core/factories/internal/metadata/iterate_metadata_array.go +65 -65
- package/native/core/factories/internal/metadata/iterate_metadata_atomic.go +49 -49
- package/native/core/factories/internal/metadata/iterate_metadata_coalesce.go +22 -22
- package/native/core/factories/internal/metadata/iterate_metadata_collection.go +228 -228
- package/native/core/factories/internal/metadata/iterate_metadata_comment_tags.go +12 -12
- package/native/core/factories/internal/metadata/iterate_metadata_constant.go +71 -71
- package/native/core/factories/internal/metadata/iterate_metadata_escape.go +48 -48
- package/native/core/factories/internal/metadata/iterate_metadata_function.go +82 -82
- package/native/core/factories/internal/metadata/iterate_metadata_intersection.go +319 -319
- package/native/core/factories/internal/metadata/iterate_metadata_map.go +51 -51
- package/native/core/factories/internal/metadata/iterate_metadata_native.go +85 -85
- package/native/core/factories/internal/metadata/iterate_metadata_object.go +27 -27
- package/native/core/factories/internal/metadata/iterate_metadata_set.go +37 -37
- package/native/core/factories/internal/metadata/iterate_metadata_sort.go +137 -137
- package/native/core/factories/internal/metadata/iterate_metadata_template.go +33 -33
- package/native/core/factories/internal/metadata/iterate_metadata_tuple.go +16 -16
- package/native/core/factories/internal/metadata/iterate_metadata_union.go +18 -18
- package/native/core/programmers/AssertProgrammer.go +389 -389
- package/native/core/programmers/ImportProgrammer.go +196 -196
- package/native/core/programmers/IsProgrammer.go +293 -293
- package/native/core/programmers/RandomProgrammer.go +1094 -1094
- package/native/core/programmers/ValidateProgrammer.go +369 -369
- package/native/core/programmers/functional/FunctionalAssertFunctionProgrammer.go +133 -133
- package/native/core/programmers/functional/FunctionalAssertParametersProgrammer.go +104 -104
- package/native/core/programmers/functional/FunctionalAssertReturnProgrammer.go +100 -100
- package/native/core/programmers/functional/FunctionalIsFunctionProgrammer.go +79 -79
- package/native/core/programmers/functional/FunctionalIsParametersProgrammer.go +159 -159
- package/native/core/programmers/functional/FunctionalIsReturnProgrammer.go +99 -99
- package/native/core/programmers/functional/FunctionalValidateFunctionProgrammer.go +138 -138
- package/native/core/programmers/functional/FunctionalValidateParametersProgrammer.go +222 -222
- package/native/core/programmers/functional/FunctionalValidateReturnProgrammer.go +116 -116
- package/native/core/programmers/functional/internal/FunctionalGeneralProgrammer.go +36 -36
- package/native/core/programmers/helpers/AtomicPredicator.go +35 -35
- package/native/core/programmers/helpers/CloneJoiner.go +217 -217
- package/native/core/programmers/helpers/FunctionProgrammer.go +79 -79
- package/native/core/programmers/helpers/HttpMetadataUtil.go +17 -17
- package/native/core/programmers/helpers/ICheckEntry.go +5 -5
- package/native/core/programmers/helpers/IExpressionEntry.go +6 -6
- package/native/core/programmers/helpers/NotationJoiner.go +159 -159
- package/native/core/programmers/helpers/OptionPredicator.go +4 -4
- package/native/core/programmers/helpers/ProtobufUtil.go +231 -231
- package/native/core/programmers/helpers/ProtobufWire.go +6 -6
- package/native/core/programmers/helpers/PruneJoiner.go +227 -227
- package/native/core/programmers/helpers/RandomJoiner.go +155 -155
- package/native/core/programmers/helpers/StringifyJoinder.go +331 -331
- package/native/core/programmers/helpers/StringifyPredicator.go +10 -10
- package/native/core/programmers/helpers/UnionExplorer.go +835 -835
- package/native/core/programmers/helpers/UnionPredicator.go +78 -78
- package/native/core/programmers/helpers/disable_function_programmer_declare.go +6 -6
- package/native/core/programmers/http/HttpAssertFormDataProgrammer.go +93 -93
- package/native/core/programmers/http/HttpAssertHeadersProgrammer.go +42 -42
- package/native/core/programmers/http/HttpAssertQueryProgrammer.go +51 -51
- package/native/core/programmers/http/HttpFormDataProgrammer.go +351 -351
- package/native/core/programmers/http/HttpHeadersProgrammer.go +370 -370
- package/native/core/programmers/http/HttpIsFormDataProgrammer.go +109 -109
- package/native/core/programmers/http/HttpIsHeadersProgrammer.go +36 -36
- package/native/core/programmers/http/HttpIsQueryProgrammer.go +45 -45
- package/native/core/programmers/http/HttpParameterProgrammer.go +158 -158
- package/native/core/programmers/http/HttpQueryProgrammer.go +422 -422
- package/native/core/programmers/http/HttpValidateFormDataProgrammer.go +87 -87
- package/native/core/programmers/http/HttpValidateHeadersProgrammer.go +39 -39
- package/native/core/programmers/http/HttpValidateQueryProgrammer.go +48 -48
- package/native/core/programmers/internal/CheckerProgrammer.go +1490 -1490
- package/native/core/programmers/internal/FeatureProgrammer.go +589 -589
- package/native/core/programmers/iterate/check_array_length.go +46 -46
- package/native/core/programmers/iterate/check_bigint.go +52 -52
- package/native/core/programmers/iterate/check_dynamic_key.go +220 -220
- package/native/core/programmers/iterate/check_dynamic_properties.go +245 -245
- package/native/core/programmers/iterate/check_everything.go +21 -21
- package/native/core/programmers/iterate/check_native.go +25 -25
- package/native/core/programmers/iterate/check_number.go +135 -135
- package/native/core/programmers/iterate/check_object.go +66 -66
- package/native/core/programmers/iterate/check_string.go +52 -52
- package/native/core/programmers/iterate/check_template.go +57 -57
- package/native/core/programmers/iterate/check_union_array_like.go +372 -372
- package/native/core/programmers/iterate/decode_union_object.go +118 -118
- package/native/core/programmers/iterate/feature_object_entries.go +134 -134
- package/native/core/programmers/iterate/json_schema_alias.go +52 -52
- package/native/core/programmers/iterate/json_schema_array.go +52 -52
- package/native/core/programmers/iterate/json_schema_bigint.go +8 -8
- package/native/core/programmers/iterate/json_schema_boolean.go +8 -8
- package/native/core/programmers/iterate/json_schema_constant.go +38 -38
- package/native/core/programmers/iterate/json_schema_description.go +12 -12
- package/native/core/programmers/iterate/json_schema_discriminator.go +47 -47
- package/native/core/programmers/iterate/json_schema_escaped.go +58 -58
- package/native/core/programmers/iterate/json_schema_jsDocTags.go +34 -34
- package/native/core/programmers/iterate/json_schema_native.go +43 -43
- package/native/core/programmers/iterate/json_schema_number.go +8 -8
- package/native/core/programmers/iterate/json_schema_object.go +149 -149
- package/native/core/programmers/iterate/json_schema_plugin.go +35 -35
- package/native/core/programmers/iterate/json_schema_station.go +211 -211
- package/native/core/programmers/iterate/json_schema_string.go +8 -8
- package/native/core/programmers/iterate/json_schema_template.go +53 -53
- package/native/core/programmers/iterate/json_schema_title.go +16 -16
- package/native/core/programmers/iterate/json_schema_tuple.go +34 -34
- package/native/core/programmers/iterate/metadata_to_pattern.go +53 -53
- package/native/core/programmers/iterate/postfix_of_tuple.go +5 -5
- package/native/core/programmers/iterate/prune_object_properties.go +85 -85
- package/native/core/programmers/iterate/stringify_dynamic_properties.go +193 -193
- package/native/core/programmers/iterate/stringify_native.go +1 -1
- package/native/core/programmers/iterate/stringify_regular_properties.go +84 -84
- package/native/core/programmers/iterate/template_to_pattern.go +20 -20
- package/native/core/programmers/iterate/wrap_metadata_rest_tuple.go +13 -13
- package/native/core/programmers/json/JsonApplicationProgrammer.go +323 -323
- package/native/core/programmers/json/JsonAssertParseProgrammer.go +100 -100
- package/native/core/programmers/json/JsonAssertStringifyProgrammer.go +88 -88
- package/native/core/programmers/json/JsonIsParseProgrammer.go +130 -130
- package/native/core/programmers/json/JsonIsStringifyProgrammer.go +92 -92
- package/native/core/programmers/json/JsonSchemaProgrammer.go +65 -65
- package/native/core/programmers/json/JsonSchemasProgrammer.go +116 -116
- package/native/core/programmers/json/JsonStringifyProgrammer.go +1245 -1245
- package/native/core/programmers/json/JsonValidateParseProgrammer.go +89 -89
- package/native/core/programmers/json/JsonValidateStringifyProgrammer.go +106 -106
- package/native/core/programmers/llm/LlmApplicationProgrammer.go +445 -445
- package/native/core/programmers/llm/LlmCoerceProgrammer.go +79 -79
- package/native/core/programmers/llm/LlmControllerProgrammer.go +35 -35
- package/native/core/programmers/llm/LlmMetadataFactory.go +74 -74
- package/native/core/programmers/llm/LlmParametersProgrammer.go +104 -104
- package/native/core/programmers/llm/LlmParseProgrammer.go +88 -88
- package/native/core/programmers/llm/LlmSchemaProgrammer.go +702 -702
- package/native/core/programmers/llm/LlmStructuredOutputProgrammer.go +123 -123
- package/native/core/programmers/misc/MiscAssertCloneProgrammer.go +82 -82
- package/native/core/programmers/misc/MiscAssertPruneProgrammer.go +97 -97
- package/native/core/programmers/misc/MiscCloneProgrammer.go +1056 -1056
- package/native/core/programmers/misc/MiscIsCloneProgrammer.go +94 -94
- package/native/core/programmers/misc/MiscIsPruneProgrammer.go +86 -86
- package/native/core/programmers/misc/MiscLiteralsProgrammer.go +99 -99
- package/native/core/programmers/misc/MiscPruneProgrammer.go +700 -700
- package/native/core/programmers/misc/MiscValidateCloneProgrammer.go +103 -103
- package/native/core/programmers/misc/MiscValidatePruneProgrammer.go +94 -94
- package/native/core/programmers/notations/NotationAssertGeneralProgrammer.go +85 -85
- package/native/core/programmers/notations/NotationGeneralProgrammer.go +1188 -1188
- package/native/core/programmers/notations/NotationIsGeneralProgrammer.go +90 -90
- package/native/core/programmers/notations/NotationValidateGeneralProgrammer.go +109 -109
- package/native/core/programmers/protobuf/ProtobufAssertDecodeProgrammer.go +99 -99
- package/native/core/programmers/protobuf/ProtobufAssertEncodeProgrammer.go +114 -114
- package/native/core/programmers/protobuf/ProtobufDecodeProgrammer.go +697 -697
- package/native/core/programmers/protobuf/ProtobufEncodeProgrammer.go +1039 -1039
- package/native/core/programmers/protobuf/ProtobufIsDecodeProgrammer.go +99 -99
- package/native/core/programmers/protobuf/ProtobufIsEncodeProgrammer.go +93 -93
- package/native/core/programmers/protobuf/ProtobufMessageProgrammer.go +228 -228
- package/native/core/programmers/protobuf/ProtobufValidateDecodeProgrammer.go +88 -88
- package/native/core/programmers/protobuf/ProtobufValidateEncodeProgrammer.go +120 -120
- package/native/core/schemas/metadata/IMetadataDictionary.go +4 -4
- package/native/core/schemas/metadata/MetadataAlias.go +15 -15
- package/native/core/schemas/metadata/MetadataAliasType.go +36 -36
- package/native/core/schemas/metadata/MetadataApplication.go +25 -25
- package/native/core/schemas/metadata/MetadataArray.go +15 -15
- package/native/core/schemas/metadata/MetadataArrayType.go +31 -31
- package/native/core/schemas/metadata/MetadataAtomic.go +45 -45
- package/native/core/schemas/metadata/MetadataCollection.go +380 -380
- package/native/core/schemas/metadata/MetadataComponents.go +95 -95
- package/native/core/schemas/metadata/MetadataConstant.go +31 -31
- package/native/core/schemas/metadata/MetadataConstantValue.go +63 -63
- package/native/core/schemas/metadata/MetadataEscaped.go +17 -17
- package/native/core/schemas/metadata/MetadataFunction.go +30 -30
- package/native/core/schemas/metadata/MetadataMap.go +21 -21
- package/native/core/schemas/metadata/MetadataNative.go +48 -48
- package/native/core/schemas/metadata/MetadataObject.go +15 -15
- package/native/core/schemas/metadata/MetadataObjectType.go +116 -116
- package/native/core/schemas/metadata/MetadataParameter.go +28 -28
- package/native/core/schemas/metadata/MetadataProperty.go +32 -32
- package/native/core/schemas/metadata/MetadataSchema.go +766 -766
- package/native/core/schemas/metadata/MetadataSet.go +17 -17
- package/native/core/schemas/metadata/MetadataTemplate.go +43 -43
- package/native/core/schemas/metadata/MetadataTuple.go +10 -10
- package/native/core/schemas/metadata/MetadataTupleType.go +38 -38
- package/native/core/schemas/protobuf/IProtobufProperty.go +2 -2
- package/native/core/schemas/protobuf/IProtobufPropertyType.go +18 -18
- package/native/core/schemas/protobuf/IProtobufSchema.go +17 -17
- package/native/core/typings/Writable.go +1 -1
- package/native/core/utils/PatternUtil.go +38 -38
- package/native/core/utils/ProtobufNameEncoder.go +28 -28
- package/native/shim/printer/go.mod +1 -1
- package/native/shim/printer/shim.go +213 -213
- package/native/third_party/ttsc/driver/host.go +9 -9
- package/native/third_party/ttsc/driver/program.go +344 -281
- package/native/third_party/ttsc/driver/rewrite.go +247 -221
- package/native/third_party/ttsc/go.mod +5 -3
- package/native/third_party/ttsc/go.sum +2 -2
- package/native/third_party/ttsc/shim/ast/go.mod +1 -1
- package/native/third_party/ttsc/shim/ast/lint.go +174 -171
- package/native/third_party/ttsc/shim/ast/shim.go +86 -85
- package/native/third_party/ttsc/shim/bundled/go.mod +1 -1
- package/native/third_party/ttsc/shim/bundled/shim.go +5 -1
- package/native/third_party/ttsc/shim/checker/go.mod +1 -1
- package/native/third_party/ttsc/shim/checker/shim.go +79 -79
- package/native/third_party/ttsc/shim/compiler/go.mod +1 -1
- package/native/third_party/ttsc/shim/compiler/shim.go +16 -1
- package/native/third_party/ttsc/shim/core/go.mod +1 -1
- package/native/third_party/ttsc/shim/core/shim.go +13 -10
- package/native/third_party/ttsc/shim/diagnosticwriter/go.mod +1 -1
- package/native/third_party/ttsc/shim/diagnosticwriter/lint.go +79 -79
- package/native/third_party/ttsc/shim/diagnosticwriter/shim.go +19 -19
- package/native/third_party/ttsc/shim/parser/go.mod +1 -1
- package/native/third_party/ttsc/shim/parser/shim.go +7 -1
- package/native/third_party/ttsc/shim/scanner/go.mod +1 -1
- package/native/third_party/ttsc/shim/scanner/shim.go +39 -1
- package/native/third_party/ttsc/shim/tsoptions/go.mod +1 -1
- package/native/third_party/ttsc/shim/tsoptions/shim.go +51 -1
- package/native/third_party/ttsc/shim/tspath/go.mod +1 -1
- package/native/third_party/ttsc/shim/tspath/shim.go +72 -1
- package/native/third_party/ttsc/shim/vfs/cachedvfs/go.mod +1 -1
- package/native/third_party/ttsc/shim/vfs/cachedvfs/shim.go +1 -1
- package/native/third_party/ttsc/shim/vfs/go.mod +1 -1
- package/native/third_party/ttsc/shim/vfs/osvfs/go.mod +1 -1
- package/native/third_party/ttsc/shim/vfs/osvfs/shim.go +1 -1
- package/native/third_party/ttsc/shim/vfs/shim.go +4 -1
- package/native/transform/CallExpressionTransformer.go +556 -556
- package/native/transform/FileTransformer.go +123 -123
- package/native/transform/ImportTransformer.go +224 -224
- package/native/transform/NodeTransformer.go +11 -11
- package/native/transform/TypiaGenerator.go +136 -136
- package/native/transform/features/AssertTransformer.go +28 -28
- package/native/transform/features/CreateAssertTransformer.go +28 -28
- package/native/transform/features/CreateIsTransformer.go +24 -24
- package/native/transform/features/CreateRandomTransformer.go +35 -35
- package/native/transform/features/CreateValidateTransformer.go +24 -24
- package/native/transform/features/IsTransformer.go +24 -24
- package/native/transform/features/RandomTransformer.go +37 -37
- package/native/transform/features/ValidateTransformer.go +24 -24
- package/native/transform/features/functional/FunctionalGenericTransformer.go +48 -48
- package/native/transform/features/http/CreateHttpAssertFormDataTransformer.go +11 -11
- package/native/transform/features/http/CreateHttpAssertHeadersTransformer.go +11 -11
- package/native/transform/features/http/CreateHttpAssertQueryTransformer.go +17 -17
- package/native/transform/features/http/CreateHttpFormDataTransformer.go +11 -11
- package/native/transform/features/http/CreateHttpHeadersTransformer.go +11 -11
- package/native/transform/features/http/CreateHttpIsFormDataTransformer.go +11 -11
- package/native/transform/features/http/CreateHttpIsHeadersTransformer.go +11 -11
- package/native/transform/features/http/CreateHttpIsQueryTransformer.go +17 -17
- package/native/transform/features/http/CreateHttpParameterTransformer.go +11 -11
- package/native/transform/features/http/CreateHttpQueryTransformer.go +17 -17
- package/native/transform/features/http/CreateHttpValidateFormDataTransformer.go +11 -11
- package/native/transform/features/http/CreateHttpValidateHeadersTransformer.go +11 -11
- package/native/transform/features/http/CreateHttpValidateQueryTransformer.go +17 -17
- package/native/transform/features/http/HttpAssertFormDataTransformer.go +11 -11
- package/native/transform/features/http/HttpAssertHeadersTransformer.go +11 -11
- package/native/transform/features/http/HttpAssertQueryTransformer.go +17 -17
- package/native/transform/features/http/HttpFormDataTransformer.go +11 -11
- package/native/transform/features/http/HttpHeadersTransformer.go +11 -11
- package/native/transform/features/http/HttpIsFormDataTransformer.go +11 -11
- package/native/transform/features/http/HttpIsHeadersTransformer.go +11 -11
- package/native/transform/features/http/HttpIsQueryTransformer.go +17 -17
- package/native/transform/features/http/HttpParameterTransformer.go +11 -11
- package/native/transform/features/http/HttpQueryTransformer.go +17 -17
- package/native/transform/features/http/HttpValidateFormDataTransformer.go +11 -11
- package/native/transform/features/http/HttpValidateHeadersTransformer.go +11 -11
- package/native/transform/features/http/HttpValidateQueryTransformer.go +17 -17
- package/native/transform/features/json/JsonApplicationTransformer.go +61 -61
- package/native/transform/features/json/JsonAssertParseTransformer.go +11 -11
- package/native/transform/features/json/JsonAssertStringifyTransformer.go +11 -11
- package/native/transform/features/json/JsonCreateAssertParseTransformer.go +11 -11
- package/native/transform/features/json/JsonCreateAssertStringifyTransformer.go +11 -11
- package/native/transform/features/json/JsonCreateIsParseTransformer.go +11 -11
- package/native/transform/features/json/JsonCreateIsStringifyTransformer.go +11 -11
- package/native/transform/features/json/JsonCreateStringifyTransformer.go +11 -11
- package/native/transform/features/json/JsonCreateValidateParseTransformer.go +11 -11
- package/native/transform/features/json/JsonCreateValidateStringifyProgrammer.go +11 -11
- package/native/transform/features/json/JsonIsParseTransformer.go +11 -11
- package/native/transform/features/json/JsonIsStringifyTransformer.go +11 -11
- package/native/transform/features/json/JsonSchemaTransformer.go +148 -148
- package/native/transform/features/json/JsonSchemasTransformer.go +94 -94
- package/native/transform/features/json/JsonStringifyTransformer.go +11 -11
- package/native/transform/features/json/JsonValidateParseTransformer.go +11 -11
- package/native/transform/features/json/JsonValidateStringifyTransformer.go +11 -11
- package/native/transform/features/llm/LlmApplicationTransformer.go +43 -43
- package/native/transform/features/llm/LlmCoerceTransformer.go +50 -50
- package/native/transform/features/llm/LlmControllerTransformer.go +48 -48
- package/native/transform/features/llm/LlmCreateCoerceTransformer.go +43 -43
- package/native/transform/features/llm/LlmCreateParseTransformer.go +43 -43
- package/native/transform/features/llm/LlmParametersTransformer.go +38 -38
- package/native/transform/features/llm/LlmParseTransformer.go +50 -50
- package/native/transform/features/llm/LlmSchemaTransformer.go +129 -129
- package/native/transform/features/llm/LlmStructuredOutputTransformer.go +44 -44
- package/native/transform/features/misc/MiscAssertCloneTransformer.go +11 -11
- package/native/transform/features/misc/MiscAssertPruneTransformer.go +11 -11
- package/native/transform/features/misc/MiscCloneTransformer.go +11 -11
- package/native/transform/features/misc/MiscCreateAssertCloneTransformer.go +11 -11
- package/native/transform/features/misc/MiscCreateAssertPruneTransformer.go +11 -11
- package/native/transform/features/misc/MiscCreateCloneTransformer.go +11 -11
- package/native/transform/features/misc/MiscCreateIsCloneTransformer.go +11 -11
- package/native/transform/features/misc/MiscCreateIsPruneTransformer.go +11 -11
- package/native/transform/features/misc/MiscCreatePruneTransformer.go +11 -11
- package/native/transform/features/misc/MiscCreateValidateCloneTransformer.go +11 -11
- package/native/transform/features/misc/MiscCreateValidatePruneTransformer.go +11 -11
- package/native/transform/features/misc/MiscIsCloneTransformer.go +11 -11
- package/native/transform/features/misc/MiscIsPruneTransformer.go +11 -11
- package/native/transform/features/misc/MiscLiteralsTransformer.go +21 -21
- package/native/transform/features/misc/MiscPruneTransformer.go +11 -11
- package/native/transform/features/misc/MiscValidateCloneTransformer.go +11 -11
- package/native/transform/features/misc/MiscValidatePruneTransformer.go +11 -11
- package/native/transform/features/notations/NotationAssertGeneralTransformer.go +16 -16
- package/native/transform/features/notations/NotationCreateAssertGeneralTransformer.go +16 -16
- package/native/transform/features/notations/NotationCreateGeneralTransformer.go +16 -16
- package/native/transform/features/notations/NotationCreateIsGeneralTransformer.go +16 -16
- package/native/transform/features/notations/NotationCreateValidateGeneralTransformer.go +16 -16
- package/native/transform/features/notations/NotationGeneralTransformer.go +21 -21
- package/native/transform/features/notations/NotationIsGeneralTransformer.go +16 -16
- package/native/transform/features/notations/NotationValidateGeneralTransformer.go +16 -16
- package/native/transform/features/protobuf/ProtobufAssertDecodeTransformer.go +11 -11
- package/native/transform/features/protobuf/ProtobufAssertEncodeTransformer.go +11 -11
- package/native/transform/features/protobuf/ProtobufCreateAssertDecodeTransformer.go +11 -11
- package/native/transform/features/protobuf/ProtobufCreateAssertEncodeTransformer.go +11 -11
- package/native/transform/features/protobuf/ProtobufCreateDecodeTransformer.go +11 -11
- package/native/transform/features/protobuf/ProtobufCreateEncodeTransformer.go +11 -11
- package/native/transform/features/protobuf/ProtobufCreateIsDecodeTransformer.go +11 -11
- package/native/transform/features/protobuf/ProtobufCreateIsEncodeTransformer.go +11 -11
- package/native/transform/features/protobuf/ProtobufCreateValidateDecodeTransformer.go +11 -11
- package/native/transform/features/protobuf/ProtobufCreateValidateEncodeTransformer.go +11 -11
- package/native/transform/features/protobuf/ProtobufDecodeTransformer.go +11 -11
- package/native/transform/features/protobuf/ProtobufEncodeTransformer.go +11 -11
- package/native/transform/features/protobuf/ProtobufIsDecodeTransformer.go +11 -11
- package/native/transform/features/protobuf/ProtobufIsEncodeTransformer.go +11 -11
- package/native/transform/features/protobuf/ProtobufMessageTransformer.go +20 -20
- package/native/transform/features/protobuf/ProtobufValidateDecodeTransformer.go +11 -11
- package/native/transform/features/protobuf/ProtobufValidateEncodeTransformer.go +11 -11
- package/native/transform/features/reflect/ReflectMetadataTransformer.go +59 -59
- package/native/transform/features/reflect/ReflectNameTransformer.go +78 -78
- package/native/transform/features/reflect/ReflectSchemaTransformer.go +121 -121
- package/native/transform/features/reflect/ReflectSchemasTransformer.go +55 -55
- package/native/transform/internal/GenericTransformer.go +173 -173
- package/native/transform/transform.go +32 -32
- package/package.json +5 -5
- package/src/executable/generate/ttsc.ts +2 -3
- package/src/executable/setup/PluginConfigurator.ts +2 -3
- package/src/internal/_randomInteger.ts +5 -5
- package/src/internal/_validateReport.ts +1 -2
- package/src/transform.ts +1 -1
|
@@ -1,21 +1,23 @@
|
|
|
1
1
|
package driver
|
|
2
2
|
|
|
3
3
|
import (
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
4
|
+
"context"
|
|
5
|
+
"errors"
|
|
6
|
+
"fmt"
|
|
7
|
+
"io"
|
|
8
|
+
"path/filepath"
|
|
9
|
+
"strings"
|
|
10
|
+
"time"
|
|
11
|
+
|
|
12
|
+
"github.com/microsoft/typescript-go/shim/ast"
|
|
13
|
+
shimchecker "github.com/microsoft/typescript-go/shim/checker"
|
|
14
|
+
shimcompiler "github.com/microsoft/typescript-go/shim/compiler"
|
|
15
|
+
"github.com/microsoft/typescript-go/shim/core"
|
|
16
|
+
shimdiagnosticwriter "github.com/microsoft/typescript-go/shim/diagnosticwriter"
|
|
17
|
+
shimscanner "github.com/microsoft/typescript-go/shim/scanner"
|
|
18
|
+
"github.com/microsoft/typescript-go/shim/tsoptions"
|
|
19
|
+
"github.com/microsoft/typescript-go/shim/tspath"
|
|
20
|
+
"github.com/microsoft/typescript-go/shim/vfs"
|
|
19
21
|
)
|
|
20
22
|
|
|
21
23
|
// Diagnostic is the compilation diagnostic shape ttsc passes around. Kept
|
|
@@ -27,13 +29,16 @@ import (
|
|
|
27
29
|
// `@ttsc/lint`). At most one of `raw` / `lint` is non-nil; both nil falls
|
|
28
30
|
// back to the legacy single-line form.
|
|
29
31
|
type Diagnostic struct {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
32
|
+
File string
|
|
33
|
+
Line int
|
|
34
|
+
Column int
|
|
35
|
+
Code int32
|
|
36
|
+
Start *int
|
|
37
|
+
Length *int
|
|
38
|
+
Message string
|
|
39
|
+
Severity Severity
|
|
40
|
+
raw *ast.Diagnostic
|
|
41
|
+
lint *shimdiagnosticwriter.LintDiagnostic
|
|
37
42
|
}
|
|
38
43
|
|
|
39
44
|
// Severity classifies a diagnostic's blast radius. ttsc treats Error as a
|
|
@@ -41,12 +46,12 @@ type Diagnostic struct {
|
|
|
41
46
|
type Severity int
|
|
42
47
|
|
|
43
48
|
const (
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
49
|
+
// SeverityError is the default for tsgo typecheck output and any
|
|
50
|
+
// plugin-emitted finding that should fail the build.
|
|
51
|
+
SeverityError Severity = iota
|
|
52
|
+
// SeverityWarning prints with warning coloring but keeps the build
|
|
53
|
+
// status at zero.
|
|
54
|
+
SeverityWarning
|
|
50
55
|
)
|
|
51
56
|
|
|
52
57
|
// IsError reports whether the diagnostic counts toward the build's error
|
|
@@ -60,56 +65,60 @@ func (d Diagnostic) IsError() bool { return d.Severity == SeverityError }
|
|
|
60
65
|
// rule's enum index). Severity controls both the rendered banner color and
|
|
61
66
|
// the exit-code outcome.
|
|
62
67
|
func NewLintDiagnostic(
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
+
file *ast.SourceFile,
|
|
69
|
+
pos, end int,
|
|
70
|
+
code int32,
|
|
71
|
+
severity Severity,
|
|
72
|
+
message string,
|
|
68
73
|
) Diagnostic {
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
74
|
+
cat := shimdiagnosticwriter.LintCategoryError
|
|
75
|
+
if severity == SeverityWarning {
|
|
76
|
+
cat = shimdiagnosticwriter.LintCategoryWarning
|
|
77
|
+
}
|
|
78
|
+
lint := shimdiagnosticwriter.NewLintDiagnostic(file, pos, end, code, cat, message)
|
|
79
|
+
d := Diagnostic{
|
|
80
|
+
Code: code,
|
|
81
|
+
Message: message,
|
|
82
|
+
Severity: severity,
|
|
83
|
+
lint: lint,
|
|
84
|
+
}
|
|
85
|
+
if file != nil {
|
|
86
|
+
d.File = file.FileName()
|
|
87
|
+
if pos >= 0 {
|
|
88
|
+
length := end - pos
|
|
89
|
+
d.Start = &pos
|
|
90
|
+
d.Length = &length
|
|
91
|
+
line, col := shimscanner.GetECMALineAndByteOffsetOfPosition(file, pos)
|
|
92
|
+
d.Line = line + 1
|
|
93
|
+
d.Column = col + 1
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
return d
|
|
88
97
|
}
|
|
89
98
|
|
|
90
99
|
// SourceFile returns the program source file matching filename.
|
|
91
100
|
func (p *Program) SourceFile(filename string) *ast.SourceFile {
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
101
|
+
if p == nil || p.TSProgram == nil {
|
|
102
|
+
return nil
|
|
103
|
+
}
|
|
104
|
+
normalized := filepath.ToSlash(filename)
|
|
105
|
+
for _, file := range p.TSProgram.SourceFiles() {
|
|
106
|
+
if filepath.ToSlash(file.FileName()) == normalized {
|
|
107
|
+
return file
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
return nil
|
|
102
111
|
}
|
|
103
112
|
|
|
104
113
|
// String returns a `path:line:col: message` formatted string.
|
|
105
114
|
func (d Diagnostic) String() string {
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
115
|
+
if d.File == "" {
|
|
116
|
+
return d.Message
|
|
117
|
+
}
|
|
118
|
+
if d.Line > 0 {
|
|
119
|
+
return fmt.Sprintf("%s:%d:%d: %s", d.File, d.Line, d.Column, d.Message)
|
|
120
|
+
}
|
|
121
|
+
return fmt.Sprintf("%s: %s", d.File, d.Message)
|
|
113
122
|
}
|
|
114
123
|
|
|
115
124
|
// WritePrettyDiagnostics renders diagnostics with TypeScript-style colors,
|
|
@@ -118,90 +127,91 @@ func (d Diagnostic) String() string {
|
|
|
118
127
|
// are rendered through the same color/context pipeline; entries without
|
|
119
128
|
// either anchor fall back to the legacy `path:line:col: message` form.
|
|
120
129
|
func WritePrettyDiagnostics(w io.Writer, diagnostics []Diagnostic, cwd string) {
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
130
|
+
if len(diagnostics) == 0 {
|
|
131
|
+
return
|
|
132
|
+
}
|
|
133
|
+
rich := make([]Diagnostic, 0, len(diagnostics))
|
|
134
|
+
plain := make([]Diagnostic, 0)
|
|
135
|
+
for _, d := range diagnostics {
|
|
136
|
+
if d.raw != nil || d.lint != nil {
|
|
137
|
+
rich = append(rich, d)
|
|
138
|
+
} else {
|
|
139
|
+
plain = append(plain, d)
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
if len(rich) > 0 {
|
|
143
|
+
astDiags := make([]*ast.Diagnostic, 0, len(rich))
|
|
144
|
+
lintDiags := make([]*shimdiagnosticwriter.LintDiagnostic, 0, len(rich))
|
|
145
|
+
for _, d := range rich {
|
|
146
|
+
if d.raw != nil {
|
|
147
|
+
astDiags = append(astDiags, d.raw)
|
|
148
|
+
}
|
|
149
|
+
if d.lint != nil {
|
|
150
|
+
lintDiags = append(lintDiags, d.lint)
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
shimdiagnosticwriter.FormatMixedDiagnostics(w, astDiags, lintDiags, cwd)
|
|
154
|
+
}
|
|
155
|
+
for _, d := range plain {
|
|
156
|
+
fmt.Fprintln(w, " -", d.String())
|
|
157
|
+
}
|
|
149
158
|
}
|
|
150
159
|
|
|
151
160
|
// CountErrors returns the number of diagnostics that should fail the build.
|
|
152
161
|
// tsgo diagnostics carry their own `Error` category; lint diagnostics carry a
|
|
153
162
|
// caller-set Severity. Anything that isn't an explicit warning counts.
|
|
154
163
|
func CountErrors(diagnostics []Diagnostic) int {
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
164
|
+
n := 0
|
|
165
|
+
for _, d := range diagnostics {
|
|
166
|
+
if d.lint != nil {
|
|
167
|
+
if d.lint.IsError() {
|
|
168
|
+
n++
|
|
169
|
+
}
|
|
170
|
+
continue
|
|
171
|
+
}
|
|
172
|
+
if d.raw != nil {
|
|
173
|
+
// tsgo diagnostics use the diagnostics package category. The
|
|
174
|
+
// renderer shim already mirrors the same Error/Warning split, so
|
|
175
|
+
// re-categorize via the public IsError shortcut.
|
|
176
|
+
if d.Severity != SeverityWarning {
|
|
177
|
+
n++
|
|
178
|
+
}
|
|
179
|
+
continue
|
|
180
|
+
}
|
|
181
|
+
// Plain text diagnostics (manually assembled): treat as errors so
|
|
182
|
+
// "ttsc: tsconfig not found"-style failures still flip the exit code.
|
|
183
|
+
n++
|
|
184
|
+
}
|
|
185
|
+
return n
|
|
177
186
|
}
|
|
178
187
|
|
|
179
188
|
// Program is the shim-agnostic facade the rest of the engine sees.
|
|
180
189
|
type Program struct {
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
190
|
+
TSProgram *shimcompiler.Program
|
|
191
|
+
ParsedConfig *tsoptions.ParsedCommandLine
|
|
192
|
+
Checker *shimchecker.Checker
|
|
193
|
+
checkerRelease func()
|
|
194
|
+
Host shimcompiler.CompilerHost
|
|
195
|
+
FS vfs.FS
|
|
187
196
|
}
|
|
188
197
|
|
|
189
198
|
// LoadProgramOptions controls tsconfig overrides applied before tsgo creates
|
|
190
|
-
// the program. `ForceEmit` is used by `ttsc --emit` and
|
|
191
|
-
// so
|
|
199
|
+
// the program. `ForceEmit` is used by `ttsc --emit` and runtime compilation
|
|
200
|
+
// so execution still works when the project defaults to `noEmit`.
|
|
192
201
|
type LoadProgramOptions struct {
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
202
|
+
ForceEmit bool
|
|
203
|
+
ForceNoEmit bool
|
|
204
|
+
OutDir string
|
|
205
|
+
SourcePreamble string
|
|
196
206
|
}
|
|
197
207
|
|
|
198
208
|
// Close releases the checker pool lease acquired by LoadProgram.
|
|
199
209
|
func (p *Program) Close() error {
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
210
|
+
if p.checkerRelease != nil {
|
|
211
|
+
p.checkerRelease()
|
|
212
|
+
p.checkerRelease = nil
|
|
213
|
+
}
|
|
214
|
+
return nil
|
|
205
215
|
}
|
|
206
216
|
|
|
207
217
|
// ParseTSConfig parses a tsconfig.json file via tsgo's native JSONC parser.
|
|
@@ -211,36 +221,36 @@ func (p *Program) Close() error {
|
|
|
211
221
|
// tsgo's filesystem APIs require absolute paths — mirrors what tsc does when
|
|
212
222
|
// you pass a relative `--project` flag.
|
|
213
223
|
func ParseTSConfig(fs vfs.FS, cwd, tsconfigPath string, host shimcompiler.CompilerHost) (*tsoptions.ParsedCommandLine, []Diagnostic, error) {
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
224
|
+
resolved := tspath.ResolvePath(cwd, tsconfigPath)
|
|
225
|
+
if !fs.FileExists(resolved) {
|
|
226
|
+
return nil, nil, fmt.Errorf("tsconfig not found: %s", resolved)
|
|
227
|
+
}
|
|
228
|
+
parsed, diags := tsoptions.GetParsedCommandLineOfConfigFile(resolved, &core.CompilerOptions{}, nil, host, nil)
|
|
229
|
+
if len(diags) > 0 {
|
|
230
|
+
return nil, convertDiagnostics(diags), nil
|
|
231
|
+
}
|
|
232
|
+
if parsed == nil {
|
|
233
|
+
return nil, nil, errors.New("tsoptions: parsed command line was nil")
|
|
234
|
+
}
|
|
235
|
+
if len(parsed.Errors) > 0 {
|
|
236
|
+
return nil, convertDiagnostics(parsed.Errors), nil
|
|
237
|
+
}
|
|
238
|
+
return parsed, nil, nil
|
|
229
239
|
}
|
|
230
240
|
|
|
231
241
|
// CreateProgramFromConfig builds a tsgo Program from the parsed config.
|
|
232
242
|
func CreateProgramFromConfig(parsed *tsoptions.ParsedCommandLine, host shimcompiler.CompilerHost) (*shimcompiler.Program, []Diagnostic, error) {
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
243
|
+
opts := shimcompiler.ProgramOptions{
|
|
244
|
+
Config: parsed,
|
|
245
|
+
SingleThreaded: core.TSTrue,
|
|
246
|
+
Host: host,
|
|
247
|
+
UseSourceOfProjectReference: true,
|
|
248
|
+
}
|
|
249
|
+
p := shimcompiler.NewProgram(opts)
|
|
250
|
+
if p == nil {
|
|
251
|
+
return nil, nil, errors.New("shimcompiler.NewProgram returned nil")
|
|
252
|
+
}
|
|
253
|
+
return p, nil, nil
|
|
244
254
|
}
|
|
245
255
|
|
|
246
256
|
// LoadProgram is the one-shot convenience used by `ttsc`.
|
|
@@ -249,155 +259,208 @@ func CreateProgramFromConfig(parsed *tsoptions.ParsedCommandLine, host shimcompi
|
|
|
249
259
|
//
|
|
250
260
|
// cwd must be absolute; tsconfigPath may be relative to cwd.
|
|
251
261
|
func LoadProgram(cwd, tsconfigPath string, options LoadProgramOptions) (*Program, []Diagnostic, error) {
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
262
|
+
if !filepath.IsAbs(cwd) {
|
|
263
|
+
if abs, err := filepath.Abs(cwd); err == nil {
|
|
264
|
+
cwd = abs
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
cwd = tspath.ResolvePath(cwd)
|
|
268
|
+
fs := DefaultFS()
|
|
269
|
+
if options.SourcePreamble != "" {
|
|
270
|
+
fs = sourcePreambleFS{
|
|
271
|
+
FS: fs,
|
|
272
|
+
preamble: options.SourcePreamble,
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
host := DefaultHost(cwd, fs)
|
|
276
|
+
|
|
277
|
+
parsed, diags, err := ParseTSConfig(fs, cwd, tsconfigPath, host)
|
|
278
|
+
if err != nil {
|
|
279
|
+
return nil, nil, err
|
|
280
|
+
}
|
|
281
|
+
if len(diags) > 0 {
|
|
282
|
+
return nil, diags, nil
|
|
283
|
+
}
|
|
284
|
+
if options.ForceNoEmit {
|
|
285
|
+
forceNoEmit(parsed)
|
|
286
|
+
}
|
|
287
|
+
if options.ForceEmit {
|
|
288
|
+
forceEmit(parsed)
|
|
289
|
+
}
|
|
290
|
+
if options.OutDir != "" {
|
|
291
|
+
overrideOutDir(cwd, parsed, options.OutDir)
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
tsProgram, progDiags, err := CreateProgramFromConfig(parsed, host)
|
|
295
|
+
if err != nil {
|
|
296
|
+
return nil, nil, err
|
|
297
|
+
}
|
|
298
|
+
if len(progDiags) > 0 {
|
|
299
|
+
return nil, progDiags, nil
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
checker, done := tsProgram.GetTypeChecker(context.Background())
|
|
303
|
+
return &Program{
|
|
304
|
+
TSProgram: tsProgram,
|
|
305
|
+
ParsedConfig: parsed,
|
|
306
|
+
Checker: checker,
|
|
307
|
+
checkerRelease: done,
|
|
308
|
+
Host: host,
|
|
309
|
+
FS: fs,
|
|
310
|
+
}, nil, nil
|
|
295
311
|
}
|
|
296
312
|
|
|
297
313
|
func forceEmit(parsed *tsoptions.ParsedCommandLine) {
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
314
|
+
if parsed == nil || parsed.ParsedConfig == nil || parsed.ParsedConfig.CompilerOptions == nil {
|
|
315
|
+
return
|
|
316
|
+
}
|
|
317
|
+
options := parsed.ParsedConfig.CompilerOptions
|
|
318
|
+
options.NoEmit = core.TSFalse
|
|
319
|
+
options.EmitDeclarationOnly = core.TSFalse
|
|
304
320
|
}
|
|
305
321
|
|
|
306
322
|
func forceNoEmit(parsed *tsoptions.ParsedCommandLine) {
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
323
|
+
if parsed == nil || parsed.ParsedConfig == nil || parsed.ParsedConfig.CompilerOptions == nil {
|
|
324
|
+
return
|
|
325
|
+
}
|
|
326
|
+
parsed.ParsedConfig.CompilerOptions.NoEmit = core.TSTrue
|
|
311
327
|
}
|
|
312
328
|
|
|
313
329
|
func overrideOutDir(cwd string, parsed *tsoptions.ParsedCommandLine, outDir string) {
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
330
|
+
if parsed == nil || parsed.ParsedConfig == nil || parsed.ParsedConfig.CompilerOptions == nil {
|
|
331
|
+
return
|
|
332
|
+
}
|
|
333
|
+
parsed.ParsedConfig.CompilerOptions.OutDir = tspath.ResolvePath(cwd, outDir)
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
type sourcePreambleFS struct {
|
|
337
|
+
vfs.FS
|
|
338
|
+
preamble string
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
func (fs sourcePreambleFS) ReadFile(filePath string) (string, bool) {
|
|
342
|
+
contents, ok := fs.FS.ReadFile(filePath)
|
|
343
|
+
if !ok || !isSourcePreambleTarget(filePath) {
|
|
344
|
+
return contents, ok
|
|
345
|
+
}
|
|
346
|
+
return fs.preamble + contents, true
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
func (fs sourcePreambleFS) WriteFile(filePath string, data string) error {
|
|
350
|
+
return fs.FS.WriteFile(filePath, data)
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
func (fs sourcePreambleFS) AppendFile(filePath string, data string) error {
|
|
354
|
+
return fs.FS.AppendFile(filePath, data)
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
func (fs sourcePreambleFS) Remove(filePath string) error {
|
|
358
|
+
return fs.FS.Remove(filePath)
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
func (fs sourcePreambleFS) Chtimes(filePath string, aTime time.Time, mTime time.Time) error {
|
|
362
|
+
return fs.FS.Chtimes(filePath, aTime, mTime)
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
func isSourcePreambleTarget(filePath string) bool {
|
|
366
|
+
lower := strings.ToLower(filepath.ToSlash(filePath))
|
|
367
|
+
for _, suffix := range []string{".d.ts", ".d.mts", ".d.cts"} {
|
|
368
|
+
if strings.HasSuffix(lower, suffix) {
|
|
369
|
+
return false
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
for _, suffix := range []string{".ts", ".tsx", ".mts", ".cts", ".js", ".jsx", ".mjs", ".cjs"} {
|
|
373
|
+
if strings.HasSuffix(lower, suffix) {
|
|
374
|
+
return true
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
return false
|
|
318
378
|
}
|
|
319
379
|
|
|
320
380
|
// SourceFiles exposes the program's user-authored source files (declaration
|
|
321
381
|
// files filtered out).
|
|
322
382
|
func (p *Program) SourceFiles() []*ast.SourceFile {
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
383
|
+
out := make([]*ast.SourceFile, 0)
|
|
384
|
+
for _, f := range p.TSProgram.SourceFiles() {
|
|
385
|
+
if f.IsDeclarationFile {
|
|
386
|
+
continue
|
|
387
|
+
}
|
|
388
|
+
out = append(out, f)
|
|
389
|
+
}
|
|
390
|
+
return out
|
|
331
391
|
}
|
|
332
392
|
|
|
333
393
|
// Diagnostics returns project diagnostics that must block compilation or
|
|
334
394
|
// runtime execution before any JavaScript is emitted or evaluated.
|
|
335
395
|
func (p *Program) Diagnostics() []Diagnostic {
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
396
|
+
if p == nil || p.TSProgram == nil {
|
|
397
|
+
return []Diagnostic{{Message: "driver: nil program"}}
|
|
398
|
+
}
|
|
399
|
+
ctx := context.Background()
|
|
400
|
+
raw := shimcompiler.GetDiagnosticsOfAnyProgram(
|
|
401
|
+
ctx,
|
|
402
|
+
p.TSProgram,
|
|
403
|
+
nil,
|
|
404
|
+
false,
|
|
405
|
+
p.TSProgram.GetBindDiagnostics,
|
|
406
|
+
p.TSProgram.GetSemanticDiagnostics,
|
|
407
|
+
)
|
|
408
|
+
raw = filterDiagnostics(raw)
|
|
409
|
+
return convertDiagnostics(shimcompiler.SortAndDeduplicateDiagnostics(raw))
|
|
350
410
|
}
|
|
351
411
|
|
|
352
412
|
func filterDiagnostics(in []*ast.Diagnostic) []*ast.Diagnostic {
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
413
|
+
out := in[:0]
|
|
414
|
+
for _, d := range in {
|
|
415
|
+
if isUnusedOverloadSignatureTypeParameterDiagnostic(d) {
|
|
416
|
+
continue
|
|
417
|
+
}
|
|
418
|
+
out = append(out, d)
|
|
419
|
+
}
|
|
420
|
+
return out
|
|
361
421
|
}
|
|
362
422
|
|
|
363
423
|
func isUnusedOverloadSignatureTypeParameterDiagnostic(d *ast.Diagnostic) bool {
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
424
|
+
if d == nil || d.File() == nil {
|
|
425
|
+
return false
|
|
426
|
+
}
|
|
427
|
+
switch d.Code() {
|
|
428
|
+
case 6196, 6205: // unused declaration / all type parameters are unused
|
|
429
|
+
default:
|
|
430
|
+
return false
|
|
431
|
+
}
|
|
432
|
+
node := ast.GetNodeAtPosition(d.File(), d.Pos(), false)
|
|
433
|
+
for node != nil {
|
|
434
|
+
if node.Kind == ast.KindFunctionDeclaration {
|
|
435
|
+
return node.Body() == nil
|
|
436
|
+
}
|
|
437
|
+
node = node.Parent
|
|
438
|
+
}
|
|
439
|
+
return false
|
|
380
440
|
}
|
|
381
441
|
|
|
382
442
|
// convertDiagnostics translates shim-specific diagnostics into the plain
|
|
383
443
|
// Diagnostic struct with line/column populated via tsgo's ECMALineMap (the
|
|
384
444
|
// same helper tsc uses for its "file:line:col: message" banner).
|
|
385
445
|
func convertDiagnostics(in []*ast.Diagnostic) []Diagnostic {
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
446
|
+
out := make([]Diagnostic, 0, len(in))
|
|
447
|
+
for _, d := range in {
|
|
448
|
+
if d == nil {
|
|
449
|
+
continue
|
|
450
|
+
}
|
|
451
|
+
diag := Diagnostic{Code: d.Code(), Message: d.String(), raw: d}
|
|
452
|
+
if file := d.File(); file != nil {
|
|
453
|
+
diag.File = file.FileName()
|
|
454
|
+
if pos := d.Pos(); pos >= 0 {
|
|
455
|
+
length := d.Len()
|
|
456
|
+
diag.Start = &pos
|
|
457
|
+
diag.Length = &length
|
|
458
|
+
line, col := shimscanner.GetECMALineAndByteOffsetOfPosition(file, pos)
|
|
459
|
+
diag.Line = line + 1
|
|
460
|
+
diag.Column = col + 1
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
out = append(out, diag)
|
|
464
|
+
}
|
|
465
|
+
return out
|
|
403
466
|
}
|