Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/huge-files-smile.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@virtual-live-lab/tsconfig": major
---

feat!: enable exactOptionalPropertyTypes
7 changes: 7 additions & 0 deletions .changeset/proud-months-repeat.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@virtual-live-lab/tsconfig": major
---

feat!: enable noUncheckedSideEffectImports

BREAKING CHANGE: Now all presets require TypeScript 5.6 or later.
5 changes: 5 additions & 0 deletions .changeset/twelve-rice-repeat.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@virtual-live-lab/tsconfig": major
---

feat!: enable verbatimModuleSyntax
3 changes: 3 additions & 0 deletions packages/tsconfig/base.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
"noImplicitReturns": true,
"noPropertyAccessFromIndexSignature": true,
"noUncheckedIndexedAccess": true,
"exactOptionalPropertyTypes": true,
"noUncheckedSideEffectImports": true,
"strict": true,
"strictNullChecks": true,
// modules
Expand All @@ -18,6 +20,7 @@
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"isolatedModules": true,
"verbatimModuleSyntax": true,
// language-and-environment
"target": "ES2022",
"lib": ["ES2023"],
Expand Down
17 changes: 12 additions & 5 deletions packages/tsconfig/docs/base/compiler-options.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,15 @@

### [Exact Optional Property Types](https://www.typescriptlang.org/ja/tsconfig/#exactOptionalPropertyTypes)

設定値: `false (default)`
設定値: `true`

オプショナルなプロパティの型を厳密にチェックするかどうかを設定する。例についてはドキュメントを見たほうが早い。
`?`をつけたプロパティであっても、明示的に許可しない限り`undefined`を渡せなくなる。
この点に関しては非常に良いルールであると考える。実際TypeScript公式も有効化を推奨している。

**ただし、実際に有効にすると様々な関数、特に外部ライブラリの関数に`option`のような設定オブジェクトを渡す場合にエラーが発生する。これらにすべてts-expect-errorをつけるまでして有効化すべきでないと判断したため、デフォルト値のままとする。**
~~ただし、実際に有効にすると様々な関数、特に外部ライブラリの関数に`option`のような設定オブジェクトを渡す場合にエラーが発生する。これらにすべてts-expect-errorをつけるまでして有効化すべきでないと判断したため、デフォルト値のままとする。~~

TypeScript 5.9 以降この設定は `tsc --init` で生成される推奨設定に含まれていており、このオプションを有効にして問題ないほどエコシステムが成熟したと考えられるため有効化した。<https://devblogs.microsoft.com/typescript/announcing-typescript-5-9-rc/>

### [No Fallthrough Cases In Switch](https://www.typescriptlang.org/ja/tsconfig/#noFallthroughCasesInSwitch)

Expand Down Expand Up @@ -276,6 +278,9 @@ Module Suffixに指定したSuffixを考慮してモジュール解決を行う

安全性が向上するため、有効にしておく。

補足: 一度 <https://github.com/VirtualLiveLab/js-config/pull/193> で有効化したが、 <https://github.com/VirtualLiveLab/js-config/pull/345> のような事情により無効化されていた。
TS 5.9 以降この設定は `tsc --init` で生成される推奨設定に含まれていており、十分一般的な設定になっていると判断したため有効化する。<https://devblogs.microsoft.com/typescript/announcing-typescript-5-9-rc/>

### [Paths](https://www.typescriptlang.org/ja/tsconfig/#paths)

設定値: not set
Expand Down Expand Up @@ -605,15 +610,17 @@ CommonJSモジュールをimportする際に、NameSpaceオブジェクトを生

### [Verbatim Module Syntax](https://www.typescriptlang.org/ja/tsconfig/#verbatimModuleSyntax)

設定値: `false (default)`
設定値: `true`

import文の処理が逐語的なトランスパイルになる。

このため、`import type {}`文は丸ごと削除され、`import {a, type B}`のような文は`import {a}`に変換される。

しかし、このオプションを有効にするとCommon JS向けにトランスパイルする際にもimport文がrequire文に変換されないため非常に面倒になる。
~~しかし、このオプションを有効にするとCommon JS向けにトランスパイルする際にもimport文がrequire文に変換されないため非常に面倒になる。~~

~~これと同等のチェックをESLintのプリセットで行うように設定しているため、TypeScript側ではデフォルト値のままとする。~~

これと同等のチェックをESLintのプリセットで行うように設定しているため、TypeScript側ではデフォルト値のままとする。
この設定は TS 5.9 以降、`tsc --init` で生成される推奨設定に含まれていており、CJS 向けのトランスパイルも基本行わない情勢になっているので有効化する。<https://devblogs.microsoft.com/typescript/announcing-typescript-5-9-rc/>

## Backwards Compatibility

Expand Down
2 changes: 1 addition & 1 deletion packages/tsconfig/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"*.json"
],
"peerDependencies": {
"typescript": "^5.0.0"
"typescript": "^5.6.0"
},
"devDependencies": {
"typescript": "catalog:"
Expand Down