TypeScript: TypeScript 3.5 compile errors in the VS Code codebase

TypeScript Version: 3.5.0-dev.20190512

Repo Build VS Code with TypeScript@next:

git clone https://github.com/microsoft/vscode.git
cd vscode
yarn add typescript@next
yarn run watch

Potential issues There are 68 compile errors on TS@next, compared to zero when compiling with TS@3.4.5:

[15:39:42] Error: /Users/matb/projects/vscode/src/vs/workbench/contrib/welcome/walkThrough/browser/editor/editorWalkThrough.ts(53,9): Property 'deserialize' in type 'EditorWalkThroughInputFactory' is not assignable to the same property in base type 'IEditorInputFactory'.
  Type '(instantiationService: IInstantiationService, serializedEditorInput: string) => WalkThroughInput' is not assignable to type '(instantiationService: IInstantiationService, serializedEditorInput: string) => EditorInput | undefined'.
    Type 'WalkThroughInput' is not assignable to type 'EditorInput'.
      Types of property 'getTelemetryDescriptor' are incompatible.
        Type '() => object' is not assignable to type '() => { [key: string]: unknown; }'.
          Type 'object' is not assignable to type '{ [key: string]: unknown; }'.
            Index signature is missing in type '{}'.
[15:39:42] Error: /Users/matb/projects/vscode/src/vs/workbench/contrib/welcome/walkThrough/common/walkThroughInput.ts(83,2): Property 'getTelemetryDescriptor' in type 'WalkThroughInput' is not assignable to the same property in base type 'EditorInput'.
  Type '() => object' is not assignable to type '() => { [key: string]: unknown; }'.
    Type 'object' is not assignable to type '{ [key: string]: unknown; }'.
[15:39:42] Error: /Users/matb/projects/vscode/src/vs/workbench/contrib/welcome/walkThrough/browser/walkThroughPart.ts(254,2): Property 'setInput' in type 'WalkThroughPart' is not assignable to the same property in base type 'BaseEditor'.
  Type '(input: WalkThroughInput, options: EditorOptions, token: CancellationToken) => Promise<void>' is not assignable to type '(input: EditorInput, options: EditorOptions | null, token: CancellationToken) => Promise<void>'.
    Types of parameters 'input' and 'input' are incompatible.
      Type 'EditorInput' is missing the following properties from type 'WalkThroughInput': disposables, promise, maxTopScroll, maxBottomScroll, and 5 more.
[15:39:42] Error: /Users/matb/projects/vscode/src/vs/workbench/contrib/welcome/walkThrough/browser/walkThroughPart.ts(262,25): Argument of type 'WalkThroughInput' is not assignable to parameter of type 'EditorInput'.
[15:39:42] Error: /Users/matb/projects/vscode/src/vs/workbench/contrib/welcome/walkThrough/browser/walkThroughPart.ts(266,10): Parameter 'model' implicitly has an 'any' type.
[15:39:42] Error: /Users/matb/projects/vscode/src/vs/workbench/contrib/welcome/walkThrough/browser/walkThroughPart.ts(298,29): Parameter 'snippet' implicitly has an 'any' type.
[15:39:42] Error: /Users/matb/projects/vscode/src/vs/workbench/contrib/welcome/walkThrough/browser/walkThroughPart.ts(298,38): Parameter 'i' implicitly has an 'any' type.
[15:39:42] Error: /Users/matb/projects/vscode/src/vs/workbench/contrib/welcome/walkThrough/browser/walkThroughPart.ts(481,51): Argument of type 'WalkThroughInput' is not assignable to parameter of type 'EditorInput'.
[15:39:42] Error: /Users/matb/projects/vscode/src/vs/workbench/contrib/welcome/walkThrough/browser/walkThroughPart.ts(492,65): Argument of type 'WalkThroughInput' is not assignable to parameter of type 'EditorInput'.
[15:39:42] Error: /Users/matb/projects/vscode/src/vs/workbench/contrib/welcome/walkThrough/browser/walkThrough.contribution.ts(24,3): Argument of type 'typeof WalkThroughPart' is not assignable to parameter of type 'IConstructorSignature0<BaseEditor>'.
  Type 'WalkThroughPart' is not assignable to type 'BaseEditor'.
    Types of property 'setInput' are incompatible.
      Type '(input: WalkThroughInput, options: EditorOptions, token: CancellationToken) => Promise<void>' is not assignable to type '(input: EditorInput, options: EditorOptions | null, token: CancellationToken) => Promise<void>'.
        Types of parameters 'input' and 'input' are incompatible.
          Type 'EditorInput' is not assignable to type 'WalkThroughInput'.
