[Code]: clean uneccessary ts-ignores (#34203)

This commit is contained in:
Fuyao Zhao 2019-03-30 10:19:19 -07:00 committed by GitHub
parent 0f157b653d
commit 817f43e6ec
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
18 changed files with 85 additions and 92 deletions

View file

@ -45,8 +45,8 @@
"@types/d3-array": "^1.2.1", "@types/d3-array": "^1.2.1",
"@types/d3-scale": "^2.0.0", "@types/d3-scale": "^2.0.0",
"@types/d3-shape": "^1.3.1", "@types/d3-shape": "^1.3.1",
"@types/d3-time-format": "^2.1.0",
"@types/d3-time": "^1.0.7", "@types/d3-time": "^1.0.7",
"@types/d3-time-format": "^2.1.0",
"@types/elasticsearch": "^5.0.30", "@types/elasticsearch": "^5.0.30",
"@types/git-url-parse": "^9.0.0", "@types/git-url-parse": "^9.0.0",
"@types/glob": "^7.1.1", "@types/glob": "^7.1.1",
@ -63,11 +63,11 @@
"@types/nock": "^9.3.0", "@types/nock": "^9.3.0",
"@types/node": "^10.12.27", "@types/node": "^10.12.27",
"@types/node-fetch": "^2.1.4", "@types/node-fetch": "^2.1.4",
"@types/object-hash": "^1.2.0",
"@types/papaparse": "^4.5.5", "@types/papaparse": "^4.5.5",
"@types/pngjs": "^3.3.1", "@types/pngjs": "^3.3.1",
"@types/prop-types": "^15.5.3", "@types/prop-types": "^15.5.3",
"@types/proper-lockfile": "^3.0.0", "@types/proper-lockfile": "^3.0.0",
"@types/object-hash": "^1.2.0",
"@types/react": "^16.8.0", "@types/react": "^16.8.0",
"@types/react-dom": "^16.8.0", "@types/react-dom": "^16.8.0",
"@types/react-infinite-scroller": "^1.2.0", "@types/react-infinite-scroller": "^1.2.0",
@ -87,6 +87,7 @@
"@types/tar-fs": "^1.16.1", "@types/tar-fs": "^1.16.1",
"@types/tinycolor2": "^1.4.1", "@types/tinycolor2": "^1.4.1",
"@types/uuid": "^3.4.4", "@types/uuid": "^3.4.4",
"@types/wreck": "^14.0.0",
"abab": "^1.0.4", "abab": "^1.0.4",
"ansi-colors": "^3.0.5", "ansi-colors": "^3.0.5",
"ansicolors": "0.3.2", "ansicolors": "0.3.2",

View file

@ -4,7 +4,6 @@
* you may not use this file except in compliance with the Elastic License. * you may not use this file except in compliance with the Elastic License.
*/ */
// @ts-ignore
import { import {
EuiButton, EuiButton,
EuiFieldText, EuiFieldText,

View file

@ -4,6 +4,7 @@
* you may not use this file except in compliance with the Elastic License. * you may not use this file except in compliance with the Elastic License.
*/ */
import { editor } from 'monaco-editor';
import React from 'react'; import React from 'react';
import { MonacoDiffEditor } from '../../monaco/monaco_diff_editor'; import { MonacoDiffEditor } from '../../monaco/monaco_diff_editor';
@ -34,8 +35,7 @@ export class DiffEditor extends React.Component<Props> {
} }
public updateLayout(renderSideBySide: boolean) { public updateLayout(renderSideBySide: boolean) {
// @ts-ignore this.diffEditor!.diffEditor!.updateOptions({ renderSideBySide } as editor.IDiffEditorOptions);
this.diffEditor!.diffEditor!.updateOptions({ renderSideBySide });
} }
public render() { public render() {

View file

@ -96,8 +96,6 @@ export class HoverWidget extends React.PureComponent<HoverWidgetProps> {
private renderInitialting() { private renderInitialting() {
return ( return (
<div className="hover-row"> <div className="hover-row">
{/*
// @ts-ignore */}
<Text textAlign="center"> <Text textAlign="center">
<h4>Language Server is initializing</h4> <h4>Language Server is initializing</h4>
<p>Depending on the size of your repo, this could take a few minutes.</p> <p>Depending on the size of your repo, this could take a few minutes.</p>

View file

@ -4,7 +4,6 @@
* you may not use this file except in compliance with the Elastic License. * you may not use this file except in compliance with the Elastic License.
*/ */
// @ts-ignore
import { EuiButton, EuiButtonGroup, EuiTitle } from '@elastic/eui'; import { EuiButton, EuiButtonGroup, EuiTitle } from '@elastic/eui';
import theme from '@elastic/eui/dist/eui_theme_light.json'; import theme from '@elastic/eui/dist/eui_theme_light.json';
import 'github-markdown-css/github-markdown.css'; import 'github-markdown-css/github-markdown.css';

View file

@ -20,24 +20,16 @@ export const ErrorPanel = (props: { title: ReactNode; content: string }) => {
<Root> <Root>
<EuiPanel> <EuiPanel>
<EuiSpacer /> <EuiSpacer />
{/*
// @ts-ignore */}
<EuiText textAlign="center"> <EuiText textAlign="center">
<ErrorIcon /> <ErrorIcon />
</EuiText> </EuiText>
{/*
// @ts-ignore */}
<EuiText textAlign="center">{props.title}</EuiText> <EuiText textAlign="center">{props.title}</EuiText>
<EuiSpacer /> <EuiSpacer />
{/*
// @ts-ignore */}
<EuiText textAlign="center"> <EuiText textAlign="center">
<EuiTextColor>{props.content}</EuiTextColor> <EuiTextColor>{props.content}</EuiTextColor>
</EuiText> </EuiText>
<EuiSpacer /> <EuiSpacer />
<EuiSpacer /> <EuiSpacer />
{/*
// @ts-ignore */}
<EuiText textAlign="center"> <EuiText textAlign="center">
<EuiButton fill={true} onClick={history.goBack}> <EuiButton fill={true} onClick={history.goBack}>
Go Back Go Back

View file

@ -61,7 +61,6 @@ export const SuggestionComponent: SFC<Props> = props => {
onClick={click} onClick={click}
// active={props.selected} // active={props.selected}
onMouseEnter={props.onMouseEnter} onMouseEnter={props.onMouseEnter}
// @ts-ignore
ref={props.innerRef} ref={props.innerRef}
id={props.ariaId} id={props.ariaId}
aria-selected={props.selected} aria-selected={props.selected}

View file

@ -5,9 +5,7 @@
*/ */
import { import {
// @ts-ignore
EuiFacetButton, EuiFacetButton,
// @ts-ignore
EuiFacetGroup, EuiFacetGroup,
EuiFlexGroup, EuiFlexGroup,
EuiFlexItem, EuiFlexItem,

View file

@ -5,6 +5,7 @@
*/ */
import { EuiFlexGroup, EuiFlexItem, EuiIcon, EuiSideNav, EuiText, EuiToken } from '@elastic/eui'; import { EuiFlexGroup, EuiFlexItem, EuiIcon, EuiSideNav, EuiText, EuiToken } from '@elastic/eui';
import { IconType } from '@elastic/eui';
import theme from '@elastic/eui/dist/eui_theme_light.json'; import theme from '@elastic/eui/dist/eui_theme_light.json';
import React from 'react'; import React from 'react';
import { Link } from 'react-router-dom'; import { Link } from 'react-router-dom';
@ -104,9 +105,7 @@ export class CodeSymbolTree extends React.PureComponent<Props, { activePath?: st
onClick={this.getClickHandler(path)} onClick={this.getClickHandler(path)}
> >
<EuiFlexGroup gutterSize="none" alignItems="center" className="code-structure-node"> <EuiFlexGroup gutterSize="none" alignItems="center" className="code-structure-node">
{/* <Token iconType={tokenType as IconType} />
// @ts-ignore */}
<Token iconType={tokenType} />
<EuiText data-test-subj={`codeStructureTreeNode-${name}`} size="s"> <EuiText data-test-subj={`codeStructureTreeNode-${name}`} size="s">
{name} {name}
</EuiText> </EuiText>

View file

@ -99,25 +99,6 @@ import chrome from 'ui/chrome';
const IS_DARK_THEME = chrome.getUiSettingsClient().get('theme:darkMode'); const IS_DARK_THEME = chrome.getUiSettingsClient().get('theme:darkMode');
// @ts-ignore
/*self.MonacoEnvironment = {
getWorkerUrl(moduleId: string, label: string) {
// if (label === 'json') {
// return './json.worker.bundle.js';
// }
// if (label === 'css') {
// return './css.worker.bundle.js';
// }
// if (label === 'html') {
// return './html.worker.bundle.js';
// }
// if (label === 'typescript' || label === 'javascript') {
// return './ts.worker.bundle.js';
// }
return './editor.worker.bundle.js';
},
};*/
const themeName = IS_DARK_THEME ? darkTheme : lightTheme; const themeName = IS_DARK_THEME ? darkTheme : lightTheme;
const syntaxTheme = { const syntaxTheme = {

View file

@ -3,23 +3,22 @@
* or more contributor license agreements. Licensed under the Elastic License; * or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License. * you may not use this file except in compliance with the Elastic License.
*/ */
/* tslint:disable */
import fs from 'fs';
import Git from '@elastic/nodegit'; import Git from '@elastic/nodegit';
import fs from 'fs';
import mkdirp from 'mkdirp';
import path from 'path';
// import rimraf from 'rimraf'; // import rimraf from 'rimraf';
import sinon from 'sinon'; import sinon from 'sinon';
import path from 'path';
import mkdirp from 'mkdirp';
import { LspService } from "../lsp/lsp_service";
import { ConsoleLoggerFactory } from "../utils/console_logger_factory";
import { RepositoryGitStatusReservedField, RepositoryConfigReservedField } from '../indexer/schema';
import { InstallManager } from "../lsp/install_manager";
import assert from 'assert'; import assert from 'assert';
import { Server } from 'hapi';
import { RepositoryConfigReservedField, RepositoryGitStatusReservedField } from '../indexer/schema';
import { InstallManager } from '../lsp/install_manager';
import { LspService } from '../lsp/lsp_service';
import { RepositoryConfigController } from '../repository_config_controller'; import { RepositoryConfigController } from '../repository_config_controller';
import { createTestServerOption } from '../test_utils'; import { createTestServerOption } from '../test_utils';
import { Server } from 'hapi'; import { ConsoleLoggerFactory } from '../utils/console_logger_factory';
const filename = 'hello.ts'; const filename = 'hello.ts';
describe('lsp_service tests', () => { describe('lsp_service tests', () => {
@ -32,9 +31,16 @@ describe('lsp_service tests', () => {
await index.addByPath(filename); await index.addByPath(filename);
index.write(); index.write();
const treeId = await index.writeTree(); const treeId = await index.writeTree();
const committer = Git.Signature.create("tester", const committer = Git.Signature.create('tester', 'test@test.com', Date.now() / 1000, 60);
"test@test.com", Date.now() / 1000, 60); const commit = await repo.createCommit(
const commit = await repo.createCommit("HEAD", committer, committer, "commit for test", treeId, []); 'HEAD',
committer,
committer,
'commit for test',
treeId,
[]
);
// tslint:disable-next-line:no-console
console.log(`created commit ${commit.tostrS()}`); console.log(`created commit ${commit.tostrS()}`);
return repo; return repo;
} }
@ -44,19 +50,19 @@ describe('lsp_service tests', () => {
function mockEsClient(): any { function mockEsClient(): any {
const api = { const api = {
get: function (params: any) { get(params: any) {
return { return {
_source: { _source: {
[RepositoryGitStatusReservedField]: { [RepositoryGitStatusReservedField]: {
cloneProgress: { cloneProgress: {
isCloned: true isCloned: true,
} },
}, },
[RepositoryConfigReservedField]: { [RepositoryConfigReservedField]: {
disableTypescript: false disableTypescript: false,
} },
} },
} };
}, },
}; };
return api; return api;
@ -66,12 +72,9 @@ describe('lsp_service tests', () => {
// @ts-ignore // @ts-ignore
before(async () => { before(async () => {
await prepareProject( await prepareProject(path.join(serverOptions.repoPath, repoUri));
path.join(serverOptions.repoPath, repoUri)
);
}); });
function comparePath(pathA: string, pathB: string) { function comparePath(pathA: string, pathB: string) {
const pa = fs.realpathSync(pathA); const pa = fs.realpathSync(pathA);
const pb = fs.realpathSync(pathB); const pb = fs.realpathSync(pathB);
@ -79,11 +82,17 @@ describe('lsp_service tests', () => {
} }
it('process a hover request', async () => { it('process a hover request', async () => {
const esClient = mockEsClient();
let esClient = mockEsClient();
const revision = 'master'; const revision = 'master';
const lspservice = new LspService('127.0.0.1', serverOptions, esClient, installManager, new ConsoleLoggerFactory(), new RepositoryConfigController(esClient)); const lspservice = new LspService(
'127.0.0.1',
serverOptions,
esClient,
installManager,
new ConsoleLoggerFactory(),
new RepositoryConfigController(esClient)
);
try { try {
const params = { const params = {
textDocument: { textDocument: {
@ -92,44 +101,59 @@ describe('lsp_service tests', () => {
position: { position: {
line: 0, line: 0,
character: 1, character: 1,
} },
}; };
const workspaceHandler = lspservice.workspaceHandler; const workspaceHandler = lspservice.workspaceHandler;
const wsSpy = sinon.spy(workspaceHandler, 'handleRequest'); const wsSpy = sinon.spy(workspaceHandler, 'handleRequest');
const controller = lspservice.controller; const controller = lspservice.controller;
const ctrlSpy = sinon.spy(controller, 'handleRequest'); const ctrlSpy = sinon.spy(controller, 'handleRequest');
let method = 'textDocument/hover'; const method = 'textDocument/hover';
const response = await lspservice.sendRequest(method, params); const response = await lspservice.sendRequest(method, params);
assert.ok(response); assert.ok(response);
assert.ok(response.result.contents); assert.ok(response.result.contents);
wsSpy.restore(); wsSpy.restore();
ctrlSpy.restore(); ctrlSpy.restore();
const workspaceFolderExists = fs.existsSync(path.join(serverOptions.workspacePath, repoUri, revision)); const workspaceFolderExists = fs.existsSync(
path.join(serverOptions.workspacePath, repoUri, revision)
);
// workspace is opened // workspace is opened
assert.ok(workspaceFolderExists); assert.ok(workspaceFolderExists);
const workspacePath = fs.realpathSync(path.resolve(serverOptions.workspacePath, repoUri, revision)); const workspacePath = fs.realpathSync(
path.resolve(serverOptions.workspacePath, repoUri, revision)
);
// workspace handler is working, filled workspacePath // workspace handler is working, filled workspacePath
sinon.assert.calledWith(ctrlSpy, sinon.match.has("workspacePath", sinon.match((value) => comparePath(value, workspacePath)))); sinon.assert.calledWith(
ctrlSpy,
sinon.match.has('workspacePath', sinon.match(value => comparePath(value, workspacePath)))
);
// uri is changed by workspace handler // uri is changed by workspace handler
sinon.assert.calledWith(ctrlSpy, sinon.match.hasNested("params.textDocument.uri", `file://${workspacePath}/${filename}`)); sinon.assert.calledWith(
ctrlSpy,
sinon.match.hasNested('params.textDocument.uri', `file://${workspacePath}/${filename}`)
);
return; return;
} finally { } finally {
await lspservice.shutdown() await lspservice.shutdown();
} }
// @ts-ignore // @ts-ignore
}).timeout(10000); }).timeout(10000);
it("unload a workspace", async () => { it('unload a workspace', async () => {
let esClient = mockEsClient(); const esClient = mockEsClient();
const revision = 'master'; const revision = 'master';
const lspservice = new LspService('127.0.0.1', serverOptions, esClient, installManager, new ConsoleLoggerFactory(), new RepositoryConfigController(esClient)); const lspservice = new LspService(
'127.0.0.1',
serverOptions,
esClient,
installManager,
new ConsoleLoggerFactory(),
new RepositoryConfigController(esClient)
);
try { try {
const params = { const params = {
textDocument: { textDocument: {
@ -138,10 +162,10 @@ describe('lsp_service tests', () => {
position: { position: {
line: 0, line: 0,
character: 1, character: 1,
} },
}; };
let method = 'textDocument/hover'; const method = 'textDocument/hover';
// send a dummy request to open a workspace; // send a dummy request to open a workspace;
const response = await lspservice.sendRequest(method, params); const response = await lspservice.sendRequest(method, params);
assert.ok(response); assert.ok(response);
@ -151,7 +175,7 @@ describe('lsp_service tests', () => {
assert.ok(workspaceFolderExists); assert.ok(workspaceFolderExists);
const controller = lspservice.controller; const controller = lspservice.controller;
// @ts-ignore // @ts-ignore
const languageServer = controller.languageServerMap['typescript']; const languageServer = controller.languageServerMap.typescript;
const realWorkspacePath = fs.realpathSync(workspacePath); const realWorkspacePath = fs.realpathSync(workspacePath);
// @ts-ignore // @ts-ignore
@ -172,9 +196,8 @@ describe('lsp_service tests', () => {
assert.strictEqual(exists, false); assert.strictEqual(exists, false);
return; return;
} finally { } finally {
await lspservice.shutdown() await lspservice.shutdown();
} }
// @ts-ignore // @ts-ignore
}).timeout(10000); }).timeout(10000);
}); });

View file

@ -6,7 +6,6 @@
import Boom from 'boom'; import Boom from 'boom';
import hapi from 'hapi'; import hapi from 'hapi';
// @ts-ignore
import { groupBy, last } from 'lodash'; import { groupBy, last } from 'lodash';
import { ResponseError } from 'vscode-jsonrpc'; import { ResponseError } from 'vscode-jsonrpc';
import { ResponseMessage } from 'vscode-jsonrpc/lib/messages'; import { ResponseMessage } from 'vscode-jsonrpc/lib/messages';

View file

@ -6,7 +6,6 @@
import hapi from 'hapi'; import hapi from 'hapi';
import url from 'url'; import url from 'url';
// @ts-ignore
import wreck from 'wreck'; import wreck from 'wreck';
import { Logger } from '../log'; import { Logger } from '../log';

View file

@ -64,7 +64,6 @@ export class SecureRoute {
} }
private isSecurityEnabledInEs() { private isSecurityEnabledInEs() {
// @ts-ignore
const xpackInfo = this.server.plugins.xpack_main.info; const xpackInfo = this.server.plugins.xpack_main.info;
if ( if (
xpackInfo.isAvailable() && xpackInfo.isAvailable() &&

View file

@ -5,7 +5,6 @@
*/ */
import { Request } from 'hapi'; import { Request } from 'hapi';
// @ts-ignore
import { AnyObject, EsClient } from '../lib/esqueue'; import { AnyObject, EsClient } from '../lib/esqueue';
import { EsIndexClient } from './es_index_client'; import { EsIndexClient } from './es_index_client';
import { WithRequest } from './with_request'; import { WithRequest } from './with_request';

View file

@ -20,7 +20,6 @@ export function promiseTimeout<T>(ms: number, promise: Promise<T>): Promise<T> {
}); });
// Returns a race between our timeout and the passed in promise // Returns a race between our timeout and the passed in promise
// @ts-ignore
return Promise.race([promise, timeout]); return Promise.race([promise, timeout]);
} else { } else {
return Promise.reject(boom); return Promise.reject(boom);

View file

@ -2554,6 +2554,15 @@
resolved "https://registry.yarnpkg.com/@types/wrap-ansi/-/wrap-ansi-2.0.14.tgz#5afbdd8374de9ff8ad752cb03ab9f225f7c2ee24" resolved "https://registry.yarnpkg.com/@types/wrap-ansi/-/wrap-ansi-2.0.14.tgz#5afbdd8374de9ff8ad752cb03ab9f225f7c2ee24"
integrity sha1-Wvvdg3Ten/itdSywOrnyJffC7iQ= integrity sha1-Wvvdg3Ten/itdSywOrnyJffC7iQ=
"@types/wreck@^14.0.0":
version "14.0.0"
resolved "https://registry.yarnpkg.com/@types/wreck/-/wreck-14.0.0.tgz#8bf39fd789d32af63176bee5eb5705108cd8be5e"
integrity sha512-cxA8o5fGbXg2e/UUoA7z8lMaEw4CwxvJW1Fv+E8xP/n2MOzRdeQUX+e7aUxgr1ganECiIQXUka0OwwKR2ixo1w==
dependencies:
"@types/boom" "*"
"@types/events" "*"
"@types/node" "*"
"@types/write-pkg@^3.1.0": "@types/write-pkg@^3.1.0":
version "3.1.0" version "3.1.0"
resolved "https://registry.yarnpkg.com/@types/write-pkg/-/write-pkg-3.1.0.tgz#f58767f4fb9a6a3ad8e95d3e9cd1f2d026ceab26" resolved "https://registry.yarnpkg.com/@types/write-pkg/-/write-pkg-3.1.0.tgz#f58767f4fb9a6a3ad8e95d3e9cd1f2d026ceab26"