Skip to content

Commit b5d13fb

Browse files
Remove promiseTry error suppression comments
Co-authored-by: DanielRosenwasser <972891+DanielRosenwasser@users.noreply.github.com>
1 parent 76d1dd4 commit b5d13fb

5 files changed

Lines changed: 60 additions & 36 deletions

File tree

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
promiseTry.ts(15,9): error TS2554: Expected 2 arguments, but got 1.
2+
promiseTry.ts(19,35): error TS2554: Expected 1 arguments, but got 2.
3+
promiseTry.ts(23,70): error TS2554: Expected 3 arguments, but got 4.
4+
promiseTry.ts(24,9): error TS2554: Expected 3 arguments, but got 2.
5+
6+
7+
==== promiseTry.ts (4 errors) ====
8+
Promise.try(() => {
9+
return "Sync result";
10+
});
11+
12+
Promise.try(async () => {
13+
return "Async result";
14+
});
15+
16+
const a = Promise.try(() => "Sync result");
17+
const b = Promise.try(async () => "Async result");
18+
19+
// SINGLE PARAMETER
20+
Promise.try((foo: string) => "Async result", "foo");
21+
Promise.try((foo) => "Async result", "foo");
22+
Promise.try((foo) => "Async result");
23+
~~~
24+
!!! error TS2554: Expected 2 arguments, but got 1.
25+
!!! related TS6236 lib.es2025.promise.d.ts:--:--: Arguments for the rest parameter 'args' were not provided.
26+
Promise.try((foo: string | undefined) => "Async result", undefined);
27+
Promise.try((foo: string | undefined) => "Async result", "foo");
28+
Promise.try((foo) => "Async result", undefined);
29+
Promise.try(() => "Async result", "foo");
30+
~~~~~
31+
!!! error TS2554: Expected 1 arguments, but got 2.
32+
33+
// MULTIPLE PARAMETERS
34+
Promise.try((foo: string, bar: number) => "Async result", "foo", 42);
35+
Promise.try((foo: string, bar: number) => "Async result", "foo", 42, "baz");
36+
~~~~~
37+
!!! error TS2554: Expected 3 arguments, but got 4.
38+
Promise.try((foo: string, bar: number) => "Async result", "foo");
39+
~~~
40+
!!! error TS2554: Expected 3 arguments, but got 2.
41+
Promise.try((foo: string, bar?: number) => "Async result", "foo");
42+
Promise.try((foo: string, bar?: number) => "Async result", "foo", undefined);
43+
Promise.try((foo: string, bar?: number) => "Async result", "foo", 42);
44+

‎tsc/testdata/baselines/reference/compiler/promiseTry.js‎

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,15 @@ const b = Promise.try(async () => "Async result");
1515
// SINGLE PARAMETER
1616
Promise.try((foo: string) => "Async result", "foo");
1717
Promise.try((foo) => "Async result", "foo");
18-
// @ts-expect-error too few parameters
1918
Promise.try((foo) => "Async result");
2019
Promise.try((foo: string | undefined) => "Async result", undefined);
2120
Promise.try((foo: string | undefined) => "Async result", "foo");
2221
Promise.try((foo) => "Async result", undefined);
23-
// @ts-expect-error too many parameters
2422
Promise.try(() => "Async result", "foo");
2523