[15:39:42] Error: /Users/matb/projects/vscode/src/vs/workbench/contrib/welcome/walkThrough/browser/walkThrough.contribution.ts(35,147): Argument of type 'typeof EditorWalkThroughInputFactory' is not assignable to parameter of type 'IConstructorSignature0<IEditorInputFactory>'.
  Type 'EditorWalkThroughInputFactory' is not assignable to type 'IEditorInputFactory'.
    Types of property 'deserialize' are incompatible.
      Type '(instantiationService: IInstantiationService, serializedEditorInput: string) => WalkThroughInput' is not assignable to type '(instantiationService: IInstantiationService, serializedEditorInput: string) => EditorInput | undefined'.
[15:39:42] Error: /Users/matb/projects/vscode/src/vs/workbench/contrib/welcome/page/browser/welcomePage.ts(610,9): Property 'deserialize' in type 'WelcomeInputFactory' is not assignable to the same property in base type 'IEditorInputFactory'.
  Type '(instantiationService: IInstantiationService, serializedEditorInput: string) => WalkThroughInput' is not assignable to type '(instantiationService: IInstantiationService, serializedEditorInput: string) => EditorInput | undefined'.
    Type 'WalkThroughInput' is not assignable to type 'EditorInput'.
[15:39:42] Error: /Users/matb/projects/vscode/src/vs/workbench/contrib/welcome/page/browser/welcomePage.contribution.ts(45,132): Argument of type 'typeof WelcomeInputFactory' is not assignable to parameter of type 'IConstructorSignature0<IEditorInputFactory>'.
  Type 'WelcomeInputFactory' is not assignable to type 'IEditorInputFactory'.
    Types of property 'deserialize' are incompatible.
      Type '(instantiationService: IInstantiationService, serializedEditorInput: string) => WalkThroughInput' is not assignable to type '(instantiationService: IInstantiationService, serializedEditorInput: string) => EditorInput | undefined'.
[15:39:42] Error: /Users/matb/projects/vscode/src/vs/workbench/services/themes/common/fileIconThemeData.ts(121,7): Type 'any' is not assignable to type 'never'.
[15:39:42] Error: /Users/matb/projects/vscode/src/vs/workbench/services/themes/common/colorThemeData.ts(254,7): Type 'any' is not assignable to type 'never'.
[15:39:42] Error: /Users/matb/projects/vscode/src/vs/workbench/services/keybinding/common/keybindingEditing.ts(213,17): Object is of type 'unknown'.
[15:39:42] Error: /Users/matb/projects/vscode/src/vs/workbench/services/extensions/node/extensionPoints.ts(292,16): Property 'hasOwnProperty' does not exist on type 'T'.
[15:39:42] Error: /Users/matb/projects/vscode/src/vs/workbench/services/editor/browser/editorService.ts(510,4): Type 'SideBySideEditorInput' is not assignable to type 'EditorInput'.
  Types of property 'getTelemetryDescriptor' are incompatible.
    Type '() => object' is not assignable to type '() => { [key: string]: unknown; }'.
      Type 'object' is not assignable to type '{ [key: string]: unknown; }'.
[15:39:42] Error: /Users/matb/projects/vscode/src/vs/workbench/services/editor/browser/editorService.ts(525,4): Type 'DiffEditorInput' is not assignable to type 'EditorInput'.
  Types of property 'getTelemetryDescriptor' are incompatible.
    Type '() => object' is not assignable to type '() => { [key: string]: unknown; }'.
