-
Notifications
You must be signed in to change notification settings - Fork 13.1k
Filtering mapped types declarations #51650
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
sandersn
merged 7 commits into
microsoft:main
from
Andarist:filtering-mapped-types-declarations
Feb 16, 2023
Merged
Changes from 4 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
6791d39
Add declarations to filtering mapped types
Andarist fde7b0a
update baselines
Andarist 7741604
Update tests/cases/fourslash/goToDefinition_filteringMappedType.ts
Andarist a1e5700
Add find all references test
Andarist 93f65ac
Merge remote-tracking branch 'origin/main' into filtering-mapped-type…
Andarist bf58389
Merge remote-tracking branch 'origin/main' into filtering-mapped-type…
Andarist 19e340b
Merge remote-tracking branch 'origin/main' into filtering-mapped-type…
Andarist 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
284 changes: 284 additions & 0 deletions
284
tests/baselines/reference/findAllReferencesFilteringMappedTypeProperty.baseline.jsonc
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,284 @@ | ||
| // === /tests/cases/fourslash/findAllReferencesFilteringMappedTypeProperty.ts === | ||
| // const obj = { /*FIND ALL REFS*/[|a|]: 1, b: 2 }; | ||
| // const filtered: { [P in keyof typeof obj as P extends 'b' ? never : P]: 0; } = { [|a|]: 0 }; | ||
| // filtered.[|a|]; | ||
|
|
||
| [ | ||
| { | ||
| "definition": { | ||
| "containerKind": "", | ||
| "containerName": "", | ||
| "fileName": "/tests/cases/fourslash/findAllReferencesFilteringMappedTypeProperty.ts", | ||
| "kind": "property", | ||
| "name": "(property) a: number", | ||
| "textSpan": { | ||
| "start": 14, | ||
| "length": 1 | ||
| }, | ||
| "displayParts": [ | ||
| { | ||
| "text": "(", | ||
| "kind": "punctuation" | ||
| }, | ||
| { | ||
| "text": "property", | ||
| "kind": "text" | ||
| }, | ||
| { | ||
| "text": ")", | ||
| "kind": "punctuation" | ||
| }, | ||
| { | ||
| "text": " ", | ||
| "kind": "space" | ||
| }, | ||
| { | ||
| "text": "a", | ||
| "kind": "propertyName" | ||
| }, | ||
| { | ||
| "text": ":", | ||
| "kind": "punctuation" | ||
| }, | ||
| { | ||
| "text": " ", | ||
| "kind": "space" | ||
| }, | ||
| { | ||
| "text": "number", | ||
| "kind": "keyword" | ||
| } | ||
| ], | ||
| "contextSpan": { | ||
| "start": 14, | ||
| "length": 4 | ||
| } | ||
| }, | ||
| "references": [ | ||
| { | ||
| "textSpan": { | ||
| "start": 14, | ||
| "length": 1 | ||
| }, | ||
| "fileName": "/tests/cases/fourslash/findAllReferencesFilteringMappedTypeProperty.ts", | ||
| "contextSpan": { | ||
| "start": 14, | ||
| "length": 4 | ||
| }, | ||
| "isWriteAccess": true, | ||
| "isDefinition": true | ||
| }, | ||
| { | ||
| "textSpan": { | ||
| "start": 109, | ||
| "length": 1 | ||
| }, | ||
| "fileName": "/tests/cases/fourslash/findAllReferencesFilteringMappedTypeProperty.ts", | ||
| "contextSpan": { | ||
| "start": 109, | ||
| "length": 4 | ||
| }, | ||
| "isWriteAccess": true, | ||
| "isDefinition": false | ||
| }, | ||
| { | ||
| "textSpan": { | ||
| "start": 126, | ||
| "length": 1 | ||
| }, | ||
| "fileName": "/tests/cases/fourslash/findAllReferencesFilteringMappedTypeProperty.ts", | ||
| "isWriteAccess": false, | ||
| "isDefinition": false | ||
| } | ||
| ] | ||
| } | ||
| ] | ||
|
|
||
| // === /tests/cases/fourslash/findAllReferencesFilteringMappedTypeProperty.ts === | ||
| // const obj = { [|a|]: 1, b: 2 }; | ||
| // const filtered: { [P in keyof typeof obj as P extends 'b' ? never : P]: 0; } = { /*FIND ALL REFS*/[|a|]: 0 }; | ||
| // filtered.[|a|]; | ||
|
|
||
| [ | ||
| { | ||
| "definition": { | ||
| "containerKind": "", | ||
| "containerName": "", | ||
| "fileName": "/tests/cases/fourslash/findAllReferencesFilteringMappedTypeProperty.ts", | ||
| "kind": "property", | ||
| "name": "(property) a: number", | ||
| "textSpan": { | ||
| "start": 14, | ||
| "length": 1 | ||
| }, | ||
| "displayParts": [ | ||
| { | ||
| "text": "(", | ||
| "kind": "punctuation" | ||
| }, | ||
| { | ||
| "text": "property", | ||
| "kind": "text" | ||
| }, | ||
| { | ||
| "text": ")", | ||
| "kind": "punctuation" | ||
| }, | ||
| { | ||
| "text": " ", | ||
| "kind": "space" | ||
| }, | ||
| { | ||
| "text": "a", | ||
| "kind": "propertyName" | ||
| }, | ||
| { | ||
| "text": ":", | ||
| "kind": "punctuation" | ||
| }, | ||
| { | ||
| "text": " ", | ||
| "kind": "space" | ||
| }, | ||
| { | ||
| "text": "number", | ||
| "kind": "keyword" | ||
| } | ||
| ], | ||
| "contextSpan": { | ||
| "start": 14, | ||
| "length": 4 | ||
| } | ||
| }, | ||
| "references": [ | ||
| { | ||
| "textSpan": { | ||
| "start": 14, | ||
| "length": 1 | ||
| }, | ||
| "fileName": "/tests/cases/fourslash/findAllReferencesFilteringMappedTypeProperty.ts", | ||
| "contextSpan": { | ||
| "start": 14, | ||
| "length": 4 | ||
| }, | ||
| "isWriteAccess": true, | ||
| "isDefinition": false | ||
| }, | ||
| { | ||
| "textSpan": { | ||
| "start": 109, | ||
| "length": 1 | ||
| }, | ||
| "fileName": "/tests/cases/fourslash/findAllReferencesFilteringMappedTypeProperty.ts", | ||
| "contextSpan": { | ||
| "start": 109, | ||
| "length": 4 | ||
| }, | ||
| "isWriteAccess": true, | ||
| "isDefinition": true | ||
| }, | ||
| { | ||
| "textSpan": { | ||
| "start": 126, | ||
| "length": 1 | ||
| }, | ||
| "fileName": "/tests/cases/fourslash/findAllReferencesFilteringMappedTypeProperty.ts", | ||
| "isWriteAccess": false, | ||
| "isDefinition": false | ||
| } | ||
| ] | ||
| } | ||
| ] | ||
|
|
||
| // === /tests/cases/fourslash/findAllReferencesFilteringMappedTypeProperty.ts === | ||
| // const obj = { [|a|]: 1, b: 2 }; | ||
| // const filtered: { [P in keyof typeof obj as P extends 'b' ? never : P]: 0; } = { [|a|]: 0 }; | ||
| // filtered./*FIND ALL REFS*/[|a|]; | ||
|
|
||
| [ | ||
| { | ||
| "definition": { | ||
| "containerKind": "", | ||
| "containerName": "", | ||
| "fileName": "/tests/cases/fourslash/findAllReferencesFilteringMappedTypeProperty.ts", | ||
| "kind": "property", | ||
| "name": "(property) a: number", | ||
| "textSpan": { | ||
| "start": 14, | ||
| "length": 1 | ||
| }, | ||
| "displayParts": [ | ||
| { | ||
| "text": "(", | ||
| "kind": "punctuation" | ||
| }, | ||
| { | ||
| "text": "property", | ||
| "kind": "text" | ||
| }, | ||
| { | ||
| "text": ")", | ||
| "kind": "punctuation" | ||
| }, | ||
| { | ||
| "text": " ", | ||
| "kind": "space" | ||
| }, | ||
| { | ||
| "text": "a", | ||
| "kind": "propertyName" | ||
| }, | ||
| { | ||
| "text": ":", | ||
| "kind": "punctuation" | ||
| }, | ||
| { | ||
| "text": " ", | ||
| "kind": "space" | ||
| }, | ||
| { | ||
| "text": "number", | ||
| "kind": "keyword" | ||
| } | ||
| ], | ||
| "contextSpan": { | ||
| "start": 14, | ||
| "length": 4 | ||
| } | ||
| }, | ||
| "references": [ | ||
| { | ||
| "textSpan": { | ||
| "start": 14, | ||
| "length": 1 | ||
| }, | ||
| "fileName": "/tests/cases/fourslash/findAllReferencesFilteringMappedTypeProperty.ts", | ||
| "contextSpan": { | ||
| "start": 14, | ||
| "length": 4 | ||
| }, | ||
| "isWriteAccess": true | ||
| }, | ||
| { | ||
| "textSpan": { | ||
| "start": 109, | ||
| "length": 1 | ||
| }, | ||
| "fileName": "/tests/cases/fourslash/findAllReferencesFilteringMappedTypeProperty.ts", | ||
| "contextSpan": { | ||
| "start": 109, | ||
| "length": 4 | ||
| }, | ||
| "isWriteAccess": true | ||
| }, | ||
| { | ||
| "textSpan": { | ||
| "start": 126, | ||
| "length": 1 | ||
| }, | ||
| "fileName": "/tests/cases/fourslash/findAllReferencesFilteringMappedTypeProperty.ts", | ||
| "isWriteAccess": false | ||
| } | ||
| ] | ||
| } | ||
| ] |
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.
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.
This seems like more work than the rest of the function does, so I'm worried about performance problems on mapped types with a nameType. I'll run the perf tests, but I don't know that any such mapped types are in there. @weswigham do you have an idea if this
isTypeAssignableTocall is likely to be (relatively) slow here?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.
Note that it's the same check that got used here:
https://github.com/microsoft/TypeScript/pull/48699/files#diff-d9ab6589e714c71e657f601cf30ff51dfc607fc98419bf72e04f6b0fa92cc4b8R15745
That said - that other PR calls this just from within
getSimplifiedIndexedAccessTypeand this is in theresolveMappedTypeMembersso the impact on the perf could still be different as it depends on how frequent are calls to those caller functions