Skip to content

Commit

Permalink
build: fix typescript version of vls
Browse files Browse the repository at this point in the history
  • Loading branch information
fi3ework committed Mar 24, 2022
1 parent 6c561e8 commit 4769045
Show file tree
Hide file tree
Showing 19 changed files with 1,994 additions and 2,771 deletions.
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,13 @@
"@types/rimraf": "^3.0.0",
"@types/semver": "^7.3.6",
"@types/ws": "^8.5.3",
"@typescript-eslint/eslint-plugin": "^4.15.2",
"@typescript-eslint/parser": "^4.15.2",
"@typescript-eslint/eslint-plugin": "^5.16.0",
"@typescript-eslint/parser": "^5.16.0",
"chalk": "^4.1.1",
"conventional-changelog-cli": "^2.1.1",
"cross-env": "^7.0.3",
"eslint": "^7.28.0",
"eslint-config-alloy": "^3.10.0",
"eslint": "^8.11.0",
"eslint-config-alloy": "^4.5.1",
"eslint-plugin-svelte3": "^3.4.0",
"execa": "^5.1.1",
"fast-json-stable-stringify": "^2.1.0",
Expand All @@ -68,7 +68,7 @@
"strip-ansi": "^7.0.0",
"svelte": "^3.46.3",
"ts-jest": "^27.1.3",
"typescript": "^4.6.2",
"typescript": "~4.5.5",
"vite": "^2.7.13",
"vite-plugin-checker": "workspace:*",
"ws": "^8.5.0",
Expand Down
6 changes: 3 additions & 3 deletions packages/vite-plugin-checker/__tests__/e2e/Sandbox/Sandbox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ export function proxyConsoleInTest(accumulate = true) {
}

export async function sleepForServerReady(ratio = 1) {
await sleep(process.env.CI ? 10000 * ratio : 5000 * ratio)
await sleep(process.env.CI ? 10e3 * ratio : 5e3 * ratio)
}

