# 04 · nullability **演示**:`querySelector` 返回 `HTMLInputElement | null`;直接访问 `.value` 报 `TS18047`。 **运行**:在 `tutorials/typescript` 下执行 `npm run build`,再执行 `npm run serve`,打开 `http://localhost:8080/examples/27-dom-web-types/04-nullability/`;开 Console。 **预期控制台输出**: ```text Ada ``` **类型检查**:`node node_modules/typescript/bin/tsc -p examples/27-dom-web-types/04-nullability/tsconfig.types.json` **预期类型错误**(`demo/possibly-null.ts`,由 `tsconfig.fail.json` 触发): ```text demo/possibly-null.ts(5,22): error TS18047: 'input' is possibly 'null'. ``` **注意**:`strictNullChecks` 是这条保护的前提;关掉它,`null` 会静默通过。