Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Code]: clean uneccessary ts-ignores #34203

Merged
merged 1 commit into from
Mar 30, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions x-pack/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@
"@types/d3-array": "^1.2.1",
"@types/d3-scale": "^2.0.0",
"@types/d3-shape": "^1.3.1",
"@types/d3-time-format": "^2.1.0",
"@types/d3-time": "^1.0.7",
"@types/d3-time-format": "^2.1.0",
"@types/elasticsearch": "^5.0.30",
"@types/git-url-parse": "^9.0.0",
"@types/glob": "^7.1.1",
Expand All @@ -63,11 +63,11 @@
"@types/nock": "^9.3.0",
"@types/node": "^10.12.27",
"@types/node-fetch": "^2.1.4",
"@types/object-hash": "^1.2.0",
"@types/papaparse": "^4.5.5",
"@types/pngjs": "^3.3.1",
"@types/prop-types": "^15.5.3",
"@types/proper-lockfile": "^3.0.0",
"@types/object-hash": "^1.2.0",
"@types/react": "^16.8.0",
"@types/react-dom": "^16.8.0",
"@types/react-infinite-scroller": "^1.2.0",
Expand All @@ -87,6 +87,7 @@
"@types/tar-fs": "^1.16.1",
"@types/tinycolor2": "^1.4.1",
"@types/uuid": "^3.4.4",
"@types/wreck": "^14.0.0",
"abab": "^1.0.4",
"ansi-colors": "^3.0.5",
"ansicolors": "0.3.2",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@ class CodeImportProject extends React.PureComponent<
</EuiFormRow>
</EuiFlexItem>
<EuiFlexItem grow={false}>
{/*
// @ts-ignore */}
{/*
// @ts-ignore */}
<ImportButton
onClick={this.submitImportProject}
data-test-subj="importRepositoryButton"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
* you may not use this file except in compliance with the Elastic License.
*/

