Skip to content

Commit 4a39972

Browse files
committed
Accept new baselines
1 parent d787239 commit 4a39972

9 files changed

+1216
-0
lines changed

tests/baselines/reference/api/tsserverlibrary.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4214,6 +4214,7 @@ declare namespace ts {
42144214
function isStringTextContainingNode(node: Node): node is StringLiteral | TemplateLiteralToken;
42154215
function isModifier(node: Node): node is Modifier;
42164216
function isEntityName(node: Node): node is EntityName;
4217+
function isEntityNameOrClassExpression(node: Node): node is EntityName;
42174218
function isPropertyName(node: Node): node is PropertyName;
42184219
function isBindingName(node: Node): node is BindingName;
42194220
function isFunctionLike(node: Node): node is SignatureDeclaration;

tests/baselines/reference/api/typescript.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4214,6 +4214,7 @@ declare namespace ts {
42144214
function isStringTextContainingNode(node: Node): node is StringLiteral | TemplateLiteralToken;
42154215
function isModifier(node: Node): node is Modifier;
42164216
function isEntityName(node: Node): node is EntityName;
4217+
function isEntityNameOrClassExpression(node: Node): node is EntityName;
42174218
function isPropertyName(node: Node): node is PropertyName;
42184219
function isBindingName(node: Node): node is BindingName;
42194220
function isFunctionLike(node: Node): node is SignatureDeclaration;

tests/baselines/reference/jsdocTypeTag.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,9 @@ var f;
6666

6767
/** @type {new (s: string) => { s: string }} */
6868
var ctor;
69+
70+
/** @type {typeof class { s: string; static n: number }} */
71+
var ctor2;
6972

7073
//// [b.ts]
7174
var S: string;
@@ -90,6 +93,7 @@ var obj: any;
9093
var Func: Function;
9194
var f: (s: string) => number;
9295
var ctor: new (s: string) => { s: string };
96+
var ctor2: typeof class { s: string; static n: number };
9397

9498

9599
//// [a.js]
@@ -137,6 +141,8 @@ var Func;
137141
var f;
138142
/** @type {new (s: string) => { s: string }} */
139143
var ctor;
144+
/** @type {typeof class { s: string; static n: number }} */
145+
var ctor2;
140146
//// [b.js]
141147
var S;
142148
var s;
@@ -160,3 +166,4 @@ var obj;
160166
var Func;
161167
var f;
162168
var ctor;
169+
var ctor2;

tests/baselines/reference/jsdocTypeTag.symbols

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,10 @@ var f;
8787
var ctor;
8888
>ctor : Symbol(ctor, Decl(a.js, 64, 3), Decl(b.ts, 21, 3))
8989

90+
/** @type {typeof class { s: string; static n: number }} */
91+
var ctor2;
92+
>ctor2 : Symbol(ctor2, Decl(a.js, 67, 3), Decl(b.ts, 22, 3))
93+
9094
=== tests/cases/conformance/jsdoc/b.ts ===
9195
var S: string;
9296
>S : Symbol(S, Decl(a.js, 1, 3), Decl(b.ts, 0, 3))
@@ -160,3 +164,8 @@ var ctor: new (s: string) => { s: string };
160164
>s : Symbol(s, Decl(b.ts, 21, 15))
161165
>s : Symbol(s, Decl(b.ts, 21, 30))
162166

167+
var ctor2: typeof class { s: string; static n: number };
168+
>ctor2 : Symbol(ctor2, Decl(a.js, 67, 3), Decl(b.ts, 22, 3))
169+
>s : Symbol((Anonymous class).s, Decl(b.ts, 22, 25))
170+
>n : Symbol((Anonymous class).n, Decl(b.ts, 22, 36))
171+

tests/baselines/reference/jsdocTypeTag.types

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,10 @@ var f;
8787
var ctor;
8888
>ctor : new (s: string) => { s: string; }
8989

90+
/** @type {typeof class { s: string; static n: number }} */
91+
var ctor2;
92+
>ctor2 : typeof (Anonymous class)
93+
9094
=== tests/cases/conformance/jsdoc/b.ts ===
9195
var S: string;
9296
>S : string
@@ -160,3 +164,9 @@ var ctor: new (s: string) => { s: string };
160164
>s : string
161165
>s : string
162166

167+
var ctor2: typeof class { s: string; static n: number };
168+
>ctor2 : typeof (Anonymous class)
169+
>class { s: string; static n: number } : typeof (Anonymous class)
170+
>s : string
171+
>n : number
172+
Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
tests/cases/conformance/types/specifyingTypes/typeQueries/typeofClassExpression1.ts(35,10): error TS2511: Cannot create an instance of an abstract class.
2+
3+
4+
==== tests/cases/conformance/types/specifyingTypes/typeQueries/typeofClassExpression1.ts (1 errors) ====
5+
type TC1 = typeof class {
6+
constructor(s: string);
7+
static n: number;
8+
s: string;
9+
}
10+
11+
declare let C1: TC1;
12+
C1.n;
13+
let c1 = new C1('hello');
14+
c1.s;
15+
16+
declare let C2: typeof class {
17+
constructor(s: string);
18+
static n: number;
19+
s: string;
20+
}
21+
C2.n;
22+
let c2 = new C2('hello');
23+
c2.s;
24+
25+
declare let C3: typeof class extends Error {
26+
constructor(s: string);
27+
static n: number;
28+
}
29+
C3.n;
30+
let c3 = new C3('hello');
31+
c3.message;
32+
33+
declare let C4: typeof abstract class {
34+
constructor(s: string);
35+
static n: number;
36+
s: string;
37+
}
38+
C4.n;
39+
let c4 = new C4('hello'); // Error
40+
~~~~~~~~~~~~~~~
41+
!!! error TS2511: Cannot create an instance of an abstract class.
42+
43+
declare let C5: typeof class<T> {
44+
constructor(x: T);
45+
x: T;
46+
}
47+
48+
let c51 = new C5('hello');
49+
c51.x;
50+
let c52 = new C5(42);
51+
c52.x;
52+
53+
type BoxFactory<T> = typeof class Box {
54+
static default: T;
55+
constructor(value?: T);
56+
value: T;
57+
}
58+
59+
declare let StringBox: BoxFactory<string>;
60+
StringBox.default;
61+
let sb = new StringBox('hello');
62+
sb.value;
63+
64+
declare let NumberBox: BoxFactory<number>;
65+
NumberBox.default;
66+
let nb = new NumberBox(42);
67+
nb.value;
68+
69+
declare const sb1: InstanceType<BoxFactory<string>>;
70+
sb1.value;
71+
72+
declare const nb1: InstanceType<BoxFactory<number>>;
73+
nb1.value;
74+
75+
function Printable1<T extends new (...args: any[]) => object>(Base: T) {
76+
return class extends Base {
77+
static foo: string;
78+
print() {}
79+
}
80+
}
81+
82+
declare function Printable2<T extends new (...args: any[]) => object>(Base: T): typeof class extends Base {
83+
static foo: string;
84+
print(): void;
85+
};
86+
87+
type PrintableMixin = typeof class {
88+
constructor(...args: any[]); // Indicates class is a mixin
89+
static foo: string;
90+
print(): void;
91+
};
92+
93+
declare function Printable3<T extends new (...args: any[]) => object, U>(Base: T): T & PrintableMixin;
94+
95+
declare function Printable4<T extends new (...args: any[]) => object>(Base: T): T & typeof class Printable {
96+
constructor(...args: any[]); // Indicates class is a mixin
97+
static foo: string;
98+
print(): void;
99+
};
100+
101+
class MyClass {
102+
static bar: number;
103+
x!: boolean;
104+
}
105+
106+
let PC1 = Printable1(MyClass);
107+
let pc1 = new PC1();
108+
pc1.x;
109+
pc1.print;
110+
111+
let PC2 = Printable2(MyClass);
112+
let pc2 = new PC2();
113+
pc2.x;
114+
pc2.print;
115+
116+
let PC3 = Printable3(MyClass);
117+
let pc3 = new PC3();
118+
pc3.x;
119+
pc3.print;
120+
121+
let PC4 = Printable4(MyClass);
122+
let pc4 = new PC4();
123+
pc4.x;
124+
pc4.print;
125+

0 commit comments

Comments
 (0)