Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(vue-tsc): support volar v1.0.14 #194

Merged
merged 1 commit into from Dec 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/vite-plugin-checker/package.json
Expand Up @@ -104,6 +104,6 @@
"typescript": "~4.5.5",
"vls": "^0.7.6",
"vti": "^0.1.7",
"vue-tsc": "0.38.9"
"vue-tsc": "1.0.14"
}
}
14 changes: 12 additions & 2 deletions packages/vite-plugin-checker/src/checkers/vueTsc/prepareVueTsc.ts
Expand Up @@ -8,7 +8,17 @@ const _require = createRequire(import.meta.url)
const _filename = fileURLToPath(import.meta.url)
const _dirname = dirname(_filename)

const proxyPath = _require.resolve('vue-tsc/out/proxy')
let proxyPath: string
let createProgramFunction: string
try {
// vue-tsc exposes the proxy in vue-tsc/out/index after v1.0.14
proxyPath = _require.resolve('vue-tsc/out/index')
createProgramFunction = 'createProgram'
} catch (e) {
// vue-tsc exposes the proxy in vue-tsc/out/proxy before v1.0.14
proxyPath = _require.resolve('vue-tsc/out/proxy')
createProgramFunction = 'createProgramProxy'
}

const textToReplace: { target: string; replacement: string }[] = [
{
Expand All @@ -34,7 +44,7 @@ const textToReplace: { target: string; replacement: string }[] = [
target: `function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _configFileParsingDiagnostics) {`,
replacement: `function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _configFileParsingDiagnostics) { return require(${JSON.stringify(
proxyPath
)}).createProgramProxy(...arguments);`,
)}).${createProgramFunction}(...arguments);`,
},
{
target: `ts.executeCommandLine(ts.sys, ts.noop, ts.sys.args);`,
Expand Down
@@ -1,10 +1,10 @@
// Vitest Snapshot v1

exports[`vue-tsc-vue3 > serve > get initial error and subsequent error 1`] = `"[{\\"checkerId\\":\\"vue-tsc\\",\\"frame\\":\\" 1 | <template>/n 2 | <img alt=/\\"Vue logo/\\" src=/\\"./assets/logo.png/\\" />/n > 3 | <HelloWorld msg1=/\\"Diana/\\" />/n | ^^^^^^^^^^/n 4 | </template>/n 5 |/n 6 | <script lang=/\\"ts/\\">\\",\\"id\\":\\"<PROJECT_ROOT>/playground-temp/vue-tsc-vue3/src/App.vue\\",\\"level\\":1,\\"loc\\":{\\"column\\":4,\\"file\\":\\"<PROJECT_ROOT>/playground-temp/vue-tsc-vue3/src/App.vue\\",\\"line\\":3},\\"message\\":\\"Type '{ msg1: string; }' is not assignable to type 'IntrinsicAttributes & Partial<{}> & Omit<Readonly<ExtractPropTypes<{ msg: { type: StringConstructor; required: true; }; }>> & VNodeProps & AllowedComponentProps & ComponentCustomProps, never>'./n Property 'msg' is missing in type '{ msg1: string; }' but required in type 'Omit<Readonly<ExtractPropTypes<{ msg: { type: StringConstructor; required: true; }; }>> & VNodeProps & AllowedComponentProps & ComponentCustomProps, never>'.\\",\\"stack\\":\\"\\"}]"`;
exports[`vue-tsc-vue3 > serve > get initial error and subsequent error 1`] = `"[{\\"checkerId\\":\\"vue-tsc\\",\\"frame\\":\\" 1 | <template>/n 2 | <img alt=/\\"Vue logo/\\" src=/\\"./assets/logo.png/\\" />/n > 3 | <HelloWorld msg1=/\\"Diana/\\" />/n | ^^^^^^^^^^/n 4 | </template>/n 5 |/n 6 | <script lang=/\\"ts/\\">\\",\\"id\\":\\"<PROJECT_ROOT>/playground-temp/vue-tsc-vue3/src/App.vue\\",\\"level\\":1,\\"loc\\":{\\"column\\":4,\\"file\\":\\"<PROJECT_ROOT>/playground-temp/vue-tsc-vue3/src/App.vue\\",\\"line\\":3},\\"message\\":\\"Type '{ msg1: string; }' is not assignable to type 'ComponentProps<DefineComponent<{ msg: { type: StringConstructor; required: true; }; }, { count: Ref<number>; }, unknown, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, ... 4 more ..., {}>>'./n Property 'msg' is missing in type '{ msg1: string; }' but required in type 'Omit<Readonly<ExtractPropTypes<{ msg: { type: StringConstructor; required: true; }; }>> & VNodeProps & AllowedComponentProps & ComponentCustomProps, never>'.\\",\\"stack\\":\\"\\"}]"`;

exports[`vue-tsc-vue3 > serve > get initial error and subsequent error 2`] = `
"
ERROR(vue-tsc) Type '{ msg1: string; }' is not assignable to type 'IntrinsicAttributes & Partial<{}> & Omit<Readonly<ExtractPropTypes<{ msg: { type: StringConstructor; required: true; }; }>> & VNodeProps & AllowedComponentProps & ComponentCustomProps, never>'.
ERROR(vue-tsc) Type '{ msg1: string; }' is not assignable to type 'ComponentProps<DefineComponent<{ msg: { type: StringConstructor; required: true; }; }, { count: Ref<number>; }, unknown, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, ... 4 more ..., {}>>'.
Property 'msg' is missing in type '{ msg1: string; }' but required in type 'Omit<Readonly<ExtractPropTypes<{ msg: { type: StringConstructor; required: true; }; }>> & VNodeProps & AllowedComponentProps & ComponentCustomProps, never>'.
FILE <PROJECT_ROOT>/playground-temp/vue-tsc-vue3/src/App.vue:3:4

