Skip to content
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

fix(language-service): determine index types accessed using dot notation #33884

Closed

Conversation

@ayazhafiz
Copy link
Member

ayazhafiz commented Nov 17, 2019

Commit 53fc2ed added support for
determining index types accessed using index signatures, but did not
include support for index types accessed using dot notation:

const obj<T>: { [key: string]: T };
obj['stringKey']. // gets `T.` completions
obj.stringKey.    // did not peviously get `T.` completions

This adds support for determining an index type accessed via dot
notation by rigging an object's symbol table to return the string index
signature type a property access refers to, if that property does not
explicitly exist on the object. This is very similar to @ivanwonder's
work in #29811.

SymbolWrapper now takes an additional parameter to explicitly set the
type of the symbol wrapped. This is done because
SymbolTableWrapper#get only has access to the symbol of the index
type, not the index signature symbol itself. An attempt to get the
type of the index type will give an error.

Closes #29811
Closes angular/vscode-ng-language-service#126
Closes angular/vscode-ng-language-service#149

PR Checklist

Please check if your PR fulfills the following requirements:

Does this PR introduce a breaking change?

  • Yes
  • No
@ayazhafiz ayazhafiz requested a review from kyliau Nov 17, 2019
@ayazhafiz ayazhafiz requested a review from angular/tools-language-service as a code owner Nov 17, 2019
@ayazhafiz ayazhafiz self-assigned this Nov 17, 2019
@ngbot ngbot bot added this to the needsTriage milestone Nov 17, 2019
@googlebot googlebot added the cla: yes label Nov 17, 2019
@ngbot ngbot bot added this to the needsTriage milestone Nov 17, 2019
@ayazhafiz ayazhafiz requested a review from kyliau Nov 25, 2019
@kyliau
kyliau approved these changes Nov 25, 2019
@andrius-pra

This comment has been minimized.

Copy link
Contributor

andrius-pra commented Nov 26, 2019

@kyliau @ayazhafiz , would it be possible to change label to master & patch and also cherry-pick 53fc2ed into 9.0.x branch?

@kyliau

This comment has been minimized.

Copy link
Member

kyliau commented Nov 26, 2019

@kyliau @ayazhafiz , would it be possible to change label to master & patch and also cherry-pick 53fc2ed into 9.0.x branch?

Ah yes, this should target master & patch. Thank you for pointing that out!

@ayazhafiz Could you please submit a separate PR for 53fc2ed that targets patch-only?

@ayazhafiz

This comment has been minimized.

Copy link
Member Author

ayazhafiz commented Nov 26, 2019

sure!

ayazhafiz added 3 commits Nov 17, 2019
Commit 53fc2ed added support for
determining index types accessed using index signatures, but did not
include support for index types accessed using dot notation:

```typescript
const obj<T>: { [key: string]: T };
obj['stringKey']. // gets `T.` completions
obj.stringKey.    // did not peviously get `T.` completions
```

This adds support for determining an index type accessed via dot
notation by rigging an object's symbol table to return the string index
signature type a property access refers to, if that property does not
explicitly exist on the object. This is very similar to @ivanwonder's
work in #29811.

`SymbolWrapper` now takes an additional parameter to explicitly set the
type of the symbol wrapped. This is done because
`SymbolTableWrapper#get` only has access to the symbol of the index
type, _not_ the index signature symbol itself. An attempt to get the
type of the index type will give an error.

Closes #29811
Closes angular/vscode-ng-language-service#126
…t notation
…t notation
@ayazhafiz ayazhafiz force-pushed the ayazhafiz:fix/string-access-dot-notation branch from 0a74bc0 to 6b3080f Nov 26, 2019
@JounQin

This comment has been minimized.

Copy link

JounQin commented Nov 26, 2019

Finally!

mhevery added a commit that referenced this pull request Nov 27, 2019
…ion (#33884)

Commit 53fc2ed added support for
determining index types accessed using index signatures, but did not
include support for index types accessed using dot notation:

```typescript
const obj<T>: { [key: string]: T };
obj['stringKey']. // gets `T.` completions
obj.stringKey.    // did not peviously get `T.` completions
```

This adds support for determining an index type accessed via dot
notation by rigging an object's symbol table to return the string index
signature type a property access refers to, if that property does not
explicitly exist on the object. This is very similar to @ivanwonder's
work in #29811.

`SymbolWrapper` now takes an additional parameter to explicitly set the
type of the symbol wrapped. This is done because
`SymbolTableWrapper#get` only has access to the symbol of the index
type, _not_ the index signature symbol itself. An attempt to get the
type of the index type will give an error.

Closes #29811
Closes angular/vscode-ng-language-service#126

PR Close #33884
@mhevery mhevery closed this in 49804fe Nov 27, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.