From e4f07530d30aa1d57e5caa34bef001ce351c5d96 Mon Sep 17 00:00:00 2001 From: yoyo930021 Date: Sat, 16 Oct 2021 10:36:13 +0800 Subject: [PATCH] Upgrade to typescript 4.4 --- client/commands/generateGrammarCommand.ts | 2 +- package.json | 2 +- server/package.json | 4 ++-- server/src/modes/style/stylus/parser.ts | 2 +- .../src/modes/template/interpolationMode.ts | 2 +- .../src/modes/template/services/htmlLinks.ts | 2 +- .../tagProviders/externalTagProviders.ts | 4 ++-- .../src/modes/template/tagProviders/index.ts | 2 +- server/src/modes/vue/snippets.ts | 4 ++-- server/src/services/dependencyService.ts | 4 ++-- server/src/services/projectService.ts | 2 +- .../services/typescriptService/preprocess.ts | 2 +- server/src/utils/prettier/index.ts | 8 ++++---- server/src/utils/vueVersion.ts | 2 +- server/yarn.lock | 8 ++++---- test/grammar/grammar.test.ts | 4 ++-- vti/src/commands/diagnostics.ts | 20 +++++++++---------- yarn.lock | 8 ++++---- 18 files changed, 40 insertions(+), 42 deletions(-) diff --git a/client/commands/generateGrammarCommand.ts b/client/commands/generateGrammarCommand.ts index c467fb7a63..b3f9ecccb3 100644 --- a/client/commands/generateGrammarCommand.ts +++ b/client/commands/generateGrammarCommand.ts @@ -15,7 +15,7 @@ export function generateGrammarCommandHandler(extensionPath: string) { writeFileSync(resolve(extensionPath, 'syntaxes/vue-generated.json'), generatedGrammar, 'utf-8'); vscode.window.showInformationMessage('Successfully generated vue grammar. Reload VS Code to enable it.'); } catch (e) { - console.error(e.stack); + console.error((e as Error).stack); vscode.window.showErrorMessage( 'Failed to generate vue grammar. `vetur.grammar.customBlocks` contain invalid language values' ); diff --git a/package.json b/package.json index 9555f2b47f..901707dbf4 100644 --- a/package.json +++ b/package.json @@ -623,7 +623,7 @@ "shelljs": "^0.8.4", "ts-node": "^10.0.0", "tslint": "^6.1.3", - "typescript": "^4.3.2", + "typescript": "^4.4.4", "vscode-languageclient": "^7.0.0", "vscode-languageserver-types": "^3.16.0" } diff --git a/server/package.json b/server/package.json index 4a4e7d980b..d04ade744b 100644 --- a/server/package.json +++ b/server/package.json @@ -27,10 +27,10 @@ "prettier": "^2.3.2", "pug-lexer": "^5.0.1", "tslint": "6.1.3", - "typescript": "^4.3.2" + "typescript": "^4.4.4" }, "resolutions": { - "typescript": "^4.3.2" + "typescript": "^4.4.4" }, "devDependencies": { "@prettier/plugin-pug": "^1.16.7", diff --git a/server/src/modes/style/stylus/parser.ts b/server/src/modes/style/stylus/parser.ts index f84479ded3..39b3008ee0 100644 --- a/server/src/modes/style/stylus/parser.ts +++ b/server/src/modes/style/stylus/parser.ts @@ -114,7 +114,7 @@ export function buildAst(text: string): StylusNode | null { addScope(ret, 0, []); return ret; } catch (error) { - console.error(error.stack); + console.error((error as Error).stack); return null; } } diff --git a/server/src/modes/template/interpolationMode.ts b/server/src/modes/template/interpolationMode.ts index 2bf458c8cb..ee03044c34 100644 --- a/server/src/modes/template/interpolationMode.ts +++ b/server/src/modes/template/interpolationMode.ts @@ -168,7 +168,7 @@ export class VueInterpolationMode implements LanguageMode { }); } catch (err) { console.log('Interpolation completion failed'); - console.error(err.stack); + console.error((err as Error).stack); } if (!completions) { diff --git a/server/src/modes/template/services/htmlLinks.ts b/server/src/modes/template/services/htmlLinks.ts index dd67c51ede..e7d3129a6a 100644 --- a/server/src/modes/template/services/htmlLinks.ts +++ b/server/src/modes/template/services/htmlLinks.ts @@ -70,7 +70,7 @@ function isValidURI(uri: string) { URI.parse(uri); return true; } catch (e) { - console.error(e.stack); + console.error((e as Error).stack); return false; } } diff --git a/server/src/modes/template/tagProviders/externalTagProviders.ts b/server/src/modes/template/tagProviders/externalTagProviders.ts index e979ab1677..009d062562 100644 --- a/server/src/modes/template/tagProviders/externalTagProviders.ts +++ b/server/src/modes/template/tagProviders/externalTagProviders.ts @@ -40,7 +40,7 @@ export function getWorkspaceTagProvider(packageRoot: string, rootPkgJson: any): } return null; } catch (err) { - console.error(err.stack); + console.error((err as Error).stack); return null; } } @@ -67,7 +67,7 @@ export function getDependencyTagProvider( const attrsJson = JSON.parse(fs.readFileSync(attrsPath, 'utf-8')); return getExternalTagProvider(depName, tagsJson, attrsJson); } catch (err) { - console.error(err.stack); + console.error((err as Error).stack); return null; } } diff --git a/server/src/modes/template/tagProviders/index.ts b/server/src/modes/template/tagProviders/index.ts index 37c3526597..7a954a1af8 100644 --- a/server/src/modes/template/tagProviders/index.ts +++ b/server/src/modes/template/tagProviders/index.ts @@ -134,7 +134,7 @@ export function getTagProviderSettings(packagePath: string | undefined) { settings[dep] = true; } } catch (e) { - console.error(e.stack); + console.error((e as Error).stack); } return settings; } diff --git a/server/src/modes/vue/snippets.ts b/server/src/modes/vue/snippets.ts index de9a99671e..2c520f7ded 100644 --- a/server/src/modes/vue/snippets.ts +++ b/server/src/modes/vue/snippets.ts @@ -95,7 +95,7 @@ function loadAllSnippets(rootDir: string, source: SnippetSource): Snippet[] { } }); } catch (err) { - logger.logDebug(err.message); + logger.logDebug((err as Error).message); } return snippets; @@ -120,7 +120,7 @@ function loadSnippetsFromDir(dir: string, source: SnippetSource, type: SnippetTy }); }); } catch (err) { - logger.logDebug(err.message); + logger.logDebug((err as Error).message); } return snippets; diff --git a/server/src/services/dependencyService.ts b/server/src/services/dependencyService.ts index b7fbd2bac7..ff5e637deb 100644 --- a/server/src/services/dependencyService.ts +++ b/server/src/services/dependencyService.ts @@ -163,7 +163,7 @@ export const createDependencyService = async ( throw new Error('No useWorkspaceDependencies.'); } catch (e) { - logger.logDebug(e.message); + logger.logDebug((e as Error).message); logger.logInfo(`Loaded bundled typescript@${ts.version}.`); return [ { @@ -199,7 +199,7 @@ export const createDependencyService = async ( } throw new Error('No useWorkspaceDependencies.'); } catch (e) { - logger.logDebug(e.message); + logger.logDebug((e as Error).message); // TODO: Get bundle package version logger.logInfo(`Loaded bundled ${name}.`); return [ diff --git a/server/src/services/projectService.ts b/server/src/services/projectService.ts index d4c277cfec..3c774da5e4 100644 --- a/server/src/services/projectService.ts +++ b/server/src/services/projectService.ts @@ -126,7 +126,7 @@ export async function createProjectService( allEdits.push(edit); } } catch (err) { - errMessages.push(err.toString()); + errMessages.push((err as Error).toString()); } } }); diff --git a/server/src/services/typescriptService/preprocess.ts b/server/src/services/typescriptService/preprocess.ts index b7a10c7ba7..5ff7368edc 100644 --- a/server/src/services/typescriptService/preprocess.ts +++ b/server/src/services/typescriptService/preprocess.ts @@ -104,7 +104,7 @@ export function createUpdater( injectVueTemplate(tsModule, sourceFile, expressions, scriptSrc); } catch (err) { console.log(`Failed to transform template of ${vueTemplateFileName}`); - console.error(err.stack); + console.error((err as Error).stack); } let newText = printer.printFile(sourceFile); diff --git a/server/src/utils/prettier/index.ts b/server/src/utils/prettier/index.ts index 6402961f93..e8a5f9d4fc 100644 --- a/server/src/utils/prettier/index.ts +++ b/server/src/utils/prettier/index.ts @@ -34,7 +34,7 @@ export function prettierify( return [toReplaceTextedit(prettierifiedCode, range, vlsFormatConfig, initialIndent)]; } catch (e) { console.log('Prettier format failed'); - console.error(e.stack); + console.error((e as Error).stack); return []; } } @@ -70,7 +70,7 @@ export function prettierEslintify( return [toReplaceTextedit(prettierifiedCode, range, vlsFormatConfig, initialIndent)]; } catch (e) { console.log('Prettier-Eslint format failed'); - console.error(e.stack); + console.error((e as Error).stack); return []; } } @@ -100,7 +100,7 @@ export function prettierTslintify( return [toReplaceTextedit(prettierifiedCode, range, vlsFormatConfig, initialIndent)]; } catch (e) { console.log('Prettier-Tslint format failed'); - console.error(e.stack); + console.error((e as Error).stack); return []; } } @@ -131,7 +131,7 @@ export function prettierPluginPugify( return [toReplaceTextedit(prettierifiedCode, range, vlsFormatConfig, initialIndent)]; } catch (e) { console.log('Prettier format failed'); - console.error(e.stack); + console.error((e as Error).stack); return []; } } diff --git a/server/src/utils/vueVersion.ts b/server/src/utils/vueVersion.ts index a11b41435f..c7c622920a 100644 --- a/server/src/utils/vueVersion.ts +++ b/server/src/utils/vueVersion.ts @@ -42,7 +42,7 @@ export function inferVueVersion(packagePath: string | undefined): VueVersion { return floatVersionToEnum(nodeModulesVueVersion); } catch (e) { - console.error(e.stack); + console.error((e as Error).stack); return VueVersion.VPre25; } } diff --git a/server/yarn.lock b/server/yarn.lock index 908f5db66f..d5293bae51 100644 --- a/server/yarn.lock +++ b/server/yarn.lock @@ -4375,10 +4375,10 @@ typedarray@^0.0.6: version "0.0.6" resolved "https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777" -typescript@^3.9.3, typescript@^4.3.2: - version "4.3.2" - resolved "https://packages.golden168.win/typescript/-/typescript-4.3.2.tgz#399ab18aac45802d6f2498de5054fcbbe716a805" - integrity sha512-zZ4hShnmnoVnAHpVHWpTcxdv7dWP60S2FsydQLV8V5PbS3FifjWFFRiHSWpDJahly88PRyV5teTSLoq4eG7mKw== +typescript@^3.9.3, typescript@^4.4.4: + version "4.4.4" + resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.4.4.tgz#2cd01a1a1f160704d3101fd5a58ff0f9fcb8030c" + integrity sha512-DqGhF5IKoBl8WNf8C1gu8q0xZSInh9j1kJJMqT3a94w1JzVaBU4EXOSMrz9yDqMT0xt3selp83fuFMQ0uzv6qA== unherit@^1.0.4: version "1.1.1" diff --git a/test/grammar/grammar.test.ts b/test/grammar/grammar.test.ts index 82fec8707f..6efaf34c40 100644 --- a/test/grammar/grammar.test.ts +++ b/test/grammar/grammar.test.ts @@ -54,10 +54,10 @@ async function assertUnchangedTokens(testFixurePath: string, done: (err?: Error) } done(); } catch (e) { - done(e); + done(e as Error); } } catch (e) { - return done(e); + return done(e as Error); } } diff --git a/vti/src/commands/diagnostics.ts b/vti/src/commands/diagnostics.ts index 02ec65a5b7..619f5beb81 100644 --- a/vti/src/commands/diagnostics.ts +++ b/vti/src/commands/diagnostics.ts @@ -85,18 +85,16 @@ async function prepareClientConnection(workspaceUri: URI) { const serverConnection = createConnection(new StreamMessageReader(up), new StreamMessageWriter(down)); const vls = new VLS(serverConnection as any); - serverConnection.onInitialize( - async (params: InitializeParams): Promise => { - await vls.init(params); + serverConnection.onInitialize(async (params: InitializeParams): Promise => { + await vls.init(params); - console.log('Vetur initialized'); - console.log('===================================='); + console.log('Vetur initialized'); + console.log('===================================='); - return { - capabilities: vls.capabilities as ServerCapabilities - }; - } - ); + return { + capabilities: vls.capabilities as ServerCapabilities + }; + }); vls.listen(); clientConnection.listen(); @@ -192,7 +190,7 @@ async function getDiagnostics(workspaceUri: URI, paths: string[], severity: Diag console.log(''); } } catch (err) { - console.error(err.stack); + console.error((err as Error).stack); } } diff --git a/yarn.lock b/yarn.lock index 5e9495d71f..bee8a73e80 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2091,10 +2091,10 @@ type-fest@^0.11.0: resolved "https://registry.yarnpkg.com/type-fest/-/type-fest-0.11.0.tgz#97abf0872310fed88a5c466b25681576145e33f1" integrity sha512-OdjXJxnCN1AvyLSzeKIgXTXxV+99ZuXl3Hpo9XpJAv9MBcHrrJOQ5kV7ypXOuQie+AmWG25hLbiKdwYTifzcfQ== -typescript@^4.3.2: - version "4.3.2" - resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.3.2.tgz#399ab18aac45802d6f2498de5054fcbbe716a805" - integrity sha512-zZ4hShnmnoVnAHpVHWpTcxdv7dWP60S2FsydQLV8V5PbS3FifjWFFRiHSWpDJahly88PRyV5teTSLoq4eG7mKw== +typescript@^4.4.4: + version "4.4.4" + resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.4.4.tgz#2cd01a1a1f160704d3101fd5a58ff0f9fcb8030c" + integrity sha512-DqGhF5IKoBl8WNf8C1gu8q0xZSInh9j1kJJMqT3a94w1JzVaBU4EXOSMrz9yDqMT0xt3selp83fuFMQ0uzv6qA== universalify@^0.1.0: version "0.1.2"