From aebaf7965face5d46dd06fa3ef7bc65fd295836b Mon Sep 17 00:00:00 2001 From: Haoqun Jiang Date: Sun, 16 Mar 2025 23:34:03 +0800 Subject: [PATCH 1/2] feat!: turn on noUncheckedIndexedAccess for libraries See https://www.semver-ts.org/formal-spec/5-compiler-considerations.html#strictness for the arguments for turning on noUncheckedIndexedAccess for libraries. In short, it helps prevent shipping accidental breaking type changes to library consumers. (Note the link also suggests turning on `exactOptionalPropertyTypes`, but I still have doubts about it, as it would not be helpful without a specific coding style, which is hard to enforce.) --- tsconfig.lib.json | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tsconfig.lib.json b/tsconfig.lib.json index 964598a..3ce7121 100644 --- a/tsconfig.lib.json +++ b/tsconfig.lib.json @@ -8,6 +8,8 @@ // Libraries generally require more strict type accuracy. // For example, its types must be compatible with the Vue types. // So we don't want to skip the type checking of its dependencies. - "skipLibCheck": false + "skipLibCheck": false, + + "noUncheckedIndexedAccess": true } } From b5f50c1cf34636dcf03aa5b3c6f0836806b6e047 Mon Sep 17 00:00:00 2001 From: Haoqun Jiang Date: Thu, 17 Jul 2025 17:27:15 +0800 Subject: [PATCH 2/2] feat!: enable `noUncheckedIndexedAccess` and `exactOptionalPropertyTypes` As recommended in TS 5.9: https://github.com/microsoft/TypeScript/pull/61813 --- tsconfig.json | 5 +++++ tsconfig.lib.json | 2 -- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/tsconfig.json b/tsconfig.json index 56402e7..ea3f593 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -31,6 +31,11 @@ "noImplicitThis": true, "strict": true, + // See + // These 2 options are also part of the recommended tsconfig as of TS 5.9 + "noUncheckedIndexedAccess": true, + "exactOptionalPropertyTypes": true, + // // Any imports or exports without a type modifier are left around. This is important for `