Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
84 additions
and
1 deletion.
There are no files selected for viewing
68 changes: 68 additions & 0 deletions
68
tests/baselines/reference/newOperatorConformance.errors.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
tests/cases/conformance/expressions/newOperator/newOperatorConformance.ts(32,5): error TS2403: Subsequent variable declarations must have the same type. Variable 'c1' must be of type 'T<unknown>', but here has type 'T<{}>'. | ||
|
||
|
||
==== tests/cases/conformance/expressions/newOperator/newOperatorConformance.ts (1 errors) ==== | ||
class C0 { | ||
|
||
} | ||
class C1 { | ||
constructor(n: number, s: string) { } | ||
} | ||
|
||
class T<T> { | ||
constructor(n?: T) { } | ||
} | ||
|
||
var anyCtor: { | ||
new (): any; | ||
}; | ||
|
||
var anyCtor1: { | ||
new (n): any; | ||
}; | ||
|
||
interface nestedCtor { | ||
new (): nestedCtor; | ||
} | ||
var nestedCtor: nestedCtor; | ||
|
||
// Construct expression with no parentheses for construct signature with 0 parameters | ||
var a = new C0; | ||
var a: C0; | ||
|
||
|
||
// Generic construct expression with no parentheses | ||
var c1 = new T; | ||
var c1: T<{}>; | ||
~~ | ||
!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'c1' must be of type 'T<unknown>', but here has type 'T<{}>'. | ||
|
||
// Construct expression where constructor is of type 'any' with no parentheses | ||
var d = new anyCtor; | ||
var d: any; | ||
|
||
// Construct expression where constructor is of type 'any' with > 1 arg | ||
var d = new anyCtor1(undefined); | ||
|
||
// Construct expression of type where apparent type has a construct signature with 0 arguments | ||
function newFn1<T extends { new (): number }>(s: T) { | ||
var p = new s; | ||
var p: number; | ||
} | ||
|
||
// Construct expression of type where apparent type has a construct signature with 1 arguments | ||
function newFn2<T extends { new (s: number): string}>(s: T) { | ||
var p = new s(32); | ||
var p: string; | ||
} | ||
|
||
// Construct expression of void returning function | ||
function fnVoid(): void { } | ||
var t = new fnVoid(); | ||
var t: any; | ||
|
||
// Chained new expressions | ||
var nested = new (new (new nestedCtor())())(); | ||
var n = new nested(); | ||
var n = new nested(); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
tests/baselines/reference/wrappedAndRecursiveConstraints2.errors.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
tests/cases/conformance/types/typeParameters/typeArgumentLists/wrappedAndRecursiveConstraints2.ts(6,5): error TS2403: Subsequent variable declarations must have the same type. Variable 'c' must be of type 'C<number>', but here has type 'C<C<string>>'. | ||
|
||
|
||
==== tests/cases/conformance/types/typeParameters/typeArgumentLists/wrappedAndRecursiveConstraints2.ts (1 errors) ==== | ||
class C<T extends C<T>> { // error | ||
constructor(x: T) { } | ||
} | ||
|
||
var c = new C(1); | ||
var c = new C(new C('')); // error | ||
~ | ||
!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'c' must be of type 'C<number>', but here has type 'C<C<string>>'. |