Skip to content

Commit 5dd90c9

Browse files
committed
fix: compatible with mac’s duplication watch report
1 parent 30510a6 commit 5dd90c9

File tree

9 files changed

+44
-75
lines changed

9 files changed

+44
-75
lines changed

packages/vite-plugin-checker/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,6 @@
112112
"typescript": "^5.0.4",
113113
"vls": "^0.7.6",
114114
"vti": "^0.1.7",
115-
"vue-tsc": "^1.4.3"
115+
"vue-tsc": "^1.6.1"
116116
}
117117
}

packages/vite-plugin-checker/src/checkers/vueTsc/main.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,7 @@ const createDiagnostic: CreateDiagnostic<'vueTsc'> = (pluginConfig) => {
3838
invariant(pluginConfig.vueTsc, 'config.vueTsc should be `false`')
3939

4040
const { targetTsDir } = await prepareVueTsc()
41-
4241
const vueTs = _require(path.resolve(targetTsDir, 'lib/typescript.js'))
43-
4442
const finalConfig =
4543
pluginConfig.vueTsc === true
4644
? { root, tsconfigPath: 'tsconfig.json' }
@@ -64,6 +62,7 @@ const createDiagnostic: CreateDiagnostic<'vueTsc'> = (pluginConfig) => {
6462
}
6563

6664
let logChunk = ''
65+
let prevLogChunk = ''
6766

6867
// https://github.com/microsoft/TypeScript/blob/a545ab1ac2cb24ff3b1aaf0bfbfb62c499742ac2/src/compiler/watch.ts#L12-L28
6968
const reportDiagnostic = (diagnostic: ts.Diagnostic) => {
@@ -110,9 +109,15 @@ const createDiagnostic: CreateDiagnostic<'vueTsc'> = (pluginConfig) => {
110109
}
111110

112111
if (terminal) {
113-
consoleLog(
112+
logChunk =
114113
logChunk + os.EOL + wrapCheckerSummary('vue-tsc', diagnostic.messageText.toString())
115-
)
114+
if (logChunk === prevLogChunk) {
115+
return
116+
}
117+
118+
// TODO: only macOS will report multiple times for same result
119+
prevLogChunk = logChunk
120+
consoleLog(logChunk)
116121
}
117122
})
118123
}

packages/vite-plugin-checker/src/checkers/vueTsc/prepareVueTsc.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ export async function prepareVueTsc() {
3030
// 1. copy typescript to folder
3131
const targetTsDir = path.resolve(_dirname, 'typescript-vue-tsc')
3232
const vueTscFlagFile = path.resolve(targetTsDir, 'vue-tsc-resolve-path')
33-
// let currTsVersion: string = ''
3433
const currTsVersion = _require('typescript/package.json').version
3534

3635
let shouldBuildFixture = true

playground/vue-tsc-vue3-ts4/__tests__/__snapshots__/test.spec.ts.snap

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -35,18 +35,5 @@ exports[`vue-tsc-vue3-ts4 > serve > get initial error and subsequent error 4`] =
3535
5 |
3636
6 | <script lang=\\"ts\\">
3737
38-
[vue-tsc] Found 1 error. Watching for file changes.
39-
ERROR(vue-tsc) Argument of type '{ msg2: string; }' is not assignable to parameter of type 'Partial<{}> & Omit<Readonly<ExtractPropTypes<{ msg: { type: StringConstructor; required: true; }; }>> & VNodeProps & AllowedComponentProps & ComponentCustomProps, never> & Record<...>'.
40-
Property 'msg' is missing in type '{ msg2: string; }' but required in type 'Omit<Readonly<ExtractPropTypes<{ msg: { type: StringConstructor; required: true; }; }>> & VNodeProps & AllowedComponentProps & ComponentCustomProps, never>'.
41-
FILE <PROJECT_ROOT>/playground-temp/vue-tsc-vue3-ts4/src/App.vue:3:4
42-
43-
1 | <template>
44-
2 | <img alt=\\"Vue logo\\" src=\\"./assets/logo.png\\" />
45-
> 3 | <HelloWorld msg2=\\"Diana\\" />
46-
| ^^^^^^^^^^
47-
4 | </template>
48-
5 |
49-
6 | <script lang=\\"ts\\">
50-
5138
[vue-tsc] Found 1 error. Watching for file changes."
5239
`;

playground/vue-tsc-vue3-ts4/__tests__/test.spec.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@ describe('vue-tsc-vue3-ts4', () => {
1919
it('get initial error and subsequent error', async () => {
2020
await sleepForServerReady(2)
2121
expect(stringify(diagnostics)).toMatchSnapshot()
22-
console.log('🙇 diagnostics', stringify(diagnostics))
23-
console.log('🙇 stripedLog', stripedLog)
2422
expect(stripedLog).toMatchSnapshot()
2523

2624
console.log('-- edit file --')

playground/vue-tsc-vue3-ts4/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@
99
"serve": "vite preview"
1010
},
1111
"dependencies": {
12-
"vue": "^3.2.25"
12+
"vue": "^3.2.47"
1313
},
1414
"devDependencies": {
1515
"@vitejs/plugin-vue": "^2.0.1",
1616
"typescript": "^4",
1717
"vite": "^4.3.0",
1818
"vite-plugin-checker": "workspace:*",
19-
"vue-tsc": "^1.4.3"
19+
"vue-tsc": "^1.6.1"
2020
}
2121
}

playground/vue-tsc-vue3/__tests__/__snapshots__/test.spec.ts.snap

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -35,18 +35,5 @@ exports[`vue-tsc-vue3 > serve > get initial error and subsequent error 4`] = `
3535
5 |
3636
6 | <script lang=\\"ts\\">
3737
38-
[vue-tsc] Found 1 error. Watching for file changes.
39-
ERROR(vue-tsc) Argument of type '{ msg2: string; }' is not assignable to parameter of type 'Partial<{}> & Omit<Readonly<ExtractPropTypes<{ msg: { type: StringConstructor; required: true; }; }>> & VNodeProps & AllowedComponentProps & ComponentCustomProps, never> & Record<...>'.
40-
Property 'msg' is missing in type '{ msg2: string; }' but required in type 'Omit<Readonly<ExtractPropTypes<{ msg: { type: StringConstructor; required: true; }; }>> & VNodeProps & AllowedComponentProps & ComponentCustomProps, never>'.
41-
FILE <PROJECT_ROOT>/playground-temp/vue-tsc-vue3/src/App.vue:3:4
42-
43-
1 | <template>
44-
2 | <img alt=\\"Vue logo\\" src=\\"./assets/logo.png\\" />
45-
> 3 | <HelloWorld msg2=\\"Diana\\" />
46-
| ^^^^^^^^^^
47-
4 | </template>
48-
5 |
49-
6 | <script lang=\\"ts\\">
50-
5138
[vue-tsc] Found 1 error. Watching for file changes."
5239
`;

playground/vue-tsc-vue3/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@
99
"serve": "vite preview"
1010
},
1111
"dependencies": {
12-
"vue": "^3.2.25"
12+
"vue": "^3.2.47"
1313
},
1414
"devDependencies": {
1515
"@vitejs/plugin-vue": "^2.0.1",
1616
"typescript": "^5.0.4",
1717
"vite": "^4.3.0",
1818
"vite-plugin-checker": "workspace:*",
19-
"vue-tsc": "^1.4.3"
19+
"vue-tsc": "^1.6.1"
2020
}
2121
}

pnpm-lock.yaml

Lines changed: 30 additions & 37 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)