export async function sleepForEdit() {
await sleep(process.env.CI ? 4000 : 2000)
export async function sleepForEdit(ratio = 1) {
await sleep(process.env.CI ? 4e3 * ratio : 2e3 * ratio)
}

export function resetReceivedLog() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ Object {
"javascript": Object {
"format": Object {},
},
"languageStylus": Object {},
"stylusSupremacy": Object {},
"typescript": Object {
"format": Object {},
Expand Down Expand Up @@ -78,6 +79,7 @@ Object {
"javascript": Object {
"format": Object {},
},
"languageStylus": Object {},
"stylusSupremacy": Object {},
"typescript": Object {
"format": Object {},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ export const eslintResult1: ESLint.LintResult = {
},
],
errorCount: 2,
fatalErrorCount: 2,
warningCount: 0,
fixableErrorCount: 2,
fixableWarningCount: 0,
Expand Down
3 changes: 2 additions & 1 deletion packages/vite-plugin-checker/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,9 @@
"esbuild": "^0.14.13",
"npm-run-all": "^4.1.5",
"optionator": "^0.9.1",
"vls": "^0.7.2",
"vls": "^0.7.6",
"vue-tsc": "0.33.5",
"typescript": "~4.5.5",
"@volar/vue-typescript": "^0.33.0"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import { DeepPartial } from '../../types'
import { getInitParams, VlsOptions } from './initParams'

import { FileDiagnosticManager } from '../../FileDiagnosticManager'

enum DOC_VERSION {
init = -1,
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export function prepareVueTsc() {
const tsVersion = require('typescript/package.json').version
if (toDirVersion !== tsVersion) {
shouldPrepare = true
fs.rmdirSync(tsDirTo)
rimraf(tsDirTo)
}
} else {
shouldPrepare = true
Expand Down Expand Up @@ -88,3 +88,20 @@ function modifyFileText(
}
fs.writeFileSync(filePath, newText)
}

/**
* https://stackoverflow.com/a/42505874
*/
function rimraf(dir_path: string) {
if (fs.existsSync(dir_path)) {
fs.readdirSync(dir_path).forEach(function (entry) {
var entry_path = path.join(dir_path, entry)
if (fs.lstatSync(entry_path).isDirectory()) {
rimraf(entry_path)
} else {
fs.unlinkSync(entry_path)
}
})
fs.rmdirSync(dir_path)
}
}
16 changes: 12 additions & 4 deletions playground/basic/__tests__/__snapshots__/overlay-true.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,29 @@ exports[`overlay-true overlay prompts and changes 1`] = `"Unexpected var, use le
exports[`overlay-true overlay prompts and changes 2`] = `"<PROJECT_ROOT>/temp/basic/src/main.ts:3:1"`;
exports[`overlay-true overlay prompts and changes 3`] = `
" 1 | import { text } from './text'
"
1 | import { text } from './text'
2 |
> 3 | var hello = 'Hello'
| ^^^^^^^^^^^^^^^^^^^
4 |
5 | const rootDom = document.querySelector('#root')! as HTMLElement
6 | rootDom.innerHTML = hello + text"
6 | rootDom.innerHTML = hello + text
"
`;
exports[`overlay-true overlay prompts and changes 4`] = `
" 1 | import { text } from './text'
"
1 | import { text } from './text'
2 |
> 3 | var hello = 'Hello1'
| ^^^^^^^^^^^^^^^^^^^^
4 |
5 | const rootDom = document.querySelector('#root')! as HTMLElement
6 | rootDom.innerHTML = hello + text"
6 | rootDom.innerHTML = hello + text
"
`;
6 changes: 3 additions & 3 deletions playground/basic/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
"devDependencies": {
"@types/react": "^17.0.0",
"@types/react-dom": "^17.0.0",
"eslint": "^7.28.0",
"@typescript-eslint/eslint-plugin": "^4.15.2",
"typescript": "^4.6.2",
"eslint": "^8.11.0",
"@typescript-eslint/eslint-plugin": "^5.16.0",
"typescript": "~4.5.5",
"vite": "^2.7.13",
"vite-plugin-checker": "workspace:*"
}
Expand Down
6 changes: 3 additions & 3 deletions playground/eslint/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
"devDependencies": {
"@types/react": "^17.0.0",
"@types/react-dom": "^17.0.0",
"eslint": "^7.28.0",
"@typescript-eslint/eslint-plugin": "^4.15.2",
"typescript": "^4.6.2",
"eslint": "^8.11.0",
"@typescript-eslint/eslint-plugin": "^5.16.0",
"typescript": "~4.5.5",
"vite": "^2.7.13",
"vite-plugin-checker": "workspace:*"
}
Expand Down
2 changes: 1 addition & 1 deletion playground/multiple-hmr/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"@types/react": "^17.0.0",
"@types/react-dom": "^17.0.0",
"@vitejs/plugin-react": "^1.1.4",
"typescript": "^4.6.2",
"typescript": "~4.5.5",
"vite": "^2.7.13",
"vite-plugin-checker": "workspace:*"
}
Expand Down
2 changes: 1 addition & 1 deletion playground/multiple-reload/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"@types/react": "^17.0.0",
"@types/react-dom": "^17.0.0",
"@vitejs/plugin-react-refresh": "^1.3.1",
"typescript": "^4.6.2",
"typescript": "~4.5.5",
"vite": "^2.7.13",
"vite-plugin-checker": "workspace:*"
}
Expand Down
2 changes: 1 addition & 1 deletion playground/react-ts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"@types/react": "^17.0.0",
"@types/react-dom": "^17.0.0",
"@vitejs/plugin-react": "^1.1.4",
"typescript": "^4.6.2",
"typescript": "~4.5.5",
"vite": "^2.7.13",
"vite-plugin-checker": "workspace:*"
}
Expand Down
6 changes: 3 additions & 3 deletions playground/vue2-vls/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@
"eslint-plugin-vue": "^7.6.0",
"prettier": "2.3.0",
"sass": "^1.32.7",
"typescript": "^4.6.2",
"vite": "^2.7.13",
"vite-plugin-checker": "workspace:*",
"vite-plugin-components": "^0.12.2",
"vite-plugin-vue2": "^1.9.0",
"vls": "^0.7.2",
"typescript": "~4.3.2",
"vite-plugin-checker": "workspace:*",
"vls": "^0.7.6",
"vue-template-compiler": "^2.6.14"
}
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`vue3-vue-tsc serve get initial error and subsequent error 1`] = `"[{\\"checkerId\\":\\"TypeScript\\",\\"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>/temp/vue3-vue-tsc/src/App.vue\\",\\"level\\":1,\\"loc\\":{\\"column\\":4,\\"file\\":\\"<PROJECT_ROOT>/temp/vue3-vue-tsc/src/App.vue\\",\\"line\\":3},\\"message\\":\\"Type '{ msg1: string; }' is not assignable to type 'IntrinsicAttributes & Partial<{}> & Omit<Readonly<{ msg?: unknown; } & { msg: string; } & {}> & VNodeProps & AllowedComponentProps & ComponentCustomProps, never>'./n Property 'msg' is missing in type '{ msg1: string; }' but required in type 'Omit<Readonly<{ msg?: unknown; } & { msg: string; } & {}> & VNodeProps & AllowedComponentProps & ComponentCustomProps, never>'.\\",\\"stack\\":\\"\\"}]"`;
exports[`vue3-vue-tsc 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>/temp/vue3-vue-tsc/src/App.vue\\",\\"level\\":1,\\"loc\\":{\\"column\\":4,\\"file\\":\\"<PROJECT_ROOT>/temp/vue3-vue-tsc/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[`vue3-vue-tsc serve get initial error and subsequent error 2`] = `
"
ERROR(TypeScript) Type '{ msg1: string; }' is not assignable to type 'IntrinsicAttributes & Partial<{}> & Omit<Readonly<{ msg?: unknown; } & { msg: string; } & {}> & VNodeProps & AllowedComponentProps & ComponentCustomProps, never>'.
Property 'msg' is missing in type '{ msg1: string; }' but required in type 'Omit<Readonly<{ msg?: unknown; } & { msg: string; } & {}> & VNodeProps & AllowedComponentProps & ComponentCustomProps, never>'.
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>'.
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>/temp/vue3-vue-tsc/src/App.vue:3:4
1 | <template>
Expand All @@ -16,15 +16,15 @@ exports[`vue3-vue-tsc serve get initial error and subsequent error 2`] = `
5 |
6 | <script lang=\\"ts\\">
[TypeScript] Found 1 error. Watching for file changes."
[vue-tsc] Found 1 error. Watching for file changes."
`;
exports[`vue3-vue-tsc serve get initial error and subsequent error 3`] = `"[{\\"checkerId\\":\\"TypeScript\\",\\"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>/temp/vue3-vue-tsc/src/App.vue\\",\\"level\\":1,\\"loc\\":{\\"column\\":4,\\"file\\":\\"<PROJECT_ROOT>/temp/vue3-vue-tsc/src/App.vue\\",\\"line\\":3},\\"message\\":\\"Type '{ msg2: string; }' is not assignable to type 'IntrinsicAttributes & Partial<{}> & Omit<Readonly<{ msg?: unknown; } & { msg: string; } & {}> & VNodeProps & AllowedComponentProps & ComponentCustomProps, never>'./n Property 'msg' is missing in type '{ msg2: string; }' but required in type 'Omit<Readonly<{ msg?: unknown; } & { msg: string; } & {}> & VNodeProps & AllowedComponentProps & ComponentCustomProps, never>'.\\",\\"stack\\":\\"\\"}]"`;
exports[`vue3-vue-tsc 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>/temp/vue3-vue-tsc/src/App.vue\\",\\"level\\":1,\\"loc\\":{\\"column\\":4,\\"file\\":\\"<PROJECT_ROOT>/temp/vue3-vue-tsc/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[`vue3-vue-tsc serve get initial error and subsequent error 4`] = `
"
ERROR(TypeScript) Type '{ msg2: string; }' is not assignable to type 'IntrinsicAttributes & Partial<{}> & Omit<Readonly<{ msg?: unknown; } & { msg: string; } & {}> & VNodeProps & AllowedComponentProps & ComponentCustomProps, never>'.
Property 'msg' is missing in type '{ msg2: string; }' but required in type 'Omit<Readonly<{ msg?: unknown; } & { msg: string; } & {}> & VNodeProps & AllowedComponentProps & ComponentCustomProps, never>'.
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>'.
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>/temp/vue3-vue-tsc/src/App.vue:3:4
1 | <template>
Expand All @@ -35,5 +35,5 @@ exports[`vue3-vue-tsc serve get initial error and subsequent error 4`] = `
5 |
6 | <script lang=\\"ts\\">
[TypeScript] Found 1 error. Watching for file changes."
[vue-tsc] Found 1 error. Watching for file changes."
`;
4 changes: 2 additions & 2 deletions playground/vue3-vue-tsc/__tests__/test.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,14 @@ describe('vue3-vue-tsc', () => {
editFile('src/App.vue', (code) =>
code.replace('<HelloWorld msg1="Diana" />', '<HelloWorld msg2="Diana" />')
)
await sleepForEdit()
await sleepForEdit(2)
expect(stringify(diagnostics)).toMatchSnapshot()
expect(stripedLog).toMatchSnapshot()
})
})

describe('build', () => {
const errMsg = `error TS2322: Type '{ msg1: string; }' is not assignable to type 'IntrinsicAttributes & Partial<{}> & Omit<Readonly<{ msg?: unknown; } & { msg: string; } & {}> & VNodeProps & AllowedComponentProps & ComponentCustomProps, never>'.`
const errMsg = `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>'.`

it('enableBuild: true', async () => {
await viteBuild({
Expand Down
2 changes: 1 addition & 1 deletion playground/vue3-vue-tsc/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
},
"devDependencies": {
"@vitejs/plugin-vue": "^2.0.1",
"typescript": "^4.6.2",
"typescript": "~4.5.5",
"vite": "^2.7.13",
"vite-plugin-checker": "workspace:*",
"vue-tsc": "0.33.5"
Expand Down
Loading

0 comments on commit 4769045

Please sign in to comment.