Skip to content

Commit 40db6d1

Browse files
committed
FR translation: copy file to translate
1 parent 6527850 commit 40db6d1

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
//// { compiler: { noImplicitAny: false }, order: 2 }
2+
3+
// With 3.7 TypeScript's existing 'infer from usage'
4+
// code fix became smarter. It will now use a list of
5+
// known important types (string, number, array, Promise)
6+
// and infer whether the usage of a type matches the API
7+
// of these objects.
8+
9+
// For the next few examples, select the parameters of
10+
// the functions, click the light bulb and choose
11+
// "Infer Parameter types..."
12+
13+
// Infer a number array:
14+
15+
function pushNumber(arr) {
16+
arr.push(12);
17+
}
18+
19+
// Infer a promise:
20+
21+
function awaitPromise(promise) {
22+
promise.then((value) => console.log(value));
23+
}
24+
25+
// Infer the function, and its return type:
26+
27+
function inferAny(app) {
28+
const result = app.use("hi");
29+
return result;
30+
}
31+
32+
// Infer a string array because a string
33+
// was added to it:
34+
35+
function insertString(names) {
36+
names[1] = "hello";
37+
}

0 commit comments

Comments
 (0)