Skip to content

Commit dfd5678

Browse files
committed
format code
1 parent d4b56e1 commit dfd5678

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

README-zh_CN.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4021,20 +4021,20 @@ NoInfer 是一种实用类型,旨在阻止泛型函数范围内类型的自动
40214021
```typescript
40224022
// 泛型函数范围内类型的自动推断。
40234023
function fn<T extends string>(x: T[], y: T) {
4024-
return x.concat(y);
4024+
return x.concat(y);
40254025
}
4026-
const r = fn(['a', 'b'], 'c'); // 此处的类型为 ("a" | "b" | "c")[]
4026+
const r = fn(["a", "b"], "c"); // 此处的类型为 ("a" | "b" | "c")[]
40274027
```
40284028

40294029
使用 NoInfer
40304030

40314031
```typescript
40324032
// 使用 NoInfer 阻止类型推断的示例函数
40334033
function fn2<T extends string>(x: T[], y: NoInfer<T>) {
4034-
return x.concat(y);
4034+
return x.concat(y);
40354035
}
40364036
4037-
const r2 = fn2(['a', 'b'], 'c'); // 错误:类型为“c”的类型参数不能分配给类型为“a”|“b”的参数。
4037+
const r2 = fn2(["a", "b"], "c"); // 错误:类型为“c”的类型参数不能分配给类型为“a”|“b”的参数。
40384038
```
40394039

40404040
## 其他

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4054,20 +4054,20 @@ Example:
40544054
```typescript
40554055
// Automatic inference of types within the scope of a generic function.
40564056
function fn<T extends string>(x: T[], y: T) {
4057-
return x.concat(y);
4057+
return x.concat(y);
40584058
}
4059-
const r = fn(['a', 'b'], 'c'); // Type here is ("a" | "b" | "c")[]
4059+
const r = fn(["a", "b"], "c"); // Type here is ("a" | "b" | "c")[]
40604060
```
40614061

40624062
With NoInfer:
40634063

40644064
```typescript
40654065
// Example function that uses NoInfer to prevent type inference
40664066
function fn2<T extends string>(x: T[], y: NoInfer<T>) {
4067-
return x.concat(y);
4067+
return x.concat(y);
40684068
}
40694069

4070-
const r2 = fn2(['a', 'b'], 'c'); // Error: Type Argument of type '"c"' is not assignable to parameter of type '"a" | "b"'.
4070+
const r2 = fn2(["a", "b"], "c"); // Error: Type Argument of type '"c"' is not assignable to parameter of type '"a" | "b"'.
40714071
```
40724072

40734073
## Others

0 commit comments

Comments
 (0)