Skip to content

Commit

Permalink
repo: upgrade to typescript@~4.5.5
Browse files Browse the repository at this point in the history
  • Loading branch information
paul-marechal committed Feb 2, 2022
1 parent 0ad6d10 commit 94b0f67
Show file tree
Hide file tree
Showing 29 changed files with 77 additions and 64 deletions.
4 changes: 2 additions & 2 deletions .vscode/settings.json
Expand Up @@ -4,7 +4,6 @@
// - Linux: $HOME/.config/Code/User/settings.json
// - Mac: $HOME/Library/Application Support/Code/User/settings.json
{
"tslint.enable": true,
"editor.formatOnSave": true,
"search.exclude": {
"**/node_modules": true,
Expand Down Expand Up @@ -55,7 +54,8 @@
"typescript.tsdk": "node_modules/typescript/lib",
"files.insertFinalNewline": true,
"clang-format.language.typescript.enable": false,
// ESLint `max-len` rule.
"editor.rulers": [
180
], // ESLint `max-len` rule.
],
}
2 changes: 1 addition & 1 deletion dev-packages/localization-manager/package.json
Expand Up @@ -33,7 +33,7 @@
"deepmerge": "^4.2.2",
"fs-extra": "^4.0.2",
"glob": "^7.2.0",
"typescript": "^4.4.3"
"typescript": "~4.5.5"
},
"devDependencies": {
"@theia/ext-scripts": "1.22.1"
Expand Down
9 changes: 8 additions & 1 deletion doc/Migration.md
Expand Up @@ -19,9 +19,16 @@ For example:
}
```

### v1.23.0

#### TypeScript 4.5.5

If you are using TypeScript <= 4.5.5 and you encounter issues when building your Theia application because your compiler fails to parse our type definitions,
then you should upgrade to TypeScript >= 4.5.5.

### v1.22.0

### Electron Update
#### Electron Update

Electron got updated from 9 to 15, this might involve some modifications in your code based on the new APIs.

Expand Down
3 changes: 1 addition & 2 deletions license-check-baseline.json
@@ -1,6 +1,5 @@
{
"npm/npmjs/-/eslint-plugin-deprecation/1.2.1": "Approved as 'works-with': https://dev.eclipse.org/ipzilla/show_bug.cgi?id=22573",
"npm/npmjs/-/jschardet/2.3.0": "Approved for Eclipse Theia: https://dev.eclipse.org/ipzilla/show_bug.cgi?id=22481",
"npm/npmjs/-/jsdom/11.12.0": "Approved as 'works-with': https://dev.eclipse.org/ipzilla/show_bug.cgi?id=23640https://dev.eclipse.org/ipzilla/show_bug.cgi?id=23640",
"npm/npmjs/-/node-pty/0.11.0-beta17": "Manually checked using ClearlyDefined"
"npm/npmjs/-/jsdom/11.12.0": "Approved as 'works-with': https://dev.eclipse.org/ipzilla/show_bug.cgi?id=23640https://dev.eclipse.org/ipzilla/show_bug.cgi?id=23640"
}
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -46,7 +46,7 @@
"tslint": "^5.12.0",
"typedoc": "0.20.36",
"typedoc-plugin-external-module-map": "1.2.1",
"typescript": "^3.9.2",
"typescript": "~4.5.5",
"uuid": "^8.0.0",
"yargs": "^15.3.1"
},
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/browser/authentication-service.ts
Expand Up @@ -160,7 +160,7 @@ export class AuthenticationServiceImpl implements AuthenticationService {
}
});
this.commands.registerCommand(this.noAccountsCommand, {
execute: () => {},
execute: () => { },
isEnabled: () => false
});
}
Expand Down Expand Up @@ -264,7 +264,7 @@ export class AuthenticationServiceImpl implements AuthenticationService {
// Activate has already been called for the authentication provider, but it cannot block on registering itself
// since this is sync and returns a disposable. So, wait for registration event to fire that indicates the
// provider is now in the map.
await new Promise((resolve, _) => {
await new Promise<void>((resolve, _) => {
this.onDidRegisterAuthenticationProvider(e => {
if (e.id === providerId) {
provider = this.authenticationProviders.get(providerId);
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/browser/shell/tab-bars.ts
Expand Up @@ -640,6 +640,7 @@ export class ToolbarAwareTabBar extends ScrollableTabBar {
/**
* Overrides the `contentNode` property getter in PhosphorJS' TabBar.
*/
// @ts-expect-error TS2611 `TabBar<T>.contentNode` is declared as `readonly contentNode` but is implemented as a getter.
get contentNode(): HTMLUListElement {
return this.tabBarContainer.getElementsByClassName(ToolbarAwareTabBar.Styles.TAB_BAR_CONTENT)[0] as HTMLUListElement;
}
Expand Down
10 changes: 6 additions & 4 deletions packages/core/src/browser/source-tree/source-tree.ts
Expand Up @@ -14,6 +14,8 @@
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
********************************************************************************/

/* eslint-disable @typescript-eslint/no-explicit-any */

import { injectable } from 'inversify';
import { MaybePromise } from '../../common/types';
import { TreeImpl, CompositeTreeNode, TreeNode, SelectableTreeNode, ExpandableTreeNode } from '../tree';
Expand Down Expand Up @@ -67,15 +69,15 @@ export class SourceTree extends TreeImpl {
} as TreeElementNode;
}
if (CompositeTreeElementNode.is(updated)) {
delete updated.expanded;
delete updated.children;
delete (updated as any).expanded;
delete (updated as any).children;
}
if (updated) {
if (ExpandableTreeNode.is(updated)) {
delete updated.expanded;
delete (updated as any).expanded;
}
if (CompositeTreeNode.is(updated)) {
delete updated.children;
delete (updated as any).children;
}
return updated;
}
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/browser/view-container.ts
Expand Up @@ -1307,6 +1307,7 @@ export class ViewContainerLayout extends SplitLayout {
return map(this.items, item => item.widget);
}

// @ts-expect-error TS2611 `SplitLayout.widgets` is declared as `readonly widgets` but is implemented as a getter.
get widgets(): ViewContainerPart[] {
return toArray(this.iter());
}
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/common/event.ts
Expand Up @@ -330,7 +330,7 @@ export namespace WaitUntilEvent {
// Asynchronous calls to `waitUntil` should fail.
Object.freeze(waitables);
} finally {
delete asyncEvent['waitUntil'];
delete (asyncEvent as any)['waitUntil'];
}
if (!waitables.length) {
return;
Expand Down Expand Up @@ -390,7 +390,7 @@ export class AsyncEmitter<T extends WaitUntilEvent> extends Emitter<T> {
} catch (e) {
console.error(e);
} finally {
delete asyncEvent['waitUntil'];
delete (asyncEvent as any)['waitUntil'];
}
if (!waitables.length) {
return;
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/common/messaging/proxy-factory.ts
Expand Up @@ -236,7 +236,7 @@ export class JsonRpcProxyFactory<T extends object> implements ProxyHandler<T> {
const method = p.toString();
const capturedError = new Error(`Request '${method}' failed`);
return this.connectionPromise.then(connection =>
new Promise((resolve, reject) => {
new Promise<void>((resolve, reject) => {
try {
if (isNotify) {
connection.sendNotification(method, ...args);
Expand Down
14 changes: 9 additions & 5 deletions packages/core/src/node/messaging/ipc-connection-provider.ts
Expand Up @@ -17,7 +17,7 @@
import * as cp from 'child_process';
import * as path from 'path';
import { injectable, inject } from 'inversify';
import { Trace, IPCMessageReader, IPCMessageWriter, createMessageConnection, MessageConnection, Message } from 'vscode-ws-jsonrpc';
import { Trace, Tracer, IPCMessageReader, IPCMessageWriter, createMessageConnection, MessageConnection, Message } from 'vscode-ws-jsonrpc';
import { ILogger, ConnectionErrorHandler, DisposableCollection, Disposable } from '../../common';
import { createIpcEnv } from './ipc-protocol';

Expand Down Expand Up @@ -83,10 +83,14 @@ export class IPCConnectionProvider {
info: (message: string) => this.logger.info(`[${options.serverName}: ${childProcess.pid}] ${message}`),
log: (message: string) => this.logger.info(`[${options.serverName}: ${childProcess.pid}] ${message}`)
});
const traceVerbosity = this.logger.isDebug() ? Trace.Verbose : Trace.Off;
connection.trace(traceVerbosity, {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
log: (message: any, data?: string) => this.logger.debug(`[${options.serverName}: ${childProcess.pid}] ${message}` + (typeof data === 'string' ? ' ' + data : ''))
const tracer: Tracer = {
log: (message: unknown, data?: string) => this.logger.debug(`[${options.serverName}: ${childProcess.pid}] ${message}` + (typeof data === 'string' ? ' ' + data : ''))
};
connection.trace(Trace.Verbose, tracer);
this.logger.isDebug().then(isDebug => {
if (!isDebug) {
connection.trace(Trace.Off, tracer);
}
});
return connection;
}
Expand Down
Expand Up @@ -45,7 +45,7 @@ describe('directory-archiver', () => {
await archiver.archive(fromPath, path.join(toPath, 'output.tar'));
expect(fs.existsSync(path.join(toPath, 'output.tar'))).to.be.true;
const assertPath = track.mkdirSync('assertPath');
return new Promise(resolve => {
return new Promise<void>(resolve => {
fs.createReadStream(path.join(toPath, 'output.tar')).pipe(extract(assertPath)).on('finish', () => {
expect(fs.readdirSync(assertPath).sort()).to.be.deep.equal(['A.txt', 'B.txt']);
expect(fs.readFileSync(path.join(assertPath, 'A.txt'), { encoding: 'utf8' })).to.be.equal(fs.readFileSync(path.join(fromPath, 'A.txt'), { encoding: 'utf8' }));
Expand Down
2 changes: 1 addition & 1 deletion packages/git/src/node/git-repository-watcher.ts
Expand Up @@ -95,7 +95,7 @@ export class GitRepositoryWatcher implements Disposable {
this.skipNextIdle = false;
} else {
const idleTimeout = this.watching ? 5000 : /* super long */ 1000 * 60 * 60 * 24;
await new Promise(resolve => {
await new Promise<void>(resolve => {
const id = setTimeout(resolve, idleTimeout);
this.interruptIdle = () => { clearTimeout(id); resolve(); };
}).then(() => {
Expand Down
2 changes: 1 addition & 1 deletion packages/monaco/src/browser/monaco-editor-provider.ts
Expand Up @@ -209,7 +209,7 @@ export class MonacoEditorProvider {
let keydownListener: monaco.IDisposable | undefined;
const keybindingService = editor.getControl()._standaloneKeybindingService;
for (const listener of keybindingService._store._toDispose) {
if ('_type' in listener && listener['_type'] === 'keydown') {
if ((listener as any)['_type'] === 'keydown') {
keydownListener = listener;
break;
}
Expand Down
5 changes: 0 additions & 5 deletions packages/plugin-ext/src/common/plugin-api-rpc-model.ts
Expand Up @@ -511,11 +511,6 @@ export interface RenameLocation {
text: string;
}

export interface RenameProvider {
provideRenameEdits(model: monaco.editor.ITextModel, position: Position, newName: string): PromiseLike<WorkspaceEdit & Rejection>;
resolveRenameLocation?(model: monaco.editor.ITextModel, position: Position): PromiseLike<RenameLocation & Rejection>;
}

export interface CallHierarchyDefinition {
name: string;
kind: SymbolKind;
Expand Down
3 changes: 2 additions & 1 deletion packages/plugin-ext/src/hosted/node/plugin-reader.ts
Expand Up @@ -58,7 +58,8 @@ export class HostedPluginReader implements BackendApplicationContribution {
// the request was already closed
return;
}
if ('code' in e && e['code'] === 'ENOENT') {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
if ((e as any)['code'] === 'ENOENT') {
res.status(404).send(`No such file found in '${escape_html(pluginId)}' plugin.`);
} else {
res.status(500).send(`Failed to transfer a file from '${escape_html(pluginId)}' plugin.`);
Expand Down
Expand Up @@ -32,7 +32,7 @@ export class ViewColumnService {
) {
let oldColumnValues = new Map<string, number>();
const update = async () => {
await new Promise((resolve => setTimeout(() => resolve())));
await new Promise<void>((resolve => setTimeout(resolve)));
this.updateViewColumns();
this.viewColumnIds.forEach((ids: string[], viewColumn: number) => {
ids.forEach((id: string) => {
Expand Down
Expand Up @@ -142,7 +142,7 @@ export class PluginPathsServiceImpl implements PluginPathsService {

private async cleanupOldLogs(parentLogsDir: string): Promise<void> {
// @ts-ignore - fs-extra types (Even latest version) is not updated with the `withFileTypes` option.
const dirEntries = await readdir(parentLogsDir, { withFileTypes: true });
const dirEntries = await readdir(parentLogsDir, { withFileTypes: true }) as string[];
// `Dirent` type is defined in @types/node since 10.10.0
// However, upgrading the @types/node in theia to 10.11 (as defined in engine field)
// Causes other packages to break in compilation, so we are using the infamous `any` type...
Expand Down
Expand Up @@ -195,7 +195,8 @@ export class PreferenceTreeGenerator {
};
const isTopLevel = Preference.TreeNode.isTopLevel(newNode);
if (!isTopLevel) {
delete newNode.expanded;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
delete (newNode as any).expanded;
}
newNode.depth = isTopLevel ? 0 : 1;
CompositeTreeNode.addChild(root, newNode);
Expand Down
Expand Up @@ -130,7 +130,7 @@ export class MarkdownPreviewHandler implements PreviewHandler {
return NodeFilter.FILTER_SKIP;
}
};
const treeWalker = document.createTreeWalker(content, NodeFilter.SHOW_ELEMENT, filter, false);
const treeWalker = document.createTreeWalker(content, NodeFilter.SHOW_ELEMENT, filter);
if (treeWalker.nextNode()) {
const element = treeWalker.currentNode as HTMLElement;
return element;
Expand Down Expand Up @@ -198,7 +198,7 @@ export class MarkdownPreviewHandler implements PreviewHandler {
return NodeFilter.FILTER_REJECT;
}
};
const treeWalker = document.createTreeWalker(content, NodeFilter.SHOW_ELEMENT, filter, false);
const treeWalker = document.createTreeWalker(content, NodeFilter.SHOW_ELEMENT, filter);
const lineElements: HTMLElement[] = [];
while (treeWalker.nextNode()) {
const element = treeWalker.currentNode as HTMLElement;
Expand Down
6 changes: 3 additions & 3 deletions packages/process/src/node/multi-ring-buffer.spec.ts
Expand Up @@ -329,7 +329,7 @@ describe('MultiRingBuffer', function (): void {
const buffer = 'abc';

const astream = ringBuffer.getStream();
const p = new Promise(resolve => {
const p = new Promise<void>(resolve => {
astream.on('data', (chunk: string) => {
expect(chunk).to.be.equal(buffer);
resolve();
Expand All @@ -347,7 +347,7 @@ describe('MultiRingBuffer', function (): void {
ringBuffer.enq(buffer);

const astream = ringBuffer.getStream();
const p = new Promise(resolve => {
const p = new Promise<void>(resolve => {
astream.on('data', (chunk: string) => {
expect(chunk).to.be.equal(buffer);
resolve();
Expand Down Expand Up @@ -403,7 +403,7 @@ describe('MultiRingBuffer', function (): void {
ringBuffer.enq(buffer);

const astream = ringBuffer.getStream('hex');
const p = new Promise(resolve => {
const p = new Promise<void>(resolve => {
astream.on('data', (chunk: string) => {
expect(chunk).to.be.equal('74657374');
resolve();
Expand Down
11 changes: 4 additions & 7 deletions packages/process/src/node/raw-process.spec.ts
Expand Up @@ -100,16 +100,13 @@ describe('RawProcess', function (): void {
const args = ['--version'];
const rawProcess = rawProcessFactory({ command: process.execPath, 'args': args });
const p = new Promise<number>((resolve, reject) => {
rawProcess.onError(error => {
reject();
});

rawProcess.onError(reject);
rawProcess.onExit(event => {
if (event.code === undefined) {
reject();
reject(new Error('event.code is undefined'));
} else {
resolve(event.code);
}

resolve(event.code);
});
});

Expand Down
Expand Up @@ -401,7 +401,7 @@ export class ScmHistoryWidget extends ScmNavigableListWidget<ScmHistoryListNode>
// eslint-disable-next-line @typescript-eslint/no-explicit-any
protected doLoadMoreRows(params: IndexRange): Promise<any> {
let resolver: () => void;
const promise = new Promise(resolve => resolver = resolve);
const promise = new Promise<void>(resolve => resolver = resolve);
const lastRow = this.scmNodes[params.stopIndex - 1];
if (ScmCommitNode.is(lastRow)) {
const toRevision = lastRow.commitDetails.id;
Expand Down
Expand Up @@ -904,13 +904,16 @@ describe('ripgrep-search-in-workspace-server', function (): void {
it('fails gracefully when rg isn\'t found', async function (): Promise<void> {
const errorString = await new Promise<string>((resolve, reject) => {
const rgServer = createInstance('/non-existent/rg');

rgServer.setClient({
onResult: (searchId: number, result: SearchInWorkspaceResult): void => {
reject();
},
onDone: (searchId: number, error?: string): void => {
resolve(error);
if (typeof error === 'string') {
resolve(error);
} else {
reject();
}
},
});
rgServer.search('pattern', [rootDirA]);
Expand All @@ -934,7 +937,11 @@ describe('ripgrep-search-in-workspace-server', function (): void {
reject();
},
onDone: (searchId: number, error?: string): void => {
resolve(error);
if (typeof error === 'string') {
resolve(error);
} else {
reject();
}
},
});
rgServer.search('pattern', [rootDirA]);
Expand Down

0 comments on commit 94b0f67

Please sign in to comment.