typia 13.1.1 → 13.1.19
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/README.md +3 -0
- package/lib/_virtual/_rolldown/runtime.mjs +1 -5
- package/lib/executable/FileSystemIdentity.d.ts +21 -0
- package/lib/executable/FileSystemIdentity.js +183 -0
- package/lib/executable/FileSystemIdentity.js.map +1 -0
- package/lib/executable/FileSystemIdentity.mjs +129 -0
- package/lib/executable/FileSystemIdentity.mjs.map +1 -0
- package/lib/executable/TypiaGenerateWizard.js +264 -104
- package/lib/executable/TypiaGenerateWizard.js.map +1 -1
- package/lib/executable/TypiaGenerateWizard.mjs +233 -93
- package/lib/executable/TypiaGenerateWizard.mjs.map +1 -1
- package/lib/functional.d.ts +15 -12
- package/lib/functional.js.map +1 -1
- package/lib/functional.mjs.map +1 -1
- package/lib/internal/_ProtobufReader.d.ts +17 -0
- package/lib/internal/_ProtobufReader.js +117 -45
- package/lib/internal/_ProtobufReader.js.map +1 -1
- package/lib/internal/_ProtobufReader.mjs +108 -39
- package/lib/internal/_ProtobufReader.mjs.map +1 -1
- package/lib/internal/_createStandardSchema.js +18 -1
- package/lib/internal/_createStandardSchema.js.map +1 -1
- package/lib/internal/_createStandardSchema.mjs +12 -1
- package/lib/internal/_createStandardSchema.mjs.map +1 -1
- package/lib/internal/_decimal.d.ts +14 -0
- package/lib/internal/_decimal.js +61 -0
- package/lib/internal/_decimal.js.map +1 -0
- package/lib/internal/_decimal.mjs +49 -0
- package/lib/internal/_decimal.mjs.map +1 -0
- package/lib/internal/_httpQueryParseURLSearchParams.js +23 -2
- package/lib/internal/_httpQueryParseURLSearchParams.js.map +1 -1
- package/lib/internal/_httpQueryParseURLSearchParams.mjs +20 -2
- package/lib/internal/_httpQueryParseURLSearchParams.mjs.map +1 -1
- package/lib/internal/_isFormatByte.js +2 -5
- package/lib/internal/_isFormatByte.js.map +1 -1
- package/lib/internal/_isFormatByte.mjs +2 -5
- package/lib/internal/_isFormatByte.mjs.map +1 -1
- package/lib/internal/_isFormatDate.js +15 -2
- package/lib/internal/_isFormatDate.js.map +1 -1
- package/lib/internal/_isFormatDate.mjs +22 -2
- package/lib/internal/_isFormatDate.mjs.map +1 -1
- package/lib/internal/_isFormatDateTime.js +21 -2
- package/lib/internal/_isFormatDateTime.js.map +1 -1
- package/lib/internal/_isFormatDateTime.mjs +13 -2
- package/lib/internal/_isFormatDateTime.mjs.map +1 -1
- package/lib/internal/_isFormatIri.js +3 -2
- package/lib/internal/_isFormatIri.js.map +1 -1
- package/lib/internal/_isFormatIri.mjs +3 -2
- package/lib/internal/_isFormatIri.mjs.map +1 -1
- package/lib/internal/_isFormatIriReference.js +10 -2
- package/lib/internal/_isFormatIriReference.js.map +1 -1
- package/lib/internal/_isFormatIriReference.mjs +9 -2
- package/lib/internal/_isFormatIriReference.mjs.map +1 -1
- package/lib/internal/_isFormatUriReference.js +1 -1
- package/lib/internal/_isFormatUriReference.js.map +1 -1
- package/lib/internal/_isFormatUriReference.mjs +1 -1
- package/lib/internal/_isFormatUriReference.mjs.map +1 -1
- package/lib/internal/_isMultipleOf.d.ts +1 -0
- package/lib/internal/_isMultipleOf.js +13 -0
- package/lib/internal/_isMultipleOf.js.map +1 -0
- package/lib/internal/_isMultipleOf.mjs +12 -0
- package/lib/internal/_isMultipleOf.mjs.map +1 -0
- package/lib/internal/_isTypeFloat.js +1 -1
- package/lib/internal/_isTypeFloat.js.map +1 -1
- package/lib/internal/_isTypeFloat.mjs +1 -1
- package/lib/internal/_isTypeFloat.mjs.map +1 -1
- package/lib/internal/_isTypeInt64.js +1 -0
- package/lib/internal/_isTypeInt64.js.map +1 -1
- package/lib/internal/_isTypeInt64.mjs.map +1 -1
- package/lib/internal/_isTypeInt64Bigint.d.ts +1 -0
- package/lib/internal/_isTypeInt64Bigint.js +15 -0
- package/lib/internal/_isTypeInt64Bigint.js.map +1 -0
- package/lib/internal/_isTypeInt64Bigint.mjs +8 -0
- package/lib/internal/_isTypeInt64Bigint.mjs.map +1 -0
- package/lib/internal/_isTypeUint64.js +1 -0
- package/lib/internal/_isTypeUint64.js.map +1 -1
- package/lib/internal/_isTypeUint64.mjs.map +1 -1
- package/lib/internal/_isTypeUint64Bigint.d.ts +1 -0
- package/lib/internal/_isTypeUint64Bigint.js +10 -0
- package/lib/internal/_isTypeUint64Bigint.js.map +1 -0
- package/lib/internal/_isTypeUint64Bigint.mjs +8 -0
- package/lib/internal/_isTypeUint64Bigint.mjs.map +1 -0
- package/lib/internal/_isUniqueItems.js +96 -109
- package/lib/internal/_isUniqueItems.js.map +1 -1
- package/lib/internal/_isUniqueItems.mjs +62 -50
- package/lib/internal/_isUniqueItems.mjs.map +1 -1
- package/lib/internal/_notationAny.js +8 -1
- package/lib/internal/_notationAny.js.map +1 -1
- package/lib/internal/_notationAny.mjs +7 -1
- package/lib/internal/_notationAny.mjs.map +1 -1
- package/lib/internal/_notationAssign.d.ts +1 -0
- package/lib/internal/_notationAssign.js +18 -0
- package/lib/internal/_notationAssign.js.map +1 -0
- package/lib/internal/_notationAssign.mjs +17 -0
- package/lib/internal/_notationAssign.mjs.map +1 -0
- package/lib/internal/_notationCamel.js +30 -9
- package/lib/internal/_notationCamel.js.map +1 -1
- package/lib/internal/_notationCamel.mjs +13 -5
- package/lib/internal/_notationCamel.mjs.map +1 -1
- package/lib/internal/_notationKebab.d.ts +1 -0
- package/lib/internal/_notationKebab.js +15 -0
- package/lib/internal/_notationKebab.js.map +1 -0
- package/lib/internal/_notationKebab.mjs +15 -0
- package/lib/internal/_notationKebab.mjs.map +1 -0
- package/lib/internal/_notationKeyCollision.d.ts +1 -0
- package/lib/internal/_notationKeyCollision.js +8 -0
- package/lib/internal/_notationKeyCollision.js.map +1 -0
- package/lib/internal/_notationKeyCollision.mjs +8 -0
- package/lib/internal/_notationKeyCollision.mjs.map +1 -0
- package/lib/internal/_notationPascal.js +20 -5
- package/lib/internal/_notationPascal.js.map +1 -1
- package/lib/internal/_notationPascal.mjs +10 -5
- package/lib/internal/_notationPascal.mjs.map +1 -1
- package/lib/internal/_notationSnake.js +25 -22
- package/lib/internal/_notationSnake.js.map +1 -1
- package/lib/internal/_notationSnake.mjs +11 -11
- package/lib/internal/_notationSnake.mjs.map +1 -1
- package/lib/internal/_plainCloneAny.js +174 -38
- package/lib/internal/_plainCloneAny.js.map +1 -1
- package/lib/internal/_plainCloneAny.mjs +126 -22
- package/lib/internal/_plainCloneAny.mjs.map +1 -1
- package/lib/internal/_randomArray.d.ts +1 -1
- package/lib/internal/_randomArray.js +11 -4
- package/lib/internal/_randomArray.js.map +1 -1
- package/lib/internal/_randomArray.mjs +9 -3
- package/lib/internal/_randomArray.mjs.map +1 -1
- package/lib/internal/_randomFormatByte.d.ts +2 -1
- package/lib/internal/_randomFormatByte.js +2 -1
- package/lib/internal/_randomFormatByte.js.map +1 -1
- package/lib/internal/_randomFormatByte.mjs +2 -1
- package/lib/internal/_randomFormatByte.mjs.map +1 -1
- package/lib/internal/_randomFormatDate.d.ts +2 -0
- package/lib/internal/_randomFormatDate.js +3 -2
- package/lib/internal/_randomFormatDate.js.map +1 -1
- package/lib/internal/_randomFormatDate.mjs +3 -2
- package/lib/internal/_randomFormatDate.mjs.map +1 -1
- package/lib/internal/_randomFormatDatetime.d.ts +2 -0
- package/lib/internal/_randomFormatDatetime.js +3 -2
- package/lib/internal/_randomFormatDatetime.js.map +1 -1
- package/lib/internal/_randomFormatDatetime.mjs +3 -2
- package/lib/internal/_randomFormatDatetime.mjs.map +1 -1
- package/lib/internal/_randomFormatDuration.d.ts +2 -1
- package/lib/internal/_randomFormatDuration.js +3 -2
- package/lib/internal/_randomFormatDuration.js.map +1 -1
- package/lib/internal/_randomFormatDuration.mjs +3 -2
- package/lib/internal/_randomFormatDuration.mjs.map +1 -1
- package/lib/internal/_randomFormatEmail.d.ts +2 -1
- package/lib/internal/_randomFormatEmail.js +8 -1
- package/lib/internal/_randomFormatEmail.js.map +1 -1
- package/lib/internal/_randomFormatEmail.mjs +5 -1
- package/lib/internal/_randomFormatEmail.mjs.map +1 -1
- package/lib/internal/_randomFormatHostname.d.ts +8 -1
- package/lib/internal/_randomFormatHostname.js +45 -2
- package/lib/internal/_randomFormatHostname.js.map +1 -1
- package/lib/internal/_randomFormatHostname.mjs +38 -2
- package/lib/internal/_randomFormatHostname.mjs.map +1 -1
- package/lib/internal/_randomFormatIdnEmail.d.ts +2 -1
- package/lib/internal/_randomFormatIdnEmail.js +16 -2
- package/lib/internal/_randomFormatIdnEmail.js.map +1 -1
- package/lib/internal/_randomFormatIdnEmail.mjs +11 -2
- package/lib/internal/_randomFormatIdnEmail.mjs.map +1 -1
- package/lib/internal/_randomFormatIdnHostname.d.ts +2 -1
- package/lib/internal/_randomFormatIdnHostname.js +26 -1
- package/lib/internal/_randomFormatIdnHostname.js.map +1 -1
- package/lib/internal/_randomFormatIdnHostname.mjs +25 -2
- package/lib/internal/_randomFormatIdnHostname.mjs.map +1 -1
- package/lib/internal/_randomFormatIpv4.d.ts +2 -1
- package/lib/internal/_randomFormatIpv4.js +2 -1
- package/lib/internal/_randomFormatIpv4.js.map +1 -1
- package/lib/internal/_randomFormatIpv4.mjs +2 -1
- package/lib/internal/_randomFormatIpv4.mjs.map +1 -1
- package/lib/internal/_randomFormatIpv6.d.ts +2 -1
- package/lib/internal/_randomFormatIpv6.js +2 -1
- package/lib/internal/_randomFormatIpv6.js.map +1 -1
- package/lib/internal/_randomFormatIpv6.mjs +2 -1
- package/lib/internal/_randomFormatIpv6.mjs.map +1 -1
- package/lib/internal/_randomFormatIri.d.ts +2 -1
- package/lib/internal/_randomFormatIri.js +1 -1
- package/lib/internal/_randomFormatIri.js.map +1 -1
- package/lib/internal/_randomFormatIri.mjs +1 -1
- package/lib/internal/_randomFormatIri.mjs.map +1 -1
- package/lib/internal/_randomFormatIriReference.d.ts +2 -1
- package/lib/internal/_randomFormatIriReference.js +1 -1
- package/lib/internal/_randomFormatIriReference.js.map +1 -1
- package/lib/internal/_randomFormatIriReference.mjs +1 -1
- package/lib/internal/_randomFormatIriReference.mjs.map +1 -1
- package/lib/internal/_randomFormatJsonPointer.d.ts +2 -1
- package/lib/internal/_randomFormatJsonPointer.js +8 -1
- package/lib/internal/_randomFormatJsonPointer.js.map +1 -1
- package/lib/internal/_randomFormatJsonPointer.mjs +5 -1
- package/lib/internal/_randomFormatJsonPointer.mjs.map +1 -1
- package/lib/internal/_randomFormatPassword.d.ts +2 -1
- package/lib/internal/_randomFormatPassword.js +7 -5
- package/lib/internal/_randomFormatPassword.js.map +1 -1
- package/lib/internal/_randomFormatPassword.mjs +5 -1
- package/lib/internal/_randomFormatPassword.mjs.map +1 -1
- package/lib/internal/_randomFormatRegex.d.ts +2 -1
- package/lib/internal/_randomFormatRegex.js +2 -1
- package/lib/internal/_randomFormatRegex.js.map +1 -1
- package/lib/internal/_randomFormatRegex.mjs +2 -1
- package/lib/internal/_randomFormatRegex.mjs.map +1 -1
- package/lib/internal/_randomFormatRelativeJsonPointer.d.ts +2 -1
- package/lib/internal/_randomFormatRelativeJsonPointer.js +3 -2
- package/lib/internal/_randomFormatRelativeJsonPointer.js.map +1 -1
- package/lib/internal/_randomFormatRelativeJsonPointer.mjs +3 -2
- package/lib/internal/_randomFormatRelativeJsonPointer.mjs.map +1 -1
- package/lib/internal/_randomFormatTime.d.ts +2 -1
- package/lib/internal/_randomFormatTime.js +3 -2
- package/lib/internal/_randomFormatTime.js.map +1 -1
- package/lib/internal/_randomFormatTime.mjs +3 -2
- package/lib/internal/_randomFormatTime.mjs.map +1 -1
- package/lib/internal/_randomFormatUri.d.ts +2 -1
- package/lib/internal/_randomFormatUri.js +1 -1
- package/lib/internal/_randomFormatUri.js.map +1 -1
- package/lib/internal/_randomFormatUri.mjs +1 -1
- package/lib/internal/_randomFormatUri.mjs.map +1 -1
- package/lib/internal/_randomFormatUriReference.d.ts +2 -1
- package/lib/internal/_randomFormatUriReference.js +1 -1
- package/lib/internal/_randomFormatUriReference.js.map +1 -1
- package/lib/internal/_randomFormatUriReference.mjs +1 -1
- package/lib/internal/_randomFormatUriReference.mjs.map +1 -1
- package/lib/internal/_randomFormatUriTemplate.d.ts +2 -1
- package/lib/internal/_randomFormatUriTemplate.js +1 -1
- package/lib/internal/_randomFormatUriTemplate.js.map +1 -1
- package/lib/internal/_randomFormatUriTemplate.mjs +1 -1
- package/lib/internal/_randomFormatUriTemplate.mjs.map +1 -1
- package/lib/internal/_randomFormatUrl.d.ts +2 -1
- package/lib/internal/_randomFormatUrl.js +21 -1
- package/lib/internal/_randomFormatUrl.js.map +1 -1
- package/lib/internal/_randomFormatUrl.mjs +18 -1
- package/lib/internal/_randomFormatUrl.mjs.map +1 -1
- package/lib/internal/_randomFormatUuid.d.ts +2 -1
- package/lib/internal/_randomFormatUuid.js +3 -2
- package/lib/internal/_randomFormatUuid.js.map +1 -1
- package/lib/internal/_randomFormatUuid.mjs +3 -2
- package/lib/internal/_randomFormatUuid.mjs.map +1 -1
- package/lib/internal/_randomInteger.js +59 -28
- package/lib/internal/_randomInteger.js.map +1 -1
- package/lib/internal/_randomInteger.mjs +56 -16
- package/lib/internal/_randomInteger.mjs.map +1 -1
- package/lib/internal/_randomMultiple.d.ts +8 -0
- package/lib/internal/_randomMultiple.js +168 -0
- package/lib/internal/_randomMultiple.js.map +1 -0
- package/lib/internal/_randomMultiple.mjs +158 -0
- package/lib/internal/_randomMultiple.mjs.map +1 -0
- package/lib/internal/_randomNumber.js +42 -42
- package/lib/internal/_randomNumber.js.map +1 -1
- package/lib/internal/_randomNumber.mjs +41 -27
- package/lib/internal/_randomNumber.mjs.map +1 -1
- package/lib/internal/_randomPattern.d.ts +2 -1
- package/lib/internal/_randomPattern.js +19 -4
- package/lib/internal/_randomPattern.js.map +1 -1
- package/lib/internal/_randomPattern.mjs +10 -4
- package/lib/internal/_randomPattern.mjs.map +1 -1
- package/lib/internal/_randomStringLength.d.ts +33 -0
- package/lib/internal/_randomStringLength.js +48 -0
- package/lib/internal/_randomStringLength.js.map +1 -0
- package/lib/internal/_randomStringLength.mjs +44 -0
- package/lib/internal/_randomStringLength.mjs.map +1 -0
- package/lib/internal/_stringLength.d.ts +1 -0
- package/lib/internal/_stringLength.js +11 -0
- package/lib/internal/_stringLength.js.map +1 -0
- package/lib/internal/_stringLength.mjs +10 -0
- package/lib/internal/_stringLength.mjs.map +1 -0
- package/lib/internal/_validateReport.js +4 -1
- package/lib/internal/_validateReport.js.map +1 -1
- package/lib/internal/_validateReport.mjs +2 -1
- package/lib/internal/_validateReport.mjs.map +1 -1
- package/lib/internal/private/__notationRename.d.ts +14 -0
- package/lib/internal/private/__notationRename.js +25 -0
- package/lib/internal/private/__notationRename.js.map +1 -0
- package/lib/internal/private/__notationRename.mjs +24 -0
- package/lib/internal/private/__notationRename.mjs.map +1 -0
- package/lib/json.d.ts +2 -2
- package/lib/json.mjs.map +1 -1
- package/lib/module.d.ts +2 -2
- package/lib/module.js.map +1 -1
- package/lib/module.mjs.map +1 -1
- package/lib/notations.d.ts +20 -4
- package/lib/notations.js.map +1 -1
- package/lib/notations.mjs.map +1 -1
- package/native/adapter/plugin_options.go +117 -0
- package/native/adapter/plugin_options_payload_matrix_test.go +181 -0
- package/native/cmd/ttsc-typia/any_array_type_tags_transform_test.go +63 -9
- package/native/cmd/ttsc-typia/assert_guard_factory_contract_test.go +152 -0
- package/native/cmd/ttsc-typia/build.go +81 -64
- package/native/cmd/ttsc-typia/build_no_emit_preserves_analysis_options_test.go +67 -0
- package/native/cmd/ttsc-typia/build_no_emit_transform_diagnostics_test.go +138 -0
- package/native/cmd/ttsc-typia/build_plugin_options_come_from_payload_test.go +48 -0
- package/native/cmd/ttsc-typia/build_transactional_emit_success_test.go +81 -0
- package/native/cmd/ttsc-typia/build_transform_failure_atomicity_test.go +138 -0
- package/native/cmd/ttsc-typia/command_routes_and_diagnostics_coverage_test.go +3 -1
- package/native/cmd/ttsc-typia/compare_less_nan_transform_test.go +98 -0
- package/native/cmd/ttsc-typia/compare_native_object_overmatch_transform_test.go +161 -0
- package/native/cmd/ttsc-typia/compare_nondiscriminable_union_transform_test.go +343 -0
- package/native/cmd/ttsc-typia/compare_union_discrimination_transform_test.go +289 -0
- package/native/cmd/ttsc-typia/escaped_property_key_path_transform_test.go +193 -0
- package/native/cmd/ttsc-typia/finite_option_number_leaf_transform_test.go +240 -0
- package/native/cmd/ttsc-typia/functional_promised_type_transform_test.go +220 -0
- package/native/cmd/ttsc-typia/functional_receiver_transform_test.go +232 -0
- package/native/cmd/ttsc-typia/is_object_function_member_transform_test.go +205 -0
- package/native/cmd/ttsc-typia/json_application_alias_function_validation_transform_test.go +151 -0
- package/native/cmd/ttsc-typia/json_is_stringify_finite_number_transform_test.go +198 -0
- package/native/cmd/ttsc-typia/json_stringify_special_key_transform_test.go +238 -0
- package/native/cmd/ttsc-typia/main_wasm.go +21 -2
- package/native/cmd/ttsc-typia/native_collection_identity_is_transform_test.go +234 -0
- package/native/cmd/ttsc-typia/native_generic_name_guard_is_transform_test.go +194 -0
- package/native/cmd/ttsc-typia/native_name_collision_is_transform_test.go +204 -0
- package/native/cmd/ttsc-typia/non_trailing_rest_tuple_transform_test.go +23 -11
- package/native/cmd/ttsc-typia/notation_dynamic_keys_transform_test.go +286 -0
- package/native/cmd/ttsc-typia/notation_kebab_case_transform_test.go +1 -1
- package/native/cmd/ttsc-typia/notation_literal_collision_transform_test.go +164 -0
- package/native/cmd/ttsc-typia/notation_pascal_case_transform_test.go +230 -0
- package/native/cmd/ttsc-typia/notation_unicode_key_transform_test.go +309 -0
- package/native/cmd/ttsc-typia/pattern_line_terminator_escape_transform_test.go +224 -0
- package/native/cmd/ttsc-typia/plain_prune_union_object_overmatch_transform_test.go +219 -0
- package/native/cmd/ttsc-typia/plugin_options_payload_helpers_test.go +181 -0
- package/native/cmd/ttsc-typia/private_field_filter_is_transform_test.go +278 -0
- package/native/cmd/ttsc-typia/project_catalog_transform_coverage_test.go +73 -27
- package/native/cmd/ttsc-typia/project_dependencies_barrel_reexport_transform_test.go +120 -0
- package/native/cmd/ttsc-typia/project_dependencies_collapsed_alias_transform_test.go +134 -0
- package/native/cmd/ttsc-typia/project_dependencies_custom_lib_name_transform_test.go +135 -0
- package/native/cmd/ttsc-typia/project_dependencies_default_barrel_transform_test.go +114 -0
- package/native/cmd/ttsc-typia/project_dependencies_empty_heritage_transform_test.go +100 -0
- package/native/cmd/ttsc-typia/project_dependencies_envelope_transform_test.go +148 -0
- package/native/cmd/ttsc-typia/project_dependencies_index_signature_alias_transform_test.go +139 -0
- package/native/cmd/ttsc-typia/project_dependencies_local_reexport_transform_test.go +122 -0
- package/native/cmd/ttsc-typia/project_dependencies_signature_alias_transform_test.go +125 -0
- package/native/cmd/ttsc-typia/project_dependencies_star_barrel_transform_test.go +112 -0
- package/native/cmd/ttsc-typia/project_reference_graph_envelope_transform_test.go +190 -0
- package/native/cmd/ttsc-typia/protobuf_is_encode_finite_number_transform_test.go +98 -0
- package/native/cmd/ttsc-typia/protobuf_sequence_field_numbers_transform_test.go +52 -22
- package/native/cmd/ttsc-typia/symbol_key_member_filter_transform_test.go +279 -0
- package/native/cmd/ttsc-typia/template_interpolation_type_tags_transform_test.go +86 -23
- package/native/cmd/ttsc-typia/template_literal_type_tags_transform_test.go +3 -1
- package/native/cmd/ttsc-typia/transform.go +228 -39
- package/native/cmd/ttsc-typia/{transform_declaration_source_produces_no_js_test.go → transform_declaration_source_produces_no_javascript_test.go} +10 -2
- package/native/cmd/ttsc-typia/transform_fixtures_emit_coverage_test.go +21 -4
- package/native/cmd/ttsc-typia/transform_helpers_test.go +159 -1
- package/native/cmd/ttsc-typia/transform_plugin_options_come_from_payload_test.go +43 -0
- package/native/cmd/ttsc-typia/transform_single_file_failure_atomicity_test.go +114 -0
- package/native/cmd/ttsc-typia/transform_single_file_failure_writes_no_stdout_test.go +43 -0
- package/native/cmd/ttsc-typia/transform_single_file_js_distinguishes_same_basename_sources_test.go +81 -0
- package/native/cmd/ttsc-typia/transform_single_file_js_empty_emit_reports_no_output_test.go +100 -0
- package/native/cmd/ttsc-typia/transform_single_file_js_locates_output_across_layouts_test.go +160 -0
- package/native/cmd/ttsc-typia/transform_single_file_success_publishes_artifact_test.go +54 -0
- package/native/cmd/ttsc-typia/transform_wasm_host_argv_reports_diagnostics_test.go +39 -0
- package/native/cmd/ttsc-typia/tuple_optional_compare_clone_transform_test.go +227 -0
- package/native/core/factories/FormatCheatSheet.go +40 -7
- package/native/core/factories/IdentifierFactory.go +131 -4
- package/native/core/factories/MetadataCommentTagFactory.go +83 -40
- package/native/core/factories/MetadataTypeTagFactory.go +13 -1
- package/native/core/factories/NumericRangeFactory.go +60 -17
- package/native/core/factories/ProtobufFactory.go +7 -4
- package/native/core/factories/factory_utility_coverage_test.go +8 -2
- package/native/core/factories/format_alias_resolves_to_cheat_sheet_test.go +57 -0
- package/native/core/factories/format_alias_table_targets_the_cheat_sheet_test.go +44 -0
- package/native/core/factories/identifier_factory_postfix_escapes_every_key_test.go +147 -0
- package/native/core/factories/identifier_factory_postfix_survives_every_code_point_test.go +86 -0
- package/native/core/factories/internal/metadata/MetadataHelper.go +60 -6
- package/native/core/factories/internal/metadata/emplace_metadata_object.go +116 -8
- package/native/core/factories/internal/metadata/iterate_metadata.go +6 -0
- package/native/core/factories/internal/metadata/iterate_metadata_function.go +4 -11
- package/native/core/factories/internal/metadata/iterate_metadata_intersection.go +8 -6
- package/native/core/factories/internal/metadata/iterate_metadata_map.go +9 -0
- package/native/core/factories/internal/metadata/iterate_metadata_native.go +27 -2
- package/native/core/factories/internal/metadata/iterate_metadata_set.go +9 -0
- package/native/core/factories/internal/metadata/type_arguments_precondition_test.go +70 -0
- package/native/core/factories/metadata_comment_tag_factory_coverage_test.go +39 -0
- package/native/core/factories/metadata_comment_tag_factory_exclusivity_matches_interface_test.go +84 -0
- package/native/core/factories/metadata_type_tag_factory_accepts_legal_tag_combinations_test.go +60 -0
- package/native/core/factories/metadata_type_tag_factory_declarations_test.go +86 -0
- package/native/core/factories/metadata_type_tag_factory_keeps_bool_form_exclusivity_test.go +38 -0
- package/native/core/factories/metadata_type_tag_factory_rejects_cross_kind_exclusive_tags_test.go +65 -0
- package/native/core/factories/metadata_type_tag_factory_rejects_duplicated_array_form_tags_test.go +41 -0
- package/native/core/factories/numeric_range_factory_enforces_64bit_bounds_test.go +69 -0
- package/native/core/factories/protobuf_recovery_ownership_test.go +64 -0
- package/native/core/programmers/IsProgrammer.go +15 -1
- package/native/core/programmers/RandomProgrammer.go +51 -14
- package/native/core/programmers/compare/CompareEqualProgrammer.go +393 -5
- package/native/core/programmers/compare/CompareLessProgrammer.go +4 -2
- package/native/core/programmers/functional/FunctionalAssertFunctionProgrammer.go +4 -6
- package/native/core/programmers/functional/FunctionalAssertParametersProgrammer.go +5 -13
- package/native/core/programmers/functional/FunctionalAssertReturnProgrammer.go +6 -14
- package/native/core/programmers/functional/FunctionalIsFunctionProgrammer.go +4 -6
- package/native/core/programmers/functional/FunctionalIsParametersProgrammer.go +49 -14
- package/native/core/programmers/functional/FunctionalIsReturnProgrammer.go +5 -13
- package/native/core/programmers/functional/FunctionalValidateFunctionProgrammer.go +4 -6
- package/native/core/programmers/functional/FunctionalValidateParametersProgrammer.go +5 -13
- package/native/core/programmers/functional/FunctionalValidateReturnProgrammer.go +5 -13
- package/native/core/programmers/functional/internal/FunctionalGeneralProgrammer.go +4 -17
- package/native/core/programmers/helpers/CloneJoiner.go +32 -0
- package/native/core/programmers/helpers/NotationJoiner.go +86 -28
- package/native/core/programmers/helpers/StringifyJoinder.go +32 -1
- package/native/core/programmers/helpers/UnionExplorer.go +203 -61
- package/native/core/programmers/helpers/joiner_branch_coverage_test.go +5 -3
- package/native/core/programmers/helpers/union_explorer_coverage_test.go +1 -1
- package/native/core/programmers/internal/CheckerProgrammer.go +100 -48
- package/native/core/programmers/iterate/check_template.go +344 -32
- package/native/core/programmers/iterate/json_schema_discriminator.go +36 -10
- package/native/core/programmers/iterate/json_schema_discriminator_declaration_syntax_test.go +205 -0
- package/native/core/programmers/iterate/openapi_v3_downgrader.go +641 -0
- package/native/core/programmers/iterate/openapi_v3_downgrader_boolean_default_test.go +95 -0
- package/native/core/programmers/iterate/openapi_v3_downgrader_test.go +123 -0
- package/native/core/programmers/iterate/template_interpolation_tags_test.go +40 -8
- package/native/core/programmers/iterate/template_runtime_pattern.go +52 -7
- package/native/core/programmers/json/JsonApplicationProgrammer.go +45 -11
- package/native/core/programmers/json/JsonSchemasProgrammer.go +12 -2
- package/native/core/programmers/llm/LlmApplicationProgrammer.go +12 -10
- package/native/core/programmers/llm/LlmSchemaProgrammer.go +23 -6
- package/native/core/programmers/llm/llm_reference_codec_test.go +24 -0
- package/native/core/programmers/notations/NotationGeneralProgrammer.go +183 -67
- package/native/core/programmers/notations/notation_general_helpers_test.go +1 -3
- package/native/core/programmers/notations/notation_general_programmer_pascal_multiword_test.go +72 -0
- package/native/core/programmers/notations/notation_general_programmer_underscore_boundary_test.go +68 -0
- package/native/core/programmers/plain/PlainClassifyProgrammer.go +23 -15
- package/native/core/programmers/plain/PlainCloneProgrammer.go +20 -7
- package/native/core/programmers/plain/PlainPruneProgrammer.go +19 -5
- package/native/core/programmers/plain/plain_tuple_seed_recovery_ownership_test.go +25 -0
- package/native/core/programmers/protobuf/ProtobufDecodeProgrammer.go +37 -28
- package/native/core/programmers/protobuf/ProtobufMessageProgrammer.go +40 -21
- package/native/core/programmers/protobuf/protobuf_programmer_helper_coverage_test.go +26 -0
- package/native/core/programmers/random_programmer_length_argument_test.go +53 -0
- package/native/core/schemas/metadata/MetadataCollection.go +270 -20
- package/native/core/schemas/metadata/MetadataDependency.go +388 -0
- package/native/core/schemas/metadata/MetadataObjectType.go +17 -4
- package/native/core/schemas/metadata/metadata_collection_generic_argument_dot_test.go +122 -0
- package/native/core/schemas/metadata/metadata_collection_name_allocation_test.go +147 -0
- package/native/core/schemas/metadata/metadata_collection_openapi_name_cascade_test.go +55 -0
- package/native/core/schemas/metadata/metadata_collection_openapi_name_test.go +68 -0
- package/native/core/utils/PatternUtil.go +13 -0
- package/native/core/utils/PromiseTypeFactory.go +59 -0
- package/native/core/utils/ProtobufNameEncoder.go +8 -0
- package/native/core/utils/promise_type_factory_semantics_test.go +118 -0
- package/native/go.mod +9 -1
- package/native/transform/CallExpressionTransformer.go +12 -0
- package/native/transform/features/json/JsonApplicationTransformer.go +1 -1
- package/native/transform/features/json/JsonSchemaTransformer.go +1 -1
- package/native/transform/features/json/JsonSchemasTransformer.go +5 -4
- package/package.json +16 -4
- package/src/executable/FileSystemIdentity.ts +189 -0
- package/src/executable/TypiaGenerateWizard.ts +377 -110
- package/src/functional.ts +30 -60
- package/src/internal/_ProtobufReader.ts +129 -43
- package/src/internal/_createStandardSchema.ts +15 -1
- package/src/internal/_decimal.ts +69 -0
- package/src/internal/_httpQueryParseURLSearchParams.ts +24 -2
- package/src/internal/_isFormatByte.ts +2 -5
- package/src/internal/_isFormatDate.ts +15 -2
- package/src/internal/_isFormatDateTime.ts +28 -2
- package/src/internal/_isFormatIri.ts +5 -2
- package/src/internal/_isFormatIriReference.ts +11 -3
- package/src/internal/_isFormatUriReference.ts +1 -1
- package/src/internal/_isMultipleOf.ts +8 -0
- package/src/internal/_isTypeFloat.ts +1 -1
- package/src/internal/_isTypeInt64.ts +1 -0
- package/src/internal/_isTypeInt64Bigint.ts +12 -0
- package/src/internal/_isTypeUint64.ts +1 -0
- package/src/internal/_isTypeUint64Bigint.ts +7 -0
- package/src/internal/_isUniqueItems.ts +134 -132
- package/src/internal/_notationAny.ts +9 -4
- package/src/internal/_notationAssign.ts +20 -0
- package/src/internal/_notationCamel.ts +31 -10
- package/src/internal/_notationKebab.ts +11 -0
- package/src/internal/_notationKeyCollision.ts +9 -0
- package/src/internal/_notationPascal.ts +19 -6
- package/src/internal/_notationSnake.ts +24 -21
- package/src/internal/_plainCloneAny.ts +208 -33
- package/src/internal/_randomArray.ts +13 -4
- package/src/internal/_randomFormatByte.ts +4 -1
- package/src/internal/_randomFormatDate.ts +17 -12
- package/src/internal/_randomFormatDatetime.ts +15 -10
- package/src/internal/_randomFormatDuration.ts +16 -14
- package/src/internal/_randomFormatEmail.ts +8 -2
- package/src/internal/_randomFormatHostname.ts +48 -1
- package/src/internal/_randomFormatIdnEmail.ts +18 -2
- package/src/internal/_randomFormatIdnHostname.ts +34 -2
- package/src/internal/_randomFormatIpv4.ts +3 -2
- package/src/internal/_randomFormatIpv6.ts +3 -2
- package/src/internal/_randomFormatIri.ts +3 -1
- package/src/internal/_randomFormatIriReference.ts +3 -1
- package/src/internal/_randomFormatJsonPointer.ts +8 -2
- package/src/internal/_randomFormatPassword.ts +11 -6
- package/src/internal/_randomFormatRegex.ts +4 -1
- package/src/internal/_randomFormatRelativeJsonPointer.ts +13 -6
- package/src/internal/_randomFormatTime.ts +13 -10
- package/src/internal/_randomFormatUri.ts +3 -1
- package/src/internal/_randomFormatUriReference.ts +3 -1
- package/src/internal/_randomFormatUriTemplate.ts +3 -1
- package/src/internal/_randomFormatUrl.ts +25 -2
- package/src/internal/_randomFormatUuid.ts +10 -6
- package/src/internal/_randomInteger.ts +87 -40
- package/src/internal/_randomMultiple.ts +245 -0
- package/src/internal/_randomNumber.ts +72 -55
- package/src/internal/_randomPattern.ts +26 -4
- package/src/internal/_randomStringLength.ts +72 -0
- package/src/internal/_stringLength.ts +5 -0
- package/src/internal/_validateReport.ts +5 -1
- package/src/internal/private/__notationRename.ts +24 -0
- package/src/json.ts +2 -2
- package/src/module.ts +4 -6
- package/src/notations.ts +20 -4
- package/lib/internal/private/__notationCapitalize.d.ts +0 -1
- package/lib/internal/private/__notationCapitalize.js +0 -6
- package/lib/internal/private/__notationCapitalize.js.map +0 -1
- package/lib/internal/private/__notationCapitalize.mjs +0 -6
- package/lib/internal/private/__notationCapitalize.mjs.map +0 -1
- package/lib/internal/private/__notationUnsnake.d.ts +0 -4
- package/lib/internal/private/__notationUnsnake.js +0 -26
- package/lib/internal/private/__notationUnsnake.js.map +0 -1
- package/lib/internal/private/__notationUnsnake.mjs +0 -15
- package/lib/internal/private/__notationUnsnake.mjs.map +0 -1
- package/native/cmd/ttsc-typia/plugin_options_missing_config_test.go +0 -26
- package/native/cmd/ttsc-typia/plugin_options_undefined_false_test.go +0 -36
- package/src/internal/private/__notationCapitalize.ts +0 -2
- package/src/internal/private/__notationUnsnake.ts +0 -24
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
package main
|
|
2
|
+
|
|
3
|
+
import (
|
|
4
|
+
"os"
|
|
5
|
+
"os/exec"
|
|
6
|
+
"path/filepath"
|
|
7
|
+
"strings"
|
|
8
|
+
"testing"
|
|
9
|
+
)
|
|
10
|
+
|
|
11
|
+
// TestNativeGenericNameGuardIsTransform verifies that a user type whose name
|
|
12
|
+
// begins with WeakMap/WeakSet is not misdetected as the native generic.
|
|
13
|
+
//
|
|
14
|
+
// Native generic detection matched WeakMap/WeakSet with a bare
|
|
15
|
+
// strings.HasPrefix(name, generic.Name) while the Map/Set siblings require the
|
|
16
|
+
// name to be exactly the generic. A user interface named WeakMapLike therefore
|
|
17
|
+
// took the native path and emitted `input instanceof WeakMap`, so
|
|
18
|
+
// typia.is<WeakMapLike>({...}) returned false (issue #2181). The guard now
|
|
19
|
+
// admits a native only when the stripped name equals the generic, so a genuine
|
|
20
|
+
// WeakMap<K, V>/WeakSet<T> stays native while WeakMapLike validates its shape.
|
|
21
|
+
//
|
|
22
|
+
// 1. Transform typia.is calls for WeakMapLike, WeakSetLike, WeakMapEntry, a
|
|
23
|
+
// MapLike control, and genuine WeakMap<object, number>/WeakSet<object>.
|
|
24
|
+
// 2. Assert the emitted TypeScript keeps the native `instanceof` path for the
|
|
25
|
+
// genuine generics.
|
|
26
|
+
// 3. Execute the emitted validators so the user-named objects validate as
|
|
27
|
+
// their shape while the genuine natives still accept only their instance.
|
|
28
|
+
func TestNativeGenericNameGuardIsTransform(t *testing.T) {
|
|
29
|
+
project := nativeGenericNameGuardProject(t)
|
|
30
|
+
ts := nativeGenericNameGuardTransform(t, project, "ts")
|
|
31
|
+
for _, needle := range []string{"instanceof WeakMap", "instanceof WeakSet"} {
|
|
32
|
+
if !strings.Contains(ts, needle) {
|
|
33
|
+
t.Fatalf("expected genuine native path %q in transform output:\n%s", needle, ts)
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
nativeGenericNameGuardRunRuntimeCases(t, project, nativeGenericNameGuardTransform(t, project, "js"))
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
func nativeGenericNameGuardProject(t *testing.T) string {
|
|
40
|
+
t.Helper()
|
|
41
|
+
root := ttscTypiaTestRepoRoot(t)
|
|
42
|
+
base := filepath.Join(root, "packages", "typia", "native", ".tmp-ttsc-typia-tests")
|
|
43
|
+
if err := os.MkdirAll(base, 0o755); err != nil {
|
|
44
|
+
t.Fatalf("mkdir temp base: %v", err)
|
|
45
|
+
}
|
|
46
|
+
dir, err := os.MkdirTemp(base, "native-generic-name-guard-")
|
|
47
|
+
if err != nil {
|
|
48
|
+
t.Fatalf("create temp fixture: %v", err)
|
|
49
|
+
}
|
|
50
|
+
t.Cleanup(func() {
|
|
51
|
+
_ = os.RemoveAll(dir)
|
|
52
|
+
})
|
|
53
|
+
src := filepath.Join(dir, "src")
|
|
54
|
+
if err := os.MkdirAll(src, 0o755); err != nil {
|
|
55
|
+
t.Fatalf("mkdir fixture src: %v", err)
|
|
56
|
+
}
|
|
57
|
+
if err := os.WriteFile(filepath.Join(dir, "tsconfig.json"), []byte(nativeGenericNameGuardTSConfig), 0o644); err != nil {
|
|
58
|
+
t.Fatalf("write tsconfig: %v", err)
|
|
59
|
+
}
|
|
60
|
+
if err := os.WriteFile(filepath.Join(src, "main.ts"), []byte(nativeGenericNameGuardSource), 0o644); err != nil {
|
|
61
|
+
t.Fatalf("write source: %v", err)
|
|
62
|
+
}
|
|
63
|
+
return dir
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
func nativeGenericNameGuardTransform(t *testing.T, project string, output string) string {
|
|
67
|
+
t.Helper()
|
|
68
|
+
out, errText, code := ttscTypiaTestCapture(func() int {
|
|
69
|
+
return runTransform([]string{
|
|
70
|
+
"--cwd", project,
|
|
71
|
+
"--tsconfig", "tsconfig.json",
|
|
72
|
+
"--file", "src/main.ts",
|
|
73
|
+
"--output", output,
|
|
74
|
+
})
|
|
75
|
+
})
|
|
76
|
+
if code != 0 {
|
|
77
|
+
t.Fatalf("native generic name guard transform failed: output=%s code=%d stderr=\n%s", output, code, errText)
|
|
78
|
+
}
|
|
79
|
+
return out
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
func nativeGenericNameGuardRunRuntimeCases(t *testing.T, project string, js string) {
|
|
83
|
+
t.Helper()
|
|
84
|
+
node, err := exec.LookPath("node")
|
|
85
|
+
if err != nil {
|
|
86
|
+
t.Skip("node executable not found")
|
|
87
|
+
}
|
|
88
|
+
runtimeDir := filepath.Join(project, "runtime")
|
|
89
|
+
if err := os.MkdirAll(runtimeDir, 0o755); err != nil {
|
|
90
|
+
t.Fatalf("mkdir runtime dir: %v", err)
|
|
91
|
+
}
|
|
92
|
+
ttscTypiaTestWriteCommonRuntimeStubs(t, runtimeDir)
|
|
93
|
+
runtimeJS := ttscTypiaTestRewriteCommonJS(t, js)
|
|
94
|
+
if err := os.WriteFile(filepath.Join(runtimeDir, "main.cjs"), []byte(runtimeJS), 0o644); err != nil {
|
|
95
|
+
t.Fatalf("write runtime module: %v", err)
|
|
96
|
+
}
|
|
97
|
+
runner := filepath.Join(runtimeDir, "run.cjs")
|
|
98
|
+
if err := os.WriteFile(runner, []byte(nativeGenericNameGuardRuntimeRunner), 0o644); err != nil {
|
|
99
|
+
t.Fatalf("write runtime runner: %v", err)
|
|
100
|
+
}
|
|
101
|
+
cmd := exec.Command(node, runner)
|
|
102
|
+
cmd.Dir = runtimeDir
|
|
103
|
+
if output, err := cmd.CombinedOutput(); err != nil {
|
|
104
|
+
t.Fatalf("native generic name guard runtime cases failed: %v\n%s", err, output)
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
const nativeGenericNameGuardTSConfig = `{
|
|
109
|
+
"compilerOptions": {
|
|
110
|
+
"target": "ES2022",
|
|
111
|
+
"module": "commonjs",
|
|
112
|
+
"moduleResolution": "bundler",
|
|
113
|
+
"ignoreDeprecations": "6.0",
|
|
114
|
+
"types": ["*"],
|
|
115
|
+
"esModuleInterop": true,
|
|
116
|
+
"strict": true,
|
|
117
|
+
"skipLibCheck": true
|
|
118
|
+
},
|
|
119
|
+
"include": ["src"]
|
|
120
|
+
}
|
|
121
|
+
`
|
|
122
|
+
|
|
123
|
+
const nativeGenericNameGuardSource = `import typia from "typia";
|
|
124
|
+
|
|
125
|
+
interface WeakMapLike {
|
|
126
|
+
id: number;
|
|
127
|
+
count: number;
|
|
128
|
+
}
|
|
129
|
+
interface WeakSetLike {
|
|
130
|
+
id: number;
|
|
131
|
+
count: number;
|
|
132
|
+
}
|
|
133
|
+
interface WeakMapEntry {
|
|
134
|
+
id: number;
|
|
135
|
+
count: number;
|
|
136
|
+
}
|
|
137
|
+
interface MapLike {
|
|
138
|
+
id: number;
|
|
139
|
+
count: number;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
export const isWeakMapLike = (input: unknown): boolean =>
|
|
143
|
+
typia.is<WeakMapLike>(input);
|
|
144
|
+
export const isWeakSetLike = (input: unknown): boolean =>
|
|
145
|
+
typia.is<WeakSetLike>(input);
|
|
146
|
+
export const isWeakMapEntry = (input: unknown): boolean =>
|
|
147
|
+
typia.is<WeakMapEntry>(input);
|
|
148
|
+
export const isMapLike = (input: unknown): boolean =>
|
|
149
|
+
typia.is<MapLike>(input);
|
|
150
|
+
export const isNativeWeakMap = (input: unknown): boolean =>
|
|
151
|
+
typia.is<WeakMap<object, number>>(input);
|
|
152
|
+
export const isNativeWeakSet = (input: unknown): boolean =>
|
|
153
|
+
typia.is<WeakSet<object>>(input);
|
|
154
|
+
`
|
|
155
|
+
|
|
156
|
+
const nativeGenericNameGuardRuntimeRunner = `const mod = require("./main.cjs");
|
|
157
|
+
|
|
158
|
+
const expect = (label, actual, expected) => {
|
|
159
|
+
if (actual !== expected) {
|
|
160
|
+
throw new Error(label + ": expected " + expected + ", got " + actual);
|
|
161
|
+
}
|
|
162
|
+
};
|
|
163
|
+
|
|
164
|
+
const shaped = { id: 1, count: 2 };
|
|
165
|
+
|
|
166
|
+
// A user interface whose name is merely prefixed by a native generic must
|
|
167
|
+
// validate against its declared shape, not the native instanceof path.
|
|
168
|
+
expect("WeakMapLike accepts its shape", mod.isWeakMapLike(shaped), true);
|
|
169
|
+
expect("WeakMapLike rejects a missing property", mod.isWeakMapLike({ id: 1 }), false);
|
|
170
|
+
expect("WeakMapLike rejects a wrong property type", mod.isWeakMapLike({ id: 1, count: "2" }), false);
|
|
171
|
+
expect("WeakMapLike rejects a real WeakMap", mod.isWeakMapLike(new WeakMap()), false);
|
|
172
|
+
|
|
173
|
+
expect("WeakSetLike accepts its shape", mod.isWeakSetLike(shaped), true);
|
|
174
|
+
expect("WeakSetLike rejects a missing property", mod.isWeakSetLike({ id: 1 }), false);
|
|
175
|
+
expect("WeakSetLike rejects a real WeakSet", mod.isWeakSetLike(new WeakSet()), false);
|
|
176
|
+
|
|
177
|
+
expect("WeakMapEntry accepts its shape", mod.isWeakMapEntry(shaped), true);
|
|
178
|
+
expect("WeakMapEntry rejects a missing property", mod.isWeakMapEntry({ id: 1 }), false);
|
|
179
|
+
|
|
180
|
+
// MapLike is the already-guarded control: it stays a plain object exactly as
|
|
181
|
+
// the WeakMap*/WeakSet* names now do.
|
|
182
|
+
expect("MapLike control accepts its shape", mod.isMapLike(shaped), true);
|
|
183
|
+
expect("MapLike control rejects a missing property", mod.isMapLike({ id: 1 }), false);
|
|
184
|
+
|
|
185
|
+
// Genuine native generics always carry angle brackets, so the exact-name guard
|
|
186
|
+
// keeps them on the native instanceof path unchanged.
|
|
187
|
+
expect("native WeakMap accepts an instance", mod.isNativeWeakMap(new WeakMap()), true);
|
|
188
|
+
expect("native WeakMap rejects a plain object", mod.isNativeWeakMap(shaped), false);
|
|
189
|
+
expect("native WeakMap rejects a WeakSet", mod.isNativeWeakMap(new WeakSet()), false);
|
|
190
|
+
|
|
191
|
+
expect("native WeakSet accepts an instance", mod.isNativeWeakSet(new WeakSet()), true);
|
|
192
|
+
expect("native WeakSet rejects a plain object", mod.isNativeWeakSet(shaped), false);
|
|
193
|
+
expect("native WeakSet rejects a WeakMap", mod.isNativeWeakSet(new WeakMap()), false);
|
|
194
|
+
`
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
package main
|
|
2
|
+
|
|
3
|
+
import (
|
|
4
|
+
"os"
|
|
5
|
+
"os/exec"
|
|
6
|
+
"path/filepath"
|
|
7
|
+
"strings"
|
|
8
|
+
"testing"
|
|
9
|
+
)
|
|
10
|
+
|
|
11
|
+
// TestNativeNameCollisionIsTransform pins the runtime and emit behavior of
|
|
12
|
+
// typia.is / assert / validate for a user type whose name collides with a
|
|
13
|
+
// built-in native (#2200).
|
|
14
|
+
//
|
|
15
|
+
// Native classification matched a type against the simples table by name alone,
|
|
16
|
+
// so a user `interface File { name; size }` yielded the base name "File", matched
|
|
17
|
+
// iterate_metadata_native_simples["File"], and emitted `input instanceof File` —
|
|
18
|
+
// ignoring the user's own members. Every valid `File` value was therefore
|
|
19
|
+
// rejected, and in a runtime without the DOM/File global the check threw a
|
|
20
|
+
// ReferenceError. The same struck `Blob`, `Date`, the typed arrays, and every
|
|
21
|
+
// other simples name.
|
|
22
|
+
//
|
|
23
|
+
// After the fix native classification requires the matched symbol to be declared
|
|
24
|
+
// in a `.d.ts` declaration file (a TypeScript default library or an ambient
|
|
25
|
+
// package such as @types/node), which a real built-in always is and a user type
|
|
26
|
+
// in a `.ts` module never is. A colliding user type then falls through to the
|
|
27
|
+
// structural object path and validates against its declared members, while a
|
|
28
|
+
// genuine native (`Date`, `Uint8Array`) keeps its native `instanceof` check.
|
|
29
|
+
//
|
|
30
|
+
// 1. Transform is / validate for user interfaces named File and Blob, a near-miss
|
|
31
|
+
// control (Filer), and the genuine natives Date and Uint8Array.
|
|
32
|
+
// 2. Assert the emitted TypeScript drops `instanceof File` / `instanceof Blob`
|
|
33
|
+
// for the user types while keeping `instanceof Date` / `instanceof Uint8Array`
|
|
34
|
+
// for the real natives.
|
|
35
|
+
// 3. Execute the emitted validators in Node against the boundary matrix, and
|
|
36
|
+
// require the runner to report the exact executed case count so a runner that
|
|
37
|
+
// silently skipped cases cannot pass as a false green.
|
|
38
|
+
func TestNativeNameCollisionIsTransform(t *testing.T) {
|
|
39
|
+
project := nativeNameCollisionProject(t)
|
|
40
|
+
js := nativeNameCollisionTransform(t, project)
|
|
41
|
+
for _, gone := range []string{"instanceof File", "instanceof Blob"} {
|
|
42
|
+
if strings.Contains(js, gone) {
|
|
43
|
+
t.Fatalf("expected user type collision %q to be reclassified structurally, but it survived in:\n%s", gone, js)
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
for _, kept := range []string{"instanceof Date", "instanceof Uint8Array"} {
|
|
47
|
+
if !strings.Contains(js, kept) {
|
|
48
|
+
t.Fatalf("expected genuine native path %q to remain in transform output:\n%s", kept, js)
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
nativeNameCollisionRunRuntimeCases(t, project, js)
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
func nativeNameCollisionProject(t *testing.T) string {
|
|
55
|
+
t.Helper()
|
|
56
|
+
root := ttscTypiaTestRepoRoot(t)
|
|
57
|
+
base := filepath.Join(root, "packages", "typia", "native", ".tmp-ttsc-typia-tests")
|
|
58
|
+
if err := os.MkdirAll(base, 0o755); err != nil {
|
|
59
|
+
t.Fatalf("mkdir temp base: %v", err)
|
|
60
|
+
}
|
|
61
|
+
dir, err := os.MkdirTemp(base, "native-name-collision-")
|
|
62
|
+
if err != nil {
|
|
63
|
+
t.Fatalf("create temp fixture: %v", err)
|
|
64
|
+
}
|
|
65
|
+
t.Cleanup(func() {
|
|
66
|
+
_ = os.RemoveAll(dir)
|
|
67
|
+
})
|
|
68
|
+
src := filepath.Join(dir, "src")
|
|
69
|
+
if err := os.MkdirAll(src, 0o755); err != nil {
|
|
70
|
+
t.Fatalf("mkdir fixture src: %v", err)
|
|
71
|
+
}
|
|
72
|
+
if err := os.WriteFile(filepath.Join(dir, "tsconfig.json"), []byte(finiteOptionNumberLeafTSConfig), 0o644); err != nil {
|
|
73
|
+
t.Fatalf("write tsconfig: %v", err)
|
|
74
|
+
}
|
|
75
|
+
if err := os.WriteFile(filepath.Join(src, "main.ts"), []byte(nativeNameCollisionSource), 0o644); err != nil {
|
|
76
|
+
t.Fatalf("write source: %v", err)
|
|
77
|
+
}
|
|
78
|
+
return dir
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
func nativeNameCollisionTransform(t *testing.T, project string) string {
|
|
82
|
+
t.Helper()
|
|
83
|
+
payload := `[{"config":{"transform":"typia/lib/transform"},"name":"typia","stage":"transform"}]`
|
|
84
|
+
out, errText, code := ttscTypiaTestCapture(func() int {
|
|
85
|
+
return runTransform([]string{
|
|
86
|
+
"--cwd", project,
|
|
87
|
+
"--tsconfig", "tsconfig.json",
|
|
88
|
+
"--file", "src/main.ts",
|
|
89
|
+
"--output", "js",
|
|
90
|
+
"--plugins-json", payload,
|
|
91
|
+
})
|
|
92
|
+
})
|
|
93
|
+
if code != 0 {
|
|
94
|
+
t.Fatalf("native name collision transform failed: code=%d stderr=\n%s", code, errText)
|
|
95
|
+
}
|
|
96
|
+
return out
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
func nativeNameCollisionRunRuntimeCases(t *testing.T, project string, js string) {
|
|
100
|
+
t.Helper()
|
|
101
|
+
node, err := exec.LookPath("node")
|
|
102
|
+
if err != nil {
|
|
103
|
+
t.Skip("node executable not found")
|
|
104
|
+
}
|
|
105
|
+
runtimeDir := filepath.Join(project, "runtime")
|
|
106
|
+
if err := os.MkdirAll(runtimeDir, 0o755); err != nil {
|
|
107
|
+
t.Fatalf("mkdir runtime dir: %v", err)
|
|
108
|
+
}
|
|
109
|
+
ttscTypiaTestWriteCommonRuntimeStubs(t, runtimeDir)
|
|
110
|
+
runtimeJS := ttscTypiaTestRewriteCommonJS(t, js)
|
|
111
|
+
if err := os.WriteFile(filepath.Join(runtimeDir, "main.cjs"), []byte(runtimeJS), 0o644); err != nil {
|
|
112
|
+
t.Fatalf("write runtime module: %v", err)
|
|
113
|
+
}
|
|
114
|
+
runner := filepath.Join(runtimeDir, "run.cjs")
|
|
115
|
+
if err := os.WriteFile(runner, []byte(nativeNameCollisionRuntimeRunner), 0o644); err != nil {
|
|
116
|
+
t.Fatalf("write runtime runner: %v", err)
|
|
117
|
+
}
|
|
118
|
+
cmd := exec.Command(node, runner)
|
|
119
|
+
cmd.Dir = runtimeDir
|
|
120
|
+
output, err := cmd.CombinedOutput()
|
|
121
|
+
if err != nil {
|
|
122
|
+
t.Fatalf("native name collision runtime cases failed: %v\n%s", err, output)
|
|
123
|
+
}
|
|
124
|
+
const expected = "RAN 23 CASES"
|
|
125
|
+
if !strings.Contains(string(output), expected) {
|
|
126
|
+
t.Fatalf("native name collision runner did not report %q; got:\n%s", expected, output)
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
const nativeNameCollisionSource = `import typia from "typia";
|
|
131
|
+
|
|
132
|
+
interface File {
|
|
133
|
+
name: string;
|
|
134
|
+
size: number;
|
|
135
|
+
}
|
|
136
|
+
interface Blob {
|
|
137
|
+
size: number;
|
|
138
|
+
type: string;
|
|
139
|
+
}
|
|
140
|
+
interface Filer {
|
|
141
|
+
name: string;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
export const isFile = typia.createIs<File>();
|
|
145
|
+
export const validateFile = typia.createValidate<File>();
|
|
146
|
+
export const isBlob = typia.createIs<Blob>();
|
|
147
|
+
export const isFiler = typia.createIs<Filer>();
|
|
148
|
+
|
|
149
|
+
export const isDate = typia.createIs<Date>();
|
|
150
|
+
export const isU8 = typia.createIs<Uint8Array>();
|
|
151
|
+
`
|
|
152
|
+
|
|
153
|
+
const nativeNameCollisionRuntimeRunner = `const mod = require("./main.cjs");
|
|
154
|
+
|
|
155
|
+
let ran = 0;
|
|
156
|
+
const eq = (name, actual, expected) => {
|
|
157
|
+
ran += 1;
|
|
158
|
+
if (actual !== expected) {
|
|
159
|
+
throw new Error(name + ": expected " + expected + " but got " + actual);
|
|
160
|
+
}
|
|
161
|
+
};
|
|
162
|
+
|
|
163
|
+
// A user interface named File must validate against its own members, not the
|
|
164
|
+
// native File instanceof path (#2200 core cases).
|
|
165
|
+
eq("isFile valid", mod.isFile({ name: "a", size: 1 }), true);
|
|
166
|
+
eq("isFile missing size", mod.isFile({ name: "a" }), false);
|
|
167
|
+
eq("isFile missing name", mod.isFile({ size: 1 }), false);
|
|
168
|
+
eq("isFile wrong size type", mod.isFile({ name: "a", size: "1" }), false);
|
|
169
|
+
eq("isFile null", mod.isFile(null), false);
|
|
170
|
+
eq("isFile primitive", mod.isFile(5), false);
|
|
171
|
+
|
|
172
|
+
// validate shares the structural object path, so it agrees with is and names no
|
|
173
|
+
// File expected type.
|
|
174
|
+
eq("validateFile valid", mod.validateFile({ name: "a", size: 1 }).success, true);
|
|
175
|
+
eq("validateFile invalid", mod.validateFile({ name: "a" }).success, false);
|
|
176
|
+
|
|
177
|
+
// A user interface named Blob is structural too.
|
|
178
|
+
eq("isBlob valid", mod.isBlob({ size: 1, type: "x" }), true);
|
|
179
|
+
eq("isBlob missing type", mod.isBlob({ size: 1 }), false);
|
|
180
|
+
eq("isBlob null", mod.isBlob(null), false);
|
|
181
|
+
|
|
182
|
+
// A near-miss name that is not a native was always structural and stays so.
|
|
183
|
+
eq("isFiler valid", mod.isFiler({ name: "a" }), true);
|
|
184
|
+
eq("isFiler invalid", mod.isFiler({}), false);
|
|
185
|
+
|
|
186
|
+
// Genuine natives keep their instanceof check and accept a real instance while
|
|
187
|
+
// rejecting a plain object of the same shape.
|
|
188
|
+
eq("isDate real", mod.isDate(new Date()), true);
|
|
189
|
+
eq("isDate plain object", mod.isDate({}), false);
|
|
190
|
+
eq("isDate null", mod.isDate(null), false);
|
|
191
|
+
|
|
192
|
+
eq("isU8 real", mod.isU8(new Uint8Array(4)), true);
|
|
193
|
+
eq("isU8 plain object", mod.isU8({}), false);
|
|
194
|
+
eq("isU8 array", mod.isU8([1, 2, 3]), false);
|
|
195
|
+
eq("isU8 null", mod.isU8(null), false);
|
|
196
|
+
|
|
197
|
+
// A user File/Blob value is not a real native instance, and a real native is not
|
|
198
|
+
// a user shape: the two classifications stay disjoint.
|
|
199
|
+
eq("isFile rejects a real Date", mod.isFile(new Date()), false);
|
|
200
|
+
eq("isDate rejects a user File shape", mod.isDate({ name: "a", size: 1 }), false);
|
|
201
|
+
eq("isBlob rejects a real Date", mod.isBlob(new Date()), false);
|
|
202
|
+
|
|
203
|
+
console.log("RAN " + ran + " CASES");
|
|
204
|
+
`
|
|
@@ -18,20 +18,22 @@ import (
|
|
|
18
18
|
// addresses tuples by fixed leading positions, so the honest resolution is
|
|
19
19
|
// a compile-time rejection, mirroring the json.schemas bigint precedent.
|
|
20
20
|
//
|
|
21
|
-
// 1. Require leading-rest and middle-rest tuples to be rejected: the
|
|
22
|
-
//
|
|
23
|
-
//
|
|
24
|
-
//
|
|
21
|
+
// 1. Require leading-rest and middle-rest tuples to be rejected: the transform
|
|
22
|
+
// records a diagnostic naming the offending tuple, which every host --
|
|
23
|
+
// single-file included since samchon/typia#2117 -- reports while refusing to
|
|
24
|
+
// publish an artifact.
|
|
25
25
|
// 2. Require trailing-rest tuples to keep compiling and validating
|
|
26
26
|
// correctly at every length.
|
|
27
27
|
func TestNonTrailingRestTupleTransform(t *testing.T) {
|
|
28
28
|
t.Run("leading rest rejected", func(t *testing.T) {
|
|
29
29
|
nonTrailingRestExpectRejection(t, "leading-",
|
|
30
|
-
"export const validate = typia.createValidate<[...unknown[], string]>();"
|
|
30
|
+
"export const validate = typia.createValidate<[...unknown[], string]>();",
|
|
31
|
+
"[...unknown[], string]")
|
|
31
32
|
})
|
|
32
33
|
t.Run("middle rest rejected", func(t *testing.T) {
|
|
33
34
|
nonTrailingRestExpectRejection(t, "middle-",
|
|
34
|
-
"export const validate = typia.createValidate<[number, ...boolean[], string]>();"
|
|
35
|
+
"export const validate = typia.createValidate<[number, ...boolean[], string]>();",
|
|
36
|
+
"[number, ...boolean[], string]")
|
|
35
37
|
})
|
|
36
38
|
t.Run("trailing rest keeps working", func(t *testing.T) {
|
|
37
39
|
nonTrailingRestTrailingControl(t)
|
|
@@ -66,7 +68,12 @@ func nonTrailingRestProject(t *testing.T, prefix string, body string) string {
|
|
|
66
68
|
return dir
|
|
67
69
|
}
|
|
68
70
|
|
|
69
|
-
|
|
71
|
+
// nonTrailingRestExpectRejection requires the rejection to reach the caller as a
|
|
72
|
+
// diagnostic naming `tuple`, with no artifact published. This previously asserted
|
|
73
|
+
// code 0 and inspected the untransformed call in stdout; that success code was
|
|
74
|
+
// the samchon/typia#2117 defect, and in `js` mode the surviving `.createValidate()`
|
|
75
|
+
// was only type erasure, so the diagnostic is the load-bearing evidence anyway.
|
|
76
|
+
func nonTrailingRestExpectRejection(t *testing.T, prefix string, body string, tuple string) {
|
|
70
77
|
t.Helper()
|
|
71
78
|
project := nonTrailingRestProject(t, prefix, body)
|
|
72
79
|
out, errText, code := ttscTypiaTestCapture(func() int {
|
|
@@ -77,11 +84,16 @@ func nonTrailingRestExpectRejection(t *testing.T, prefix string, body string) {
|
|
|
77
84
|
"--output", "js",
|
|
78
85
|
})
|
|
79
86
|
})
|
|
80
|
-
if code !=
|
|
81
|
-
t.Fatalf("
|
|
87
|
+
if code != 3 {
|
|
88
|
+
t.Fatalf("non-trailing rest tuple should be rejected with code 3: code=%d stdout=\n%s\nstderr=\n%s", code, out, errText)
|
|
89
|
+
}
|
|
90
|
+
if !strings.Contains(errText, "error TS(typia.createValidate):") ||
|
|
91
|
+
!strings.Contains(errText, tuple) ||
|
|
92
|
+
!strings.Contains(errText, "non-trailing rest element in tuple type is not supported.") {
|
|
93
|
+
t.Fatalf("rejection diagnostic did not name the tuple and cause:\n%s", errText)
|
|
82
94
|
}
|
|
83
|
-
if
|
|
84
|
-
t.Fatalf("
|
|
95
|
+
if out != "" {
|
|
96
|
+
t.Fatalf("rejected transform published an artifact:\n%s", out)
|
|
85
97
|
}
|
|
86
98
|
}
|
|
87
99
|
|