-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Defer index types on remapping mapped types #55140
Defer index types on remapping mapped types #55140
Conversation
src/compiler/checker.ts
Outdated
@@ -38913,7 +38922,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { | |||
// Check if the index type is assignable to 'keyof T' for the object type. | |||
const objectType = (type as IndexedAccessType).objectType; | |||
const indexType = (type as IndexedAccessType).indexType; | |||
if (isTypeAssignableTo(indexType, getIndexType(objectType, IndexFlags.None))) { | |||
if (isTypeAssignableTo(indexType, getIndexType(objectType, IndexFlags.NoRemappingMappedTypeDeferral))) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I kinda expected that I would have to pass this at more locations. Given the fact that this is the only call site using this... maybe I just should remove this IndexFlags.NoRemappingMappedTypeDeferral
and perform the targeted simplification of keyof RemappingMappedType
here to pass it to the isTypeAssignableTo
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That would probably be better - IndexFlags
originally only existed to support the keyofStringsOnly
flag, and its' other uses have kind of become a convenience. With keyofStringsOnly
likely to go away soonish, it'd be nice if we could stop having all these quiet variant index types.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pushed out this change
src/compiler/checker.ts
Outdated
@@ -38913,7 +38922,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { | |||
// Check if the index type is assignable to 'keyof T' for the object type. | |||
const objectType = (type as IndexedAccessType).objectType; | |||
const indexType = (type as IndexedAccessType).indexType; | |||
if (isTypeAssignableTo(indexType, getIndexType(objectType, IndexFlags.None))) { | |||
if (isTypeAssignableTo(indexType, getIndexType(objectType, IndexFlags.NoRemappingMappedTypeDeferral))) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That would probably be better - IndexFlags
originally only existed to support the keyofStringsOnly
flag, and its' other uses have kind of become a convenience. With keyofStringsOnly
likely to go away soonish, it'd be nice if we could stop having all these quiet variant index types.
src/compiler/checker.ts
Outdated
const enum MappedTypeNameTypeKind { | ||
None = 0, | ||
Filtering = 1 << 0, | ||
Remapping = 1 << 1, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this a flags enum? I can't see anywhere we actually combine multiple flags - in fact, it seems to me like a mapped type can only be one, given the implementation of getMappedTypeNameTypeKind
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had some composite values here before but removed them at the end since I didn't actually use them anywhere. Refactored this now to be a non-flag enum
…-on-remapping-mapped-types
…-on-remapping-mapped-types
…-on-remapping-mapped-types
@typescript-bot test this |
Heya @weswigham, I've started to run the regular perf test suite on this PR at 9f95520. You can monitor the build here. Update: The results are in! |
Heya @weswigham, I've started to run the parallelized Definitely Typed test suite on this PR at 9f95520. You can monitor the build here. Update: The results are in! |
Heya @weswigham, I've started to run the diff-based top-repos suite on this PR at 9f95520. You can monitor the build here. Update: The results are in! |
@weswigham Here they are:
CompilerComparison Report - baseline..pr
System info unknown
Hosts
Scenarios
tsserverComparison Report - baseline..pr
System info unknown
Hosts
Scenarios
StartupComparison Report - baseline..pr
System info unknown
Hosts
Scenarios
Developer Information: |
@weswigham Here are the results of running the top-repos suite comparing Everything looks good! |
Hey @weswigham, it looks like the DT test run failed. Please check the log for more details. |
@typescript-bot run dt |
Heya @sandersn, I've started to run the parallelized Definitely Typed test suite on this PR at 847cb6d. You can monitor the build here. Update: The results are in! |
Hey @sandersn, the results of running the DT tests are ready. |
fixes #55129