From 5459b3c348f3faa6b2f95a27f9c3406b2376f29d Mon Sep 17 00:00:00 2001 From: ruanyf Date: Tue, 22 Aug 2023 00:06:03 +0800 Subject: [PATCH] docs(types): fixed #64 --- docs/types.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/docs/types.md b/docs/types.md index dac280c..c05c8d1 100644 --- a/docs/types.md +++ b/docs/types.md @@ -129,9 +129,11 @@ const x:null = null; 上面示例中,变量`x`就属于 null 类型。 -注意,如果没有声明类型的变量,被赋值为`undefined`或`null`,它们的类型会被推断为`any`。 +注意,如果没有声明类型的变量,被赋值为`undefined`或`null`,在关闭编译设置`noImplicitAny`和`strictNullChecks`时,它们的类型会被推断为`any`。 ```typescript +// 关闭 noImplicitAny 和 strictNullChecks + let a = undefined; // any const b = undefined; // any @@ -143,6 +145,7 @@ const d = null; // any ```typescript // 打开编译设置 strictNullChecks + let a = undefined; // undefined const b = undefined; // undefined