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/nested type 9.0.x patch #34047

Closed

Conversation

@ayazhafiz
Copy link
Member

ayazhafiz commented Nov 26, 2019

This PR patches 9.0.x with 53fc2ed.

ayazhafiz added 4 commits Nov 12, 2019
Previously, indexing a container type would not return completions for
the indexed type because for every TypeScript type, the recorded index
type was always marked as `undefined`, regardless of the index
signature.

This PR now returns the index type of TypeScript containers with numeric
or string index signatures. This allows use to generate completions for
arrays and defined index types:

```typescript
interface Container<T> {
  [key: string]: T;
}
const ctr: Container<T>;
ctr['stringKey']. // gives `T.` completions

const arr: T[];
arr[0]. // gives `T.` completions
```

Note that this does _not_ provide completions for properties indexed by
string literals, e.g.

```typescript
interface Container<T> {
  foo: T;
}
const ctr: Container<T>;
ctr['foo']. // does not give `T.` completions
```

Closes angular/vscode-ng-language-service#110
Closes angular/vscode-ng-language-service#277
@ayazhafiz ayazhafiz requested a review from kyliau Nov 26, 2019
@ayazhafiz ayazhafiz requested a review from angular/tools-language-service as a code owner Nov 26, 2019
@ayazhafiz ayazhafiz self-assigned this Nov 26, 2019
@ngbot ngbot bot modified the milestone: needsTriage Nov 26, 2019
@googlebot googlebot added the cla: yes label Nov 26, 2019
@kyliau
kyliau approved these changes Nov 26, 2019
matsko added a commit that referenced this pull request Nov 26, 2019
Previously, indexing a container type would not return completions for
the indexed type because for every TypeScript type, the recorded index
type was always marked as `undefined`, regardless of the index
signature.

This PR now returns the index type of TypeScript containers with numeric
or string index signatures. This allows use to generate completions for
arrays and defined index types:

```typescript
interface Container<T> {
  [key: string]: T;
}
const ctr: Container<T>;
ctr['stringKey']. // gives `T.` completions

const arr: T[];
arr[0]. // gives `T.` completions
```

Note that this does _not_ provide completions for properties indexed by
string literals, e.g.

```typescript
interface Container<T> {
  foo: T;
}
const ctr: Container<T>;
ctr['foo']. // does not give `T.` completions
```

Closes angular/vscode-ng-language-service#110
Closes angular/vscode-ng-language-service#277

PR Close #34047
@matsko

This comment has been minimized.

Copy link
Member

matsko commented Nov 26, 2019

Landed as 8a565c8

@matsko matsko closed this Nov 26, 2019
@matsko matsko reopened this Nov 26, 2019
@matsko matsko closed this Nov 26, 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.