Expand All @@ -19,11 +19,11 @@ exports[`vue-tsc-vue3 > serve > get initial error and subsequent error 2`] = `
[vue-tsc] Found 1 error. Watching for file changes."
`;

exports[`vue-tsc-vue3 > serve > get initial error and subsequent error 3`] = `"[{\\"checkerId\\":\\"vue-tsc\\",\\"frame\\":\\" 1 | <template>/n 2 | <img alt=/\\"Vue logo/\\" src=/\\"./assets/logo.png/\\" />/n > 3 | <HelloWorld msg2=/\\"Diana/\\" />/n | ^^^^^^^^^^/n 4 | </template>/n 5 |/n 6 | <script lang=/\\"ts/\\">\\",\\"id\\":\\"<PROJECT_ROOT>/playground-temp/vue-tsc-vue3/src/App.vue\\",\\"level\\":1,\\"loc\\":{\\"column\\":4,\\"file\\":\\"<PROJECT_ROOT>/playground-temp/vue-tsc-vue3/src/App.vue\\",\\"line\\":3},\\"message\\":\\"Type '{ msg2: string; }' is not assignable to type 'IntrinsicAttributes & Partial<{}> & Omit<Readonly<ExtractPropTypes<{ msg: { type: StringConstructor; required: true; }; }>> & VNodeProps & AllowedComponentProps & ComponentCustomProps, never>'./n Property 'msg' is missing in type '{ msg2: string; }' but required in type 'Omit<Readonly<ExtractPropTypes<{ msg: { type: StringConstructor; required: true; }; }>> & VNodeProps & AllowedComponentProps & ComponentCustomProps, never>'.\\",\\"stack\\":\\"\\"}]"`;
exports[`vue-tsc-vue3 > serve > get initial error and subsequent error 3`] = `"[{\\"checkerId\\":\\"vue-tsc\\",\\"frame\\":\\" 1 | <template>/n 2 | <img alt=/\\"Vue logo/\\" src=/\\"./assets/logo.png/\\" />/n > 3 | <HelloWorld msg2=/\\"Diana/\\" />/n | ^^^^^^^^^^/n 4 | </template>/n 5 |/n 6 | <script lang=/\\"ts/\\">\\",\\"id\\":\\"<PROJECT_ROOT>/playground-temp/vue-tsc-vue3/src/App.vue\\",\\"level\\":1,\\"loc\\":{\\"column\\":4,\\"file\\":\\"<PROJECT_ROOT>/playground-temp/vue-tsc-vue3/src/App.vue\\",\\"line\\":3},\\"message\\":\\"Type '{ msg2: string; }' is not assignable to type 'ComponentProps<DefineComponent<{ msg: { type: StringConstructor; required: true; }; }, { count: Ref<number>; }, unknown, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, ... 4 more ..., {}>>'./n Property 'msg' is missing in type '{ msg2: string; }' but required in type 'Omit<Readonly<ExtractPropTypes<{ msg: { type: StringConstructor; required: true; }; }>> & VNodeProps & AllowedComponentProps & ComponentCustomProps, never>'.\\",\\"stack\\":\\"\\"}]"`;

exports[`vue-tsc-vue3 > serve > get initial error and subsequent error 4`] = `
"
ERROR(vue-tsc) Type '{ msg2: string; }' is not assignable to type 'IntrinsicAttributes & Partial<{}> & Omit<Readonly<ExtractPropTypes<{ msg: { type: StringConstructor; required: true; }; }>> & VNodeProps & AllowedComponentProps & ComponentCustomProps, never>'.
ERROR(vue-tsc) Type '{ msg2: string; }' is not assignable to type 'ComponentProps<DefineComponent<{ msg: { type: StringConstructor; required: true; }; }, { count: Ref<number>; }, unknown, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, ... 4 more ..., {}>>'.
Property 'msg' is missing in type '{ msg2: string; }' but required in type 'Omit<Readonly<ExtractPropTypes<{ msg: { type: StringConstructor; required: true; }; }>> & VNodeProps & AllowedComponentProps & ComponentCustomProps, never>'.
FILE <PROJECT_ROOT>/playground-temp/vue-tsc-vue3/src/App.vue:3:4

Expand Down
2 changes: 1 addition & 1 deletion playground/vue-tsc-vue3/__tests__/test.spec.ts
Expand Up @@ -34,7 +34,7 @@ describe('vue-tsc-vue3', () => {

describe.runIf(isBuild)('build', () => {
it('should fail', async () => {
const expectedMsg = `src/App.vue(3,4): error TS2322: Type '{ msg1: string; }' is not assignable to type 'IntrinsicAttributes & Partial<{}> & Omit<Readonly<ExtractPropTypes<{ msg: { type: StringConstructor; required: true; }; }>> & VNodeProps & AllowedComponentProps & ComponentCustomProps, never>'.`
const expectedMsg = `src/App.vue(3,4): error TS2322: Type '{ msg1: string; }' is not assignable to type 'ComponentProps<DefineComponent<{ msg: { type: StringConstructor; required: true; }; }, { count: Ref<number>; }, unknown, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, ... 4 more ..., {}>>'.`
expectStderrContains(log, expectedMsg)
})
})
Expand Down
2 changes: 1 addition & 1 deletion playground/vue-tsc-vue3/package.json
Expand Up @@ -16,6 +16,6 @@
"typescript": "~4.5.5",
"vite": "^3.0.4",
"vite-plugin-checker": "workspace:*",
"vue-tsc": "^0.39.5"
"vue-tsc": "^1.0.14"
}
}