Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions internal/checker/checker.go
Original file line number Diff line number Diff line change
Expand Up @@ -7028,7 +7028,9 @@ func (c *Checker) getQuickTypeOfExpression(node *ast.Node) *Type {
if isCallChain(expr) {
return c.getReturnTypeOfSingleNonGenericSignatureOfCallChain(expr)
}
return c.getReturnTypeOfSingleNonGenericCallSignature(c.checkNonNullExpression(expr.Expression()))
return c.getReturnTypeOfSingleNonGenericSignature(c.checkNonNullExpression(expr.Expression()), SignatureKindCall)
case ast.IsNewExpression(expr):
return c.getReturnTypeOfSingleNonGenericSignature(c.checkNonNullExpression(expr.Expression()), SignatureKindConstruct)
case ast.IsAssertionExpression(expr) && !ast.IsConstTypeReference(expr.Type()):
return c.getTypeFromTypeNode(expr.Type())
case ast.IsLiteralExpression(node) || ast.IsBooleanLiteral(node):
Expand All @@ -7037,8 +7039,8 @@ func (c *Checker) getQuickTypeOfExpression(node *ast.Node) *Type {
return nil
}

func (c *Checker) getReturnTypeOfSingleNonGenericCallSignature(funcType *Type) *Type {
signature := c.getSingleCallSignature(funcType)
func (c *Checker) getReturnTypeOfSingleNonGenericSignature(funcType *Type, kind SignatureKind) *Type {
signature := c.getSingleSignature(funcType, kind, true /*allowMembers*/)
if signature != nil && len(signature.typeParameters) == 0 {
return c.getReturnTypeOfSignature(signature)
}
Expand All @@ -7048,7 +7050,7 @@ func (c *Checker) getReturnTypeOfSingleNonGenericCallSignature(funcType *Type) *
func (c *Checker) getReturnTypeOfSingleNonGenericSignatureOfCallChain(expr *ast.Node) *Type {
funcType := c.checkExpression(expr.Expression())
nonOptionalType := c.getOptionalExpressionType(funcType, expr.Expression())
returnType := c.getReturnTypeOfSingleNonGenericCallSignature(funcType)
returnType := c.getReturnTypeOfSingleNonGenericSignature(funcType, SignatureKindCall)
if returnType != nil {
return c.propagateOptionalTypeMarker(returnType, expr, nonOptionalType != funcType)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
>A : A

new A();
>new A() : any
>new A() : A
>A : typeof A

new B();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
--- old.abstractClassInLocalScopeIsAbstract.types
+++ new.abstractClassInLocalScopeIsAbstract.types
@@= skipped -13, +13 lines =@@
>A : A

new A();
->new A() : any
+>new A() : A
>A : typeof A

new B();
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ import A from "./a";
>A : typeof A

new A();
>new A() : any
>new A() : A
>A : typeof A

Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
--- old.newAbstractInstance2.types
+++ new.newAbstractInstance2.types
@@= skipped -8, +8 lines =@@
>A : typeof A

new A();
->new A() : any
+>new A() : A
>A : typeof A
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class CrashTrigger extends Mixin(Empty) {
>trigger : () => void

new Concrete();
>new Concrete() : any
>new Concrete() : Concrete
>Concrete : typeof Concrete
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,12 @@
+>Mixin : <TBase extends Constructor<{}>>(Base: TBase) => { new (...args: any[]): (Anonymous class); prototype: Mixin.(Anonymous class); } & TBase
>Empty : typeof Empty

public trigger() {
public trigger() {
>trigger : () => void

new Concrete();
->new Concrete() : any
+>new Concrete() : Concrete
>Concrete : typeof Concrete
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ new AA;
>AA : typeof A

new BB;
>new BB : any
>new BB : B
>BB : typeof B

new CC;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
--- old.classAbstractConstructorAssignability.types
+++ new.classAbstractConstructorAssignability.types
@@= skipped -31, +31 lines =@@
>AA : typeof A

new BB;
->new BB : any
+>new BB : B
>BB : typeof B

new CC;
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ function NewB(Factory: typeof B) {
>B : typeof B

return new B;
>new B : any
>new B : B
>B : typeof B
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
--- old.classAbstractFactoryFunction.types
+++ new.classAbstractFactoryFunction.types
@@= skipped -23, +23 lines =@@
>B : typeof B

return new B;
->new B : any
+>new B : B
>B : typeof B
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ module M {
>A : A

new A;
>new A : any
>new A : A
>A : typeof A
}

Expand All @@ -18,6 +18,6 @@ import myA = M.A;
>A : myA

new myA;
>new myA : any
>new myA : myA
>myA : typeof myA

Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
--- old.classAbstractImportInstantiation.types
+++ new.classAbstractImportInstantiation.types
@@= skipped -7, +7 lines =@@
>A : A

new A;
->new A : any
+>new A : A
>A : typeof A
}

@@= skipped -10, +10 lines =@@
>A : myA

new myA;
->new myA : any
+>new myA : myA
>myA : typeof myA
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ module M {
}

new M.A;
>new M.A : any
>new M.A : M.A
>M.A : typeof M.A
>M : typeof M
>A : typeof M.A
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
--- old.classAbstractInAModule.types
+++ new.classAbstractInAModule.types
@@= skipped -12, +12 lines =@@
}

new M.A;
->new M.A : any
+>new M.A : M.A
>M.A : typeof M.A
>M : typeof M
>A : typeof M.A
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ abstract class C extends B {}
>B : B

new A;
>new A : any
>new A : A
>A : typeof A

new A(1); // should report 1 error
>new A(1) : any
>new A(1) : A
>A : typeof A
>1 : 1

Expand All @@ -30,7 +30,7 @@ new B;
>B : typeof B

new C;
>new C : any
>new C : C
>C : typeof C

var a : A;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
--- old.classAbstractInstantiations1.types
+++ new.classAbstractInstantiations1.types
@@= skipped -16, +16 lines =@@
>B : B

new A;
->new A : any
+>new A : A
>A : typeof A

new A(1); // should report 1 error
->new A(1) : any
+>new A(1) : A
>A : typeof A
>1 : 1

@@= skipped -13, +13 lines =@@
>B : typeof B

new C;
->new C : any
+>new C : C
>C : typeof C

var a : A;
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ abstract class B {
}

new B; // error
>new B : any
>new B : B
>B : typeof B

var BB: typeof B = B;
Expand All @@ -45,7 +45,7 @@ function constructB(Factory : typeof B) {
>B : typeof B

new Factory; // error -- Factory is of type typeof B.
>new Factory : any
>new Factory : B
>Factory : typeof B
}

Expand All @@ -54,7 +54,7 @@ var BB = B;
>B : typeof B

new BB; // error -- BB is of type typeof B.
>new BB : any
>new BB : B
>BB : typeof B

var x : any = C;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
--- old.classAbstractInstantiations2.types
+++ new.classAbstractInstantiations2.types
@@= skipped -21, +21 lines =@@
}

new B; // error
->new B : any
+>new B : B
>B : typeof B

var BB: typeof B = B;
@@= skipped -23, +23 lines =@@
>B : typeof B

new Factory; // error -- Factory is of type typeof B.
->new Factory : any
+>new Factory : B
>Factory : typeof B
}

@@= skipped -9, +9 lines =@@
>B : typeof B

new BB; // error -- BB is of type typeof B.
->new BB : any
+>new BB : B
>BB : typeof B

var x : any = C;
Original file line number Diff line number Diff line change
Expand Up @@ -53,39 +53,39 @@ declare abstract class DCC2 {}
>DCC2 : DCC2

new CM;
>new CM : any
>new CM : CM
>CM : typeof CM

new MC;
>new MC : any
>new MC : MC
>MC : typeof MC

new CI;
>new CI : any
>new CI : CI
>CI : typeof CI

new IC;
>new IC : any
>new IC : IC
>IC : typeof IC

new CC1;
>new CC1 : any
>new CC1 : CC1
>CC1 : typeof CC1

new CC2;
>new CC2 : CC2
>CC2 : typeof CC2

new DCI;
>new DCI : any
>new DCI : DCI
>DCI : typeof DCI

new DIC;
>new DIC : any
>new DIC : DIC
>DIC : typeof DIC

new DCC1;
>new DCC1 : any
>new DCC1 : DCC1
>DCC1 : typeof DCC1

new DCC2;
Expand Down
Loading