// @ts-ignore
import {
EuiButton,
EuiFieldText,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
* you may not use this file except in compliance with the Elastic License.
*/

import { editor } from 'monaco-editor';
import React from 'react';
import { MonacoDiffEditor } from '../../monaco/monaco_diff_editor';

Expand Down Expand Up @@ -34,8 +35,7 @@ export class DiffEditor extends React.Component<Props> {
}

public updateLayout(renderSideBySide: boolean) {
// @ts-ignore
this.diffEditor!.diffEditor!.updateOptions({ renderSideBySide });
this.diffEditor!.diffEditor!.updateOptions({ renderSideBySide } as editor.IDiffEditorOptions);
}

public render() {
Expand Down
2 changes: 0 additions & 2 deletions x-pack/plugins/code/public/components/hover/hover_widget.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,6 @@ export class HoverWidget extends React.PureComponent<HoverWidgetProps> {
private renderInitialting() {
return (
<div className="hover-row">
{/*
// @ts-ignore */}
<Text textAlign="center">
<h4>Language Server is initializing…</h4>
<p>Depending on the size of your repo, this could take a few minutes.</p>
Expand Down
1 change: 0 additions & 1 deletion x-pack/plugins/code/public/components/main/content.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
* you may not use this file except in compliance with the Elastic License.
*/

// @ts-ignore
import { EuiButton, EuiButtonGroup, EuiTitle } from '@elastic/eui';
import theme from '@elastic/eui/dist/eui_theme_light.json';
import 'github-markdown-css/github-markdown.css';
Expand Down
8 changes: 0 additions & 8 deletions x-pack/plugins/code/public/components/main/error_panel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,24 +20,16 @@ export const ErrorPanel = (props: { title: ReactNode; content: string }) => {
<Root>
<EuiPanel>
<EuiSpacer />
{/*
// @ts-ignore */}
<EuiText textAlign="center">
<ErrorIcon />
</EuiText>
{/*
// @ts-ignore */}
<EuiText textAlign="center">{props.title}</EuiText>
<EuiSpacer />
{/*
// @ts-ignore */}
<EuiText textAlign="center">
<EuiTextColor>{props.content}</EuiTextColor>
</EuiText>
<EuiSpacer />
<EuiSpacer />
{/*
// @ts-ignore */}
<EuiText textAlign="center">
<EuiButton fill={true} onClick={history.goBack}>
Go Back
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ export const SuggestionComponent: SFC<Props> = props => {
onClick={click}
// active={props.selected}
onMouseEnter={props.onMouseEnter}
// @ts-ignore
ref={props.innerRef}
id={props.ariaId}
aria-selected={props.selected}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@
*/

import {
// @ts-ignore
EuiFacetButton,
// @ts-ignore
EuiFacetGroup,
EuiFlexGroup,
EuiFlexItem,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
*/

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 React from 'react';
import { Link } from 'react-router-dom';
Expand Down Expand Up @@ -104,9 +105,7 @@ export class CodeSymbolTree extends React.PureComponent<Props, { activePath?: st
onClick={this.getClickHandler(path)}
>
<EuiFlexGroup gutterSize="none" alignItems="center" className="code-structure-node">
{/*
// @ts-ignore */}
<Token iconType={tokenType} />
<Token iconType={tokenType as IconType} />
<EuiText data-test-subj={`codeStructureTreeNode-${name}`} size="s">
{name}
</EuiText>
Expand Down
19 changes: 0 additions & 19 deletions x-pack/plugins/code/public/monaco/monaco.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,25 +99,6 @@ import chrome from 'ui/chrome';

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 syntaxTheme = {
Expand Down
111 changes: 67 additions & 44 deletions x-pack/plugins/code/server/__tests__/lsp_service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,22 @@
* or more contributor license agreements. Licensed under 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 fs from 'fs';
import mkdirp from 'mkdirp';
import path from 'path';
// import rimraf from 'rimraf';
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 { 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 { createTestServerOption } from '../test_utils';
import { Server } from 'hapi';
import { ConsoleLoggerFactory } from '../utils/console_logger_factory';

const filename = 'hello.ts';
describe('lsp_service tests', () => {
Expand All @@ -32,9 +31,16 @@ describe('lsp_service tests', () => {
await index.addByPath(filename);
index.write();
const treeId = await index.writeTree();
const committer = Git.Signature.create("tester",
"test@test.com", Date.now() / 1000, 60);
const commit = await repo.createCommit("HEAD", committer, committer, "commit for test", treeId, []);
const committer = Git.Signature.create('tester', 'test@test.com', Date.now() / 1000, 60);
const commit = await repo.createCommit(
'HEAD',
committer,
committer,
'commit for test',
treeId,
[]
);
// tslint:disable-next-line:no-console
console.log(`created commit ${commit.tostrS()}`);
return repo;
}
Expand All @@ -44,19 +50,19 @@ describe('lsp_service tests', () => {

function mockEsClient(): any {
const api = {
get: function (params: any) {
get(params: any) {
return {
_source: {
[RepositoryGitStatusReservedField]: {
cloneProgress: {
isCloned: true
}
} ,
isCloned: true,
},
},
[RepositoryConfigReservedField]: {
disableTypescript: false
}
}
}
disableTypescript: false,
},
},
};
},
};
return api;
Expand All @@ -66,24 +72,27 @@ describe('lsp_service tests', () => {

// @ts-ignore
before(async () => {
await prepareProject(
path.join(serverOptions.repoPath, repoUri)
);
await prepareProject(path.join(serverOptions.repoPath, repoUri));
});


function comparePath(pathA: string, pathB: string) {
const pa = fs.realpathSync(pathA);
const pb = fs.realpathSync(pathB);
return path.resolve(pa) === path.resolve(pb);
}

it('process a hover request', async () => {

let esClient = mockEsClient();
const esClient = mockEsClient();
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 {
const params = {
textDocument: {
Expand All @@ -92,44 +101,59 @@ describe('lsp_service tests', () => {
position: {
line: 0,
character: 1,
}
},
};
const workspaceHandler = lspservice.workspaceHandler;
const wsSpy = sinon.spy(workspaceHandler, 'handleRequest');
const controller = lspservice.controller;
const ctrlSpy = sinon.spy(controller, 'handleRequest');

let method = 'textDocument/hover';
const method = 'textDocument/hover';

const response = await lspservice.sendRequest(method, params);
assert.ok(response);
assert.ok(response.result.contents);


wsSpy.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
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
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
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;

} finally {
await lspservice.shutdown()
await lspservice.shutdown();
}
// @ts-ignore
}).timeout(10000);

it("unload a workspace", async () => {
let esClient = mockEsClient();
it('unload a workspace', async () => {
const esClient = mockEsClient();
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 {
const params = {
textDocument: {
Expand All @@ -138,10 +162,10 @@ describe('lsp_service tests', () => {
position: {
line: 0,
character: 1,
}
},
};

let method = 'textDocument/hover';
const method = 'textDocument/hover';
// send a dummy request to open a workspace;
const response = await lspservice.sendRequest(method, params);
assert.ok(response);
Expand All @@ -151,7 +175,7 @@ describe('lsp_service tests', () => {
assert.ok(workspaceFolderExists);
const controller = lspservice.controller;
// @ts-ignore
const languageServer = controller.languageServerMap['typescript'];
const languageServer = controller.languageServerMap.typescript;
const realWorkspacePath = fs.realpathSync(workspacePath);

// @ts-ignore
Expand All @@ -172,9 +196,8 @@ describe('lsp_service tests', () => {
assert.strictEqual(exists, false);
return;
} finally {
await lspservice.shutdown()
await lspservice.shutdown();
}
// @ts-ignore
}).timeout(10000);

});
Loading