From dfd5678ec5d12325793daccf4c7604affa3984c4 Mon Sep 17 00:00:00 2001 From: Simone Poggiali Date: Sun, 2 Jun 2024 21:26:42 +0200 Subject: [PATCH] format code --- README-zh_CN.md | 8 ++++---- README.md | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/README-zh_CN.md b/README-zh_CN.md index c6cbcc7..0c517e8 100644 --- a/README-zh_CN.md +++ b/README-zh_CN.md @@ -4021,9 +4021,9 @@ NoInfer 是一种实用类型,旨在阻止泛型函数范围内类型的自动 ```typescript // 泛型函数范围内类型的自动推断。 function fn(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: @@ -4031,10 +4031,10 @@ const r = fn(['a', 'b'], 'c'); // 此处的类型为 ("a" | "b" | "c")[] ```typescript // 使用 NoInfer 阻止类型推断的示例函数 function fn2(x: T[], y: NoInfer) { -return x.concat(y); + return x.concat(y); } -const r2 = fn2(['a', 'b'], 'c'); // 错误:类型为“c”的类型参数不能分配给类型为“a”|“b”的参数。 +const r2 = fn2(["a", "b"], "c"); // 错误:类型为“c”的类型参数不能分配给类型为“a”|“b”的参数。 ``` ## 其他 diff --git a/README.md b/README.md index 97c030d..c1f9312 100644 --- a/README.md +++ b/README.md @@ -4054,9 +4054,9 @@ Example: ```typescript // Automatic inference of types within the scope of a generic function. function fn(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: @@ -4064,10 +4064,10 @@ With NoInfer: ```typescript // Example function that uses NoInfer to prevent type inference function fn2(x: T[], y: NoInfer) { - 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