Destructuring declaration prefers type annotation type (#25282)

* Destructuring declaration prefers type annotation type

Previously, getTypeForBindingElement would always union the declarations type and
the type of the default initializer. Now, if the declaration has a type
annotation, it does not union with the initializer type. The type
annotation's type is the one used.

* Small cleanup in parentDeclarationHasTypeAnnotation

* Refactoring based on PR comments

* Combine getCombined*Flags into a single helper function

Retain the individual functions since they are used a lot.

* Remove unneeded temp
This commit is contained in:
Nathan Shively-Sanders
2018-06-28 10:41:38 -07:00
committed by GitHub
parent 950593b669
commit 5c2eeb20b1
17 changed files with 328 additions and 55 deletions

View File

@@ -1044,7 +1044,7 @@ namespace ts {
}
export function getNodeModifiers(node: Node): string {
const flags = getCombinedModifierFlags(node);
const flags = isDeclaration(node) ? getCombinedModifierFlags(node) : ModifierFlags.None;
const result: string[] = [];
if (flags & ModifierFlags.Private) result.push(ScriptElementKindModifier.privateMemberModifier);