@@ -437,39 +437,39 @@ type TypeFlags uint32
437437// conditional types should sort last as those types are potentially recursive and possibly infinite.
438438
439439const (
440- TypeFlagsNone TypeFlags = 0
441- TypeFlagsAny TypeFlags = 1 << 0
442- TypeFlagsUnknown TypeFlags = 1 << 1
443- TypeFlagsUndefined TypeFlags = 1 << 2
444- TypeFlagsNull TypeFlags = 1 << 3
445- TypeFlagsVoid TypeFlags = 1 << 4
446- TypeFlagsString TypeFlags = 1 << 5
447- TypeFlagsNumber TypeFlags = 1 << 6
448- TypeFlagsBigInt TypeFlags = 1 << 7
449- TypeFlagsBoolean TypeFlags = 1 << 8
450- TypeFlagsESSymbol TypeFlags = 1 << 9 // Type of symbol primitive introduced in ES6
451- TypeFlagsStringLiteral TypeFlags = 1 << 10
452- TypeFlagsNumberLiteral TypeFlags = 1 << 11
453- TypeFlagsBigIntLiteral TypeFlags = 1 << 12
454- TypeFlagsBooleanLiteral TypeFlags = 1 << 13
455- TypeFlagsUniqueESSymbol TypeFlags = 1 << 14 // unique symbol
456- TypeFlagsEnumLiteral TypeFlags = 1 << 15 // Always combined with StringLiteral, NumberLiteral, or Union
457- TypeFlagsEnum TypeFlags = 1 << 16 // Numeric computed enum member value (must be right after EnumLiteral, see getSortOrderFlags)
458- TypeFlagsNonPrimitive TypeFlags = 1 << 17 // intrinsic object type
459- TypeFlagsNever TypeFlags = 1 << 18 // Never type
460- TypeFlagsTypeParameter TypeFlags = 1 << 19 // Type parameter
461- TypeFlagsObject TypeFlags = 1 << 20 // Object type
462- TypeFlagsIndex TypeFlags = 1 << 21 // keyof T
463- TypeFlagsTemplateLiteral TypeFlags = 1 << 22 // Template literal type
464- TypeFlagsStringMapping TypeFlags = 1 << 23 // Uppercase/Lowercase type
465- TypeFlagsSubstitution TypeFlags = 1 << 24 // Type parameter substitution
466- TypeFlagsIndexedAccess TypeFlags = 1 << 25 // T[K]
467- TypeFlagsConditional TypeFlags = 1 << 26 // T extends U ? X : Y
468- TypeFlagsUnion TypeFlags = 1 << 27 // Union (T | U)
469- TypeFlagsIntersection TypeFlags = 1 << 28 // Intersection (T & U)
470- TypeFlagsReserved1 TypeFlags = 1 << 29 // Used by union/intersection type construction
471- TypeFlagsReserved2 TypeFlags = 1 << 30 // Used by union/intersection type construction
472- TypeFlagsReserved3 TypeFlags = 1 << 31
440+ TypeFlagsNone TypeFlags = 0
441+ TypeFlagsAny TypeFlags = 1 << 0
442+ TypeFlagsUnknown TypeFlags = 1 << 1
443+ TypeFlagsUndefined TypeFlags = 1 << 2
444+ TypeFlagsNull TypeFlags = 1 << 3
445+ TypeFlagsVoid TypeFlags = 1 << 4
446+ TypeFlagsString TypeFlags = 1 << 5
447+ TypeFlagsNumber TypeFlags = 1 << 6
448+ TypeFlagsBigInt TypeFlags = 1 << 7
449+ TypeFlagsBoolean TypeFlags = 1 << 8
450+ TypeFlagsESSymbol TypeFlags = 1 << 9 // Type of symbol primitive introduced in ES6
451+ TypeFlagsStringLiteral TypeFlags = 1 << 10
452+ TypeFlagsNumberLiteral TypeFlags = 1 << 11
453+ TypeFlagsBigIntLiteral TypeFlags = 1 << 12
454+ TypeFlagsBooleanLiteral TypeFlags = 1 << 13
455+ TypeFlagsUniqueESSymbol TypeFlags = 1 << 14 // unique symbol
456+ TypeFlagsEnumLiteral TypeFlags = 1 << 15 // Always combined with StringLiteral, NumberLiteral, or Union
457+ TypeFlagsEnum TypeFlags = 1 << 16 // Numeric computed enum member value (must be right after EnumLiteral, see getSortOrderFlags)
458+ TypeFlagsNonPrimitive TypeFlags = 1 << 17 // intrinsic object type
459+ TypeFlagsNever TypeFlags = 1 << 18 // Never type
460+ TypeFlagsTypeParameter TypeFlags = 1 << 19 // Type parameter
461+ TypeFlagsObject TypeFlags = 1 << 20 // Object type
462+ TypeFlagsIndex TypeFlags = 1 << 21 // keyof T
463+ TypeFlagsTemplateLiteral TypeFlags = 1 << 22 // Template literal type
464+ TypeFlagsStringMapping TypeFlags = 1 << 23 // Uppercase/Lowercase type
465+ TypeFlagsSubstitution TypeFlags = 1 << 24 // Type parameter substitution
466+ TypeFlagsIndexedAccess TypeFlags = 1 << 25 // T[K]
467+ TypeFlagsConditional TypeFlags = 1 << 26 // T extends U ? X : Y
468+ TypeFlagsUnion TypeFlags = 1 << 27 // Union (T | U)
469+ TypeFlagsIntersection TypeFlags = 1 << 28 // Intersection (T & U)
470+ TypeFlagsReserved1 TypeFlags = 1 << 29 // Used by union/intersection type construction
471+ TypeFlagsReserved2 TypeFlags = 1 << 30 // Used by union/intersection type construction
472+ TypeFlagsRegisteredESSymbol TypeFlags = 1 << 31 // RegisteredSymbol<K> with an unresolved key
473473
474474 TypeFlagsAnyOrUnknown = TypeFlagsAny | TypeFlagsUnknown
475475 TypeFlagsNullable = TypeFlagsUndefined | TypeFlagsNull
@@ -486,7 +486,7 @@ const (
486486 TypeFlagsBigIntLike = TypeFlagsBigInt | TypeFlagsBigIntLiteral
487487 TypeFlagsBooleanLike = TypeFlagsBoolean | TypeFlagsBooleanLiteral
488488 TypeFlagsEnumLike = TypeFlagsEnum | TypeFlagsEnumLiteral
489- TypeFlagsESSymbolLike = TypeFlagsESSymbol | TypeFlagsUniqueESSymbol
489+ TypeFlagsESSymbolLike = TypeFlagsESSymbol | TypeFlagsUniqueESSymbol | TypeFlagsRegisteredESSymbol
490490 TypeFlagsVoidLike = TypeFlagsVoid | TypeFlagsUndefined
491491 TypeFlagsPrimitive = TypeFlagsStringLike | TypeFlagsNumberLike | TypeFlagsBigIntLike | TypeFlagsBooleanLike | TypeFlagsEnumLike | TypeFlagsESSymbolLike | TypeFlagsVoidLike | TypeFlagsNull
492492 TypeFlagsDefinitelyNonNullable = TypeFlagsStringLike | TypeFlagsNumberLike | TypeFlagsBigIntLike | TypeFlagsBooleanLike | TypeFlagsEnumLike | TypeFlagsESSymbolLike | TypeFlagsObject | TypeFlagsNonPrimitive
@@ -495,7 +495,7 @@ const (
495495 TypeFlagsStructuredType = TypeFlagsObject | TypeFlagsUnion | TypeFlagsIntersection
496496 TypeFlagsTypeVariable = TypeFlagsTypeParameter | TypeFlagsIndexedAccess
497497 TypeFlagsInstantiableNonPrimitive = TypeFlagsTypeVariable | TypeFlagsConditional | TypeFlagsSubstitution
498- TypeFlagsInstantiablePrimitive = TypeFlagsIndex | TypeFlagsTemplateLiteral | TypeFlagsStringMapping
498+ TypeFlagsInstantiablePrimitive = TypeFlagsIndex | TypeFlagsTemplateLiteral | TypeFlagsStringMapping | TypeFlagsRegisteredESSymbol
499499 TypeFlagsInstantiable = TypeFlagsInstantiableNonPrimitive | TypeFlagsInstantiablePrimitive
500500 TypeFlagsStructuredOrInstantiable = TypeFlagsStructuredType | TypeFlagsInstantiable
501501 TypeFlagsObjectFlagsType = TypeFlagsAny | TypeFlagsNullable | TypeFlagsNever | TypeFlagsObject | TypeFlagsUnion | TypeFlagsIntersection
@@ -505,7 +505,7 @@ const (
505505 // This *should* be every type other than null, undefined, void, and never
506506 TypeFlagsNarrowable = TypeFlagsAny | TypeFlagsUnknown | TypeFlagsStructuredOrInstantiable | TypeFlagsStringLike | TypeFlagsNumberLike | TypeFlagsBigIntLike | TypeFlagsBooleanLike | TypeFlagsESSymbol | TypeFlagsUniqueESSymbol | TypeFlagsNonPrimitive
507507 // The following flags are aggregated during union and intersection type construction
508- TypeFlagsIncludesMask = TypeFlagsAny | TypeFlagsUnknown | TypeFlagsPrimitive | TypeFlagsNever | TypeFlagsObject | TypeFlagsUnion | TypeFlagsIntersection | TypeFlagsNonPrimitive | TypeFlagsTemplateLiteral | TypeFlagsStringMapping
508+ TypeFlagsIncludesMask = TypeFlagsAny | TypeFlagsUnknown | TypeFlagsPrimitive | TypeFlagsNever | TypeFlagsObject | TypeFlagsUnion | TypeFlagsIntersection | TypeFlagsNonPrimitive | TypeFlagsTemplateLiteral | TypeFlagsStringMapping | TypeFlagsRegisteredESSymbol
509509 // The following flags are used for different purposes during union and intersection type construction
510510 TypeFlagsIncludesMissingType = TypeFlagsTypeParameter
511511 TypeFlagsIncludesNonWideningType = TypeFlagsIndex
@@ -545,6 +545,7 @@ var typeFlagNames = [...]struct {
545545 {TypeFlagsIndex , "Index" },
546546 {TypeFlagsTemplateLiteral , "TemplateLiteral" },
547547 {TypeFlagsStringMapping , "StringMapping" },
548+ {TypeFlagsRegisteredESSymbol , "RegisteredESSymbol" },
548549 {TypeFlagsSubstitution , "Substitution" },
549550 {TypeFlagsIndexedAccess , "IndexedAccess" },
550551 {TypeFlagsConditional , "Conditional" },
@@ -724,8 +725,11 @@ func (t *Type) AsIndexType() *IndexType { return t.data.(*In
724725func (t * Type ) AsIndexedAccessType () * IndexedAccessType { return t .data .(* IndexedAccessType ) }
725726func (t * Type ) AsTemplateLiteralType () * TemplateLiteralType { return t .data .(* TemplateLiteralType ) }
726727func (t * Type ) AsStringMappingType () * StringMappingType { return t .data .(* StringMappingType ) }
727- func (t * Type ) AsSubstitutionType () * SubstitutionType { return t .data .(* SubstitutionType ) }
728- func (t * Type ) AsConditionalType () * ConditionalType { return t .data .(* ConditionalType ) }
728+ func (t * Type ) AsRegisteredESSymbolType () * RegisteredESSymbolType {
729+ return t .data .(* RegisteredESSymbolType )
730+ }
731+ func (t * Type ) AsSubstitutionType () * SubstitutionType { return t .data .(* SubstitutionType ) }
732+ func (t * Type ) AsConditionalType () * ConditionalType { return t .data .(* ConditionalType ) }
729733
730734// Casts for embedded struct types
731735
@@ -760,6 +764,8 @@ func (t *Type) Target() *Type {
760764 return t .AsIndexType ().target
761765 case t .flags & TypeFlagsStringMapping != 0 :
762766 return t .AsStringMappingType ().target
767+ case t .flags & TypeFlagsRegisteredESSymbol != 0 :
768+ return t .AsRegisteredESSymbolType ().target
763769 case t .flags & TypeFlagsObject != 0 && t .objectFlags & ObjectFlagsMapped != 0 :
764770 return t .AsMappedType ().target
765771 }
@@ -1247,6 +1253,11 @@ type StringMappingType struct {
12471253
12481254func (t * StringMappingType ) Target () * Type { return t .target }
12491255
1256+ type RegisteredESSymbolType struct {
1257+ ConstrainedType
1258+ target * Type
1259+ }
1260+
12501261type SubstitutionType struct {
12511262 ConstrainedType
12521263 baseType * Type // Target type
0 commit comments