-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Defer distributing index over generic object types #50540
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
Merged
ahejlsberg
merged 3 commits into
microsoft:main
from
Andarist:defer-distribution-index-over-object-type
Sep 1, 2022
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
77 changes: 77 additions & 0 deletions
77
tests/baselines/reference/nonNullableWithNullableGenericIndexedAccessArg.symbols
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 |
---|---|---|
@@ -0,0 +1,77 @@ | ||
=== tests/cases/compiler/nonNullableWithNullableGenericIndexedAccessArg.ts === | ||
// repro from #50539 | ||
|
||
interface StateSchema { | ||
>StateSchema : Symbol(StateSchema, Decl(nonNullableWithNullableGenericIndexedAccessArg.ts, 0, 0)) | ||
|
||
states?: { | ||
>states : Symbol(StateSchema.states, Decl(nonNullableWithNullableGenericIndexedAccessArg.ts, 2, 23)) | ||
|
||
[key: string]: StateSchema; | ||
>key : Symbol(key, Decl(nonNullableWithNullableGenericIndexedAccessArg.ts, 4, 5)) | ||
>StateSchema : Symbol(StateSchema, Decl(nonNullableWithNullableGenericIndexedAccessArg.ts, 0, 0)) | ||
|
||
}; | ||
} | ||
|
||
declare class StateNode<TStateSchema extends StateSchema> { | ||
>StateNode : Symbol(StateNode, Decl(nonNullableWithNullableGenericIndexedAccessArg.ts, 6, 1)) | ||
>TStateSchema : Symbol(TStateSchema, Decl(nonNullableWithNullableGenericIndexedAccessArg.ts, 8, 24)) | ||
>StateSchema : Symbol(StateSchema, Decl(nonNullableWithNullableGenericIndexedAccessArg.ts, 0, 0)) | ||
|
||
schema: TStateSchema; | ||
>schema : Symbol(StateNode.schema, Decl(nonNullableWithNullableGenericIndexedAccessArg.ts, 8, 59)) | ||
>TStateSchema : Symbol(TStateSchema, Decl(nonNullableWithNullableGenericIndexedAccessArg.ts, 8, 24)) | ||
} | ||
|
||
type StateNodesConfig<TStateSchema extends StateSchema> = { | ||
>StateNodesConfig : Symbol(StateNodesConfig, Decl(nonNullableWithNullableGenericIndexedAccessArg.ts, 10, 1)) | ||
>TStateSchema : Symbol(TStateSchema, Decl(nonNullableWithNullableGenericIndexedAccessArg.ts, 12, 22)) | ||
>StateSchema : Symbol(StateSchema, Decl(nonNullableWithNullableGenericIndexedAccessArg.ts, 0, 0)) | ||
|
||
[K in keyof TStateSchema["states"]]: StateNode<NonNullable<TStateSchema["states"]>[K]>; | ||
>K : Symbol(K, Decl(nonNullableWithNullableGenericIndexedAccessArg.ts, 13, 3)) | ||
>TStateSchema : Symbol(TStateSchema, Decl(nonNullableWithNullableGenericIndexedAccessArg.ts, 12, 22)) | ||
>StateNode : Symbol(StateNode, Decl(nonNullableWithNullableGenericIndexedAccessArg.ts, 6, 1)) | ||
>NonNullable : Symbol(NonNullable, Decl(lib.es5.d.ts, --, --)) | ||
>TStateSchema : Symbol(TStateSchema, Decl(nonNullableWithNullableGenericIndexedAccessArg.ts, 12, 22)) | ||
>K : Symbol(K, Decl(nonNullableWithNullableGenericIndexedAccessArg.ts, 13, 3)) | ||
|
||
}; | ||
|
||
// repro from #50539#issuecomment-1234067835 | ||
|
||
type Ordering<TOrderBy extends string> = { | ||
>Ordering : Symbol(Ordering, Decl(nonNullableWithNullableGenericIndexedAccessArg.ts, 14, 2)) | ||
>TOrderBy : Symbol(TOrderBy, Decl(nonNullableWithNullableGenericIndexedAccessArg.ts, 18, 14)) | ||
|
||
orderBy: TOrderBy | ||
>orderBy : Symbol(orderBy, Decl(nonNullableWithNullableGenericIndexedAccessArg.ts, 18, 42)) | ||
>TOrderBy : Symbol(TOrderBy, Decl(nonNullableWithNullableGenericIndexedAccessArg.ts, 18, 14)) | ||
} | ||
|
||
type Query<TOrderBy extends string> = { | ||
>Query : Symbol(Query, Decl(nonNullableWithNullableGenericIndexedAccessArg.ts, 20, 1)) | ||
>TOrderBy : Symbol(TOrderBy, Decl(nonNullableWithNullableGenericIndexedAccessArg.ts, 22, 11)) | ||
|
||
order?: Ordering<TOrderBy> | ||
>order : Symbol(order, Decl(nonNullableWithNullableGenericIndexedAccessArg.ts, 22, 39)) | ||
>Ordering : Symbol(Ordering, Decl(nonNullableWithNullableGenericIndexedAccessArg.ts, 14, 2)) | ||
>TOrderBy : Symbol(TOrderBy, Decl(nonNullableWithNullableGenericIndexedAccessArg.ts, 22, 11)) | ||
} | ||
|
||
type QueryHandler< | ||
>QueryHandler : Symbol(QueryHandler, Decl(nonNullableWithNullableGenericIndexedAccessArg.ts, 24, 1)) | ||
|
||
TQuery extends Query<TOrderBy>, | ||
>TQuery : Symbol(TQuery, Decl(nonNullableWithNullableGenericIndexedAccessArg.ts, 26, 18)) | ||
>Query : Symbol(Query, Decl(nonNullableWithNullableGenericIndexedAccessArg.ts, 20, 1)) | ||
>TOrderBy : Symbol(TOrderBy, Decl(nonNullableWithNullableGenericIndexedAccessArg.ts, 27, 35)) | ||
|
||
TOrderBy extends string = NonNullable<TQuery["order"]>["orderBy"] | ||
>TOrderBy : Symbol(TOrderBy, Decl(nonNullableWithNullableGenericIndexedAccessArg.ts, 27, 35)) | ||
>NonNullable : Symbol(NonNullable, Decl(lib.es5.d.ts, --, --)) | ||
>TQuery : Symbol(TQuery, Decl(nonNullableWithNullableGenericIndexedAccessArg.ts, 26, 18)) | ||
|
||
> = {} | ||
|
49 changes: 49 additions & 0 deletions
49
tests/baselines/reference/nonNullableWithNullableGenericIndexedAccessArg.types
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 |
---|---|---|
@@ -0,0 +1,49 @@ | ||
=== tests/cases/compiler/nonNullableWithNullableGenericIndexedAccessArg.ts === | ||
// repro from #50539 | ||
|
||
interface StateSchema { | ||
states?: { | ||
>states : { [key: string]: StateSchema; } | undefined | ||
|
||
[key: string]: StateSchema; | ||
>key : string | ||
|
||
}; | ||
} | ||
|
||
declare class StateNode<TStateSchema extends StateSchema> { | ||
>StateNode : StateNode<TStateSchema> | ||
|
||
schema: TStateSchema; | ||
>schema : TStateSchema | ||
} | ||
|
||
type StateNodesConfig<TStateSchema extends StateSchema> = { | ||
>StateNodesConfig : StateNodesConfig<TStateSchema> | ||
|
||
[K in keyof TStateSchema["states"]]: StateNode<NonNullable<TStateSchema["states"]>[K]>; | ||
}; | ||
|
||
// repro from #50539#issuecomment-1234067835 | ||
|
||
type Ordering<TOrderBy extends string> = { | ||
>Ordering : Ordering<TOrderBy> | ||
|
||
orderBy: TOrderBy | ||
>orderBy : TOrderBy | ||
} | ||
|
||
type Query<TOrderBy extends string> = { | ||
>Query : Query<TOrderBy> | ||
|
||
order?: Ordering<TOrderBy> | ||
>order : Ordering<TOrderBy> | undefined | ||
} | ||
|
||
type QueryHandler< | ||
>QueryHandler : QueryHandler<TQuery, TOrderBy> | ||
|
||
TQuery extends Query<TOrderBy>, | ||
TOrderBy extends string = NonNullable<TQuery["order"]>["orderBy"] | ||
> = {} | ||
|
33 changes: 33 additions & 0 deletions
33
tests/cases/compiler/nonNullableWithNullableGenericIndexedAccessArg.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 |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// @noEmit: true | ||
// @strict: true | ||
|
||
// repro from #50539 | ||
|
||
interface StateSchema { | ||
states?: { | ||
[key: string]: StateSchema; | ||
}; | ||
} | ||
|
||
declare class StateNode<TStateSchema extends StateSchema> { | ||
schema: TStateSchema; | ||
} | ||
|
||
type StateNodesConfig<TStateSchema extends StateSchema> = { | ||
[K in keyof TStateSchema["states"]]: StateNode<NonNullable<TStateSchema["states"]>[K]>; | ||
}; | ||
|
||
// repro from #50539#issuecomment-1234067835 | ||
|
||
type Ordering<TOrderBy extends string> = { | ||
orderBy: TOrderBy | ||
} | ||
|
||
type Query<TOrderBy extends string> = { | ||
order?: Ordering<TOrderBy> | ||
} | ||
|
||
type QueryHandler< | ||
TQuery extends Query<TOrderBy>, | ||
TOrderBy extends string = NonNullable<TQuery["order"]>["orderBy"] | ||
> = {} |
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.
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.
Change the following line to:
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'm concerned that
shouldDeferIndexType
will also do (possibly expensive) work for union types, so I'd prefer only deferring for intersection types.