chore: improve tsconfig

This commit is contained in:
Kevin Deng
2025-11-26 17:32:17 +08:00
parent 83f1f4f2dd
commit 9dac0d9a83
9 changed files with 35 additions and 24 deletions

View File

@@ -169,15 +169,15 @@ const App = {
``` ```
```jsx ```jsx
<input v-model={[val, ['modifier']]} />; ;<input v-model={[val, ['modifier']]} />
// 或者 // 或者
<input v-model_modifier={val} /> ;<input v-model_modifier={val} />
``` ```
```jsx ```jsx
<A v-model={[val, 'argument', ['modifier']]} />; ;<A v-model={[val, 'argument', ['modifier']]} />
// 或者 // 或者
<input v-model:argument_modifier={val} /> ;<input v-model:argument_modifier={val} />
``` ```
会编译成: 会编译成:

View File

@@ -173,15 +173,15 @@ const App = {
``` ```
```jsx ```jsx
<input v-model={[val, ['modifier']]} />; ;<input v-model={[val, ['modifier']]} />
// Or // Or
<input v-model_modifier={val} /> ;<input v-model_modifier={val} />
``` ```
```jsx ```jsx
<A v-model={[val, 'argument', ['modifier']]} />; ;<A v-model={[val, 'argument', ['modifier']]} />
// Or // Or
<input v-model:argument_modifier={val} /> ;<input v-model:argument_modifier={val} />
``` ```
Will compile to: Will compile to:

View File

@@ -11,7 +11,7 @@ import type { State, VueJSXPluginOptions } from './interface'
import type * as BabelCore from '@babel/core' import type * as BabelCore from '@babel/core'
import type { NodePath, Visitor } from '@babel/traverse' import type { NodePath, Visitor } from '@babel/traverse'
export { VueJSXPluginOptions } export type { VueJSXPluginOptions }
const hasJSX = (parentPath: NodePath<t.Program>) => { const hasJSX = (parentPath: NodePath<t.Program>) => {
let fileHasJSX = false let fileHasJSX = false

View File

@@ -10,7 +10,7 @@ import {
} from '@vue/compiler-sfc' } from '@vue/compiler-sfc'
import type * as BabelCore from '@babel/core' import type * as BabelCore from '@babel/core'
export { SimpleTypeResolveOptions as Options } export type { SimpleTypeResolveOptions as Options }
const plugin: ( const plugin: (
api: object, api: object,

View File

@@ -41,15 +41,15 @@ function main() {
}, },
} }
monaco.languages.typescript.typescriptDefaults.setDiagnosticsOptions({ monaco.typescript.typescriptDefaults.setDiagnosticsOptions({
noSemanticValidation: true, noSemanticValidation: true,
}) })
monaco.languages.typescript.typescriptDefaults.setCompilerOptions({ monaco.typescript.typescriptDefaults.setCompilerOptions({
allowJs: true, allowJs: true,
allowNonTsExtensions: true, allowNonTsExtensions: true,
jsx: monaco.languages.typescript.JsxEmit.Preserve, jsx: monaco.typescript.JsxEmit.Preserve,
target: monaco.languages.typescript.ScriptTarget.Latest, target: monaco.typescript.ScriptTarget.Latest,
module: monaco.languages.typescript.ModuleKind.ESNext, module: monaco.typescript.ModuleKind.ESNext,
isolatedModules: true, isolatedModules: true,
}) })

View File

@@ -1,7 +1,7 @@
import { createApp, defineComponent, reactive } from 'vue' import { createApp, defineComponent, reactive } from 'vue'
import type { VueJSXPluginOptions } from '@vue/babel-plugin-jsx' import type { VueJSXPluginOptions } from '@vue/babel-plugin-jsx'
export { VueJSXPluginOptions } export type { VueJSXPluginOptions }
export const compilerOptions: VueJSXPluginOptions = reactive({ export const compilerOptions: VueJSXPluginOptions = reactive({
mergeProps: true, mergeProps: true,

View File

@@ -0,0 +1,11 @@
import VueJSX from '@vitejs/plugin-vue-jsx'
import { defaultClientConditions, defineConfig } from 'vite'
export default defineConfig({
resolve: {
conditions: ['dev', ...defaultClientConditions],
},
define: {
'process.env.BABEL_TYPES_8_BREAKING': 'false',
},
plugins: [VueJSX()],
})

View File

@@ -1,19 +1,22 @@
{ {
"compilerOptions": { "compilerOptions": {
"target": "ESNext", "target": "esnext",
"jsx": "preserve", "jsx": "preserve",
"jsxImportSource": "vue", "jsxImportSource": "vue",
"lib": ["ES2023", "DOM", "DOM.Iterable"], "lib": ["es2023", "DOM"],
"moduleDetection": "force",
"customConditions": ["dev"], "customConditions": ["dev"],
"module": "ESNext", "module": "preserve",
"moduleResolution": "bundler", "moduleResolution": "bundler",
"resolveJsonModule": true, "resolveJsonModule": true,
"types": ["vitest/globals"], "types": ["vitest/globals"],
"allowJs": true,
"strict": true, "strict": true,
"noUnusedLocals": true, "noUnusedLocals": true,
"declaration": true,
"noEmit": true, "noEmit": true,
"esModuleInterop": true, "esModuleInterop": true,
"verbatimModuleSyntax": true,
"skipLibCheck": true "skipLibCheck": true
} },
"include": ["packages/*/src", "packages/*/test", "vitest.config.ts"]
} }

View File

@@ -3,9 +3,6 @@ import { defineConfig } from 'vitest/config'
import Jsx from './packages/babel-plugin-jsx/src' import Jsx from './packages/babel-plugin-jsx/src'
export default defineConfig({ export default defineConfig({
resolve: {
conditions: ['dev'],
},
esbuild: { esbuild: {
jsx: 'preserve', jsx: 'preserve',
}, },