2624
// MULTIPLE PARAMETERS
2725
Promise.try((foo: string, bar: number) => "Async result", "foo", 42);
28-
// @ts-expect-error too many parameters
2926
Promise.try((foo: string, bar: number) => "Async result", "foo", 42, "baz");
30-
// @ts-expect-error too few parameters
3127
Promise.try((foo: string, bar: number) => "Async result", "foo");
3228
Promise.try((foo: string, bar?: number) => "Async result", "foo");
3329
Promise.try((foo: string, bar?: number) => "Async result", "foo", undefined);
@@ -47,18 +43,14 @@ const b = Promise.try(async () => "Async result");
4743
// SINGLE PARAMETER
4844
Promise.try((foo) => "Async result", "foo");
4945
Promise.try((foo) => "Async result", "foo");
50-
// @ts-expect-error too few parameters
5146
Promise.try((foo) => "Async result");
5247
Promise.try((foo) => "Async result", undefined);
5348
Promise.try((foo) => "Async result", "foo");
5449
Promise.try((foo) => "Async result", undefined);
55-
// @ts-expect-error too many parameters
5650
Promise.try(() => "Async result", "foo");
5751
// MULTIPLE PARAMETERS
5852
Promise.try((foo, bar) => "Async result", "foo", 42);
59-
// @ts-expect-error too many parameters
6053
Promise.try((foo, bar) => "Async result", "foo", 42, "baz");
61-
// @ts-expect-error too few parameters
6254
Promise.try((foo, bar) => "Async result", "foo");
6355
Promise.try((foo, bar) => "Async result", "foo");
6456
Promise.try((foo, bar) => "Async result", "foo", undefined);

‎tsc/testdata/baselines/reference/compiler/promiseTry.symbols‎

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -42,34 +42,32 @@ Promise.try((foo) => "Async result", "foo");
4242
>try : Symbol(PromiseConstructor.try, Decl(lib.es2025.promise.d.ts, --, --))
4343
>foo : Symbol(foo, Decl(promiseTry.ts, 13, 13))
4444

45-
// @ts-expect-error too few parameters
4645
Promise.try((foo) => "Async result");
4746
>Promise.try : Symbol(PromiseConstructor.try, Decl(lib.es2025.promise.d.ts, --, --))
4847
>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2018.promise.d.ts, --, --))
4948
>try : Symbol(PromiseConstructor.try, Decl(lib.es2025.promise.d.ts, --, --))
50-
>foo : Symbol(foo, Decl(promiseTry.ts, 15, 13))
49+
>foo : Symbol(foo, Decl(promiseTry.ts, 14, 13))
5150

5251
Promise.try((foo: string | undefined) => "Async result", undefined);
5352
>Promise.try : Symbol(PromiseConstructor.try, Decl(lib.es2025.promise.d.ts, --, --))
5453
>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2018.promise.d.ts, --, --))
5554
>try : Symbol(PromiseConstructor.try, Decl(lib.es2025.promise.d.ts, --, --))
56-
>foo : Symbol(foo, Decl(promiseTry.ts, 16, 13))
55+
>foo : Symbol(foo, Decl(promiseTry.ts, 15, 13))
5756
>undefined : Symbol(undefined)
5857

5958
Promise.try((foo: string | undefined) => "Async result", "foo");
6059
>Promise.try : Symbol(PromiseConstructor.try, Decl(lib.es2025.promise.d.ts, --, --))
6160
>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2018.promise.d.ts, --, --))
6261
>try : Symbol(PromiseConstructor.try, Decl(lib.es2025.promise.d.ts, --, --))
63-
>foo : Symbol(foo, Decl(promiseTry.ts, 17, 13))
62+
>foo : Symbol(foo, Decl(promiseTry.ts, 16, 13))
6463

6564
Promise.try((foo) => "Async result", undefined);
6665
>Promise.try : Symbol(PromiseConstructor.try, Decl(lib.es2025.promise.d.ts, --, --))
6766
>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2018.promise.d.ts, --, --))
6867
>try : Symbol(PromiseConstructor.try, Decl(lib.es2025.promise.d.ts, --, --))
69-
>foo : Symbol(foo, Decl(promiseTry.ts, 18, 13))
68+
>foo : Symbol(foo, Decl(promiseTry.ts, 17, 13))
7069
>undefined : Symbol(undefined)
7170

