@@ -2673,7 +2673,7 @@ namespace ts {
26732673 }
26742674 Debug.assert(bindingElement.kind === SyntaxKind.BindingElement);
26752675 if (bindingElement.propertyName) {
2676- writer.writeSymbol (getTextOfNode(bindingElement.propertyName), bindingElement.symbol );
2676+ writer.writeProperty (getTextOfNode(bindingElement.propertyName));
26772677 writePunctuation(writer, SyntaxKind.ColonToken);
26782678 writeSpace(writer);
26792679 }
@@ -6065,6 +6065,9 @@ namespace ts {
60656065 if (maybeTypeOfKind(indexType, TypeFlags.TypeVariable | TypeFlags.Index) ||
60666066 maybeTypeOfKind(objectType, TypeFlags.TypeVariable) && !(accessNode && accessNode.kind === SyntaxKind.ElementAccessExpression) ||
60676067 isGenericMappedType(objectType)) {
6068+ if (objectType.flags & TypeFlags.Any) {
6069+ return objectType;
6070+ }
60686071 // We first check that the index type is assignable to 'keyof T' for the object type.
60696072 if (accessNode) {
60706073 if (!isTypeAssignableTo(indexType, getIndexType(objectType))) {
@@ -10450,33 +10453,37 @@ namespace ts {
1045010453 return baseConstructorType === nullWideningType;
1045110454 }
1045210455
10456+ function checkThisBeforeSuper(node: Node, container: Node, diagnosticMessage: DiagnosticMessage) {
10457+ const containingClassDecl = <ClassDeclaration>container.parent;
10458+ const baseTypeNode = getClassExtendsHeritageClauseElement(containingClassDecl);
10459+
10460+ // If a containing class does not have extends clause or the class extends null
10461+ // skip checking whether super statement is called before "this" accessing.
10462+ if (baseTypeNode && !classDeclarationExtendsNull(containingClassDecl)) {
10463+ const superCall = getSuperCallInConstructor(<ConstructorDeclaration>container);
10464+
10465+ // We should give an error in the following cases:
10466+ // - No super-call
10467+ // - "this" is accessing before super-call.
10468+ // i.e super(this)
10469+ // this.x; super();
10470+ // We want to make sure that super-call is done before accessing "this" so that
10471+ // "this" is not accessed as a parameter of the super-call.
10472+ if (!superCall || superCall.end > node.pos) {
10473+ // In ES6, super inside constructor of class-declaration has to precede "this" accessing
10474+ error(node, diagnosticMessage);
10475+ }
10476+ }
10477+ }
10478+
1045310479 function checkThisExpression(node: Node): Type {
1045410480 // Stop at the first arrow function so that we can
1045510481 // tell whether 'this' needs to be captured.
1045610482 let container = getThisContainer(node, /* includeArrowFunctions */ true);
1045710483 let needToCaptureLexicalThis = false;
1045810484
1045910485 if (container.kind === SyntaxKind.Constructor) {
10460- const containingClassDecl = <ClassDeclaration>container.parent;
10461- const baseTypeNode = getClassExtendsHeritageClauseElement(containingClassDecl);
10462-
10463- // If a containing class does not have extends clause or the class extends null
10464- // skip checking whether super statement is called before "this" accessing.
10465- if (baseTypeNode && !classDeclarationExtendsNull(containingClassDecl)) {
10466- const superCall = getSuperCallInConstructor(<ConstructorDeclaration>container);
10467-
10468- // We should give an error in the following cases:
10469- // - No super-call
10470- // - "this" is accessing before super-call.
10471- // i.e super(this)
10472- // this.x; super();
10473- // We want to make sure that super-call is done before accessing "this" so that
10474- // "this" is not accessed as a parameter of the super-call.
10475- if (!superCall || superCall.end > node.pos) {
10476- // In ES6, super inside constructor of class-declaration has to precede "this" accessing
10477- error(node, Diagnostics.super_must_be_called_before_accessing_this_in_the_constructor_of_a_derived_class);
10478- }
10479- }
10486+ checkThisBeforeSuper(node, container, Diagnostics.super_must_be_called_before_accessing_this_in_the_constructor_of_a_derived_class);
1048010487 }
1048110488
1048210489 // Now skip arrow functions to get the "real" owner of 'this'.
@@ -10624,6 +10631,10 @@ namespace ts {
1062410631 return unknownType;
1062510632 }
1062610633
10634+ if (!isCallExpression && container.kind === SyntaxKind.Constructor) {
10635+ checkThisBeforeSuper(node, container, Diagnostics.super_must_be_called_before_accessing_a_property_of_super_in_the_constructor_of_a_derived_class);
10636+ }
10637+
1062710638 if ((getModifierFlags(container) & ModifierFlags.Static) || isCallExpression) {
1062810639 nodeCheckFlag = NodeCheckFlags.SuperStatic;
1062910640 }
@@ -13512,13 +13523,14 @@ namespace ts {
1351213523 const containingClass = getContainingClass(node);
1351313524 if (containingClass) {
1351413525 const containingType = getTypeOfNode(containingClass);
13515- const baseTypes = getBaseTypes(<InterfaceType> containingType);
13516- if (baseTypes.length) {
13526+ let baseTypes = getBaseTypes(containingType as InterfaceType );
13527+ while (baseTypes.length) {
1351713528 const baseType = baseTypes[0];
1351813529 if (modifiers & ModifierFlags.Protected &&
1351913530 baseType.symbol === declaration.parent.symbol) {
1352013531 return true;
1352113532 }
13533+ baseTypes = getBaseTypes(baseType as InterfaceType);
1352213534 }
1352313535 }
1352413536 if (modifiers & ModifierFlags.Private) {
@@ -16244,7 +16256,7 @@ namespace ts {
1624416256 return undefined;
1624516257 }
1624616258
16247- const onfulfilledParameterType = getTypeWithFacts(getUnionType(map(thenSignatures, getTypeOfFirstParameterOfSignature)), TypeFacts.NEUndefined );
16259+ const onfulfilledParameterType = getTypeWithFacts(getUnionType(map(thenSignatures, getTypeOfFirstParameterOfSignature)), TypeFacts.NEUndefinedOrNull );
1624816260 if (isTypeAny(onfulfilledParameterType)) {
1624916261 return undefined;
1625016262 }
0 commit comments