From 7327b8532b032d81a7b837aa794d86296c3cd471 Mon Sep 17 00:00:00 2001 From: Simon Graband Date: Tue, 27 Apr 2021 12:05:07 +0200 Subject: [PATCH] Transpile theia to ES6 --- configs/base.tsconfig.json | 2 +- packages/core/src/browser/navigatable.ts | 4 +- packages/core/src/browser/saveable.ts | 4 +- .../core/src/browser/tree/tree-widget.tsx | 2 +- packages/monaco/src/typings/monaco/index.d.ts | 2 +- .../browser/plugin-contribution-handler.ts | 2 +- .../main/browser/view/tree-view-widget.tsx | 2 +- .../plugin-ext/src/plugin/command-registry.ts | 2 +- packages/plugin-ext/src/plugin/types-impl.ts | 41 ++++++++++++++++++- ...search-in-workspace-result-tree-widget.tsx | 2 +- .../browser/task-problem-matcher-registry.ts | 6 ++- 11 files changed, 56 insertions(+), 13 deletions(-) diff --git a/configs/base.tsconfig.json b/configs/base.tsconfig.json index 7175a17cf0299..25840e002be94 100644 --- a/configs/base.tsconfig.json +++ b/configs/base.tsconfig.json @@ -14,7 +14,7 @@ "resolveJsonModule": true, "module": "commonjs", "moduleResolution": "node", - "target": "es5", + "target": "es6", "jsx": "react", "lib": [ "es6", diff --git a/packages/core/src/browser/navigatable.ts b/packages/core/src/browser/navigatable.ts index 6d033f29e10a1..45b6906b23435 100644 --- a/packages/core/src/browser/navigatable.ts +++ b/packages/core/src/browser/navigatable.ts @@ -45,14 +45,14 @@ export namespace NavigatableWidget { return arg instanceof BaseWidget && Navigatable.is(arg); } export function* getAffected( - widgets: IterableIterator | ArrayLike, + widgets: Iterable, context: MaybeArray ): IterableIterator<[URI, T & NavigatableWidget]> { const uris = Array.isArray(context) ? context : [context]; return get(widgets, resourceUri => uris.some(uri => uri.isEqualOrParent(resourceUri))); } export function* get( - widgets: IterableIterator | ArrayLike, + widgets: Iterable, filter: (resourceUri: URI) => boolean = () => true ): IterableIterator<[URI, T & NavigatableWidget]> { for (const widget of widgets) { diff --git a/packages/core/src/browser/saveable.ts b/packages/core/src/browser/saveable.ts index ad4ca17f276f9..cea603bfaa8f2 100644 --- a/packages/core/src/browser/saveable.ts +++ b/packages/core/src/browser/saveable.ts @@ -161,11 +161,11 @@ export namespace SaveableWidget { export function is(widget: Widget | undefined): widget is SaveableWidget { return !!widget && 'closeWithoutSaving' in widget; } - export function getDirty(widgets: IterableIterator | ArrayLike): IterableIterator { + export function getDirty(widgets: Iterable): IterableIterator { return get(widgets, Saveable.isDirty); } export function* get( - widgets: IterableIterator | ArrayLike, + widgets: Iterable, filter: (widget: T) => boolean = () => true ): IterableIterator { for (const widget of widgets) { diff --git a/packages/core/src/browser/tree/tree-widget.tsx b/packages/core/src/browser/tree/tree-widget.tsx index 085f2a9f6df73..d5f448776c79e 100644 --- a/packages/core/src/browser/tree/tree-widget.tsx +++ b/packages/core/src/browser/tree/tree-widget.tsx @@ -976,7 +976,7 @@ export class TreeWidget extends ReactWidget implements StatefulWidget { decorations.push(node.decorationData); } if (this.decorations.has(node.id)) { - decorations.push(...this.decorations.get(node.id)); + decorations.push(...this.decorations.get(node.id)!); } return decorations.sort(TreeDecoration.Data.comparePriority); } diff --git a/packages/monaco/src/typings/monaco/index.d.ts b/packages/monaco/src/typings/monaco/index.d.ts index a0f65fe3e9987..938a6798827af 100644 --- a/packages/monaco/src/typings/monaco/index.d.ts +++ b/packages/monaco/src/typings/monaco/index.d.ts @@ -525,7 +525,7 @@ declare module monaco.actions { * Retrieves all the registered menu items for the given menu. * @param menuId - see https://github.com/theia-ide/vscode/blob/standalone/0.20.x/src/vs/platform/actions/common/actions.ts#L67 */ - getMenuItems(menuId: 7 /* EditorContext */ | 8 /* EditorContextPeek */ | 25 /* MenubarSelectionMenu */): IMenuItem | ISubmenuItem[]; + getMenuItems(menuId: 7 /* EditorContext */ | 8 /* EditorContextPeek */ | 25 /* MenubarSelectionMenu */): Iterable | Iterable; } // https://github.com/theia-ide/vscode/blob/standalone/0.20.x/src/vs/platform/actions/common/actions.ts#L51 diff --git a/packages/plugin-ext/src/main/browser/plugin-contribution-handler.ts b/packages/plugin-ext/src/main/browser/plugin-contribution-handler.ts index 589c37cf1bc4f..1018c5e925e7e 100644 --- a/packages/plugin-ext/src/main/browser/plugin-contribution-handler.ts +++ b/packages/plugin-ext/src/main/browser/plugin-contribution-handler.ts @@ -297,7 +297,7 @@ export class PluginContributionHandler { } if (contributions.colors) { - pushContribution('colors', () => this.colors.register(...contributions.colors)); + pushContribution('colors', () => this.colors.register(...contributions.colors!)); } if (contributions.taskDefinitions) { diff --git a/packages/plugin-ext/src/main/browser/view/tree-view-widget.tsx b/packages/plugin-ext/src/main/browser/view/tree-view-widget.tsx index cfb5468717370..35275ea828201 100644 --- a/packages/plugin-ext/src/main/browser/view/tree-view-widget.tsx +++ b/packages/plugin-ext/src/main/browser/view/tree-view-widget.tsx @@ -281,7 +281,7 @@ export class TreeViewWidget extends TreeViewWelcomeWidget { }); const children = this.getCaption(node); - return React.createElement('div', attrs, ...children); + return React.createElement('div', attrs, children); } protected getCaption(node: TreeNode): React.ReactNode { diff --git a/packages/plugin-ext/src/plugin/command-registry.ts b/packages/plugin-ext/src/plugin/command-registry.ts index a5e877d93256f..c6c9b9a5a9f94 100644 --- a/packages/plugin-ext/src/plugin/command-registry.ts +++ b/packages/plugin-ext/src/plugin/command-registry.ts @@ -102,7 +102,7 @@ export class CommandRegistryImpl implements CommandRegistryExt { // Using the KnownCommand exclusions, convert the commands manually return KnownCommands.map(id, args, (mappedId: string, mappedArgs: any[] | undefined, mappedResult: KnownCommands.ConversionFunction) => { const mr: KnownCommands.ConversionFunction = mappedResult; - return this.proxy.$executeCommand(mappedId, ...mappedArgs).then((result: any) => { + return this.proxy.$executeCommand(mappedId, ...mappedArgs!).then((result: any) => { if (!result) { return undefined; } diff --git a/packages/plugin-ext/src/plugin/types-impl.ts b/packages/plugin-ext/src/plugin/types-impl.ts index 5b039ddca5652..7d55480b4ce43 100644 --- a/packages/plugin-ext/src/plugin/types-impl.ts +++ b/packages/plugin-ext/src/plugin/types-impl.ts @@ -31,7 +31,9 @@ import { startsWithIgnoreCase } from '@theia/core/lib/common/strings'; import { MarkdownString, isMarkdownString } from './markdown-string'; import { SymbolKind } from '../common/plugin-api-rpc-model'; import { FileSystemProviderErrorCode, markAsFileSystemProviderError } from '@theia/filesystem/lib/common/files'; +import { es5ClassCompat } from '../common/types'; +@es5ClassCompat export class Disposable { private disposable: undefined | (() => void); @@ -125,6 +127,7 @@ export enum SourceControlInputBoxValidationType { Information = 2 } +@es5ClassCompat export class ColorTheme implements theia.ColorTheme { constructor(public readonly kind: ColorThemeKind) { } } @@ -151,6 +154,7 @@ export namespace TextEditorSelectionChangeKind { } } +@es5ClassCompat export class Position { private _line: number; private _character: number; @@ -308,6 +312,7 @@ export class Position { } } +@es5ClassCompat export class Range { protected _start: Position; protected _end: Position; @@ -439,6 +444,7 @@ export class Range { } +@es5ClassCompat export class Selection extends Range { private _anchor: Position; private _active: Position; @@ -490,6 +496,7 @@ export enum EnvironmentVariableMutatorType { Prepend = 3 } +@es5ClassCompat export class SnippetString { static isSnippetString(thing: {}): thing is SnippetString { @@ -571,11 +578,13 @@ export class SnippetString { } } +@es5ClassCompat export class ThemeColor { constructor(public id: string) { } } +@es5ClassCompat export class ThemeIcon { static readonly File: ThemeIcon = new ThemeIcon('file'); @@ -634,6 +643,7 @@ export enum ConfigurationTarget { Memory } +@es5ClassCompat export class RelativePattern { base: string; @@ -664,6 +674,7 @@ export enum IndentAction { Outdent = 3 } +@es5ClassCompat export class TextEdit { protected _range: Range; @@ -772,6 +783,7 @@ export enum CompletionItemKind { TypeParameter = 24 } +@es5ClassCompat export class CompletionItem implements theia.CompletionItem { label: string; @@ -794,6 +806,7 @@ export class CompletionItem implements theia.CompletionItem { } } +@es5ClassCompat export class CompletionList { isIncomplete?: boolean; @@ -861,6 +874,7 @@ export enum CompletionItemTag { Deprecated = 1, } +@es5ClassCompat export class Diagnostic { range: Range; message: string; @@ -888,6 +902,7 @@ export enum MarkerTag { Unnecessary = 1, } +@es5ClassCompat export class ParameterInformation { label: string | [number, number]; documentation?: string | MarkdownString; @@ -898,6 +913,7 @@ export class ParameterInformation { } } +@es5ClassCompat export class SignatureInformation { label: string; documentation?: string | MarkdownString; @@ -916,6 +932,7 @@ export enum SignatureHelpTriggerKind { ContentChange = 3, } +@es5ClassCompat export class SignatureHelp { signatures: SignatureInformation[]; activeSignature: number; @@ -926,6 +943,7 @@ export class SignatureHelp { } } +@es5ClassCompat export class Hover { public contents: MarkdownString[] | theia.MarkedString[]; @@ -955,6 +973,7 @@ export enum DocumentHighlightKind { Write = 2 } +@es5ClassCompat export class DocumentHighlight { public range: Range; @@ -971,6 +990,7 @@ export class DocumentHighlight { export type Definition = Location | Location[]; +@es5ClassCompat export class DocumentLink { range: Range; @@ -1012,6 +1032,7 @@ export enum CodeActionTrigger { Manual = 2, } +@es5ClassCompat export class CodeActionKind { private static readonly sep = '.'; @@ -1048,6 +1069,7 @@ export enum TextDocumentSaveReason { FocusOut = 3 } +@es5ClassCompat export class CodeAction { title: string; @@ -1100,6 +1122,7 @@ export interface FileTextEdit { metadata?: WorkspaceEditMetadata; } +@es5ClassCompat export class WorkspaceEdit implements theia.WorkspaceEdit { private _edits = new Array(); @@ -1249,6 +1272,7 @@ export enum SymbolTag { Deprecated = 1 } +@es5ClassCompat export class SymbolInformation { static validate(candidate: SymbolInformation): void { @@ -1293,6 +1317,7 @@ export class SymbolInformation { } } +@es5ClassCompat export class DocumentSymbol { static validate(candidate: DocumentSymbol): void { @@ -1337,6 +1362,7 @@ export interface QuickInputButton { readonly tooltip?: string | undefined; } +@es5ClassCompat export class QuickInputButtons { static readonly Back: QuickInputButton = { iconPath: { @@ -1359,6 +1385,7 @@ export enum FileChangeType { Deleted = 3, } +@es5ClassCompat export class FileSystemError extends Error { static FileExists(messageOrUri?: string | URI): FileSystemError { @@ -1441,6 +1468,7 @@ export class ProgressOptions { this.location = location; } } + export class Progress { /** * Report a progress update. @@ -1680,6 +1708,7 @@ export class CustomExecution { } } +@es5ClassCompat export class TaskGroup { private groupId: string; @@ -1723,6 +1752,7 @@ export enum TaskScope { Workspace = 2 } +@es5ClassCompat export class Task { private taskDefinition: theia.TaskDefinition; private taskScope: theia.TaskScope.Global | theia.TaskScope.Workspace | theia.WorkspaceFolder | undefined; @@ -1974,6 +2004,7 @@ export class DebugAdapterExecutable { /** * Represents a debug adapter running as a socket based server. */ +@es5ClassCompat export class DebugAdapterServer { /** @@ -2008,6 +2039,7 @@ export enum LogLevel { /** * The base class of all breakpoint types. */ +@es5ClassCompat export class Breakpoint { /** * Is breakpoint enabled. @@ -2049,6 +2081,7 @@ export class Breakpoint { /** * A breakpoint specified by a source location. */ +@es5ClassCompat export class SourceBreakpoint extends Breakpoint { /** * The source and line position of this breakpoint. @@ -2067,6 +2100,7 @@ export class SourceBreakpoint extends Breakpoint { /** * A breakpoint specified by a function name. */ +@es5ClassCompat export class FunctionBreakpoint extends Breakpoint { /** * The name of the function to which this breakpoint is attached. @@ -2082,6 +2116,7 @@ export class FunctionBreakpoint extends Breakpoint { } } +@es5ClassCompat export class Color { readonly red: number; readonly green: number; @@ -2096,6 +2131,7 @@ export class Color { } } +@es5ClassCompat export class ColorInformation { range: Range; color: Color; @@ -2112,6 +2148,7 @@ export class ColorInformation { } } +@es5ClassCompat export class ColorPresentation { label: string; textEdit?: TextEdit; @@ -2131,6 +2168,7 @@ export enum ColorFormat { HSL = 2 } +@es5ClassCompat export class FoldingRange { start: number; end: number; @@ -2149,6 +2187,7 @@ export enum FoldingRangeKind { Region = 3 } +@es5ClassCompat export class SelectionRange { range: Range; @@ -2254,6 +2293,7 @@ export class CallHierarchyOutgoingCall { } } +@es5ClassCompat export class TimelineItem { timestamp: number; label: string; @@ -2284,7 +2324,6 @@ export class SemanticTokensLegend { function isStrArrayOrUndefined(arg: any): arg is string[] | undefined { return ((typeof arg === 'undefined') || (Array.isArray(arg) && arg.every(e => typeof e === 'string'))); } - export class SemanticTokensBuilder { private _prevLine: number; diff --git a/packages/search-in-workspace/src/browser/search-in-workspace-result-tree-widget.tsx b/packages/search-in-workspace/src/browser/search-in-workspace-result-tree-widget.tsx index b2e414c094765..97894c89148b1 100644 --- a/packages/search-in-workspace/src/browser/search-in-workspace-result-tree-widget.tsx +++ b/packages/search-in-workspace/src/browser/search-in-workspace-result-tree-widget.tsx @@ -1075,7 +1075,7 @@ export class SearchInWorkspaceResultTreeWidget extends TreeWidget { protected getExcludeGlobs(excludeOptions?: string[]): string[] { const excludePreferences = this.filesystemPreferences['files.exclude']; const excludePreferencesGlobs = Object.keys(excludePreferences).filter(key => !!excludePreferences[key]); - return [...new Set([...excludePreferencesGlobs, ...excludeOptions])]; + return [...new Set([...excludePreferencesGlobs, ...excludeOptions!])]; } /** diff --git a/packages/task/src/browser/task-problem-matcher-registry.ts b/packages/task/src/browser/task-problem-matcher-registry.ts index 179639812d496..651ad7ba60a78 100644 --- a/packages/task/src/browser/task-problem-matcher-registry.ts +++ b/packages/task/src/browser/task-problem-matcher-registry.ts @@ -144,7 +144,11 @@ export class ProblemMatcherRegistry { patterns.push(ProblemPattern.fromProblemPatternContribution(matcher.pattern)); } } else if (baseMatcher) { - patterns.push(...baseMatcher.pattern); + if (Array.isArray(baseMatcher.pattern)) { + patterns.push(...baseMatcher.pattern); + } else { + patterns.push(baseMatcher.pattern); + } } let deprecated: boolean | undefined = matcher.deprecated;