Skip to content

Commit 30281ac

Browse files
committed
Add more tests
1 parent 905723d commit 30281ac

File tree

5 files changed

+63
-20
lines changed

5 files changed

+63
-20
lines changed

tests/baselines/reference/typeParameterConstModifiers.errors.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,12 +177,15 @@ typeParameterConstModifiers.ts(55,9): error TS1277: 'const' modifier can only ap
177177
fc2((a: string, b: number) => {}, "hello", 42);
178178

179179
declare function fd1<const T extends string[] | number[]>(args: T): T;
180-
declare function fd2<const T extends readonly string[] | readonly number[]>(args: T): T;
180+
declare function fd2<const T extends string[] | readonly number[]>(args: T): T;
181+
declare function fd3<const T extends readonly string[] | readonly number[]>(args: T): T;
181182

182183
fd1(["hello", "world"]);
183184
fd1([1, 2, 3]);
184185
fd2(["hello", "world"]);
185186
fd2([1, 2, 3]);
187+
fd3(["hello", "world"]);
188+
fd3([1, 2, 3]);
186189

187190
declare function fn1<const T extends { foo: unknown[] }[]>(...args: T): T;
188191

tests/baselines/reference/typeParameterConstModifiers.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,12 +171,15 @@ fc1((a: string, b: number) => {}, "hello", 42);
171171
fc2((a: string, b: number) => {}, "hello", 42);
172172

173173
declare function fd1<const T extends string[] | number[]>(args: T): T;
174-
declare function fd2<const T extends readonly string[] | readonly number[]>(args: T): T;
174+
declare function fd2<const T extends string[] | readonly number[]>(args: T): T;
175+
declare function fd3<const T extends readonly string[] | readonly number[]>(args: T): T;
175176

176177
fd1(["hello", "world"]);
177178
fd1([1, 2, 3]);
178179
fd2(["hello", "world"]);
179180
fd2([1, 2, 3]);
181+
fd3(["hello", "world"]);
182+
fd3([1, 2, 3]);
180183

181184
declare function fn1<const T extends { foo: unknown[] }[]>(...args: T): T;
182185

@@ -273,4 +276,6 @@ fd1(["hello", "world"]);
273276
fd1([1, 2, 3]);
274277
fd2(["hello", "world"]);
275278
fd2([1, 2, 3]);
279+
fd3(["hello", "world"]);
280+
fd3([1, 2, 3]);
276281
fn1({ foo: ["hello", 123] }, { foo: [true] });

tests/baselines/reference/typeParameterConstModifiers.symbols

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -569,13 +569,20 @@ declare function fd1<const T extends string[] | number[]>(args: T): T;
569569
>T : Symbol(T, Decl(typeParameterConstModifiers.ts, 169, 21))
570570
>T : Symbol(T, Decl(typeParameterConstModifiers.ts, 169, 21))
571571

572-
declare function fd2<const T extends readonly string[] | readonly number[]>(args: T): T;
572+
declare function fd2<const T extends string[] | readonly number[]>(args: T): T;
573573
>fd2 : Symbol(fd2, Decl(typeParameterConstModifiers.ts, 169, 70))
574574
>T : Symbol(T, Decl(typeParameterConstModifiers.ts, 170, 21))
575-
>args : Symbol(args, Decl(typeParameterConstModifiers.ts, 170, 76))
575+
>args : Symbol(args, Decl(typeParameterConstModifiers.ts, 170, 67))
576576
>T : Symbol(T, Decl(typeParameterConstModifiers.ts, 170, 21))
577577
>T : Symbol(T, Decl(typeParameterConstModifiers.ts, 170, 21))
578578

579+
declare function fd3<const T extends readonly string[] | readonly number[]>(args: T): T;
580+
>fd3 : Symbol(fd3, Decl(typeParameterConstModifiers.ts, 170, 79))
581+
>T : Symbol(T, Decl(typeParameterConstModifiers.ts, 171, 21))
582+
>args : Symbol(args, Decl(typeParameterConstModifiers.ts, 171, 76))
583+
>T : Symbol(T, Decl(typeParameterConstModifiers.ts, 171, 21))
584+
>T : Symbol(T, Decl(typeParameterConstModifiers.ts, 171, 21))
585+
579586
fd1(["hello", "world"]);
580587
>fd1 : Symbol(fd1, Decl(typeParameterConstModifiers.ts, 167, 47))
581588

@@ -588,16 +595,22 @@ fd2(["hello", "world"]);
588595
fd2([1, 2, 3]);
589596
>fd2 : Symbol(fd2, Decl(typeParameterConstModifiers.ts, 169, 70))
590597

