typia 13.1.19 → 13.2.0
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/FileSystemIdentity.d.ts +23 -0
- package/lib/executable/FileSystemIdentity.js +30 -0
- package/lib/executable/FileSystemIdentity.js.map +1 -1
- package/lib/executable/FileSystemIdentity.mjs +4 -0
- package/lib/executable/FileSystemIdentity.mjs.map +1 -1
- package/lib/executable/TypiaGenerateWizard.js +15 -9
- package/lib/executable/TypiaGenerateWizard.js.map +1 -1
- package/lib/executable/TypiaGenerateWizard.mjs +11 -7
- package/lib/executable/TypiaGenerateWizard.mjs.map +1 -1
- package/lib/internal/_ProtobufReader.d.ts +18 -3
- package/lib/internal/_ProtobufReader.js +39 -11
- package/lib/internal/_ProtobufReader.js.map +1 -1
- package/lib/internal/_ProtobufReader.mjs +37 -10
- package/lib/internal/_ProtobufReader.mjs.map +1 -1
- package/lib/internal/_jsonStringifyArray.d.ts +1 -0
- package/lib/internal/_jsonStringifyArray.js +48 -0
- package/lib/internal/_jsonStringifyArray.js.map +1 -0
- package/lib/internal/_jsonStringifyArray.mjs +40 -0
- package/lib/internal/_jsonStringifyArray.mjs.map +1 -0
- package/lib/internal/_jsonStringifyElement.d.ts +1 -0
- package/lib/internal/_jsonStringifyElement.js +23 -0
- package/lib/internal/_jsonStringifyElement.js.map +1 -0
- package/lib/internal/_jsonStringifyElement.mjs +23 -0
- package/lib/internal/_jsonStringifyElement.mjs.map +1 -0
- package/lib/internal/_jsonStringifyProperty.d.ts +1 -0
- package/lib/internal/_jsonStringifyProperty.js +31 -0
- package/lib/internal/_jsonStringifyProperty.js.map +1 -0
- package/lib/internal/_jsonStringifyProperty.mjs +31 -0
- package/lib/internal/_jsonStringifyProperty.mjs.map +1 -0
- package/lib/internal/_llmApplicationFinalize.js +1 -1
- package/lib/internal/_llmApplicationFinalize.js.map +1 -1
- package/lib/internal/_llmApplicationFinalize.mjs +1 -1
- package/lib/internal/_llmApplicationFinalize.mjs.map +1 -1
- package/lib/internal/_randomFormatByte.js +24 -1
- package/lib/internal/_randomFormatByte.js.map +1 -1
- package/lib/internal/_randomFormatByte.mjs +20 -2
- package/lib/internal/_randomFormatByte.mjs.map +1 -1
- package/lib/internal/_randomFormatDate.d.ts +3 -6
- package/lib/internal/_randomFormatDate.js +2 -10
- package/lib/internal/_randomFormatDate.js.map +1 -1
- package/lib/internal/_randomFormatDate.mjs +2 -6
- package/lib/internal/_randomFormatDate.mjs.map +1 -1
- package/lib/internal/_randomFormatDatetime.d.ts +3 -6
- package/lib/internal/_randomFormatDatetime.js +25 -8
- package/lib/internal/_randomFormatDatetime.js.map +1 -1
- package/lib/internal/_randomFormatDatetime.mjs +17 -7
- package/lib/internal/_randomFormatDatetime.mjs.map +1 -1
- package/lib/internal/_randomFormatDuration.js +23 -15
- package/lib/internal/_randomFormatDuration.js.map +1 -1
- package/lib/internal/_randomFormatDuration.mjs +23 -15
- package/lib/internal/_randomFormatDuration.mjs.map +1 -1
- package/lib/internal/_randomFormatIpv4.js +31 -1
- package/lib/internal/_randomFormatIpv4.js.map +1 -1
- package/lib/internal/_randomFormatIpv4.mjs +23 -2
- package/lib/internal/_randomFormatIpv4.mjs.map +1 -1
- package/lib/internal/_randomFormatIpv6.js +57 -1
- package/lib/internal/_randomFormatIpv6.js.map +1 -1
- package/lib/internal/_randomFormatIpv6.mjs +45 -2
- package/lib/internal/_randomFormatIpv6.mjs.map +1 -1
- package/lib/internal/_randomFormatJsonPointer.js +14 -2
- package/lib/internal/_randomFormatJsonPointer.js.map +1 -1
- package/lib/internal/_randomFormatJsonPointer.mjs +13 -3
- package/lib/internal/_randomFormatJsonPointer.mjs.map +1 -1
- package/lib/internal/_randomFormatRegex.js +14 -1
- package/lib/internal/_randomFormatRegex.js.map +1 -1
- package/lib/internal/_randomFormatRegex.mjs +14 -2
- package/lib/internal/_randomFormatRegex.mjs.map +1 -1
- package/lib/internal/_randomFormatRelativeJsonPointer.js +19 -5
- package/lib/internal/_randomFormatRelativeJsonPointer.js.map +1 -1
- package/lib/internal/_randomFormatRelativeJsonPointer.mjs +21 -6
- package/lib/internal/_randomFormatRelativeJsonPointer.mjs.map +1 -1
- package/lib/internal/_randomFormatTime.js +33 -7
- package/lib/internal/_randomFormatTime.js.map +1 -1
- package/lib/internal/_randomFormatTime.mjs +37 -5
- package/lib/internal/_randomFormatTime.mjs.map +1 -1
- package/lib/internal/_randomPattern.js.map +1 -1
- package/lib/internal/_randomPattern.mjs.map +1 -1
- package/lib/internal/_randomStringLength.d.ts +41 -10
- package/lib/internal/_randomStringLength.js +49 -13
- package/lib/internal/_randomStringLength.js.map +1 -1
- package/lib/internal/_randomStringLength.mjs +48 -13
- package/lib/internal/_randomStringLength.mjs.map +1 -1
- package/lib/internal/private/__notationRename.js.map +1 -1
- package/lib/internal/private/__notationRename.mjs.map +1 -1
- package/lib/internal/private/__randomComposition.d.ts +23 -0
- package/lib/internal/private/__randomComposition.js +48 -0
- package/lib/internal/private/__randomComposition.js.map +1 -0
- package/lib/internal/private/__randomComposition.mjs +54 -0
- package/lib/internal/private/__randomComposition.mjs.map +1 -0
- package/lib/internal/private/__randomEpoch.d.ts +19 -0
- package/lib/internal/private/__randomEpoch.js +31 -0
- package/lib/internal/private/__randomEpoch.js.map +1 -0
- package/lib/internal/private/__randomEpoch.mjs +28 -0
- package/lib/internal/private/__randomEpoch.mjs.map +1 -0
- package/native/cmd/ttsc-typia/build.go +3 -0
- package/native/cmd/ttsc-typia/callable_interface_function_semantics_transform_test.go +331 -0
- package/native/cmd/ttsc-typia/callable_type_literal_boundaries_transform_test.go +1184 -0
- package/native/cmd/ttsc-typia/compare_functional_union_membership_transform_test.go +434 -0
- package/native/cmd/ttsc-typia/compare_template_literal_union_transform_test.go +241 -0
- package/native/cmd/ttsc-typia/default_library_spoof_native_identity_transform_test.go +216 -0
- package/native/cmd/ttsc-typia/json_schema_dynamic_key_determinism_transform_test.go +246 -0
- package/native/cmd/ttsc-typia/json_stringify_contextual_undefined_transform_test.go +556 -0
- package/native/cmd/ttsc-typia/lib_replacement_native_identity_transform_test.go +277 -0
- package/native/cmd/ttsc-typia/native_named_intersection_union_transform_test.go +390 -0
- package/native/cmd/ttsc-typia/node_buffer_native_exports_is_transform_test.go +526 -0
- package/native/cmd/ttsc-typia/package_declaration_native_identity_is_transform_test.go +293 -0
- package/native/cmd/ttsc-typia/protobuf_diagnostic_code_transform_test.go +167 -0
- package/native/cmd/ttsc-typia/symbol_index_domain_transform_test.go +316 -0
- package/native/cmd/ttsc-typia/transform.go +23 -0
- package/native/cmd/ttsc-typia/transform_helpers_test.go +77 -2
- package/native/cmd/ttsc-typia/user_global_native_identity_transform_test.go +484 -0
- package/native/core/factories/ProtobufFactory.go +6 -1
- package/native/core/factories/internal/metadata/MetadataHelper.go +185 -30
- package/native/core/factories/internal/metadata/emplace_metadata_object.go +25 -0
- package/native/core/factories/internal/metadata/iterate_metadata_function.go +1 -1
- package/native/core/factories/internal/metadata/iterate_metadata_intersection.go +103 -23
- package/native/core/factories/internal/metadata/iterate_metadata_map.go +3 -7
- package/native/core/factories/internal/metadata/iterate_metadata_native.go +32 -14
- package/native/core/factories/internal/metadata/iterate_metadata_set.go +3 -7
- package/native/core/programmers/compare/CompareEqualProgrammer.go +27 -13
- package/native/core/programmers/helpers/FunctionProgrammer.go +6 -13
- package/native/core/programmers/helpers/StringifyJoinder.go +129 -50
- package/native/core/programmers/helpers/joiner_branch_coverage_test.go +116 -120
- package/native/core/programmers/iterate/iterate_check_coverage_test.go +76 -158
- package/native/core/programmers/iterate/iterate_utility_coverage_test.go +231 -270
- package/native/core/programmers/iterate/json_schema_object.go +49 -7
- package/native/core/programmers/iterate/json_schema_pattern_property_order_test.go +44 -0
- package/native/core/programmers/iterate/openapi_v3_downgrader.go +34 -1
- package/native/core/programmers/iterate/template_runtime_pattern.go +11 -0
- package/native/core/programmers/json/JsonStringifyProgrammer.go +47 -6
- package/native/core/programmers/llm/LlmApplicationProgrammer.go +9 -1
- package/native/core/programmers/protobuf/ProtobufMessageProgrammer.go +1 -1
- package/native/core/schemas/metadata/MetadataCollection.go +0 -9
- package/native/core/schemas/metadata/MetadataDefaultLibrary.go +81 -0
- package/native/core/schemas/metadata/MetadataObjectType.go +7 -18
- package/native/go.mod +4 -4
- package/native/transform/features/protobuf/ProtobufMessageTransformer.go +1 -1
- package/package.json +3 -7
- package/src/executable/FileSystemIdentity.ts +33 -0
- package/src/executable/TypiaGenerateWizard.ts +18 -12
- package/src/internal/_ProtobufReader.ts +40 -11
- package/src/internal/_jsonStringifyArray.ts +50 -0
- package/src/internal/_jsonStringifyElement.ts +19 -0
- package/src/internal/_jsonStringifyProperty.ts +30 -0
- package/src/internal/_llmApplicationFinalize.ts +6 -1
- package/src/internal/_randomFormatByte.ts +30 -3
- package/src/internal/_randomFormatDate.ts +4 -20
- package/src/internal/_randomFormatDatetime.ts +34 -20
- package/src/internal/_randomFormatDuration.ts +19 -4
- package/src/internal/_randomFormatIpv4.ts +43 -3
- package/src/internal/_randomFormatIpv6.ts +67 -3
- package/src/internal/_randomFormatJsonPointer.ts +23 -3
- package/src/internal/_randomFormatRegex.ts +21 -3
- package/src/internal/_randomFormatRelativeJsonPointer.ts +23 -10
- package/src/internal/_randomFormatTime.ts +45 -12
- package/src/internal/_randomPattern.ts +4 -1
- package/src/internal/_randomStringLength.ts +61 -17
- package/src/internal/private/__notationRename.ts +1 -4
- package/src/internal/private/__randomComposition.ts +50 -0
- package/src/internal/private/__randomEpoch.ts +34 -0
- package/native/adapter/visit.go +0 -173
- package/native/adapter/visit_property_chain_edges_test.go +0 -129
- package/native/core/programmers/helpers/disable_function_programmer_declare.go +0 -10
- package/native/core/programmers/iterate/check_union_array_like.go +0 -422
- package/native/core/programmers/iterate/prune_object_properties.go +0 -105
- package/native/core/programmers/iterate/stringify_dynamic_properties.go +0 -219
- package/native/core/programmers/iterate/stringify_native.go +0 -14
- package/native/core/programmers/iterate/stringify_regular_properties.go +0 -112
- package/native/core/schemas/metadata/MetadataApplication.go +0 -41
|
@@ -139,7 +139,7 @@ func metadata_get_type_arguments(checker *nativechecker.Checker, typ *nativechec
|
|
|
139
139
|
return checker.GetTypeArguments(typ)
|
|
140
140
|
}
|
|
141
141
|
|
|
142
|
-
func metadata_get_function_node(typ *nativechecker.Type) *nativeast.Node {
|
|
142
|
+
func metadata_get_function_node(checker *nativechecker.Checker, typ *nativechecker.Type) *nativeast.Node {
|
|
143
143
|
if typ == nil {
|
|
144
144
|
return nil
|
|
145
145
|
}
|
|
@@ -166,6 +166,9 @@ func metadata_get_function_node(typ *nativechecker.Type) *nativeast.Node {
|
|
|
166
166
|
if metadata_is_global_function_interface(symbol, node) {
|
|
167
167
|
return node
|
|
168
168
|
}
|
|
169
|
+
if metadata_is_pure_function_declaration(checker, typ, node) {
|
|
170
|
+
return node
|
|
171
|
+
}
|
|
169
172
|
if nativeast.IsPropertyAssignment(node) {
|
|
170
173
|
initializer := node.AsPropertyAssignment().Initializer
|
|
171
174
|
if nativeast.IsFunctionLike(initializer) {
|
|
@@ -287,8 +290,7 @@ func metadata_node_type_js_doc_tags(symbol *nativeast.Symbol) []schemametadata.I
|
|
|
287
290
|
// first declaration is an `InterfaceDeclaration`, and that declaration lives in a
|
|
288
291
|
// `lib.*.d.ts` — so it recognizes only the lib `Function` and never a
|
|
289
292
|
// user-declared `interface Function`, a `function Function()` value, or any
|
|
290
|
-
// other callable object type
|
|
291
|
-
// keeps its data properties). See metadata_get_function_node for why the lib
|
|
293
|
+
// other callable object type. See metadata_get_function_node for why the lib
|
|
292
294
|
// `Function` must be treated as a function type (#2178).
|
|
293
295
|
func metadata_is_global_function_interface(symbol *nativeast.Symbol, node *nativeast.Node) bool {
|
|
294
296
|
if symbol == nil || symbol.Name != "Function" {
|
|
@@ -300,50 +302,203 @@ func metadata_is_global_function_interface(symbol *nativeast.Symbol, node *nativ
|
|
|
300
302
|
return metadata_symbol_from_default_lib(symbol)
|
|
301
303
|
}
|
|
302
304
|
|
|
305
|
+
// metadata_is_pure_function_declaration reports whether an object-type
|
|
306
|
+
// declaration describes only call and/or construct signatures. TypeScript
|
|
307
|
+
// augments every callable object's apparent properties with the global Function
|
|
308
|
+
// members, so the raw properties and index infos are the boundary: a declaration
|
|
309
|
+
// that carries members of its own keeps its declared data shape, while a
|
|
310
|
+
// member-free callable or constructable one follows the same metadata path as
|
|
311
|
+
// the function type alias it is mutually assignable with (#2238).
|
|
312
|
+
//
|
|
313
|
+
// An interface body and a type literal are the two spellings TypeScript has for
|
|
314
|
+
// one object-type body, and `interface F { (v: number): string }`, `type F = { (v:
|
|
315
|
+
// number): string }`, and the anonymous `{ (v: number): string }` written at a
|
|
316
|
+
// call site are one type. The declaration's node kind is the only thing that
|
|
317
|
+
// separates them, so answering them differently is exactly the
|
|
318
|
+
// declaration-spelling dependency this predicate exists to remove. Both kinds
|
|
319
|
+
// are admitted and nothing else is: a function type or constructor type is
|
|
320
|
+
// already `IsFunctionLike` and never reaches here, and every other declaration
|
|
321
|
+
// kind that can back a callable type carries a runtime value binding whose
|
|
322
|
+
// declared shape is a different question.
|
|
323
|
+
//
|
|
324
|
+
// No member class is admitted, not even one the emitted validator ignores.
|
|
325
|
+
// #2238's invariant is that mutually assignable spellings agree, and a
|
|
326
|
+
// member-carrying callable has no plain function type to be assignable with:
|
|
327
|
+
// `{ (): void; cancel(): void }` accepts no bare `() => void`, so routing it
|
|
328
|
+
// through the function path would answer against no twin while erasing `cancel`
|
|
329
|
+
// from the declaration. It would also split two spellings that are mutually
|
|
330
|
+
// assignable with each other — `cancel(): void` and `cancel: () => void` are the
|
|
331
|
+
// same type, and only the first carries SymbolFlagsMethod — so admitting methods
|
|
332
|
+
// would make the method form a function while the property form stayed
|
|
333
|
+
// structural. Hybrid callables are #2250's merged boundary and #2238's declared
|
|
334
|
+
// negative boundary; both leave them structural.
|
|
335
|
+
func metadata_is_pure_function_declaration(
|
|
336
|
+
checker *nativechecker.Checker,
|
|
337
|
+
typ *nativechecker.Type,
|
|
338
|
+
node *nativeast.Node,
|
|
339
|
+
) bool {
|
|
340
|
+
if checker == nil || typ == nil || node == nil ||
|
|
341
|
+
(node.Kind != nativeast.KindInterfaceDeclaration && node.Kind != nativeast.KindTypeLiteral) {
|
|
342
|
+
return false
|
|
343
|
+
}
|
|
344
|
+
if len(nativechecker.Checker_getPropertiesOfType(checker, typ)) != 0 ||
|
|
345
|
+
len(nativechecker.Checker_getIndexInfosOfType(checker, typ)) != 0 {
|
|
346
|
+
return false
|
|
347
|
+
}
|
|
348
|
+
return len(checker.GetSignaturesOfType(typ, nativechecker.SignatureKindCall)) != 0 ||
|
|
349
|
+
len(checker.GetSignaturesOfType(typ, nativechecker.SignatureKindConstruct)) != 0
|
|
350
|
+
}
|
|
351
|
+
|
|
303
352
|
// metadata_symbol_from_default_lib reports whether the symbol's first locatable
|
|
304
|
-
// declaration lives in a TypeScript default library file
|
|
305
|
-
//
|
|
306
|
-
//
|
|
353
|
+
// declaration lives in a TypeScript default library file, judged by file name
|
|
354
|
+
// alone because its callers answer without a checker. Default library files are
|
|
355
|
+
// conventionally named `lib.<target>.d.ts`, which is enough for the JSDoc and
|
|
356
|
+
// global-`Function` questions that use this: both are about what a library
|
|
357
|
+
// declaration means, and neither grants a type an identity a lookalike could
|
|
358
|
+
// claim. Runtime-native identity does grant one, so it asks the program instead
|
|
359
|
+
// through schemametadata.MetadataDefaultLibrary_is.
|
|
307
360
|
func metadata_symbol_from_default_lib(symbol *nativeast.Symbol) bool {
|
|
308
361
|
for _, node := range metadata_node_declarations(symbol) {
|
|
309
362
|
src := nativeast.GetSourceFileOfNode(node)
|
|
310
363
|
if src == nil {
|
|
311
364
|
continue
|
|
312
365
|
}
|
|
313
|
-
return
|
|
366
|
+
return schemametadata.MetadataDefaultLibrary_isFileNamed(src.FileName())
|
|
314
367
|
}
|
|
315
368
|
return false
|
|
316
369
|
}
|
|
317
370
|
|
|
318
|
-
//
|
|
319
|
-
//
|
|
320
|
-
//
|
|
321
|
-
//
|
|
322
|
-
//
|
|
323
|
-
// `
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
371
|
+
// metadata_symbol_is_global_type reports whether symbol is the type that the
|
|
372
|
+
// checker resolves from its global symbol table under name. Pointer identity is
|
|
373
|
+
// deliberate: default-library natives and ambient-package globals such as
|
|
374
|
+
// Node's File and Blob resolve to that shared global symbol, while an exported
|
|
375
|
+
// package declaration remains a distinct module symbol even when its name and
|
|
376
|
+
// `.d.ts` source form are identical (#2239).
|
|
377
|
+
func metadata_symbol_is_global_type(checker *nativechecker.Checker, symbol *nativeast.Symbol, name string) bool {
|
|
378
|
+
if checker == nil || symbol == nil || name == "" {
|
|
379
|
+
return false
|
|
380
|
+
}
|
|
381
|
+
return checker.ResolveName(name, nil, nativeast.SymbolFlagsType, false) == symbol
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
// metadata_symbol_is_runtime_global_type reports whether a global name is the
|
|
385
|
+
// runtime built-in rather than a user-authored global of the same name.
|
|
386
|
+
//
|
|
387
|
+
// Global-table resolution alone answers a weaker question than the one native
|
|
388
|
+
// classification asks. `declare global { interface File { ... } }` in a project
|
|
389
|
+
// with neither DOM nor Node declarations also wins that lookup, so a
|
|
390
|
+
// resolution-only gate promotes a purely user-authored type to native identity:
|
|
391
|
+
// its members are erased, `input instanceof File` replaces them, and the check
|
|
392
|
+
// throws `ReferenceError` wherever no runtime provides that constructor (#2200).
|
|
393
|
+
//
|
|
394
|
+
// The added question is therefore provenance of the runtime constructor, not the
|
|
395
|
+
// existence of a declaration: a global qualifies only when one of the two
|
|
396
|
+
// authorities that actually describe a JavaScript runtime — a TypeScript default
|
|
397
|
+
// library, or Node's `node:buffer` / `buffer` core module — puts it in scope.
|
|
398
|
+
func metadata_symbol_is_runtime_global_type(checker *nativechecker.Checker, symbol *nativeast.Symbol, name string) bool {
|
|
399
|
+
return metadata_symbol_is_global_type(checker, symbol, name) &&
|
|
400
|
+
metadata_symbol_has_runtime_provider(checker, symbol)
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
// metadata_symbol_is_runtime_native_type applies the shared identity boundary
|
|
404
|
+
// for simple runtime-native classes. Most natives are the runtime-provided
|
|
405
|
+
// symbol resolved from the checker's global type table. Node's Blob and File
|
|
406
|
+
// module exports are a second symbol for those same runtime constructors, so
|
|
407
|
+
// their declarations qualify through the value-bearing shape shared by the
|
|
408
|
+
// supported Node type definitions (#1568, #2200, #2239).
|
|
409
|
+
func metadata_symbol_is_runtime_native_type(checker *nativechecker.Checker, symbol *nativeast.Symbol, name string) bool {
|
|
410
|
+
return metadata_symbol_is_runtime_global_type(checker, symbol, name) ||
|
|
411
|
+
metadata_symbol_is_node_buffer_native_export(symbol, name)
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
// metadata_symbol_has_runtime_provider reports whether a runtime authority is
|
|
415
|
+
// what puts this symbol's constructor in scope.
|
|
416
|
+
//
|
|
417
|
+
// A provider does not have to declare the interface itself. @types/node bridges
|
|
418
|
+
// its module classes to the bare globals with `interface Blob extends _Blob {}`
|
|
419
|
+
// plus `var Blob: ... typeof buffer.Blob` in an ordinary package `.d.ts`, so the
|
|
420
|
+
// interface declaration carries no runtime provenance at all while the value
|
|
421
|
+
// binding resolves straight into the ambient `node:buffer` module. Reading the
|
|
422
|
+
// constructor binding therefore recognizes that bridge — and every respelling of
|
|
423
|
+
// it, including the 18/20 `typeof NodeBlob` class alias and the 25 `typeof
|
|
424
|
+
// buffer.Blob` variable alias — without matching declaration text or package
|
|
425
|
+
// paths, which node_modules placement, custom typeRoots, symlinks, and
|
|
426
|
+
// virtualized package layouts all make unreliable.
|
|
427
|
+
//
|
|
428
|
+
// A user-authored global fails both halves: its interface lives in the user's
|
|
429
|
+
// own file, and any `declare var` it pairs with resolves to the user's own type
|
|
430
|
+
// literal rather than into a default library or the Node core module.
|
|
431
|
+
func metadata_symbol_has_runtime_provider(checker *nativechecker.Checker, symbol *nativeast.Symbol) bool {
|
|
432
|
+
if symbol == nil {
|
|
433
|
+
return false
|
|
434
|
+
}
|
|
435
|
+
for _, declaration := range metadata_node_declarations(symbol) {
|
|
436
|
+
if metadata_declaration_is_runtime_provided(checker, declaration) {
|
|
437
|
+
return true
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
if checker == nil || symbol.Flags&nativeast.SymbolFlagsValue == 0 {
|
|
441
|
+
return false
|
|
442
|
+
}
|
|
443
|
+
constructor := checker.GetTypeOfSymbol(symbol)
|
|
444
|
+
if constructor == nil {
|
|
445
|
+
return false
|
|
446
|
+
}
|
|
447
|
+
for _, declaration := range metadata_node_declarations(constructor.Symbol()) {
|
|
448
|
+
if metadata_declaration_is_runtime_provided(checker, declaration) {
|
|
449
|
+
return true
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
return false
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
// metadata_declaration_is_runtime_provided reports whether a declaration belongs
|
|
456
|
+
// to one of the two authorities that describe a runtime-native global: a
|
|
457
|
+
// TypeScript default library file, or the `node:buffer` / `buffer` core module
|
|
458
|
+
// that owns Node's Blob and File constructors. The default-library half comes
|
|
459
|
+
// from the program (see schemametadata.MetadataDefaultLibrary) rather than from
|
|
460
|
+
// the declaration's file name, which under `libReplacement` is an ordinary
|
|
461
|
+
// `node_modules/@typescript/lib-*/index.d.ts` and which any dependency may
|
|
462
|
+
// otherwise imitate.
|
|
463
|
+
func metadata_declaration_is_runtime_provided(checker *nativechecker.Checker, declaration *nativeast.Node) bool {
|
|
464
|
+
if declaration == nil {
|
|
465
|
+
return false
|
|
466
|
+
}
|
|
467
|
+
if schemametadata.MetadataDefaultLibrary_is(checker, nativeast.GetSourceFileOfNode(declaration)) {
|
|
468
|
+
return true
|
|
469
|
+
}
|
|
470
|
+
return metadata_node_in_node_buffer_module(declaration)
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
func metadata_node_in_node_buffer_module(node *nativeast.Node) bool {
|
|
474
|
+
for current := node; current != nil; current = current.Parent {
|
|
475
|
+
if current.Kind == nativeast.KindModuleDeclaration && current.Name() != nil {
|
|
476
|
+
module := strings.Trim(current.Name().Text(), "\"'")
|
|
477
|
+
if module == "node:buffer" || module == "buffer" {
|
|
478
|
+
return true
|
|
479
|
+
}
|
|
480
|
+
}
|
|
481
|
+
if current.Kind == nativeast.KindSourceFile {
|
|
482
|
+
return false
|
|
334
483
|
}
|
|
335
|
-
return src.IsDeclarationFile
|
|
336
484
|
}
|
|
337
485
|
return false
|
|
338
486
|
}
|
|
339
487
|
|
|
340
|
-
func
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
488
|
+
func metadata_symbol_is_node_buffer_native_export(symbol *nativeast.Symbol, name string) bool {
|
|
489
|
+
if symbol == nil || symbol.ValueDeclaration == nil || (name != "Blob" && name != "File") {
|
|
490
|
+
return false
|
|
491
|
+
}
|
|
492
|
+
declaration := symbol.ValueDeclaration
|
|
493
|
+
if declaration.Kind != nativeast.KindClassDeclaration && declaration.Kind != nativeast.KindVariableDeclaration {
|
|
494
|
+
return false
|
|
345
495
|
}
|
|
346
|
-
|
|
496
|
+
// @types/node 18/20 declare these constructor values as classes and 25
|
|
497
|
+
// declares merged interface/var pairs. The value declaration and exact core
|
|
498
|
+
// module together distinguish those runtime constructors from structural
|
|
499
|
+
// same-name interfaces without depending on node_modules placement, custom
|
|
500
|
+
// typeRoots, symlink targets, or virtualized package paths.
|
|
501
|
+
return metadata_node_in_node_buffer_module(declaration)
|
|
347
502
|
}
|
|
348
503
|
|
|
349
504
|
func metadata_is_internal(symbol *nativeast.Symbol) bool {
|
|
@@ -182,6 +182,14 @@ func Emplace_metadata_object(props IMetadataIteratorProps) *schemametadata.Metad
|
|
|
182
182
|
}
|
|
183
183
|
|
|
184
184
|
for _, index := range props.Components.IndexInfos(props.Checker, props.Type) {
|
|
185
|
+
// IndexInfo keeps union domains separate, but a branded symbol key remains
|
|
186
|
+
// an intersection. Only string/number domains can describe properties seen
|
|
187
|
+
// through Object.keys or JSON Schema additionalProperties; walk nested
|
|
188
|
+
// intersections so every symbol-only form stays outside typia's structural
|
|
189
|
+
// JSON shape, just like an explicit symbol-keyed member (#2240).
|
|
190
|
+
if emplace_metadata_object_is_symbol_index_key(index.KeyType()) {
|
|
191
|
+
continue
|
|
192
|
+
}
|
|
185
193
|
analyzer := func(typ *nativechecker.Type) func(any) *schemametadata.MetadataSchema {
|
|
186
194
|
return func(property any) *schemametadata.MetadataSchema {
|
|
187
195
|
explore := MetadataFactory_IExplore{
|
|
@@ -681,6 +689,23 @@ func emplace_metadata_object_valid_dynamic_key(key *schemametadata.MetadataSchem
|
|
|
681
689
|
return total == key.Size()
|
|
682
690
|
}
|
|
683
691
|
|
|
692
|
+
func emplace_metadata_object_is_symbol_index_key(key *nativechecker.Type) bool {
|
|
693
|
+
if key == nil {
|
|
694
|
+
return false
|
|
695
|
+
}
|
|
696
|
+
if key.Flags()&nativechecker.TypeFlagsESSymbolLike != 0 {
|
|
697
|
+
return true
|
|
698
|
+
}
|
|
699
|
+
if key.IsIntersection() {
|
|
700
|
+
for _, child := range key.Types() {
|
|
701
|
+
if emplace_metadata_object_is_symbol_index_key(child) {
|
|
702
|
+
return true
|
|
703
|
+
}
|
|
704
|
+
}
|
|
705
|
+
}
|
|
706
|
+
return false
|
|
707
|
+
}
|
|
708
|
+
|
|
684
709
|
func iterate_optional_coalesce(props struct {
|
|
685
710
|
Metadata *schemametadata.MetadataSchema
|
|
686
711
|
Type *nativechecker.Type
|
|
@@ -126,6 +126,50 @@ func Iterate_metadata_intersection(props IMetadataIteratorProps) bool {
|
|
|
126
126
|
if onlyObjects && len(tagObjects) == 0 {
|
|
127
127
|
return escape(false)
|
|
128
128
|
}
|
|
129
|
+
// A call-signature-only arm is dropped before the phantom-brand pass, and only
|
|
130
|
+
// while something else survives. It cannot join that pass: the "every arm was
|
|
131
|
+
// removable" guard below exists to refuse an intersection of nothing but
|
|
132
|
+
// brands, and an arm such as `Record<never, never>` is vacuously a phantom
|
|
133
|
+
// brand, so counting signatures as removable would turn
|
|
134
|
+
// `call & Record<never, never>` — which the interface spelling accepts — into a
|
|
135
|
+
// rejection.
|
|
136
|
+
if len(metadatas) > 1 {
|
|
137
|
+
kept := make([]*schemametadata.MetadataSchema, 0, len(metadatas))
|
|
138
|
+
keptIndexes := make([]int, 0, len(indexes))
|
|
139
|
+
for i, m := range metadatas {
|
|
140
|
+
if iterate_metadata_intersection_is_call_signature_only(m) {
|
|
141
|
+
continue
|
|
142
|
+
}
|
|
143
|
+
kept = append(kept, m)
|
|
144
|
+
keptIndexes = append(keptIndexes, indexes[i])
|
|
145
|
+
}
|
|
146
|
+
substantial := false
|
|
147
|
+
for _, m := range kept {
|
|
148
|
+
if iterate_metadata_intersection_is_removable_brand(m) == false {
|
|
149
|
+
substantial = true
|
|
150
|
+
break
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
if substantial {
|
|
154
|
+
// Something that carries real obligations survives, so the signatures are
|
|
155
|
+
// the part with nothing to describe and the members are what both
|
|
156
|
+
// spellings must answer for.
|
|
157
|
+
metadatas = kept
|
|
158
|
+
indexes = keptIndexes
|
|
159
|
+
} else if len(kept) == 0 {
|
|
160
|
+
// Every arm was signatures only — an overload set, a call-and-construct
|
|
161
|
+
// pair, or two constructors. That is a member-free callable, which is what
|
|
162
|
+
// the interface spelling of the same type produces, so this iterator has
|
|
163
|
+
// nothing to merge and hands the type back rather than refusing it.
|
|
164
|
+
//
|
|
165
|
+
// Widening this to "signatures were dropped and only brands remain" was
|
|
166
|
+
// tried and is wrong: `call & Record<never, never>` must reach the
|
|
167
|
+
// phantom-brand pass below, which drops the brand and leaves the call arm.
|
|
168
|
+
// Escaping instead makes the emitted validator refuse a function, which
|
|
169
|
+
// the `directPureCall*EmptyIntersection` anchors catch.
|
|
170
|
+
return escape(false)
|
|
171
|
+
}
|
|
172
|
+
}
|
|
129
173
|
if len(metadatas) != 1 {
|
|
130
174
|
removable := []int{}
|
|
131
175
|
for i, m := range metadatas {
|
|
@@ -297,6 +341,29 @@ func Iterate_metadata_intersection(props IMetadataIteratorProps) bool {
|
|
|
297
341
|
return true
|
|
298
342
|
}
|
|
299
343
|
|
|
344
|
+
// iterate_metadata_intersection_is_call_signature_only reports whether an arm
|
|
345
|
+
// contributes nothing but call or construct signatures, which the intersection
|
|
346
|
+
// can drop the way it drops a phantom brand.
|
|
347
|
+
//
|
|
348
|
+
// `((v: number) => string) & { label: string }` and
|
|
349
|
+
// `interface T { (v: number): string; label: string }` are the same type, and
|
|
350
|
+
// only the first reaches this function — the second is one object carrying a
|
|
351
|
+
// call signature. Without this the first was refused as a nonsensible
|
|
352
|
+
// intersection while the second was accepted, so the answer depended on the
|
|
353
|
+
// spelling (samchon/typia#2276).
|
|
354
|
+
//
|
|
355
|
+
// Dropping the arm loses nothing the interface spelling keeps. #2250 settled
|
|
356
|
+
// that a member-carrying callable stays structural, so neither spelling
|
|
357
|
+
// validates the call signature; the members are what both must describe. An arm
|
|
358
|
+
// that carries any data alongside its signatures is not this case and stays,
|
|
359
|
+
// because dropping it would erase a declared obligation.
|
|
360
|
+
func iterate_metadata_intersection_is_call_signature_only(m *schemametadata.MetadataSchema) bool {
|
|
361
|
+
return m != nil &&
|
|
362
|
+
len(m.Functions) != 0 &&
|
|
363
|
+
m.Nullable == false &&
|
|
364
|
+
m.Size() == len(m.Functions)
|
|
365
|
+
}
|
|
366
|
+
|
|
300
367
|
// iterate_metadata_intersection_is_removable_brand reports whether an explored
|
|
301
368
|
// member schema is a phantom "brand" object that an intersection with a
|
|
302
369
|
// non-object member may drop. A value intersected with a non-object survivor is
|
|
@@ -314,6 +381,8 @@ func Iterate_metadata_intersection(props IMetadataIteratorProps) bool {
|
|
|
314
381
|
// a symbol-keyed property is never observable on a JSON value. Any required
|
|
315
382
|
// string-keyed property (literal or not) might be real data, so it keeps the
|
|
316
383
|
// intersection nonsensible rather than silently dropping a declared constraint.
|
|
384
|
+
|
|
385
|
+
|
|
317
386
|
func iterate_metadata_intersection_is_removable_brand(m *schemametadata.MetadataSchema) bool {
|
|
318
387
|
if m == nil || m.Size() != 1 || len(m.Objects) != 1 {
|
|
319
388
|
return false
|
|
@@ -481,14 +550,11 @@ func iterate_metadata_intersection_is_removable_object_constraint(
|
|
|
481
550
|
if nativechecker.IsTupleType(typ) || nativechecker.Checker_isArrayType(checker, typ) {
|
|
482
551
|
return false
|
|
483
552
|
}
|
|
484
|
-
if metadata_get_function_node(typ) != nil || len(checker.GetSignaturesOfType(typ, nativechecker.SignatureKindCall)) != 0 {
|
|
553
|
+
if metadata_get_function_node(checker, typ) != nil || len(checker.GetSignaturesOfType(typ, nativechecker.SignatureKindCall)) != 0 {
|
|
485
554
|
return false
|
|
486
555
|
}
|
|
487
|
-
name :=
|
|
488
|
-
if name
|
|
489
|
-
name = iterate_metadata_native_getNativeName(metadata_type_symbol_base_name(checker.GetApparentType(typ)))
|
|
490
|
-
}
|
|
491
|
-
if _, ok := iterate_metadata_native_simples[name]; ok {
|
|
556
|
+
name, symbol := iterate_metadata_intersection_type_name_and_symbol(checker, typ)
|
|
557
|
+
if _, ok := iterate_metadata_native_simples[name]; ok && metadata_symbol_is_runtime_native_type(checker, symbol, name) {
|
|
492
558
|
return false
|
|
493
559
|
}
|
|
494
560
|
for _, generic := range iterate_metadata_native_generics {
|
|
@@ -524,6 +590,29 @@ type iterate_metadata_intersection_identity struct {
|
|
|
524
590
|
Shareable bool
|
|
525
591
|
}
|
|
526
592
|
|
|
593
|
+
// iterate_metadata_intersection_type_name_and_symbol keeps the normalized name
|
|
594
|
+
// paired with the symbol that supplied it, including the apparent-type fallback.
|
|
595
|
+
// Intersection classifiers can then apply the same runtime-native identity gate
|
|
596
|
+
// as direct native metadata without re-resolving either half independently.
|
|
597
|
+
func iterate_metadata_intersection_type_name_and_symbol(
|
|
598
|
+
checker *nativechecker.Checker,
|
|
599
|
+
typ *nativechecker.Type,
|
|
600
|
+
) (string, *nativeast.Symbol) {
|
|
601
|
+
if typ == nil {
|
|
602
|
+
return "", nil
|
|
603
|
+
}
|
|
604
|
+
symbol := typ.Symbol()
|
|
605
|
+
name := iterate_metadata_native_getNativeName(metadata_type_symbol_base_name(typ))
|
|
606
|
+
if name == "" && checker != nil {
|
|
607
|
+
apparent := checker.GetApparentType(typ)
|
|
608
|
+
if apparent != nil {
|
|
609
|
+
symbol = apparent.Symbol()
|
|
610
|
+
name = iterate_metadata_native_getNativeName(metadata_type_symbol_base_name(apparent))
|
|
611
|
+
}
|
|
612
|
+
}
|
|
613
|
+
return name, symbol
|
|
614
|
+
}
|
|
615
|
+
|
|
527
616
|
func iterate_metadata_intersection_identify(
|
|
528
617
|
checker *nativechecker.Checker,
|
|
529
618
|
collection *schemametadata.MetadataCollection,
|
|
@@ -543,10 +632,7 @@ func iterate_metadata_intersection_identify(
|
|
|
543
632
|
return iterate_metadata_intersection_identity{Kind: "primitive", Name: info.name}
|
|
544
633
|
}
|
|
545
634
|
}
|
|
546
|
-
name :=
|
|
547
|
-
if name == "" {
|
|
548
|
-
name = iterate_metadata_native_getNativeName(metadata_type_symbol_base_name(checker.GetApparentType(typ)))
|
|
549
|
-
}
|
|
635
|
+
name, symbol := iterate_metadata_intersection_type_name_and_symbol(checker, typ)
|
|
550
636
|
if atomic, ok := schemametadata.MetadataSchema_atomicLikeNative(name); ok {
|
|
551
637
|
return iterate_metadata_intersection_identity{Kind: "primitive", Name: atomic}
|
|
552
638
|
}
|
|
@@ -561,7 +647,7 @@ func iterate_metadata_intersection_identify(
|
|
|
561
647
|
return iterate_metadata_intersection_identity{Kind: "tag"}
|
|
562
648
|
}
|
|
563
649
|
}
|
|
564
|
-
if _, ok := iterate_metadata_native_simples[name]; ok {
|
|
650
|
+
if _, ok := iterate_metadata_native_simples[name]; ok && metadata_symbol_is_runtime_native_type(checker, symbol, name) {
|
|
565
651
|
return iterate_metadata_intersection_identity{Kind: "native", Name: name}
|
|
566
652
|
}
|
|
567
653
|
for _, generic := range iterate_metadata_native_generics {
|
|
@@ -668,15 +754,12 @@ func iterate_metadata_intersection_is_plain_object_only(
|
|
|
668
754
|
if nativechecker.IsTupleType(typ) || nativechecker.Checker_isArrayType(checker, typ) {
|
|
669
755
|
return false
|
|
670
756
|
}
|
|
671
|
-
if metadata_get_function_node(typ) != nil || len(checker.GetSignaturesOfType(typ, nativechecker.SignatureKindCall)) != 0 {
|
|
757
|
+
if metadata_get_function_node(checker, typ) != nil || len(checker.GetSignaturesOfType(typ, nativechecker.SignatureKindCall)) != 0 {
|
|
672
758
|
return false
|
|
673
759
|
}
|
|
674
760
|
|
|
675
|
-
name :=
|
|
676
|
-
if name
|
|
677
|
-
name = iterate_metadata_native_getNativeName(metadata_type_symbol_base_name(checker.GetApparentType(typ)))
|
|
678
|
-
}
|
|
679
|
-
if _, ok := iterate_metadata_native_simples[name]; ok {
|
|
761
|
+
name, symbol := iterate_metadata_intersection_type_name_and_symbol(checker, typ)
|
|
762
|
+
if _, ok := iterate_metadata_native_simples[name]; ok && metadata_symbol_is_runtime_native_type(checker, symbol, name) {
|
|
680
763
|
return false
|
|
681
764
|
}
|
|
682
765
|
for _, generic := range iterate_metadata_native_generics {
|
|
@@ -975,17 +1058,14 @@ func iterate_metadata_intersection_category(
|
|
|
975
1058
|
return "tag"
|
|
976
1059
|
}
|
|
977
1060
|
}
|
|
978
|
-
name :=
|
|
979
|
-
if name == "" {
|
|
980
|
-
name = iterate_metadata_native_getNativeName(metadata_type_symbol_base_name(checker.GetApparentType(typ)))
|
|
981
|
-
}
|
|
1061
|
+
name, symbol := iterate_metadata_intersection_type_name_and_symbol(checker, typ)
|
|
982
1062
|
if atomic, ok := schemametadata.MetadataSchema_atomicLikeNative(name); ok {
|
|
983
1063
|
return "primitive:" + atomic
|
|
984
1064
|
}
|
|
985
1065
|
if name == "Array" || name == "ReadonlyArray" {
|
|
986
1066
|
return "array"
|
|
987
1067
|
}
|
|
988
|
-
if _, ok := iterate_metadata_native_simples[name]; ok {
|
|
1068
|
+
if _, ok := iterate_metadata_native_simples[name]; ok && metadata_symbol_is_runtime_native_type(checker, symbol, name) {
|
|
989
1069
|
return "native:" + name
|
|
990
1070
|
}
|
|
991
1071
|
for _, generic := range iterate_metadata_native_generics {
|
|
@@ -996,7 +1076,7 @@ func iterate_metadata_intersection_category(
|
|
|
996
1076
|
if name == "Map" || name == "ReadonlyMap" || name == "Set" || name == "ReadonlySet" {
|
|
997
1077
|
return "object"
|
|
998
1078
|
}
|
|
999
|
-
if metadata_get_function_node(typ) != nil || len(checker.GetSignaturesOfType(typ, nativechecker.SignatureKindCall)) != 0 {
|
|
1079
|
+
if metadata_get_function_node(checker, typ) != nil || len(checker.GetSignaturesOfType(typ, nativechecker.SignatureKindCall)) != 0 {
|
|
1000
1080
|
return "object"
|
|
1001
1081
|
}
|
|
1002
1082
|
if typ.Flags()&nativechecker.TypeFlagsObject != 0 {
|
|
@@ -10,13 +10,9 @@ func Iterate_metadata_map(props IMetadataIteratorProps) bool {
|
|
|
10
10
|
if metadata_type_symbol_base_name(typ) != "Map" {
|
|
11
11
|
return false
|
|
12
12
|
}
|
|
13
|
-
//
|
|
14
|
-
//
|
|
15
|
-
|
|
16
|
-
// `.ts` module falls through to the structural object path and is validated
|
|
17
|
-
// against its own members instead of `input instanceof Map` — the collection
|
|
18
|
-
// half of the #2200 identity gate (#2212).
|
|
19
|
-
if !metadata_symbol_from_declaration_file(typ.Symbol()) {
|
|
13
|
+
// The native Map is the runtime-provided global type, not any same-named
|
|
14
|
+
// package declaration or user-authored global (#2200, #2212, #2239).
|
|
15
|
+
if !metadata_symbol_is_runtime_global_type(props.Checker, typ.Symbol(), "Map") {
|
|
20
16
|
return false
|
|
21
17
|
}
|
|
22
18
|
generic := metadata_get_type_arguments(props.Checker, typ)
|
|
@@ -23,12 +23,16 @@ func Iterate_metadata_native(props IMetadataIteratorProps) bool {
|
|
|
23
23
|
}
|
|
24
24
|
name = iterate_metadata_native_getNativeName(name)
|
|
25
25
|
if _, ok := iterate_metadata_native_simples[name]; ok {
|
|
26
|
-
// Match the built-in only when the
|
|
27
|
-
//
|
|
28
|
-
//
|
|
29
|
-
//
|
|
30
|
-
//
|
|
31
|
-
|
|
26
|
+
// Match the built-in only when the checker resolves this exact symbol from
|
|
27
|
+
// the global type table *and* a runtime authority provides its constructor.
|
|
28
|
+
// A colliding package declaration then falls through to its structural
|
|
29
|
+
// members regardless of whether it was authored in `.ts` or published
|
|
30
|
+
// through `.d.ts` (#2239), and so does a purely user-authored global that
|
|
31
|
+
// merely wins the same global lookup (#2200). Node's authoritative Blob and
|
|
32
|
+
// File module exports are distinct symbols for the same runtime globals, so
|
|
33
|
+
// admit only their value-bearing exact core-module declaration shape as the
|
|
34
|
+
// second identity path (#1568).
|
|
35
|
+
if !metadata_symbol_is_runtime_native_type(props.Checker, symbol, name) {
|
|
32
36
|
return false
|
|
33
37
|
}
|
|
34
38
|
iterate_metadata_native_take(props.Metadata, name)
|
|
@@ -36,14 +40,9 @@ func Iterate_metadata_native(props IMetadataIteratorProps) bool {
|
|
|
36
40
|
}
|
|
37
41
|
for _, generic := range iterate_metadata_native_generics {
|
|
38
42
|
if name == generic.Name || strings.HasPrefix(name, generic.Name+"<") {
|
|
39
|
-
//
|
|
40
|
-
//
|
|
41
|
-
|
|
42
|
-
// user `interface WeakMap<K, V> { brandWeak }` in a `.ts` module falls
|
|
43
|
-
// through to the structural object path — the same identity gate the
|
|
44
|
-
// simples path above uses (#2200), applied to the collection generics the
|
|
45
|
-
// `+"<"` arity guard (#2181) alone left ungated (#2212).
|
|
46
|
-
if !metadata_symbol_from_declaration_file(symbol) {
|
|
43
|
+
// Use the same runtime-provenance identity gate for WeakMap/WeakSet. The
|
|
44
|
+
// `+"<"` arity guard (#2181) and generic metadata remain unchanged.
|
|
45
|
+
if !metadata_symbol_is_runtime_global_type(props.Checker, symbol, generic.Name) {
|
|
47
46
|
return false
|
|
48
47
|
}
|
|
49
48
|
iterate_metadata_native_take(props.Metadata, generic.Name)
|
|
@@ -69,6 +68,25 @@ func iterate_metadata_native_getNativeName(name string) string {
|
|
|
69
68
|
if index := strings.Index(name, "<"); index != -1 {
|
|
70
69
|
name = name[:index]
|
|
71
70
|
}
|
|
71
|
+
// `global.` is the qualifier `metadata_symbol_name` produces for a symbol
|
|
72
|
+
// declared inside a `declare global` block, which is how @types/node declares
|
|
73
|
+
// the bare `Blob` and `File` globals. A project that includes the DOM library
|
|
74
|
+
// never showed it, because the DOM declares those names at file scope and the
|
|
75
|
+
// DOM declaration won the name; drop the DOM library — an ordinary Node
|
|
76
|
+
// service compiled with `"lib": ["ES2022"]` — and the only declaration left is
|
|
77
|
+
// the augmented one, so the name arrives as `global.Blob` and this lookup
|
|
78
|
+
// misses before any identity question is asked. Stripping the qualifier only
|
|
79
|
+
// restores the question; whether the declaration is a runtime-provided native
|
|
80
|
+
// or a same-named user global stays the identity gate's answer to give.
|
|
81
|
+
//
|
|
82
|
+
// An ambient module's qualifier is deliberately not stripped here: a lookalike
|
|
83
|
+
// published as `declare module "user-buffer-lookalike"` arrives as
|
|
84
|
+
// `user-buffer-lookalike.Blob` and must keep failing this lookup.
|
|
85
|
+
for _, module := range []string{"node:buffer.", "buffer.", "global."} {
|
|
86
|
+
if strings.HasPrefix(name, module) {
|
|
87
|
+
return strings.TrimPrefix(name, module)
|
|
88
|
+
}
|
|
89
|
+
}
|
|
72
90
|
if strings.HasPrefix(name, "\"") && strings.Contains(name, "\".") {
|
|
73
91
|
if index := strings.Index(name[1:], "\"."); index != -1 {
|
|
74
92
|
name = name[index+3:]
|
|
@@ -10,13 +10,9 @@ func Iterate_metadata_set(props IMetadataIteratorProps) bool {
|
|
|
10
10
|
if metadata_type_symbol_base_name(typ) != "Set" {
|
|
11
11
|
return false
|
|
12
12
|
}
|
|
13
|
-
//
|
|
14
|
-
//
|
|
15
|
-
|
|
16
|
-
// `.ts` module falls through to the structural object path and is validated
|
|
17
|
-
// against its own members instead of `input instanceof Set` — the collection
|
|
18
|
-
// half of the #2200 identity gate (#2212).
|
|
19
|
-
if !metadata_symbol_from_declaration_file(typ.Symbol()) {
|
|
13
|
+
// The native Set is the runtime-provided global type, not any same-named
|
|
14
|
+
// package declaration or user-authored global (#2200, #2212, #2239).
|
|
15
|
+
if !metadata_symbol_is_runtime_global_type(props.Checker, typ.Symbol(), "Set") {
|
|
20
16
|
return false
|
|
21
17
|
}
|
|
22
18
|
generic := metadata_get_type_arguments(props.Checker, typ)
|