Skip to content

Commit

Permalink
fix lint
Browse files Browse the repository at this point in the history
  • Loading branch information
gibbok committed Jun 2, 2024
1 parent dfd5678 commit 7b8fa9f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions README-zh_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -4021,9 +4021,9 @@ NoInfer 是一种实用类型,旨在阻止泛型函数范围内类型的自动
```typescript
// 泛型函数范围内类型的自动推断。
function fn<T extends string>(x: T[], y: T) {
return x.concat(y);
return x.concat(y);
}
const r = fn(["a", "b"], "c"); // 此处的类型为 ("a" | "b" | "c")[]
const r = fn(['a', 'b'], 'c'); // 此处的类型为 ("a" | "b" | "c")[]
```

使用 NoInfer
Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4054,20 +4054,20 @@ Example:
```typescript
// Automatic inference of types within the scope of a generic function.
function fn<T extends string>(x: T[], y: T) {
return x.concat(y);
return x.concat(y);
}
const r = fn(["a", "b"], "c"); // Type here is ("a" | "b" | "c")[]
const r = fn(['a', 'b'], 'c'); // Type here is ("a" | "b" | "c")[]
```

With NoInfer:

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

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

## Others
Expand Down Expand Up @@ -5014,5 +5014,5 @@ with dynamic import:

<!-- skip -->
```typescript
const config = import("./config.json", { with: { type: "json" } })
const config = import('./config.json', { with: { type: 'json' } });
```

0 comments on commit 7b8fa9f

Please sign in to comment.