[15:39:42] Error: /Users/matb/projects/vscode/src/vs/workbench/test/common/editor/editorGroups.test.ts(213,31): Argument of type 'DiffEditorInput' is not assignable to parameter of type 'EditorInput'.
[15:39:42] Error: /Users/matb/projects/vscode/src/vs/workbench/test/common/editor/editorGroups.test.ts(214,31): Argument of type 'DiffEditorInput' is not assignable to parameter of type 'EditorInput'.
[15:39:42] Error: /Users/matb/projects/vscode/src/vs/workbench/contrib/tasks/common/problemMatcher.ts(268,4): Type 'string' is not assignable to type 'undefined'.
[15:39:42] Error: /Users/matb/projects/vscode/src/vs/workbench/contrib/tasks/common/problemMatcher.ts(280,5): Type 'string' is not assignable to type 'undefined'.
[15:39:42] Error: /Users/matb/projects/vscode/src/vs/workbench/contrib/tasks/common/problemMatcher.ts(899,5): Type 'number' is not assignable to type 'undefined & RegExp'.
  Type 'number' is not assignable to type 'undefined'.
[15:39:42] Error: /Users/matb/projects/vscode/src/vs/workbench/contrib/search/browser/searchView.ts(647,66): Argument of type 'ITreeContextMenuEvent<FileMatch | Match | BaseFolderMatch | FolderMatch | null>' is not assignable to parameter of type 'ITreeContextMenuEvent<RenderableMatch>'.
  Type 'FileMatch | Match | BaseFolderMatch | FolderMatch | null' is not assignable to type 'RenderableMatch'.
    Type 'null' is not assignable to type 'RenderableMatch'.
[15:39:42] Error: /Users/matb/projects/vscode/src/vs/workbench/contrib/preferences/electron-browser/preferences.contribution.ts(49,3): Argument of type 'typeof PreferencesEditor' is not assignable to parameter of type 'IConstructorSignature0<BaseEditor>'.
  Type 'PreferencesEditor' is not assignable to type 'BaseEditor'.
    Types of property 'setInput' are incompatible.
      Type '(newInput: PreferencesEditorInput, options: SettingsEditorOptions, token: CancellationToken) => Promise<void>' is not assignable to type '(input: EditorInput, options: EditorOptions | null, token: CancellationToken) => Promise<void>'.
        Types of parameters 'newInput' and 'input' are incompatible.
          Type 'EditorInput' is missing the following properties from type 'PreferencesEditorInput': name, description, _details, _master, and 3 more.
[15:39:42] Error: /Users/matb/projects/vscode/src/vs/workbench/contrib/preferences/electron-browser/preferences.contribution.ts(134,5): Type 'PreferencesEditorInput' is not assignable to type 'EditorInput'.
  Types of property 'getTelemetryDescriptor' are incompatible.
    Type '() => object' is not assignable to type '() => { [key: string]: unknown; }'.
[15:39:42] Error: /Users/matb/projects/vscode/src/vs/workbench/contrib/preferences/browser/preferencesEditor.ts(157,2): Property 'setInput' in type 'PreferencesEditor' is not assignable to the same property in base type 'BaseEditor'.
  Type '(newInput: PreferencesEditorInput, options: SettingsEditorOptions, token: CancellationToken) => Promise<void>' is not assignable to type '(input: EditorInput, options: EditorOptions | null, token: CancellationToken) => Promise<void>'.
    Types of parameters 'newInput' and 'input' are incompatible.
      Type 'EditorInput' is not assignable to type 'PreferencesEditorInput'.
