MCPcopy Index your code
hub / github.com/nodejs/node / getModifiersTypeFromMappedType

Function getModifiersTypeFromMappedType

test/fixtures/snapshot/typescript.js:58658–58677  ·  view source on GitHub ↗
(type)

Source from the content-addressed store, hash-verified

58656 constraintDeclaration.operator === 140 /* SyntaxKind.KeyOfKeyword */;
58657 }
58658 function getModifiersTypeFromMappedType(type) {
58659 if (!type.modifiersType) {
58660 if (isMappedTypeWithKeyofConstraintDeclaration(type)) {
58661 // If the constraint declaration is a 'keyof T' node, the modifiers type is T. We check
58662 // AST nodes here because, when T is a non-generic type, the logic below eagerly resolves
58663 // 'keyof T' to a literal union type and we can't recover T from that type.
58664 type.modifiersType = instantiateType(getTypeFromTypeNode(getConstraintDeclarationForMappedType(type).type), type.mapper);
58665 }
58666 else {
58667 // Otherwise, get the declared constraint type, and if the constraint type is a type parameter,
58668 // get the constraint of that type parameter. If the resulting type is an indexed type 'keyof T',
58669 // the modifiers type is T. Otherwise, the modifiers type is unknown.
58670 var declaredType = getTypeFromMappedTypeNode(type.declaration);
58671 var constraint = getConstraintTypeFromMappedType(declaredType);
58672 var extendedConstraint = constraint && constraint.flags & 262144 /* TypeFlags.TypeParameter */ ? getConstraintOfTypeParameter(constraint) : constraint;
58673 type.modifiersType = extendedConstraint && extendedConstraint.flags & 4194304 /* TypeFlags.Index */ ? instantiateType(extendedConstraint.type, type.mapper) : unknownType;
58674 }
58675 }
58676 return type.modifiersType;
58677 }
58678 function getMappedTypeModifiers(type) {
58679 var declaration = type.declaration;
58680 return (declaration.readonlyToken ? declaration.readonlyToken.kind === 40 /* SyntaxKind.MinusToken */ ? 2 /* MappedTypeModifiers.ExcludeReadonly */ : 1 /* MappedTypeModifiers.IncludeReadonly */ : 0) |

Callers 5

resolveMappedTypeMembersFunction · 0.85
structuredTypeRelatedToFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…