MCPcopy Create free account
hub / github.com/microsoft/typescript-go / getConstituentTypeForKeyType

Method getConstituentTypeForKeyType

internal/checker/relater.go:1131–1137  ·  view source on GitHub ↗

Given a union type for which getKeyPropertyName returned a non-empty string, return the constituent that corresponds to the given key type for that property name.

(t *Type, keyType *Type)

Source from the content-addressed store, hash-verified

1129// Given a union type for which getKeyPropertyName returned a non-empty string, return the constituent
1130// that corresponds to the given key type for that property name.
1131func (c *Checker) getConstituentTypeForKeyType(t *Type, keyType *Type) *Type {
1132 result := t.AsUnionType().constituentMap[c.getRegularTypeOfLiteralType(keyType)]
1133 if result != c.unknownType {
1134 return result
1135 }
1136 return nil
1137}
1138
1139func (c *Checker) computeKeyPropertyNameAndMap(t *Type) (string, map[*Type]*Type) {
1140 types := t.Types()

Calls 2

AsUnionTypeMethod · 0.80

Tested by

no test coverage detected