[15:39:42] Error: /Users/matb/projects/vscode/src/vs/workbench/contrib/preferences/browser/preferencesEditor.ts(164,25): Argument of type 'PreferencesEditorInput' is not assignable to parameter of type 'EditorInput'.
[15:39:42] Error: /Users/matb/projects/vscode/src/vs/workbench/contrib/output/browser/outputPanel.ts(100,8): Object is of type 'unknown'.
[15:39:42] Error: /Users/matb/projects/vscode/src/vs/workbench/contrib/output/browser/outputPanel.ts(103,29): Object is of type 'unknown'.
[15:39:42] Error: /Users/matb/projects/vscode/src/vs/workbench/contrib/output/browser/outputPanel.ts(104,24): Object is of type 'unknown'.
[15:39:42] Error: /Users/matb/projects/vscode/src/vs/workbench/contrib/extensions/electron-browser/extensionTipsService.ts(975,83): Object is of type 'unknown'.
[15:39:42] Error: /Users/matb/projects/vscode/src/vs/workbench/contrib/extensions/electron-browser/extensionTipsService.ts(975,121): Object is of type 'unknown'.
[15:39:42] Error: /Users/matb/projects/vscode/src/vs/workbench/contrib/experiments/node/experimentService.ts(181,36): Object is of type 'unknown'.
[15:39:42] Error: /Users/matb/projects/vscode/src/vs/workbench/contrib/experiments/node/experimentService.ts(181,61): Object is of type 'unknown'.
[15:39:42] Error: /Users/matb/projects/vscode/src/vs/workbench/contrib/debug/electron-browser/debugService.ts(746,8): Argument of type 'unknown' is not assignable to parameter of type 'ITaskSummary | Thenable<ITaskSummary | null> | null | undefined'.
  Type 'unknown' is not assignable to type 'Thenable<ITaskSummary | null>'.
[15:39:42] Error: /Users/matb/projects/vscode/src/vs/workbench/browser/parts/notifications/notificationsList.ts(222,4): Type 'string | null' is not assignable to type 'string'.
  Type 'null' is not assignable to type 'string'.
[15:39:42] Error: /Users/matb/projects/vscode/src/vs/workbench/browser/parts/editor/textDiffEditor.ts(164,48): Argument of type 'string | null' is not assignable to parameter of type 'string'.
  Type 'null' is not assignable to type 'string'.
[15:39:42] Error: /Users/matb/projects/vscode/src/vs/workbench/browser/parts/editor/tabsTitleControl.ts(713,4): Type 'null' is not assignable to type 'string'.
[15:39:42] Error: /Users/matb/projects/vscode/src/vs/workbench/browser/parts/editor/tabsTitleControl.ts(714,4): Type 'null' is not assignable to type 'string'.
[15:39:42] Error: /Users/matb/projects/vscode/src/vs/workbench/browser/parts/editor/tabsTitleControl.ts(715,4): Type 'string | null' is not assignable to type 'string'.
  Type 'null' is not assignable to type 'string'.
[15:39:42] Error: /Users/matb/projects/vscode/src/vs/workbench/browser/parts/editor/tabsTitleControl.ts(716,4): Type 'null' is not assignable to type 'string'.
[15:39:42] Error: /Users/matb/projects/vscode/src/vs/workbench/browser/parts/editor/tabsTitleControl.ts(853,3): Type 'string | null' is not assignable to type 'string'.
  Type 'null' is not assignable to type 'string'.
[15:39:42] Error: /Users/matb/projects/vscode/src/vs/workbench/browser/parts/editor/sideBySideEditor.ts(96,2): Property 'setInput' in type 'SideBySideEditor' is not assignable to the same property in base type 'BaseEditor'.
  Type '(newInput: SideBySideEditorInput, options: EditorOptions, token: CancellationToken) => Promise<void>' is not assignable to type '(input: EditorInput, options: EditorOptions | null, token: CancellationToken) => Promise<void>'.
    Types of parameters 'newInput' and 'input' are incompatible.
      Type 'EditorInput' is missing the following properties from type 'SideBySideEditorInput': name, description, _details, _master, and 3 more.
[15:39:42] Error: /Users/matb/projects/vscode/src/vs/workbench/browser/parts/editor/sideBySideEditor.ts(98,25): Argument of type 'SideBySideEditorInput' is not assignable to parameter of type 'EditorInput'.
[15:39:42] Error: /Users/matb/projects/vscode/src/vs/workbench/browser/parts/editor/editorStatus.ts(1022,48): Object is of type 'unknown'.
[15:39:42] Error: /Users/matb/projects/vscode/src/vs/workbench/browser/parts/editor/editorDropTarget.ts(91,3): Type 'string | null' is not assignable to type 'string'.
  Type 'null' is not assignable to type 'string'.
[15:39:42] Error: /Users/matb/projects/vscode/src/vs/workbench/browser/parts/editor/editorDropTarget.ts(92,3): Type '"-2px" | null' is not assignable to type 'string'.
  Type 'null' is not assignable to type 'string'.
