Skip to content

Commit 4ffaeee

Browse files
authored
feat(create-vite): stricter TS configs in templates (#12604)
1 parent 3a41bd8 commit 4ffaeee

File tree

10 files changed

+65
-40
lines changed

10 files changed

+65
-40
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,23 @@
11
{
22
"compilerOptions": {
3+
"target": "ES2020",
4+
"useDefineForClassFields": true,
35
"module": "ESNext",
46
"lib": ["ES2020", "DOM", "DOM.Iterable"],
7+
"skipLibCheck": true,
8+
9+
/* Bundler mode */
10+
"moduleResolution": "bundler",
11+
"allowImportingTsExtensions": true,
12+
"resolveJsonModule": true,
13+
"isolatedModules": true,
514
"noEmit": true,
15+
16+
/* Linting */
617
"strict": true,
718
"noUnusedLocals": true,
819
"noUnusedParameters": true,
9-
"noImplicitReturns": true,
10-
"noFallthroughCasesInSwitch": true,
11-
"moduleResolution": "bundler",
12-
"isolatedModules": true,
13-
"allowSyntheticDefaultImports": true,
14-
"useDefineForClassFields": false,
15-
"skipLibCheck": true
20+
"noFallthroughCasesInSwitch": true
1621
},
1722
"include": ["src"]
1823
}
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { render } from 'preact'
2-
import { App } from './app'
2+
import { App } from './app.tsx'
33
import './index.css'
44

55
render(<App />, document.getElementById('app') as HTMLElement)

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

+13-8
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,25 @@
11
{
22
"compilerOptions": {
3-
"target": "ESNext",
3+
"target": "ES2020",
44
"useDefineForClassFields": true,
5-
"lib": ["DOM", "DOM.Iterable", "ESNext"],
6-
"allowJs": false,
7-
"skipLibCheck": true,
8-
"esModuleInterop": false,
9-
"allowSyntheticDefaultImports": true,
10-
"strict": true,
115
"module": "ESNext",
6+
"lib": ["ES2020", "DOM", "DOM.Iterable"],
7+
"skipLibCheck": true,
8+
9+
/* Bundler mode */
1210
"moduleResolution": "bundler",
11+
"allowImportingTsExtensions": true,
1312
"resolveJsonModule": true,
1413
"isolatedModules": true,
1514
"noEmit": true,
1615
"jsx": "react-jsx",
17-
"jsxImportSource": "preact"
16+
"jsxImportSource": "preact",
17+
18+
/* Linting */
19+
"strict": true,
20+
"noUnusedLocals": true,
21+
"noUnusedParameters": true,
22+
"noFallthroughCasesInSwitch": true
1823
},
1924
"include": ["src"],
2025
"references": [{ "path": "./tsconfig.node.json" }]
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { render } from 'preact'
2-
import { App } from './app'
2+
import { App } from './app.jsx'
33
import './index.css'
44

55
render(<App />, document.getElementById('app'))

packages/create-vite/template-react-ts/src/main.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React from 'react'
22
import ReactDOM from 'react-dom/client'
3-
import App from './App'
3+
import App from './App.tsx'
44
import './index.css'
55

66
ReactDOM.createRoot(document.getElementById('root') as HTMLElement).render(

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

+11-7
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,23 @@
11
{
22
"compilerOptions": {
33
"target": "ESNext",
4-
"useDefineForClassFields": true,
54
"lib": ["DOM", "DOM.Iterable", "ESNext"],
6-
"allowJs": false,
7-
"skipLibCheck": true,
8-
"esModuleInterop": false,
9-
"allowSyntheticDefaultImports": true,
10-
"strict": true,
115
"module": "ESNext",
6+
"skipLibCheck": true,
7+
8+
/* Bundler mode */
129
"moduleResolution": "bundler",
10+
"allowImportingTsExtensions": true,
1311
"resolveJsonModule": true,
1412
"isolatedModules": true,
1513
"noEmit": true,
16-
"jsx": "react-jsx"
14+
"jsx": "react-jsx",
15+
16+
/* Linting */
17+
"strict": true,
18+
"noUnusedLocals": true,
19+
"noUnusedParameters": true,
20+
"noFallthroughCasesInSwitch": true
1721
},
1822
"include": ["src"],
1923
"references": [{ "path": "./tsconfig.node.json" }]

packages/create-vite/template-react/src/main.jsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React from 'react'
22
import ReactDOM from 'react-dom/client'
3-
import App from './App'
3+
import App from './App.jsx'
44
import './index.css'
55

66
ReactDOM.createRoot(document.getElementById('root')).render(

packages/create-vite/template-vanilla-ts/src/main.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import './style.css'
22
import typescriptLogo from './typescript.svg'
33
import viteLogo from '/vite.svg'
4-
import { setupCounter } from './counter'
4+
import { setupCounter } from './counter.ts'
55

66
document.querySelector<HTMLDivElement>('#app')!.innerHTML = `
77
<div>
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,23 @@
11
{
22
"compilerOptions": {
3-
"target": "ESNext",
3+
"target": "ES2020",
44
"useDefineForClassFields": true,
55
"module": "ESNext",
6-
"lib": ["ESNext", "DOM"],
6+
"lib": ["ES2020", "DOM", "DOM.Iterable"],
7+
"skipLibCheck": true,
8+
9+
/* Bundler mode */
710
"moduleResolution": "bundler",
8-
"strict": true,
11+
"allowImportingTsExtensions": true,
912
"resolveJsonModule": true,
1013
"isolatedModules": true,
11-
"esModuleInterop": true,
1214
"noEmit": true,
15+
16+
/* Linting */
17+
"strict": true,
1318
"noUnusedLocals": true,
1419
"noUnusedParameters": true,
15-
"noImplicitReturns": true,
16-
"skipLibCheck": true
20+
"noFallthroughCasesInSwitch": true
1721
},
1822
"include": ["src"]
1923
}

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

+14-7
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,24 @@
11
{
22
"compilerOptions": {
3-
"target": "ESNext",
3+
"target": "ES2020",
44
"useDefineForClassFields": true,
55
"module": "ESNext",
6+
"lib": ["ES2020", "DOM", "DOM.Iterable"],
7+
"skipLibCheck": true,
8+
9+
/* Bundler mode */
610
"moduleResolution": "bundler",
7-
"strict": true,
8-
"jsx": "preserve",
11+
"allowImportingTsExtensions": true,
912
"resolveJsonModule": true,
1013
"isolatedModules": true,
11-
"esModuleInterop": true,
12-
"lib": ["ESNext", "DOM"],
13-
"skipLibCheck": true,
14-
"noEmit": true
14+
"noEmit": true,
15+
"jsx": "preserve",
16+
17+
/* Linting */
18+
"strict": true,
19+
"noUnusedLocals": true,
20+
"noUnusedParameters": true,
21+
"noFallthroughCasesInSwitch": true
1522
},
1623
"include": ["src/**/*.ts", "src/**/*.d.ts", "src/**/*.tsx", "src/**/*.vue"],
1724
"references": [{ "path": "./tsconfig.node.json" }]

0 commit comments

Comments
 (0)