Skip to content

Commit d4a1f35

Browse files
committed
feat: explicit set useDefineForClassFields in ts templates
Since TypeScript 4.3, `target: "esnext"` indicates that `useDefineForClassFields: true` as the new default. See <microsoft/TypeScript#42663> So I'm explicitly adding this field to the tsconfigs to avoid any confusions. Note that `lit-element` projects must use `useDefineForClassFields: false` because of <https://github.com/lit/lit-element/issues/1030> Vue projects must use `useDefineForClassFields: true` so as to support class style `prop` definition in `vue-class-component`: <vuejs/vue-class-component#465> Popular React state management library MobX requires it to be `true`: <https://mobx.js.org/installation.html#use-spec-compliant-transpilation-for-class-properties> Other frameworks seem to have no particular opinion on this. So I turned it on in all templates except for the `lit-element` one.
1 parent 73344a9 commit d4a1f35

File tree

6 files changed

+7
-1
lines changed

6 files changed

+7
-1
lines changed

packages/create-vite/template-lit-element-ts/tsconfig.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@
1414
"moduleResolution": "node",
1515
"allowSyntheticDefaultImports": true,
1616
"experimentalDecorators": true,
17-
"forceConsistentCasingInFileNames": true
17+
"forceConsistentCasingInFileNames": true,
18+
"useDefineForClassFields": false
1819
},
1920
"include": ["src/**/*.ts"],
2021
"exclude": []

packages/create-vite/template-preact-ts/tsconfig.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"compilerOptions": {
33
"target": "ESNext",
4+
"useDefineForClassFields": true,
45
"lib": ["DOM", "DOM.Iterable", "ESNext"],
56
"allowJs": false,
67
"skipLibCheck": false,

packages/create-vite/template-react-ts/tsconfig.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"compilerOptions": {
33
"target": "ESNext",
4+
"useDefineForClassFields": true,
45
"lib": ["DOM", "DOM.Iterable", "ESNext"],
56
"allowJs": false,
67
"skipLibCheck": false,

packages/create-vite/template-svelte-ts/tsconfig.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"extends": "@tsconfig/svelte/tsconfig.json",
33
"compilerOptions": {
44
"target": "esnext",
5+
"useDefineForClassFields": true,
56
"module": "esnext",
67
"resolveJsonModule": true,
78
"baseUrl": ".",

packages/create-vite/template-vanilla-ts/tsconfig.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"compilerOptions": {
33
"target": "ESNext",
4+
"useDefineForClassFields": true,
45
"module": "ESNext",
56
"lib": ["ESNext", "DOM"],
67
"moduleResolution": "Node",

packages/create-vite/template-vue-ts/tsconfig.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"compilerOptions": {
33
"target": "esnext",
4+
"useDefineForClassFields": true,
45
"module": "esnext",
56
"moduleResolution": "node",
67
"strict": true,

0 commit comments

Comments
 (0)