[15:39:42] Error: /Users/matb/projects/vscode/src/vs/workbench/browser/parts/editor/editorDropTarget.ts(93,3): Type '"dashed" | null' is not assignable to type 'string'.
  Type 'null' is not assignable to type 'string'.
[15:39:42] Error: /Users/matb/projects/vscode/src/vs/workbench/browser/parts/editor/editorDropTarget.ts(94,3): Type '"2px" | null' is not assignable to type 'string'.
  Type 'null' is not assignable to type 'string'.
[15:39:42] Error: /Users/matb/projects/vscode/src/vs/workbench/browser/parts/editor/editor.contribution.ts(84,3): Argument of type 'typeof BinaryResourceDiffEditor' is not assignable to parameter of type 'IConstructorSignature0<BaseEditor>'.
  Type 'BinaryResourceDiffEditor' is not assignable to type 'BaseEditor'.
    Types of property 'setInput' are incompatible.
      Type '(newInput: SideBySideEditorInput, options: EditorOptions, token: CancellationToken) => Promise<void>' is not assignable to type '(input: EditorInput, options: EditorOptions | null, token: CancellationToken) => Promise<void>'.
        Types of parameters 'newInput' and 'input' are incompatible.
          Type 'EditorInput' is not assignable to type 'SideBySideEditorInput'.
[15:39:42] Error: /Users/matb/projects/vscode/src/vs/workbench/browser/parts/editor/editor.contribution.ts(95,3): Argument of type 'typeof SideBySideEditor' is not assignable to parameter of type 'IConstructorSignature0<BaseEditor>'.
  Type 'SideBySideEditor' is not assignable to type 'BaseEditor'.
    Types of property 'setInput' are incompatible.
      Type '(newInput: SideBySideEditorInput, options: EditorOptions, token: CancellationToken) => Promise<void>' is not assignable to type '(input: EditorInput, options: EditorOptions | null, token: CancellationToken) => Promise<void>'.
[15:39:42] Error: /Users/matb/projects/vscode/src/vs/workbench/browser/parts/editor/editor.contribution.ts(148,52): Types of property 'language' are incompatible.
  Type 'string | null' is not assignable to type 'string | undefined'.
    Type 'null' is not assignable to type 'string | undefined'.
[15:39:42] Error: /Users/matb/projects/vscode/src/vs/workbench/browser/parts/editor/editor.contribution.ts(209,5): Type 'SideBySideEditorInput' is not assignable to type 'EditorInput'.
[15:39:42] Error: /Users/matb/projects/vscode/src/vs/workbench/browser/parts/editor/breadcrumbsPicker.ts(391,10): Conversion of type 'WorkbenchAsyncDataTree<URI | IWorkspace | IWorkspaceFolder | IFileStat, URI | IWorkspace | IWorkspaceFolder | IFileStat, [number, number, number]>' to type 'WorkbenchAsyncDataTree<BreadcrumbElement, any, [number, number, number]>' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first.
  Type 'URI | IWorkspace | IWorkspaceFolder | IFileStat' is not comparable to type 'BreadcrumbElement'.
    Type 'IFileStat' is not comparable to type 'BreadcrumbElement'.
      Type 'IFileStat' is missing the following properties from type 'OutlineElement': marker, id, parent, symbol, and 2 more.
[15:39:42] Error: /Users/matb/projects/vscode/src/vs/workbench/browser/parts/activitybar/activitybarPart.ts(211,3): Type '"border-box" | null' is not assignable to type 'string'.
  Type 'null' is not assignable to type 'string'.
[15:39:42] Error: /Users/matb/projects/vscode/src/vs/base/browser/ui/selectBox/selectBoxCustom.ts(399,4): Type 'string | null' is not assignable to type 'string'.
  Type 'null' is not assignable to type 'string'.