598+
fd3(["hello", "world"]);
599+
>fd3 : Symbol(fd3, Decl(typeParameterConstModifiers.ts, 170, 79))
600+
601+
fd3([1, 2, 3]);
602+
>fd3 : Symbol(fd3, Decl(typeParameterConstModifiers.ts, 170, 79))
603+
591604
declare function fn1<const T extends { foo: unknown[] }[]>(...args: T): T;
592-
>fn1 : Symbol(fn1, Decl(typeParameterConstModifiers.ts, 175, 15))
593-
>T : Symbol(T, Decl(typeParameterConstModifiers.ts, 177, 21))
594-
>foo : Symbol(foo, Decl(typeParameterConstModifiers.ts, 177, 38))
595-
>args : Symbol(args, Decl(typeParameterConstModifiers.ts, 177, 59))
596-
>T : Symbol(T, Decl(typeParameterConstModifiers.ts, 177, 21))
597-
>T : Symbol(T, Decl(typeParameterConstModifiers.ts, 177, 21))
605+
>fn1 : Symbol(fn1, Decl(typeParameterConstModifiers.ts, 178, 15))
606+
>T : Symbol(T, Decl(typeParameterConstModifiers.ts, 180, 21))
607+
>foo : Symbol(foo, Decl(typeParameterConstModifiers.ts, 180, 38))
608+
>args : Symbol(args, Decl(typeParameterConstModifiers.ts, 180, 59))
609+
>T : Symbol(T, Decl(typeParameterConstModifiers.ts, 180, 21))
610+
>T : Symbol(T, Decl(typeParameterConstModifiers.ts, 180, 21))
598611

599612
fn1({ foo: ["hello", 123] }, { foo: [true]});
600-
>fn1 : Symbol(fn1, Decl(typeParameterConstModifiers.ts, 175, 15))
601-
>foo : Symbol(foo, Decl(typeParameterConstModifiers.ts, 179, 5))
602-
>foo : Symbol(foo, Decl(typeParameterConstModifiers.ts, 179, 30))
613+
>fn1 : Symbol(fn1, Decl(typeParameterConstModifiers.ts, 178, 15))
614+
>foo : Symbol(foo, Decl(typeParameterConstModifiers.ts, 182, 5))
615+
>foo : Symbol(foo, Decl(typeParameterConstModifiers.ts, 182, 30))
603616

tests/baselines/reference/typeParameterConstModifiers.types

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -637,8 +637,12 @@ declare function fd1<const T extends string[] | number[]>(args: T): T;
637637
>fd1 : <const T extends string[] | number[]>(args: T) => T
638638
>args : T
639639

640-
declare function fd2<const T extends readonly string[] | readonly number[]>(args: T): T;
641-
>fd2 : <const T extends readonly string[] | readonly number[]>(args: T) => T
640+
declare function fd2<const T extends string[] | readonly number[]>(args: T): T;
641+
>fd2 : <const T extends string[] | readonly number[]>(args: T) => T
642+
>args : T
643+
644+
declare function fd3<const T extends readonly string[] | readonly number[]>(args: T): T;
645+
>fd3 : <const T extends readonly string[] | readonly number[]>(args: T) => T
642646
>args : T
643647

644648
fd1(["hello", "world"]);
@@ -657,15 +661,30 @@ fd1([1, 2, 3]);
657661
>3 : 3
658662

659663
fd2(["hello", "world"]);
660-
>fd2(["hello", "world"]) : readonly ["hello", "world"]
661-
>fd2 : <const T extends readonly string[] | readonly number[]>(args: T) => T
664+
>fd2(["hello", "world"]) : ["hello", "world"]
665+
>fd2 : <const T extends string[] | readonly number[]>(args: T) => T
662666
>["hello", "world"] : ["hello", "world"]
663667
>"hello" : "hello"
664668
>"world" : "world"
665669

666670
fd2([1, 2, 3]);
667-
>fd2([1, 2, 3]) : readonly [1, 2, 3]
668-
>fd2 : <const T extends readonly string[] | readonly number[]>(args: T) => T
671+
>fd2([1, 2, 3]) : [1, 2, 3]
672+
>fd2 : <const T extends string[] | readonly number[]>(args: T) => T
673+
>[1, 2, 3] : [1, 2, 3]
674+
>1 : 1
675+
>2 : 2
676+
>3 : 3
677+
678+
fd3(["hello", "world"]);
679+
>fd3(["hello", "world"]) : readonly ["hello", "world"]
680+
>fd3 : <const T extends readonly string[] | readonly number[]>(args: T) => T
681+
>["hello", "world"] : ["hello", "world"]
682+
>"hello" : "hello"
683+
>"world" : "world"
684+
685+
fd3([1, 2, 3]);
686+
>fd3([1, 2, 3]) : readonly [1, 2, 3]
687+
>fd3 : <const T extends readonly string[] | readonly number[]>(args: T) => T
669688
>[1, 2, 3] : [1, 2, 3]
670689
>1 : 1
671690
>2 : 2

tests/cases/conformance/types/typeParameters/typeParameterLists/typeParameterConstModifiers.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,12 +170,15 @@ fc1((a: string, b: number) => {}, "hello", 42);
170170
fc2((a: string, b: number) => {}, "hello", 42);
171171

172172
declare function fd1<const T extends string[] | number[]>(args: T): T;
173-
declare function fd2<const T extends readonly string[] | readonly number[]>(args: T): T;
173+
declare function fd2<const T extends string[] | readonly number[]>(args: T): T;
174+
declare function fd3<const T extends readonly string[] | readonly number[]>(args: T): T;
174175

175176
fd1(["hello", "world"]);
176177
fd1([1, 2, 3]);
177178
fd2(["hello", "world"]);
178179
fd2([1, 2, 3]);
180+
fd3(["hello", "world"]);
181+
fd3([1, 2, 3]);
179182

180183
declare function fn1<const T extends { foo: unknown[] }[]>(...args: T): T;
181184

0 commit comments

Comments
 (0)