refactor(language-service): Create ng.CompletionEntry to replace ts.CompletionEntry (#33379)

It is messy to keep casting `CompletionEntry.kind` from
`ng.CompletionKind` to `ts.ScriptElementKind`.

Instead, create a new type `ng.CompletionEntry` that is exactly the same
as `ts.CompletionEntry`, but with the `kind` type overridden to
`ng.CompletionKind`.

This way, we only have to cast it once, and can do so in a safe manner.

PR Close #33379
This commit is contained in:
Keen Yee Liau
2019-10-24 11:35:03 -07:00
committed by Andrew Kushnir
parent b00189bb9a
commit 73530a9e25
3 changed files with 40 additions and 45 deletions

View File

@ -70,7 +70,8 @@ class LanguageServiceImpl implements LanguageService {
isGlobalCompletion: false,
isMemberCompletion: false,
isNewIdentifierLocation: false,
entries: results,
// Cast CompletionEntry.kind from ng.CompletionKind to ts.ScriptElementKind
entries: results as unknown as ts.CompletionEntry[],
};
}