Skip to content

Commit

Permalink
fix(vue-tsc): support volar v1.0.14
Browse files Browse the repository at this point in the history
Fixes fi3ework#193

volar v1.0.14 renamed the `proxy.ts` file in `index.ts` and changed `createProgramProxy` into `createProgram`.
  • Loading branch information
cexbrayat committed Dec 20, 2022
1 parent d1c422c commit 9c987d1
Show file tree
Hide file tree
Showing 6 changed files with 139 additions and 90 deletions.
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"
}
}
Expand Up @@ -8,7 +8,14 @@ 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
try {
// vue-tsc exposes the proxy in vue-tsc/out/index after v1.0.14
proxyPath = _require.resolve('vue-tsc/out/index')
} catch (e) {
// vue-tsc exposes the proxy in vue-tsc/out/proxy before v1.0.14
proxyPath = _require.resolve('vue-tsc/out/proxy')
}

const textToReplace: { target: string; replacement: string }[] = [
{
Expand All @@ -34,7 +41,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);`,
)}).createProgram(...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"
}
}

0 comments on commit 9c987d1

Please sign in to comment.