Skip to content

Fix TS 4.1 errors in codebase #106358

@mjbvz

Description

@mjbvz

TS 4.1 fixes some strictness issues around Promise types. This caused about 90 issues in our codebase. I fixed 60 of the simple issues but we are blocked on building VS Code with TS 4.1 until we fix the remaining problems

To check / fix these issues:

  1. In the VS Code repo
  2. yarn add -D typescript@next
  3. yarn watch

Errors

(please re-assign if I got the owner wrong)

Error: src/vs/base/test/browser/ui/tree/asyncDataTree.test.ts(298,48): Argument of type 'Element[] | undefined' is not assignable to parameter of type 'Element[] | PromiseLike<Element[]>'.
  Type 'undefined' is not assignable to type 'Element[] | PromiseLike<Element[]>'.
Error: src/vs/base/test/browser/ui/tree/asyncDataTree.test.ts(341,48): Argument of type 'Element[] | undefined' is not assignable to parameter of type 'Element[] | PromiseLike<Element[]>'.
  Type 'undefined' is not assignable to type 'Element[] | PromiseLike<Element[]>'.
Error: src/vs/workbench/contrib/extensions/browser/extensionsWorkbenchService.ts(1172,105): Type '(value: unknown) => void' is not assignable to type '() => void'.
Error: src/vs/workbench/contrib/bulkEdit/browser/preview/bulkEditPane.ts(191,40): Expected 1 arguments, but got 0.
Error: src/vs/workbench/contrib/bulkEdit/browser/preview/bulkEditPane.ts(193,4): Type '(value: ResourceEdit[] | PromiseLike<ResourceEdit[]>) => void' is not assignable to type '(edit?: ResourceEdit[] | undefined) => void'.
  Types of parameters 'value' and 'edit' are incompatible.
    Type 'ResourceEdit[] | undefined' is not assignable to type 'ResourceEdit[] | PromiseLike<ResourceEdit[]>'.
      Type 'undefined' is not assignable to type 'ResourceEdit[] | PromiseLike<ResourceEdit[]>'.
Error: src/vs/workbench/services/workspaces/browser/abstractWorkspaceEditingService.ts(310,11): 'async' modifier cannot be used with 'abstract' modifier.
Error: src/vs/workbench/services/progress/browser/progressService.ts(227,46): Type '(value: R | PromiseLike<R>) => void' is not assignable to type '() => void'.
Error: src/vs/workbench/services/authentication/browser/authenticationService.ts(447,14): Argument of type 'MainThreadAuthenticationProvider | undefined' is not assignable to parameter of type 'MainThreadAuthenticationProvider | PromiseLike<MainThreadAuthenticationProvider>'.
  Type 'undefined' is not assignable to type 'MainThreadAuthenticationProvider | PromiseLike<MainThreadAuthenticationProvider>'.
Error: src/vs/workbench/contrib/tasks/browser/runAutomaticTasks.ts(72,111): Argument of type 'CustomTask | ContributedTask | InMemoryTask | undefined' is not assignable to parameter of type 'CustomTask | ContributedTask | InMemoryTask | PromiseLike<Task>'.
  Type 'undefined' is not assignable to type 'CustomTask | ContributedTask | InMemoryTask | PromiseLike<Task>'.
Error: src/vs/workbench/contrib/remote/browser/remote.ts(293,12): Argument of type 'string | undefined' is not assignable to parameter of type 'string | PromiseLike<string>'.
  Type 'undefined' is not assignable to type 'string | PromiseLike<string>'.
Error: src/vs/workbench/contrib/format/browser/formatActionsMultiple.ts(118,15): Type '(value: T | PromiseLike<T | undefined> | undefined) => void' is not assignable to type '() => void'.
Error: src/vs/workbench/contrib/debug/browser/rawDebugSession.ts(627,6): Expected 1 arguments, but got 0.
Error: src/vs/base/browser/ui/dropdown/dropdownActionViewItem.ts(89,4): The type 'readonly IAction[]' is 'readonly' and cannot be assigned to the mutable type 'IAction[]'.
Error: src/vs/workbench/api/common/extHostTerminalService.ts(123,47): Type '(value: number | PromiseLike<number>) => void' is not assignable to type '(value: number | undefined) => any'.
Error: src/vs/workbench/api/common/extHostTerminalService.ts(123,47): Type '(value: number | PromiseLike<number>) => void' is not assignable to type '(value: number | undefined) => any'.
  Types of parameters 'value' and 'value' are incompatible.
    Type 'number | undefined' is not assignable to type 'number | PromiseLike<number>'.
      Type 'undefined' is not assignable to type 'number | PromiseLike<number>'.