72-
// @ts-expect-error too many parameters
7371
Promise.try(() => "Async result", "foo");
7472
>Promise.try : Symbol(PromiseConstructor.try, Decl(lib.es2025.promise.d.ts, --, --))
7573
>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2018.promise.d.ts, --, --))
@@ -80,44 +78,42 @@ Promise.try((foo: string, bar: number) => "Async result", "foo", 42);
8078
>Promise.try : Symbol(PromiseConstructor.try, Decl(lib.es2025.promise.d.ts, --, --))
8179
>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2018.promise.d.ts, --, --))
8280
>try : Symbol(PromiseConstructor.try, Decl(lib.es2025.promise.d.ts, --, --))
83-
>foo : Symbol(foo, Decl(promiseTry.ts, 23, 13))
84-
>bar : Symbol(bar, Decl(promiseTry.ts, 23, 25))
81+
>foo : Symbol(foo, Decl(promiseTry.ts, 21, 13))
82+
>bar : Symbol(bar, Decl(promiseTry.ts, 21, 25))
8583

86-
// @ts-expect-error too many parameters
8784
Promise.try((foo: string, bar: number) => "Async result", "foo", 42, "baz");
8885
>Promise.try : Symbol(PromiseConstructor.try, Decl(lib.es2025.promise.d.ts, --, --))
8986
>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2018.promise.d.ts, --, --))
9087
>try : Symbol(PromiseConstructor.try, Decl(lib.es2025.promise.d.ts, --, --))
91-
>foo : Symbol(foo, Decl(promiseTry.ts, 25, 13))
92-
>bar : Symbol(bar, Decl(promiseTry.ts, 25, 25))
88+
>foo : Symbol(foo, Decl(promiseTry.ts, 22, 13))
89+
>bar : Symbol(bar, Decl(promiseTry.ts, 22, 25))
9390

94-
// @ts-expect-error too few parameters
9591
Promise.try((foo: string, bar: number) => "Async result", "foo");
9692
>Promise.try : Symbol(PromiseConstructor.try, Decl(lib.es2025.promise.d.ts, --, --))
9793
>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2018.promise.d.ts, --, --))
9894
>try : Symbol(PromiseConstructor.try, Decl(lib.es2025.promise.d.ts, --, --))
99-
>foo : Symbol(foo, Decl(promiseTry.ts, 27, 13))
100-
>bar : Symbol(bar, Decl(promiseTry.ts, 27, 25))
95+
>foo : Symbol(foo, Decl(promiseTry.ts, 23, 13))
96+
>bar : Symbol(bar, Decl(promiseTry.ts, 23, 25))
10197

10298
Promise.try((foo: string, bar?: number) => "Async result", "foo");
10399
>Promise.try : Symbol(PromiseConstructor.try, Decl(lib.es2025.promise.d.ts, --, --))
104100
>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2018.promise.d.ts, --, --))
105101
>try : Symbol(PromiseConstructor.try, Decl(lib.es2025.promise.d.ts, --, --))
106-
>foo : Symbol(foo, Decl(promiseTry.ts, 28, 13))
107-
>bar : Symbol(bar, Decl(promiseTry.ts, 28, 25))
102+
>foo : Symbol(foo, Decl(promiseTry.ts, 24, 13))
103+
>bar : Symbol(bar, Decl(promiseTry.ts, 24, 25))
108104

109105
Promise.try((foo: string, bar?: number) => "Async result", "foo", undefined);
110106
>Promise.try : Symbol(PromiseConstructor.try, Decl(lib.es2025.promise.d.ts, --, --))
111107
>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2018.promise.d.ts, --, --))
112108
>try : Symbol(PromiseConstructor.try, Decl(lib.es2025.promise.d.ts, --, --))
113-
>foo : Symbol(foo, Decl(promiseTry.ts, 29, 13))
114-
>bar : Symbol(bar, Decl(promiseTry.ts, 29, 25))
109+
>foo : Symbol(foo, Decl(promiseTry.ts, 25, 13))
110+
>bar : Symbol(bar, Decl(promiseTry.ts, 25, 25))
115111
>undefined : Symbol(undefined)
116112

