Skip to content

Commit

Permalink
Comply with --strict compile flag subset (golang#2294)
Browse files Browse the repository at this point in the history
  • Loading branch information
lggomez authored and ramya-rao-a committed Feb 7, 2019
1 parent f0cc90b commit 5fe9ecd
Show file tree
Hide file tree
Showing 25 changed files with 127 additions and 107 deletions.
11 changes: 10 additions & 1 deletion .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,14 @@
"isBackground": true,

// use the standard tsc in watch mode problem matcher to find compile problems in the output.
"problemMatcher": "$tsc-watch"
"problemMatcher": "$tsc-watch",
"tasks": [
{
"type": "typescript",
"tsconfig": "tsconfig.json",
"problemMatcher": [
"$tsc"
]
}
]
}
7 changes: 4 additions & 3 deletions src/debugAdapter/goDebug.ts
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ interface DiscardedBreakpoint {

// This interface should always match the schema found in `package.json`.
interface LaunchRequestArguments extends DebugProtocol.LaunchRequestArguments {
[key: string]: any;
program: string;
stopOnEntry?: boolean;
args?: string[];
Expand Down Expand Up @@ -578,7 +579,7 @@ class GoDebugSession extends LoggingDebugSession {
log('InitializeResponse');
}

protected findPathSeperator(path) {
protected findPathSeperator(path: string) {
if (/^(\w:[\\/]|\\\\)/.test(path)) return '\\';
return path.includes('/') ? '/' : '\\';
}
Expand Down Expand Up @@ -1217,7 +1218,7 @@ class GoDebugSession extends LoggingDebugSession {
let closureEpoch = this.continueEpoch;
this.continueRequestRunning = true;

const callback = (out) => {
const callback = (out: any) => {
if (closureEpoch === this.continueEpoch) {
this.continueRequestRunning = false;
}
Expand All @@ -1228,7 +1229,7 @@ class GoDebugSession extends LoggingDebugSession {
};

// If called when setting breakpoint internally, we want the error to bubble up.
const errorCallback = calledWhenSettingBreakpoint ? null : (err) => {
const errorCallback = calledWhenSettingBreakpoint ? null : (err: any) => {
if (err) {
logError('Failed to continue - ' + err.toString());
}
Expand Down
3 changes: 2 additions & 1 deletion src/goBrowsePackage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,10 @@ function showPackageFiles(pkg: string, showAllPkgsIfPkgNotFound: boolean, workDi
return showPackageList(workDir);
}

const options = {
const options: { [key: string]: any } = {
env: Object.assign({}, process.env, { GOPATH: getCurrentGoPath() })
};

if (workDir) {
options['cwd'] = workDir;
}
Expand Down
6 changes: 3 additions & 3 deletions src/goCheck.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ export function removeTestStatus(e: vscode.TextDocumentChangeEvent) {
statusBarItem.text = '';
}

export function notifyIfGeneratedFile(e: vscode.TextDocumentChangeEvent) {
let ctx = this;
export function notifyIfGeneratedFile(this: void, e: vscode.TextDocumentChangeEvent) {
let ctx: any = this;
if (e.document.isUntitled || e.document.languageId !== 'go') {
return;
}
Expand Down Expand Up @@ -65,7 +65,7 @@ export function check(fileUri: vscode.Uri, goConfig: vscode.WorkspaceConfigurati
}

let testPromise: Thenable<boolean>;
let tmpCoverPath;
let tmpCoverPath: string;
let testConfig: TestConfig = {
goConfig: goConfig,
dir: cwd,
Expand Down
2 changes: 1 addition & 1 deletion src/goCodeAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export class GoCodeActionProvider implements vscode.CodeActionProvider {
});

return Promise.all(promises).then(arrs => {
let results = {};
let results: { [key: string]: any } = {};
for (let segment of arrs) {
for (let item of segment) {
results[item.title] = item;
Expand Down
1 change: 1 addition & 0 deletions src/goCover.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ let decorators: {
uncoveredHighlightDecorator: vscode.TextEditorDecorationType;
};
let decoratorConfig: {
[key: string]: any
type: string;
coveredHighlightColor: string;
uncoveredHighlightColor: string;
Expand Down
2 changes: 1 addition & 1 deletion src/goDebugConfiguration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export class GoDebugConfigurationProvider implements vscode.DebugConfigurationPr
}
});

const dlvConfig = goConfig.get('delveConfig');
const dlvConfig: { [key: string]: any } = goConfig.get('delveConfig');
if (!debugConfiguration.hasOwnProperty('useApiV1') && dlvConfig.hasOwnProperty('useApiV1')) {
debugConfiguration['useApiV1'] = dlvConfig['useApiV1'];
}
Expand Down
34 changes: 17 additions & 17 deletions src/goDeclaration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,19 @@ interface GoDefinitionInput {
cwd: string;
}

interface GoGetDocOuput {
name: string;
import: string;
decl: string;
doc: string;
pos: string;
}

interface GuruDefinitionOuput {
objpos: string;
desc: string;
}

export function definitionLocation(document: vscode.TextDocument, position: vscode.Position, goConfig: vscode.WorkspaceConfiguration, includeDocs: boolean, token: vscode.CancellationToken): Promise<GoDefinitionInformation> {
let adjustedPos = adjustWordPosition(document, position);
if (!adjustedPos[0]) {
Expand All @@ -55,7 +68,7 @@ export function definitionLocation(document: vscode.TextDocument, position: vsco
includeDocs,
isMod: !!modFolderPath,
cwd: (modFolderPath && modFolderPath !== getModuleCache())
? modFolderPath : (getWorkspaceFolderPath(document.uri) || path.dirname(document.fileName))
? modFolderPath : (getWorkspaceFolderPath(document.uri) || path.dirname(document.fileName))
};
if (toolForDocs === 'godoc' || (ver && (ver.major < 1 || (ver.major === 1 && ver.minor < 6)))) {
return definitionLocation_godef(input, token);
Expand Down Expand Up @@ -202,7 +215,7 @@ function definitionLocation_gogetdoc(input: GoDefinitionInput, token: vscode.Can
}
let goGetDocOutput = <GoGetDocOuput>JSON.parse(stdout.toString());
let match = /(.*):(\d+):(\d+)/.exec(goGetDocOutput.pos);
let definitionInfo = {
let definitionInfo: GoDefinitionInformation = {
file: null,
line: 0,
column: 0,
Expand Down Expand Up @@ -252,7 +265,7 @@ function definitionLocation_guru(input: GoDefinitionInput, token: vscode.Cancell
}
let guruOutput = <GuruDefinitionOuput>JSON.parse(stdout.toString());
let match = /(.*):(\d+):(\d+)/.exec(guruOutput.objpos);
let definitionInfo = {
let definitionInfo: GoDefinitionInformation = {
file: null,
line: 0,
column: 0,
Expand Down Expand Up @@ -291,7 +304,7 @@ export function parseMissingError(err: any): [boolean, string] {
}

export class GoDefinitionProvider implements vscode.DefinitionProvider {
private goConfig = null;
private goConfig: vscode.WorkspaceConfiguration = null;

constructor(goConfig?: vscode.WorkspaceConfiguration) {
this.goConfig = goConfig;
Expand All @@ -314,16 +327,3 @@ export class GoDefinitionProvider implements vscode.DefinitionProvider {
});
}
}

interface GoGetDocOuput {
name: string;
import: string;
decl: string;
doc: string;
pos: string;
}

interface GuruDefinitionOuput {
objpos: string;
desc: string;
}
2 changes: 1 addition & 1 deletion src/goExtraInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { HoverProvider, Hover, TextDocument, Position, CancellationToken, Worksp
import { definitionLocation } from './goDeclaration';

export class GoHoverProvider implements HoverProvider {
private goConfig = null;
private goConfig: WorkspaceConfiguration = null;

constructor(goConfig?: WorkspaceConfiguration) {
this.goConfig = goConfig;
Expand Down
4 changes: 2 additions & 2 deletions src/goImplementations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ export class GoImplementationProvider implements vscode.ImplementationProvider {

let guruOutput = <GuruImplementsOutput>JSON.parse(stdout.toString());
let results: vscode.Location[] = [];
let addResults = list => {
list.forEach(ref => {
let addResults = (list: GuruImplementsRef[]) => {
list.forEach((ref: GuruImplementsRef) => {
let match = /^(.*):(\d+):(\d+)/.exec(ref.pos);
if (!match) return;
let [_, file, lineStartStr, colStartStr] = match;
Expand Down
2 changes: 1 addition & 1 deletion src/goLint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export function goLint(fileUri: vscode.Uri, goConfig: vscode.WorkspaceConfigurat
const lintTool = goConfig['lintTool'] || 'golint';
const lintFlags: string[] = goConfig['lintFlags'] || [];
const lintEnv = Object.assign({}, getToolsEnvVars());
const args = [];
const args: string[] = [];

lintFlags.forEach(flag => {
// --json is not a valid flag for golint and in gometalinter, it is used to print output in json which we dont want
Expand Down
2 changes: 1 addition & 1 deletion src/goLiveErrors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ interface GoLiveErrorsConfig {
enabled: boolean;
}

let runner;
let runner: NodeJS.Timer;

export function goLiveErrorsEnabled() {
let goConfig = <GoLiveErrorsConfig>vscode.workspace.getConfiguration('go', vscode.window.activeTextEditor ? vscode.window.activeTextEditor.document.uri : null)['liveErrors'];
Expand Down
2 changes: 1 addition & 1 deletion src/goMain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ export function activate(ctx: vscode.ExtensionContext): void {

offerToInstallTools();
if (checkLanguageServer()) {
const languageServerExperimentalFeatures = vscode.workspace.getConfiguration('go').get('languageServerExperimentalFeatures') || {};
const languageServerExperimentalFeatures: any = vscode.workspace.getConfiguration('go').get('languageServerExperimentalFeatures') || {};
let langServerFlags: string[] = vscode.workspace.getConfiguration('go')['languageServerFlags'] || [];

const c = new LanguageClient(
Expand Down
3 changes: 2 additions & 1 deletion src/goModifytags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ interface GomodifytagsOutput {

// Interface for settings configuration for adding and removing tags
interface GoTagsConfig {
[key: string]: any;
tags: string;
options: string;
promptForTags: boolean;
Expand Down Expand Up @@ -103,7 +104,7 @@ function getTagsAndOptions(config: GoTagsConfig, commandArgs: GoTagsConfig): The
let tags = commandArgs && commandArgs.hasOwnProperty('tags') ? commandArgs['tags'] : config['tags'];
let options = commandArgs && commandArgs.hasOwnProperty('options') ? commandArgs['options'] : config['options'];
let promptForTags = commandArgs && commandArgs.hasOwnProperty('promptForTags') ? commandArgs['promptForTags'] : config['promptForTags'];
let transformValue = commandArgs && commandArgs.hasOwnProperty('transform') ? commandArgs['transform'] : config['transform'];
let transformValue: string = commandArgs && commandArgs.hasOwnProperty('transform') ? commandArgs['transform'] : config['transform'];

if (!promptForTags) {
return Promise.resolve([tags, options, transformValue]);
Expand Down
2 changes: 1 addition & 1 deletion src/goModules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ export function getCurrentPackage(cwd: string): Promise<string> {
}
return new Promise<string>(resolve => {
let childProcess = cp.spawn(goRuntimePath, ['list'], { cwd, env: getToolsEnvVars() });
let chunks = [];
let chunks: any[] = [];
childProcess.stdout.on('data', (stdout) => {
chunks.push(stdout);
});
Expand Down
6 changes: 3 additions & 3 deletions src/goPackages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ function gopkgs(workDir?: string): Promise<Map<string, string>> {
}

const cmd = cp.spawn(gopkgsBinPath, args, { env: getToolsEnvVars() });
const chunks = [];
const errchunks = [];
const chunks: any[] = [];
const errchunks: any[] = [];
let err: any;
cmd.stdout.on('data', d => chunks.push(d));
cmd.stderr.on('data', d => errchunks.push(d));
Expand Down Expand Up @@ -257,7 +257,7 @@ export function getNonVendorPackages(folderPath: string): Promise<Map<string, st
}
return new Promise<Map<string, string>>((resolve, reject) => {
let childProcess = cp.spawn(goRuntimePath, ['list', '-f', 'ImportPath: {{.ImportPath}} FolderPath: {{.Dir}}', './...'], { cwd: folderPath, env: getToolsEnvVars() });
let chunks = [];
let chunks: any[] = [];
childProcess.stdout.on('data', (stdout) => {
chunks.push(stdout);
});
Expand Down
2 changes: 1 addition & 1 deletion src/goPath.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ export function stripBOM(s: string): string {
}

export function parseEnvFile(path: string): { [key: string]: string } {
const env = {};
const env: { [key: string]: any } = {};
if (!path) {
return env;
}
Expand Down
2 changes: 1 addition & 1 deletion src/goReferencesCodelens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export class GoReferencesCodeLensProvider extends GoBaseCodeLensProvider {
if (!this.enabled) {
return [];
}
let codeLensConfig = vscode.workspace.getConfiguration('go', document.uri).get('enableCodeLens');
let codeLensConfig: { [key: string]: any } = vscode.workspace.getConfiguration('go', document.uri).get('enableCodeLens');
let codelensEnabled = codeLensConfig ? codeLensConfig['references'] : false;
if (!codelensEnabled) {
return Promise.resolve([]);
Expand Down
4 changes: 2 additions & 2 deletions src/goRunTestCodelens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export class GoRunTestCodeLensProvider extends GoBaseCodeLensProvider {
return [];
}
let config = vscode.workspace.getConfiguration('go', document.uri);
let codeLensConfig = config.get('enableCodeLens');
let codeLensConfig: { [key: string]: any } = config.get('enableCodeLens');
let codelensEnabled = codeLensConfig ? codeLensConfig['runtest'] : false;
if (!codelensEnabled || !document.fileName.endsWith('_test.go')) {
return [];
Expand All @@ -40,7 +40,7 @@ export class GoRunTestCodeLensProvider extends GoBaseCodeLensProvider {
this.getCodeLensForPackage(document, token),
this.getCodeLensForFunctions(config, document, token)
]).then(([pkg, fns]) => {
let res = [];
let res: any[] = [];
if (pkg && Array.isArray(pkg)) {
res = res.concat(pkg);
}
Expand Down
2 changes: 1 addition & 1 deletion src/goSignature.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { definitionLocation } from './goDeclaration';
import { getParametersAndReturnType } from './util';

export class GoSignatureHelpProvider implements SignatureHelpProvider {
private goConfig = null;
private goConfig: WorkspaceConfiguration = null;

constructor(goConfig?: WorkspaceConfiguration) {
this.goConfig = goConfig;
Expand Down
6 changes: 3 additions & 3 deletions src/goSuggest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ export class GoCompletionItemProvider implements vscode.CompletionItemProvider,
return reject();
}
let results = <[number, GoCodeSuggestion[]]>JSON.parse(stdout.toString());
let suggestions = [];
let suggestions: vscode.CompletionItem[] = [];
let suggestionSet = new Set<string>();

let wordAtPosition = document.getWordRangeAtPosition(position);
Expand Down Expand Up @@ -473,7 +473,7 @@ export class GoCompletionItemProvider implements vscode.CompletionItemProvider,
const workSpaceFolder = vscode.workspace.getWorkspaceFolder(document.uri);
const currentPkgRootPath = (workSpaceFolder ? workSpaceFolder.uri.path : cwd).slice(goWorkSpace.length + 1);

let completionItems = [];
let completionItems: any[] = [];
this.pkgsList.forEach((pkgName: string, pkgPath: string) => {
if (pkgName.startsWith(word) && !suggestionSet.has(pkgName)) {

Expand Down Expand Up @@ -517,7 +517,7 @@ export class GoCompletionItemProvider implements vscode.CompletionItemProvider,
* @param input Package name
*/
private getPackageImportPath(input: string): string[] {
let matchingPackages = [];
let matchingPackages: any[] = [];
this.pkgsList.forEach((pkgName: string, pkgPath: string) => {
if (input === pkgName) {
matchingPackages.push(pkgPath);
Expand Down
2 changes: 1 addition & 1 deletion src/testUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export function getTestEnvVars(config: vscode.WorkspaceConfiguration): any {
const envVars = getToolsEnvVars();
const testEnvConfig = config['testEnvVars'] || {};

let fileEnv = {};
let fileEnv: { [key: string]: any } = {};
let testEnvFile = config['testEnvFile'];
if (testEnvFile) {
testEnvFile = resolvePath(testEnvFile);
Expand Down
Loading

0 comments on commit 5fe9ecd

Please sign in to comment.