[15:39:42] Error: /Users/matb/projects/vscode/src/vs/platform/instantiation/common/instantiationService.ts(226,13): Object is of type 'unknown'.
[15:39:42] Error: /Users/matb/projects/vscode/src/vs/platform/instantiation/common/instantiationService.ts(229,6): Object is of type 'unknown'.
[15:39:42] Error: /Users/matb/projects/vscode/src/vs/editor/contrib/colorPicker/colorDetector.ts(81,26): Object is of type 'unknown'.
[15:39:42] Error: /Users/matb/projects/vscode/src/vs/base/test/node/config.test.ts(27,28): Argument of type 'unknown' is not assignable to parameter of type 'object'.
[15:39:42] Error: /Users/matb/projects/vscode/src/vs/workbench/common/editor.ts(569,2): Property 'getTelemetryDescriptor' in type 'SideBySideEditorInput' is not assignable to the same property in base type 'EditorInput'.
  Type '() => object' is not assignable to type '() => { [key: string]: unknown; }'.
    Type 'object' is not assignable to type '{ [key: string]: unknown; }'.
[15:39:42] Error: /Users/matb/projects/vscode/src/vs/workbench/browser/dnd.ts(84,22): Types of property 'viewState' are incompatible.
  Type 'ICodeEditorViewState | IDiffEditorViewState | null' is not assignable to type 'ICodeEditorViewState | IDiffEditorViewState | undefined'.
    Type 'null' is not assignable to type 'ICodeEditorViewState | IDiffEditorViewState | undefined'.
[15:39:42] Error: /Users/matb/projects/vscode/src/vs/base/common/parsers.ts(83,15): Argument of type 'T' is not assignable to parameter of type 'object'.
[15:39:42] Error: /Users/matb/projects/vscode/src/vs/base/common/objects.ts(17,14): Argument of type 'T' is not assignable to parameter of type 'object'.
[15:39:42] Error: /Users/matb/projects/vscode/extensions/typescript-language-features/src/utils/surveyor.ts(107,27): Object is of type 'unknown'.
[15:39:42] Error: /Users/matb/projects/vscode/extensions/typescript-language-features/src/utils/surveyor.ts(107,41): Object is of type 'unknown'.

Some of these seem related to https://github.com/Microsoft/TypeScript/pull/30637 but other ones seem suspect (or should be noted in the breaking changes)

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 26 (24 by maintainers)

Most upvoted comments

@weswigham good point. Althought the temptation is to write (target as {}).hasOwnProperty as the relation to undefined is not very clear - unless you’re a smart arse 😉

Thanks

Re #31380 (comment), why can’t the types be narrowed correctly?

Let’s take that discussion to the PR please

https://github.com/microsoft/vscode/commit/fd1ac7561b05cdd0fdeb8a89c4eeac5eb2677226#diff-641fa4cc338f106854e4b4a33964acbdR84

This is an extremely real error.

Consider these three assignments:

						const k1: IDraggedEditor = {
							resource: URI.parse(draggedEditor.resource),
							backupResource: draggedEditor.backupResource ? URI.parse(draggedEditor.backupResource) : undefined,
							viewState: draggedEditor.viewState,
							isExternal: false
						};

						const k2: IDraggedResource = {
							resource: URI.parse(draggedEditor.resource),
							backupResource: draggedEditor.backupResource ? URI.parse(draggedEditor.backupResource) : undefined,
							viewState: draggedEditor.viewState,
							isExternal: false
						};

						const k3: IDraggedEditor | IDraggedResource = {
							resource: URI.parse(draggedEditor.resource),
							backupResource: draggedEditor.backupResource ? URI.parse(draggedEditor.backupResource) : undefined,
							viewState: draggedEditor.viewState,
							isExternal: false
						};

k3 should not be a legal initialization unless at least one of k1 and k2 are, but both of those are also errors. The provided object literal is not a match for either object – backupResource is extraneous in IDraggedEditor, and viewState has the wrong type in IDraggedResource.

https://github.com/microsoft/vscode/commit/fd1ac7561b05cdd0fdeb8a89c4eeac5eb2677226#diff-1e9db0aff31fe7167a26aef6c4176a19R23

The failing example looks like this:

		let watcher = new ConfigWatcher<{}>(testFile);

		let config = watcher.getConfig();
		assert.ok(config);
		assert.equal(Object.keys(config), 0);

This is a hairy variant of the foo && Object.keys(foo) problem since they’re using assert.ok to validate the truthiness of config. However, the error is entirely correct - if testFile’s contents were 5, this would throw under ES5 as specified in the target. ConfigWatcher<T> should have a constraint.