Error: src/vs/workbench/api/common/extHostTerminalService.ts(676,7): Argument of type 'undefined' is not assignable to parameter of type 'ExtHostTerminal | PromiseLike<ExtHostTerminal>'.
Error: src/vs/workbench/api/common/extHostDiagnostics.ts(81,14): Argument of type 'readonly [Uri, readonly Diagnostic[]][]' is not assignable to parameter of type '[Uri, Diagnostic[]][]'.
  The type 'readonly [Uri, readonly Diagnostic[]][]' is 'readonly' and cannot be assigned to the mutable type '[Uri, Diagnostic[]][]'.
Error: src/vs/workbench/api/common/extHostDiagnostics.ts(91,21): Argument of type 'string' is not assignable to parameter of type 'URI'.
Error: src/vs/workbench/api/common/extHostDiagnostics.ts(96,48): Argument of type 'string' is not assignable to parameter of type 'URI'.
Error: src/vs/workbench/api/common/extHostDiagnostics.ts(101,48): Argument of type 'string' is not assignable to parameter of type 'URI'.
Error: src/vs/workbench/api/browser/mainThreadMessageService.ts(95,13): Argument of type 'undefined' is not assignable to parameter of type 'number | PromiseLike<number>'.
Error: src/vs/workbench/browser/actions/layoutActions.ts(613,13): Argument of type 'string | undefined' is not assignable to parameter of type 'string | PromiseLike<string>'.
  Type 'undefined' is not assignable to type 'string | PromiseLike<string>'.
Error: src/vs/base/common/async.ts(56,102): Argument of type 'T | undefined' is not assignable to parameter of type 'T | PromiseLike<T>'.
  Type 'undefined' is not assignable to type 'T | PromiseLike<T>'.
Error: src/vs/base/common/async.ts(69,29): Type '(value: T | PromiseLike<T>) => void' is not assignable to type '() => void'.
Error: src/vs/base/common/async.ts(471,45): Type '(value: T | PromiseLike<T>) => void' is not assignable to type '(value?: T | Promise<T> | undefined) => void'.
  Types of parameters 'value' and 'value' are incompatible.
    Type 'T | Promise<T> | undefined' is not assignable to type 'T | PromiseLike<T>'.
      Type 'undefined' is not assignable to type 'T | PromiseLike<T>'.
Error: src/vs/base/node/terminalEncoding.ts(76,20): Argument of type 'undefined' is not assignable to parameter of type 'string | PromiseLike<string>'.
Error: src/vs/base/node/ps.ts(196,15): Argument of type 'ProcessItem | undefined' is not assignable to parameter of type 'ProcessItem | PromiseLike<ProcessItem>'.
  Type 'undefined' is not assignable to type 'ProcessItem | PromiseLike<ProcessItem>'.
Error: src/vs/base/node/ps.ts(231,17): Argument of type 'ProcessItem | undefined' is not assignable to parameter of type 'ProcessItem | PromiseLike<ProcessItem>'.
  Type 'undefined' is not assignable to type 'ProcessItem | PromiseLike<ProcessItem>'.
Error: src/vs/base/node/processes.ts(298,5): Type '(value: number | PromiseLike<number>) => void' is not assignable to type 'ValueCallback<number>'.
  Types of parameters 'value' and 'value' are incompatible.
    Type 'number | Promise<number> | undefined' is not assignable to type 'number | PromiseLike<number>'.
      Type 'undefined' is not assignable to type 'number | PromiseLike<number>'.

Metadata

Metadata

Assignees

Labels

debtCode quality issues

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions