From 1d19f27fbc0d7d0e1376937eb21ebac73c82c7d8 Mon Sep 17 00:00:00 2001 From: "caleb.xiang" Date: Fri, 17 Apr 2020 19:34:57 +0800 Subject: [PATCH 1/3] =?UTF-8?q?void=20=E7=B1=BB=E5=9E=8B=E4=B8=8D=E8=83=BD?= =?UTF-8?q?=E8=B5=8B=E5=80=BC=E4=B8=BAnull?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ``` > let j: void = null [eval].ts:3:5 - error TS2322: Type 'null' is not assignable to type 'void'. ``` --- basics/primitive-data-types.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/basics/primitive-data-types.md b/basics/primitive-data-types.md index 0c2b230d..ff9eb65c 100644 --- a/basics/primitive-data-types.md +++ b/basics/primitive-data-types.md @@ -104,7 +104,7 @@ function alertName(): void { } ``` -声明一个 `void` 类型的变量没有什么用,因为你只能将它赋值为 `undefined` 和 `null`: +声明一个 `void` 类型的变量没有什么用,因为你只能将它赋值为 `undefined`,(不能赋值为`null`): ```ts let unusable: void = undefined; From 607b58085f7766a7b0bf688097d3b9e04fdf190e Mon Sep 17 00:00:00 2001 From: "caleb.xiang" Date: Fri, 17 Apr 2020 22:00:18 +0800 Subject: [PATCH 2/3] Update primitive-data-types.md --- basics/primitive-data-types.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/basics/primitive-data-types.md b/basics/primitive-data-types.md index ff9eb65c..f3a160cd 100644 --- a/basics/primitive-data-types.md +++ b/basics/primitive-data-types.md @@ -104,7 +104,7 @@ function alertName(): void { } ``` -声明一个 `void` 类型的变量没有什么用,因为你只能将它赋值为 `undefined`,(不能赋值为`null`): +声明一个 `void` 类型的变量没有什么用,因为你只能将它赋值为 `undefined`,默认情况下 ts-config 的配置是:```strictNullChecks: true```,void 也不能赋值为`null`): ```ts let unusable: void = undefined; From 9abd7b199ae4107b42f40f99ee5299eaab021a88 Mon Sep 17 00:00:00 2001 From: "caleb.xiang" Date: Fri, 17 Apr 2020 22:04:21 +0800 Subject: [PATCH 3/3] Update primitive-data-types.md --- basics/primitive-data-types.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/basics/primitive-data-types.md b/basics/primitive-data-types.md index f3a160cd..6742212e 100644 --- a/basics/primitive-data-types.md +++ b/basics/primitive-data-types.md @@ -104,7 +104,7 @@ function alertName(): void { } ``` -声明一个 `void` 类型的变量没有什么用,因为你只能将它赋值为 `undefined`,默认情况下 ts-config 的配置是:```strictNullChecks: true```,void 也不能赋值为`null`): +声明一个 `void` 类型的变量没有什么用,因为你只能将它赋值为 `undefined`,默认情况下 ts-config 的配置是:```strictNullChecks: true```,所以void 也不能赋值为`null`: ```ts let unusable: void = undefined;