-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Add fastpath to isRelatedTo for type references #37481
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
weswigham
merged 9 commits into
microsoft:master
from
weswigham:early-bails-prenormalize-for-isrelatedto
Apr 13, 2020
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
5d2149c
Add fastpath to isRelatedTo for type references
weswigham bdabb0f
Merge branch 'master' into early-bails-prenormalize-for-isrelatedto
weswigham ee0b7e2
Do not check intersections or unions to ignore propegating reference …
weswigham f393ac2
Re-remove unneeded check
weswigham fdc4e50
Just check for TypeFlags.Object
weswigham 46ca0b6
Merge branch 'master' into early-bails-prenormalize-for-isrelatedto
weswigham fe7125f
Merge branch 'master' into early-bails-prenormalize-for-isrelatedto
weswigham b3ee282
Remove else clause
weswigham 51aa162
Merge branch 'master' into early-bails-prenormalize-for-isrelatedto
weswigham 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
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,66 @@ | ||
//// [recursiveArrayNotCircular.ts] | ||
type Action<T, P> = P extends void ? { type : T } : { type: T, payload: P } | ||
|
||
enum ActionType { | ||
Foo, | ||
Bar, | ||
Baz, | ||
Batch | ||
} | ||
|
||
type ReducerAction = | ||
| Action<ActionType.Bar, number> | ||
| Action<ActionType.Baz, boolean> | ||
| Action<ActionType.Foo, string> | ||
| Action<ActionType.Batch, ReducerAction[]> | ||
|
||
function assertNever(a: never): never { | ||
throw new Error("Unreachable!"); | ||
} | ||
|
||
function reducer(action: ReducerAction): void { | ||
switch(action.type) { | ||
case ActionType.Bar: | ||
const x: number = action.payload; | ||
break; | ||
case ActionType.Baz: | ||
const y: boolean = action.payload; | ||
break; | ||
case ActionType.Foo: | ||
const z: string = action.payload; | ||
break; | ||
case ActionType.Batch: | ||
action.payload.map(reducer); | ||
break; | ||
default: return assertNever(action); | ||
} | ||
} | ||
|
||
//// [recursiveArrayNotCircular.js] | ||
var ActionType; | ||
(function (ActionType) { | ||
ActionType[ActionType["Foo"] = 0] = "Foo"; | ||
ActionType[ActionType["Bar"] = 1] = "Bar"; | ||
ActionType[ActionType["Baz"] = 2] = "Baz"; | ||
ActionType[ActionType["Batch"] = 3] = "Batch"; | ||
})(ActionType || (ActionType = {})); | ||
function assertNever(a) { | ||
throw new Error("Unreachable!"); | ||
} | ||
function reducer(action) { | ||
switch (action.type) { | ||
case ActionType.Bar: | ||
var x = action.payload; | ||
break; | ||
case ActionType.Baz: | ||
var y = action.payload; | ||
break; | ||
case ActionType.Foo: | ||
var z = action.payload; | ||
break; | ||
case ActionType.Batch: | ||
action.payload.map(reducer); | ||
break; | ||
default: return assertNever(action); | ||
} | ||
} |
126 changes: 126 additions & 0 deletions
126
tests/baselines/reference/recursiveArrayNotCircular.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,126 @@ | ||
=== tests/cases/compiler/recursiveArrayNotCircular.ts === | ||
type Action<T, P> = P extends void ? { type : T } : { type: T, payload: P } | ||
>Action : Symbol(Action, Decl(recursiveArrayNotCircular.ts, 0, 0)) | ||
>T : Symbol(T, Decl(recursiveArrayNotCircular.ts, 0, 12)) | ||
>P : Symbol(P, Decl(recursiveArrayNotCircular.ts, 0, 14)) | ||
>P : Symbol(P, Decl(recursiveArrayNotCircular.ts, 0, 14)) | ||
>type : Symbol(type, Decl(recursiveArrayNotCircular.ts, 0, 38)) | ||
>T : Symbol(T, Decl(recursiveArrayNotCircular.ts, 0, 12)) | ||
>type : Symbol(type, Decl(recursiveArrayNotCircular.ts, 0, 53)) | ||
>T : Symbol(T, Decl(recursiveArrayNotCircular.ts, 0, 12)) | ||
>payload : Symbol(payload, Decl(recursiveArrayNotCircular.ts, 0, 62)) | ||
>P : Symbol(P, Decl(recursiveArrayNotCircular.ts, 0, 14)) | ||
|
||
enum ActionType { | ||
>ActionType : Symbol(ActionType, Decl(recursiveArrayNotCircular.ts, 0, 75)) | ||
|
||
Foo, | ||
>Foo : Symbol(ActionType.Foo, Decl(recursiveArrayNotCircular.ts, 2, 17)) | ||
|
||
Bar, | ||
>Bar : Symbol(ActionType.Bar, Decl(recursiveArrayNotCircular.ts, 3, 8)) | ||
|
||
Baz, | ||
>Baz : Symbol(ActionType.Baz, Decl(recursiveArrayNotCircular.ts, 4, 8)) | ||
|
||
Batch | ||
>Batch : Symbol(ActionType.Batch, Decl(recursiveArrayNotCircular.ts, 5, 8)) | ||
} | ||
|
||
type ReducerAction = | ||
>ReducerAction : Symbol(ReducerAction, Decl(recursiveArrayNotCircular.ts, 7, 1)) | ||
|
||
| Action<ActionType.Bar, number> | ||
>Action : Symbol(Action, Decl(recursiveArrayNotCircular.ts, 0, 0)) | ||
>ActionType : Symbol(ActionType, Decl(recursiveArrayNotCircular.ts, 0, 75)) | ||
>Bar : Symbol(ActionType.Bar, Decl(recursiveArrayNotCircular.ts, 3, 8)) | ||
|
||
| Action<ActionType.Baz, boolean> | ||
>Action : Symbol(Action, Decl(recursiveArrayNotCircular.ts, 0, 0)) | ||
>ActionType : Symbol(ActionType, Decl(recursiveArrayNotCircular.ts, 0, 75)) | ||
>Baz : Symbol(ActionType.Baz, Decl(recursiveArrayNotCircular.ts, 4, 8)) | ||
|
||
| Action<ActionType.Foo, string> | ||
>Action : Symbol(Action, Decl(recursiveArrayNotCircular.ts, 0, 0)) | ||
>ActionType : Symbol(ActionType, Decl(recursiveArrayNotCircular.ts, 0, 75)) | ||
>Foo : Symbol(ActionType.Foo, Decl(recursiveArrayNotCircular.ts, 2, 17)) | ||
|
||
| Action<ActionType.Batch, ReducerAction[]> | ||
>Action : Symbol(Action, Decl(recursiveArrayNotCircular.ts, 0, 0)) | ||
>ActionType : Symbol(ActionType, Decl(recursiveArrayNotCircular.ts, 0, 75)) | ||
>Batch : Symbol(ActionType.Batch, Decl(recursiveArrayNotCircular.ts, 5, 8)) | ||
>ReducerAction : Symbol(ReducerAction, Decl(recursiveArrayNotCircular.ts, 7, 1)) | ||
|
||
function assertNever(a: never): never { | ||
>assertNever : Symbol(assertNever, Decl(recursiveArrayNotCircular.ts, 13, 45)) | ||
>a : Symbol(a, Decl(recursiveArrayNotCircular.ts, 15, 21)) | ||
|
||
throw new Error("Unreachable!"); | ||
>Error : Symbol(Error, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) | ||
} | ||
|
||
function reducer(action: ReducerAction): void { | ||
>reducer : Symbol(reducer, Decl(recursiveArrayNotCircular.ts, 17, 1)) | ||
>action : Symbol(action, Decl(recursiveArrayNotCircular.ts, 19, 17)) | ||
>ReducerAction : Symbol(ReducerAction, Decl(recursiveArrayNotCircular.ts, 7, 1)) | ||
|
||
switch(action.type) { | ||
>action.type : Symbol(type, Decl(recursiveArrayNotCircular.ts, 0, 53), Decl(recursiveArrayNotCircular.ts, 0, 53), Decl(recursiveArrayNotCircular.ts, 0, 53), Decl(recursiveArrayNotCircular.ts, 0, 53), Decl(recursiveArrayNotCircular.ts, 0, 53)) | ||
>action : Symbol(action, Decl(recursiveArrayNotCircular.ts, 19, 17)) | ||
>type : Symbol(type, Decl(recursiveArrayNotCircular.ts, 0, 53), Decl(recursiveArrayNotCircular.ts, 0, 53), Decl(recursiveArrayNotCircular.ts, 0, 53), Decl(recursiveArrayNotCircular.ts, 0, 53), Decl(recursiveArrayNotCircular.ts, 0, 53)) | ||
|
||
case ActionType.Bar: | ||
>ActionType.Bar : Symbol(ActionType.Bar, Decl(recursiveArrayNotCircular.ts, 3, 8)) | ||
>ActionType : Symbol(ActionType, Decl(recursiveArrayNotCircular.ts, 0, 75)) | ||
>Bar : Symbol(ActionType.Bar, Decl(recursiveArrayNotCircular.ts, 3, 8)) | ||
|
||
const x: number = action.payload; | ||
>x : Symbol(x, Decl(recursiveArrayNotCircular.ts, 22, 17)) | ||
>action.payload : Symbol(payload, Decl(recursiveArrayNotCircular.ts, 0, 62)) | ||
>action : Symbol(action, Decl(recursiveArrayNotCircular.ts, 19, 17)) | ||
>payload : Symbol(payload, Decl(recursiveArrayNotCircular.ts, 0, 62)) | ||
|
||
break; | ||
case ActionType.Baz: | ||
>ActionType.Baz : Symbol(ActionType.Baz, Decl(recursiveArrayNotCircular.ts, 4, 8)) | ||
>ActionType : Symbol(ActionType, Decl(recursiveArrayNotCircular.ts, 0, 75)) | ||
>Baz : Symbol(ActionType.Baz, Decl(recursiveArrayNotCircular.ts, 4, 8)) | ||
|
||
const y: boolean = action.payload; | ||
>y : Symbol(y, Decl(recursiveArrayNotCircular.ts, 25, 17)) | ||
>action.payload : Symbol(payload, Decl(recursiveArrayNotCircular.ts, 0, 62), Decl(recursiveArrayNotCircular.ts, 0, 62)) | ||
>action : Symbol(action, Decl(recursiveArrayNotCircular.ts, 19, 17)) | ||
>payload : Symbol(payload, Decl(recursiveArrayNotCircular.ts, 0, 62), Decl(recursiveArrayNotCircular.ts, 0, 62)) | ||
|
||
break; | ||
case ActionType.Foo: | ||
>ActionType.Foo : Symbol(ActionType.Foo, Decl(recursiveArrayNotCircular.ts, 2, 17)) | ||
>ActionType : Symbol(ActionType, Decl(recursiveArrayNotCircular.ts, 0, 75)) | ||
>Foo : Symbol(ActionType.Foo, Decl(recursiveArrayNotCircular.ts, 2, 17)) | ||
|
||
const z: string = action.payload; | ||
>z : Symbol(z, Decl(recursiveArrayNotCircular.ts, 28, 17)) | ||
>action.payload : Symbol(payload, Decl(recursiveArrayNotCircular.ts, 0, 62)) | ||
>action : Symbol(action, Decl(recursiveArrayNotCircular.ts, 19, 17)) | ||
>payload : Symbol(payload, Decl(recursiveArrayNotCircular.ts, 0, 62)) | ||
|
||
break; | ||
case ActionType.Batch: | ||
>ActionType.Batch : Symbol(ActionType.Batch, Decl(recursiveArrayNotCircular.ts, 5, 8)) | ||
>ActionType : Symbol(ActionType, Decl(recursiveArrayNotCircular.ts, 0, 75)) | ||
>Batch : Symbol(ActionType.Batch, Decl(recursiveArrayNotCircular.ts, 5, 8)) | ||
|
||
action.payload.map(reducer); | ||
>action.payload.map : Symbol(Array.map, Decl(lib.es5.d.ts, --, --)) | ||
>action.payload : Symbol(payload, Decl(recursiveArrayNotCircular.ts, 0, 62)) | ||
>action : Symbol(action, Decl(recursiveArrayNotCircular.ts, 19, 17)) | ||
>payload : Symbol(payload, Decl(recursiveArrayNotCircular.ts, 0, 62)) | ||
>map : Symbol(Array.map, Decl(lib.es5.d.ts, --, --)) | ||
>reducer : Symbol(reducer, Decl(recursiveArrayNotCircular.ts, 17, 1)) | ||
|
||
break; | ||
default: return assertNever(action); | ||
>assertNever : Symbol(assertNever, Decl(recursiveArrayNotCircular.ts, 13, 45)) | ||
>action : Symbol(action, Decl(recursiveArrayNotCircular.ts, 19, 17)) | ||
} | ||
} |
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.