117113
Promise.try((foo: string, bar?: number) => "Async result", "foo", 42);
118114
>Promise.try : Symbol(PromiseConstructor.try, Decl(lib.es2025.promise.d.ts, --, --))
119115
>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2018.promise.d.ts, --, --))
120116
>try : Symbol(PromiseConstructor.try, Decl(lib.es2025.promise.d.ts, --, --))
121-
>foo : Symbol(foo, Decl(promiseTry.ts, 30, 13))
122-
>bar : Symbol(bar, Decl(promiseTry.ts, 30, 25))
117+
>foo : Symbol(foo, Decl(promiseTry.ts, 26, 13))
118+
>bar : Symbol(bar, Decl(promiseTry.ts, 26, 25))
123119

‎tsc/testdata/baselines/reference/compiler/promiseTry.types‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ Promise.try((foo) => "Async result", "foo");
6464
>"Async result" : "Async result"
6565
>"foo" : "foo"
6666

67-
// @ts-expect-error too few parameters
6867
Promise.try((foo) => "Async result");
6968
>Promise.try((foo) => "Async result") : Promise<unknown>
7069
>Promise.try : <T, U extends unknown[]>(callbackFn: (...args: U) => T | PromiseLike<T>, ...args: U) => Promise<Awaited<T>>
@@ -104,7 +103,6 @@ Promise.try((foo) => "Async result", undefined);
104103
>"Async result" : "Async result"
105104
>undefined : undefined
106105

107-
// @ts-expect-error too many parameters
108106
Promise.try(() => "Async result", "foo");
109107
>Promise.try(() => "Async result", "foo") : Promise<string>
110108
>Promise.try : <T, U extends unknown[]>(callbackFn: (...args: U) => T | PromiseLike<T>, ...args: U) => Promise<Awaited<T>>
@@ -127,7 +125,6 @@ Promise.try((foo: string, bar: number) => "Async result", "foo", 42);
127125
>"foo" : "foo"
128126
>42 : 42
129127

130-
// @ts-expect-error too many parameters
131128
Promise.try((foo: string, bar: number) => "Async result", "foo", 42, "baz");
132129
>Promise.try((foo: string, bar: number) => "Async result", "foo", 42, "baz") : Promise<string>
133130
>Promise.try : <T, U extends unknown[]>(callbackFn: (...args: U) => T | PromiseLike<T>, ...args: U) => Promise<Awaited<T>>
@@ -141,7 +138,6 @@ Promise.try((foo: string, bar: number) => "Async result", "foo", 42, "baz");
141138
>42 : 42
142139
>"baz" : "baz"
143140

144-
// @ts-expect-error too few parameters
145141
Promise.try((foo: string, bar: number) => "Async result", "foo");
146142
>Promise.try((foo: string, bar: number) => "Async result", "foo") : Promise<string>
147143
>Promise.try : <T, U extends unknown[]>(callbackFn: (...args: U) => T | PromiseLike<T>, ...args: U) => Promise<Awaited<T>>

‎tsc/testdata/tests/cases/compiler/promiseTry.ts‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,15 @@ const b = Promise.try(async () => "Async result");
1414
// SINGLE PARAMETER
1515
Promise.try((foo: string) => "Async result", "foo");
1616
Promise.try((foo) => "Async result", "foo");
17-
// @ts-expect-error too few parameters
1817
Promise.try((foo) => "Async result");
1918
Promise.try((foo: string | undefined) => "Async result", undefined);
2019
Promise.try((foo: string | undefined) => "Async result", "foo");
2120
Promise.try((foo) => "Async result", undefined);
22-
// @ts-expect-error too many parameters
2321
Promise.try(() => "Async result", "foo");
2422

2523
// MULTIPLE PARAMETERS
2624
Promise.try((foo: string, bar: number) => "Async result", "foo", 42);
27-
// @ts-expect-error too many parameters
2825
Promise.try((foo: string, bar: number) => "Async result", "foo", 42, "baz");
29-
// @ts-expect-error too few parameters
3026
Promise.try((foo: string, bar: number) => "Async result", "foo");
3127
Promise.try((foo: string, bar?: number) => "Async result", "foo");
3228
Promise.try((foo: string, bar?: number) => "Async result", "foo", undefined);

0 commit comments

Comments
 (0)