# 03 · index-signature **演示**:`[key: string]: string | undefined` 允许任意键,并在 `noUncheckedIndexedAccess` 下如实返回 `undefined`。 **运行**:在 `tutorials/typescript` 下执行 `npm run build`,再执行 `npm run serve`,打开 `http://localhost:8080/examples/04-object-types-structural/03-index-signature/`;开 Console。 **预期控制台输出**: ```text /usr/bin (unset) HOME,PATH ``` **类型检查**:`node node_modules/typescript/bin/tsc -p examples/04-object-types-structural/03-index-signature/tsconfig.types.json` **预期类型错误**(`demo/dot-access.ts`,由 `tsconfig.fail.json` 触发): ```text demo/dot-access.ts(8,18): error TS4111: Property 'PATH' comes from an index signature, so it must be accessed with ['PATH']. ``` **注意**:基线开启了 `noPropertyAccessFromIndexSignature`,所以点号访问是硬错误。