- Notifications
You must be signed in to change notification settings - Fork13.2k
Use objects instead of closures for type mappers#36576
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Merged
Uh oh!
There was an error while loading.Please reload this page.
Merged
Changes from1 commit
Commits
Show all changes
11 commits Select commitHold shift + click to select a range
63338f9 Use objects instead of closures for type mappers
ahejlsberg979bc6a Flatten combined type mappers
ahejlsberg82cd7a1 Merge branch 'master' into typeMappersAsObjects
ahejlsberg8e6a2b1 Single point of creation for type mappers
ahejlsbergc7d3806 More optimizations
ahejlsberg163ba2f Fix lint error
ahejlsberg61f0c7a Fewer symbol instantiations / discard type mapper after instantiation
ahejlsberg50de2db More optimizations
ahejlsbergce9ddf3 Simplify mapper layout and cache in composite mappers
ahejlsberg30e7a18 Removing cache as it doesn't seem to matter much
ahejlsberg1cb54e1 Get rid of identityMapper
ahejlsbergFile filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
PrevPrevious commit
Get rid of identityMapper
- Loading branch information
Uh oh!
There was an error while loading.Please reload this page.
commit1cb54e1836f2438f4c84e4afcbdf25b3fd2b4ac3
There are no files selected for viewing
12 changes: 5 additions & 7 deletionssrc/compiler/checker.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -728,7 +728,6 @@ namespace ts { | ||
| const keyofConstraintType = keyofStringsOnly ? stringType : stringNumberSymbolType; | ||
| const numberOrBigIntType = getUnionType([numberType, bigintType]); | ||
| const restrictiveMapper: TypeMapper = makeFunctionTypeMapper(t => t.flags & TypeFlags.TypeParameter ? getRestrictiveTypeParameter(<TypeParameter>t) : t); | ||
amcasey marked this conversation as resolved. OutdatedShow resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
| const permissiveMapper: TypeMapper = makeFunctionTypeMapper(t => t.flags & TypeFlags.TypeParameter ? wildcardType : t); | ||
| @@ -9043,14 +9042,13 @@ namespace ts { | ||
| } | ||
| function resolveObjectTypeMembers(type: ObjectType, source: InterfaceTypeWithDeclaredMembers, typeParameters: readonly TypeParameter[], typeArguments: readonly Type[]) { | ||
| let mapper: TypeMapper | undefined; | ||
| let members: SymbolTable; | ||
| let callSignatures: readonly Signature[]; | ||
| let constructSignatures: readonly Signature[] | undefined; | ||
| let stringIndexInfo: IndexInfo | undefined; | ||
| let numberIndexInfo: IndexInfo | undefined; | ||
| if (rangeEquals(typeParameters, typeArguments, 0, typeParameters.length)) { | ||
| members = source.symbol ? getMembersOfSymbol(source.symbol) : createSymbolTable(source.declaredProperties); | ||
| callSignatures = source.declaredCallSignatures; | ||
| constructSignatures = source.declaredConstructSignatures; | ||
| @@ -9709,7 +9707,7 @@ namespace ts { | ||
| function getTemplateTypeFromMappedType(type: MappedType) { | ||
| return type.templateType || | ||
| (type.templateType = type.declaration.type ? | ||
| instantiateType(addOptionality(getTypeFromTypeNode(type.declaration.type), !!(getMappedTypeModifiers(type) & MappedTypeModifiers.IncludeOptional)), type.mapper) : | ||
| errorType); | ||
| } | ||
| @@ -9729,7 +9727,7 @@ namespace ts { | ||
| // If the constraint declaration is a 'keyof T' node, the modifiers type is T. We check | ||
| // AST nodes here because, when T is a non-generic type, the logic below eagerly resolves | ||
| // 'keyof T' to a literal union type and we can't recover T from that type. | ||
| type.modifiersType = instantiateType(getTypeFromTypeNode((<TypeOperatorNode>getConstraintDeclarationForMappedType(type)).type), type.mapper); | ||
| } | ||
| else { | ||
| // Otherwise, get the declared constraint type, and if the constraint type is a type parameter, | ||
| @@ -9738,7 +9736,7 @@ namespace ts { | ||
| const declaredType = <MappedType>getTypeFromMappedTypeNode(type.declaration); | ||
| const constraint = getConstraintTypeFromMappedType(declaredType); | ||
| const extendedConstraint = constraint && constraint.flags & TypeFlags.TypeParameter ? getConstraintOfTypeParameter(<TypeParameter>constraint) : constraint; | ||
| type.modifiersType = extendedConstraint && extendedConstraint.flags & TypeFlags.Index ? instantiateType((<IndexType>extendedConstraint).type, type.mapper) : unknownType; | ||
| } | ||
| } | ||
| return type.modifiersType; | ||
| @@ -13899,7 +13897,7 @@ namespace ts { | ||
| function instantiateType(type: Type, mapper: TypeMapper | undefined): Type; | ||
| function instantiateType(type: Type | undefined, mapper: TypeMapper | undefined): Type | undefined; | ||
| function instantiateType(type: Type | undefined, mapper: TypeMapper | undefined): Type | undefined { | ||
| if (!type || !mapper) { | ||
| return type; | ||
| } | ||
| if (instantiationDepth === 50 || instantiationCount >= 5000000) { | ||
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.