Skip to content

Commit f1104cc

Browse files
committed
Add more tests
1 parent 52fe112 commit f1104cc

File tree

5 files changed

+99
-7
lines changed

5 files changed

+99
-7
lines changed

tests/baselines/reference/typeParameterConstModifiers.errors.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,14 @@ typeParameterConstModifiers.ts(55,9): error TS1277: 'const' modifier can only ap
176176
fc1((a: string, b: number) => {}, "hello", 42);
177177
fc2((a: string, b: number) => {}, "hello", 42);
178178

179+
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;
181+
182+
fd1(["hello", "world"]);
183+
fd1([1, 2, 3]);
184+
fd2(["hello", "world"]);
185+
fd2([1, 2, 3]);
186+
179187
declare function fn1<const T extends { foo: unknown[] }[]>(...args: T): T;
180188

181189
fn1({ foo: ["hello", 123] }, { foo: [true]});

tests/baselines/reference/typeParameterConstModifiers.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,14 @@ declare function fc2<const T extends readonly unknown[]>(f: (...args: T) => void
170170
fc1((a: string, b: number) => {}, "hello", 42);
171171
fc2((a: string, b: number) => {}, "hello", 42);
172172

173+
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;
175+
176+
fd1(["hello", "world"]);
177+
fd1([1, 2, 3]);
178+
fd2(["hello", "world"]);
179+
fd2([1, 2, 3]);
180+
173181
declare function fn1<const T extends { foo: unknown[] }[]>(...args: T): T;
174182

175183
fn1({ foo: ["hello", 123] }, { foo: [true]});
@@ -261,4 +269,8 @@ fb1("hello", 42);
261269
fb2("hello", 42);
262270
fc1(function (a, b) { }, "hello", 42);
263271
fc2(function (a, b) { }, "hello", 42);
272+
fd1(["hello", "world"]);
273+
fd1([1, 2, 3]);
274+
fd2(["hello", "world"]);
275+
fd2([1, 2, 3]);
264276
fn1({ foo: ["hello", 123] }, { foo: [true] });

tests/baselines/reference/typeParameterConstModifiers.symbols

Lines changed: 33 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -562,16 +562,42 @@ fc2((a: string, b: number) => {}, "hello", 42);
562562
>a : Symbol(a, Decl(typeParameterConstModifiers.ts, 167, 5))
563563
>b : Symbol(b, Decl(typeParameterConstModifiers.ts, 167, 15))
564564

565-
declare function fn1<const T extends { foo: unknown[] }[]>(...args: T): T;
566-
>fn1 : Symbol(fn1, Decl(typeParameterConstModifiers.ts, 167, 47))
565+
declare function fd1<const T extends string[] | number[]>(args: T): T;
566+
>fd1 : Symbol(fd1, Decl(typeParameterConstModifiers.ts, 167, 47))
567567
>T : Symbol(T, Decl(typeParameterConstModifiers.ts, 169, 21))
568-
>foo : Symbol(foo, Decl(typeParameterConstModifiers.ts, 169, 38))
569-
>args : Symbol(args, Decl(typeParameterConstModifiers.ts, 169, 59))
568+
>args : Symbol(args, Decl(typeParameterConstModifiers.ts, 169, 58))
570569
>T : Symbol(T, Decl(typeParameterConstModifiers.ts, 169, 21))
571570
>T : Symbol(T, Decl(typeParameterConstModifiers.ts, 169, 21))
572571

572+
declare function fd2<const T extends readonly string[] | readonly number[]>(args: T): T;
573+
>fd2 : Symbol(fd2, Decl(typeParameterConstModifiers.ts, 169, 70))
574+
>T : Symbol(T, Decl(typeParameterConstModifiers.ts, 170, 21))
575+
>args : Symbol(args, Decl(typeParameterConstModifiers.ts, 170, 76))
576+
>T : Symbol(T, Decl(typeParameterConstModifiers.ts, 170, 21))
577+
>T : Symbol(T, Decl(typeParameterConstModifiers.ts, 170, 21))
578+
579+
fd1(["hello", "world"]);
580+
>fd1 : Symbol(fd1, Decl(typeParameterConstModifiers.ts, 167, 47))
581+
582+
fd1([1, 2, 3]);
583+
>fd1 : Symbol(fd1, Decl(typeParameterConstModifiers.ts, 167, 47))
584+
585+
fd2(["hello", "world"]);
586+
>fd2 : Symbol(fd2, Decl(typeParameterConstModifiers.ts, 169, 70))
587+
588+
fd2([1, 2, 3]);
589+
>fd2 : Symbol(fd2, Decl(typeParameterConstModifiers.ts, 169, 70))
590+
591+
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))
598+
573599
fn1({ foo: ["hello", 123] }, { foo: [true]});
574-
>fn1 : Symbol(fn1, Decl(typeParameterConstModifiers.ts, 167, 47))
575-
>foo : Symbol(foo, Decl(typeParameterConstModifiers.ts, 171, 5))
576-
>foo : Symbol(foo, Decl(typeParameterConstModifiers.ts, 171, 30))
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))
577603

tests/baselines/reference/typeParameterConstModifiers.types

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -633,6 +633,44 @@ fc2((a: string, b: number) => {}, "hello", 42);
633633
>"hello" : "hello"
634634
>42 : 42
635635

636+
declare function fd1<const T extends string[] | number[]>(args: T): T;
637+
>fd1 : <const T extends string[] | number[]>(args: T) => T
638+
>args : T
639+
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
642+
>args : T
643+
644+
fd1(["hello", "world"]);
645+
>fd1(["hello", "world"]) : ["hello", "world"]
646+
>fd1 : <const T extends string[] | number[]>(args: T) => T
647+
>["hello", "world"] : ["hello", "world"]
648+
>"hello" : "hello"
649+
>"world" : "world"
650+
651+
fd1([1, 2, 3]);
652+
>fd1([1, 2, 3]) : [1, 2, 3]
653+
>fd1 : <const T extends string[] | number[]>(args: T) => T
654+
>[1, 2, 3] : [1, 2, 3]
655+
>1 : 1
656+
>2 : 2
657+
>3 : 3
658+
659+
fd2(["hello", "world"]);
660+
>fd2(["hello", "world"]) : readonly ["hello", "world"]
661+
>fd2 : <const T extends readonly string[] | readonly number[]>(args: T) => T
662+
>["hello", "world"] : ["hello", "world"]
663+
>"hello" : "hello"
664+
>"world" : "world"
665+
666+
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
669+
>[1, 2, 3] : [1, 2, 3]
670+
>1 : 1
671+
>2 : 2
672+
>3 : 3
673+
636674
declare function fn1<const T extends { foo: unknown[] }[]>(...args: T): T;
637675
>fn1 : <const T extends { foo: unknown[]; }[]>(...args: T) => T
638676
>foo : unknown[]

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,14 @@ declare function fc2<const T extends readonly unknown[]>(f: (...args: T) => void
169169
fc1((a: string, b: number) => {}, "hello", 42);
170170
fc2((a: string, b: number) => {}, "hello", 42);
171171

172+
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;
174+
175+
fd1(["hello", "world"]);
176+
fd1([1, 2, 3]);
177+
fd2(["hello", "world"]);
178+
fd2([1, 2, 3]);
179+
172180
declare function fn1<const T extends { foo: unknown[] }[]>(...args: T): T;
173181

174182
fn1({ foo: ["hello", 123] }, { foo: [true]});

0 commit comments

Comments
 (0)