提交 883ed445 编写于 作者: M Matt Bierner

Remove the checkTSC warning

The purpose of the checktsc warning has never been very clear and has caused quite a bit of confusion. I'd like to try removing it this iteration to see if many users run into TypeScript mismatch errors
上级 3c432b40
......@@ -3,17 +3,13 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import * as cp from 'child_process';
import * as fs from 'fs';
import { workspace, window, TextDocument, TextDocumentChangeEvent, TextDocumentContentChangeEvent, Disposable, MessageItem, Uri, commands } from 'vscode';
import { workspace, TextDocument, TextDocumentChangeEvent, TextDocumentContentChangeEvent, Disposable } from 'vscode';
import * as Proto from '../protocol';
import { ITypescriptServiceClient } from '../typescriptService';
import { Delayer } from '../utils/async';
import * as nls from 'vscode-nls';
let localize = nls.loadMessageBundle();
interface IDiagnosticRequestor {
requestDiagnostic(filepath: string): void;
}
......@@ -98,7 +94,6 @@ export interface Diagnostics {
delete(file: string): void;
}
const checkTscVersionSettingKey = 'check.tscVersion';
export default class BufferSyncSupport {
private readonly client: ITypescriptServiceClient;
......@@ -111,7 +106,6 @@ export default class BufferSyncSupport {
private pendingDiagnostics = new Map<string, number>();
private readonly diagnosticDelayer: Delayer<any>;
private checkGlobalTSCVersion: boolean;
constructor(
client: ITypescriptServiceClient,
......@@ -127,9 +121,6 @@ export default class BufferSyncSupport {
this.diagnosticDelayer = new Delayer<any>(300);
this.syncedBuffers = new Map<string, SyncedBuffer>();
const tsConfig = workspace.getConfiguration('typescript');
this.checkGlobalTSCVersion = client.checkGlobalTSCVersion && this.modeIds.has('typescript') && tsConfig.get(checkTscVersionSettingKey, true);
}
public listen(): void {
......@@ -175,9 +166,6 @@ export default class BufferSyncSupport {
this.syncedBuffers.set(filepath, syncedBuffer);
syncedBuffer.open();
this.requestDiagnostic(filepath);
if (document.languageId === 'typescript' || document.languageId === 'typescriptreact') {
this.checkTSCVersion();
}
}
private onDidCloseTextDocument(document: TextDocument): void {
......@@ -269,59 +257,4 @@ export default class BufferSyncSupport {
}
this.pendingDiagnostics.clear();
}
private checkTSCVersion() {
if (!this.checkGlobalTSCVersion) {
return;
}
this.checkGlobalTSCVersion = false;
interface MyMessageItem extends MessageItem {
id: number;
}
let tscVersion: string | undefined = undefined;
try {
let out = cp.execSync('tsc --version', { encoding: 'utf8' });
if (out) {
let matches = out.trim().match(/Version\s*(.*)$/);
if (matches && matches.length === 2) {
tscVersion = matches[1];
}
}
} catch (error) {
}
if (tscVersion && tscVersion !== this.client.apiVersion.versionString) {
window.showInformationMessage<MyMessageItem>(
localize('versionMismatch', 'Using TypeScript ({1}) for editor features. TypeScript ({0}) is installed globally on your machine. Errors in VS Code may differ from TSC errors', tscVersion, this.client.apiVersion.versionString),
{
title: localize('moreInformation', 'More Information'),
id: 1
},
{
title: localize('doNotCheckAgain', 'Don\'t Check Again'),
id: 2
},
{
title: localize('close', 'Close'),
id: 3,
isCloseAffordance: true
}
).then((selected) => {
if (!selected || selected.id === 3) {
return;
}
switch (selected.id) {
case 1:
commands.executeCommand('vscode.open', Uri.parse('http://go.microsoft.com/fwlink/?LinkId=826239'));
break;
case 2:
const tsConfig = workspace.getConfiguration('typescript');
tsConfig.update(checkTscVersionSettingKey, false, true);
window.showInformationMessage(localize('updateTscCheck', 'Updated user setting \'typescript.check.tscVersion\' to false'));
break;
}
});
}
}
}
\ No newline at end of file
......@@ -90,7 +90,6 @@ export interface ITypescriptServiceClient {
logTelemetry(eventName: string, properties?: { [prop: string]: string }): void;
apiVersion: API;
checkGlobalTSCVersion: boolean;
execute(command: 'configure', args: Proto.ConfigureRequestArguments, token?: CancellationToken): Promise<Proto.ConfigureResponse>;
execute(command: 'open', args: Proto.OpenRequestArgs, expectedResult: boolean, token?: CancellationToken): Promise<any>;
......
......@@ -230,7 +230,6 @@ export default class TypeScriptServiceClient implements ITypescriptServiceClient
private _onReady: { promise: Promise<void>; resolve: () => void; reject: () => void; };
private configuration: TypeScriptServiceConfiguration;
private _checkGlobalTSCVersion: boolean;
private tracer: Tracer;
private readonly logger: Logger = new Logger();
private tsServerLogFile: string | null = null;
......@@ -281,7 +280,6 @@ export default class TypeScriptServiceClient implements ITypescriptServiceClient
this.configuration = TypeScriptServiceConfiguration.loadFromWorkspace();
this._apiVersion = new API('1.0.0');
this._checkGlobalTSCVersion = true;
this.tracer = new Tracer(this.logger);
disposables.push(workspace.onDidChangeConfiguration(() => {
......@@ -343,10 +341,6 @@ export default class TypeScriptServiceClient implements ITypescriptServiceClient
return this._onTypesInstallerInitializationFailed.event;
}
public get checkGlobalTSCVersion(): boolean {
return this._checkGlobalTSCVersion;
}
public get apiVersion(): API {
return this._apiVersion;
}
......@@ -400,7 +394,6 @@ export default class TypeScriptServiceClient implements ITypescriptServiceClient
}
if (this.configuration.localTsdk) {
this._checkGlobalTSCVersion = false;
if ((<any>path).isAbsolute(this.configuration.localTsdk)) {
return path.join(this.configuration.localTsdk, 'tsserver.js');
}
......@@ -416,7 +409,6 @@ export default class TypeScriptServiceClient implements ITypescriptServiceClient
private get globalTypescriptPath(): string {
if (this.configuration.globalTsdk) {
this._checkGlobalTSCVersion = false;
if ((<any>path).isAbsolute(this.configuration.globalTsdk)) {
return path.join(this.configuration.globalTsdk, 'tsserver.js');
} else if (this.mainWorkspaceRootPath) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册