Repository navigation
TypeScript 3.5 compile errors in the VS Code codebase #31380
Copy link
Copy link
Closed
Description
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 watchPotential 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 #30637 but other ones seem suspect (or should be noted in the breaking changes)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels
Activity
mjbvz commentedon May 13, 2019
Specific issues that seem like breaking changes:
A few style properties in
dom.d.tsare no longer nullable:TS 3.5 regression casting
objectto{ [key: string]: unknown };#31381Issues around switch statement for keys that write to an object in the case body (still trying to put together a minimal repo for this one)
TS 3.5 new error when using keyof with assignment to copy property #31382
mjbvz commentedon May 14, 2019
I fixed many of these errors in microsoft/vscode@fd1ac75
RyanCavanaugh commentedon May 14, 2019
microsoft/vscode@fd1ac75#diff-fed321a94e979ed6f2aaaf1001dbac36L17
Caused by #27089. We might consider reverting the lib change because this code is manifestly correct, but our lack of ability to narrow
TtoObjectish<T>from thetypeofcheck at the top of the function means we incorrectly reject the call.RyanCavanaugh commentedon May 14, 2019
microsoft/vscode@fd1ac75#diff-4414fa1e065d93e77c72eec3db97c187L105
We previously inferred
countto be{} | undefined, but now infer it to beunknown. The{} | undefinedtype was "better" because it could narrow awayundefinedin the!count ||expression, then{}could be "safely" coerced with+count.Again, this is a case of manifestly correct code where we need type facts here to express the fact that
undefinedandnullwere removed from the type by the truthiness check.There's a case to be made that our rules around unary
+are inconsistent enough to be useless.+{}is really not any more or less suspect than+undefinedand maybe we should just allow it for everything, same as"" + unknownRyanCavanaugh commentedon May 14, 2019
microsoft/vscode@fd1ac75#diff-11b5b53dd82e487bffdf3b724fad9d83L82
We prevented a hypothetical call of
merge(0, 0, false)which would throw under ES5 (#27089)weswigham commentedon May 14, 2019
unknown & not undefined -> not undefined❤️Type facts as they exist today can only remove types from a union, not "add negated types to an intersection", so it's moreso a shortcoming in the type facts system as it exists than some specific fact being missing. Simply put: The type to narrow to in the case where
x !== undefinedsimply cannot be expressed today. You could get real close by convertingunknowninto{} | undefined | nulland narrowing that, but{}carries some object-like baggage that could cause interesting behavior down the line.RyanCavanaugh commentedon May 14, 2019
microsoft/vscode@fd1ac75#diff-6c07482b4bc75dfd16bc0d2239065809R162
Context: VS Code has
suppressImplicitAnyIndexErrorsenabled.The relevant calling code looks like this (simplified):
Most other uses of
asJsonsupply the type parameter to provide the expected JSON shape. The intent, I guess, is to fall back to something likeanywhen that's not provided. Going back tounknownis really quite bad here becauseresult's type is supposed to meaningfully include| null.It's not clear how to proceed here since the code was quite unsafe to begin with. We should get a time machine and ban uninferrable type parameters.
RyanCavanaugh commentedon May 14, 2019
microsoft/vscode@fd1ac75#diff-1e9db0aff31fe7167a26aef6c4176a19R23
The failing example looks like this:
This is a hairy variant of the
foo && Object.keys(foo)problem since they're usingassert.okto validate the truthiness ofconfig. However, the error is entirely correct - iftestFile's contents were5, this would throw under ES5 as specified in the target.ConfigWatcher<T>should have a constraint.RyanCavanaugh commentedon May 14, 2019
microsoft/vscode@fd1ac75#diff-6037e7fbd0459b235fcaf18ffc6bfba5L79
Same as #31380 (comment)
RyanCavanaugh commentedon May 14, 2019
microsoft/vscode@fd1ac75#diff-949c71ea10759301f6b17fa57cb9a9e0L223
Same as #31380 (comment)
RyanCavanaugh commentedon May 14, 2019
microsoft/vscode@fd1ac75#diff-641fa4cc338f106854e4b4a33964acbdR84
This is an extremely real error.
Consider these three assignments:
k3should not be a legal initialization unless at least one ofk1andk2are, but both of those are also errors. The provided object literal is not a match for either object --backupResourceis extraneous inIDraggedEditor, andviewStatehas the wrong type inIDraggedResource.RyanCavanaugh commentedon May 14, 2019
microsoft/vscode@fd1ac75#diff-b7604f54db2a2f61d2bf5af1fcc5047fL391
I can't tell what's going on here; this doesn't error locally for me. The type is extremely complex.
RyanCavanaugh commentedon May 14, 2019
Let's take that discussion to the PR please
RyanCavanaugh commentedon May 14, 2019
microsoft/vscode@fd1ac75#diff-1ba53e60093143b29593e77afffaacb6L1036
microsoft/vscode@fd1ac75#diff-0b973b67f859d3b8fa68baec97534643R98
More instances of indexing in to a non-null-narrowed
{} | undefinedwhich is now anunknowninstead.RyanCavanaugh commentedon May 14, 2019
microsoft/vscode@fd1ac75#diff-0f1abf8ff5283dac48ea3231f2dddfa0R96
An interesting case. This is a typical unsound method declaration where the derived class needs a specialized object from a parallel class hierarchy and would be broken by a call through a base type alias. Method bivariance allows this, but until a subsequent change this was disallowed due to differing definitions of the return type of
getTelemetryDescriptorThe change appears to be unnecessary due to the change (presumably made chronologically later as Matt was fixing stuff) to
getTelemetryDescriptorat microsoft/vscode@fd1ac75#diff-d6d4527bd487a54f95c554d21f5e05ebUpdate: Also microsoft/vscode@fd1ac75#diff-022291e875d46b01fc7f4e6ba724f466
RyanCavanaugh commentedon May 14, 2019
microsoft/vscode@fd1ac75#diff-00578f406c825a8136fefeb491625f65L722
Bullet 2 from Matt's comment; #31381
ahejlsberg commentedon May 14, 2019
Matt Bierner (@mjbvz) Regarding this one
This is an effect of #30769. The type
FileIconThemeData["id" | "label" | "description" | "settingsId" | "extensionData" | "styleSheetContent" | "hasFileIcons" | "hidesExplorerArrows" | "hasFolderIcons" | "watch"]reduces toneverwhen it is the target of an assignment because the properties are of disjoint types, i.e. there exists no type for which it is safe to perform this assignment.RyanCavanaugh commentedon May 14, 2019
microsoft/vscode@fd1ac75#diff-00578f406c825a8136fefeb491625f65L722
In 3.4,
promisehas typePromise<{} | null>, which is allowed to be used for aPromise<ITaskSummary | null>becauseITaskSummaryonly has optional properties. The type of this variable comes from three places in the function body that follows -Promise.resolve(null)(Promise<null>), a call tonew Promise((c, e) => ...that producesPromise<{}>, and an ultimately-irrelevant call tothis.taskService.run(task)that returnsPromise<ITaskSummary>. It's unsafe because we can't really say what's going in toc(at line 736 (and indeed, this seems to be an incorrect valueundefined).In 3.5, the
Promise<{}>becomesPromise<unknown>and the whole thing becomesPromise<unknown>, andunknowncan't beITaskSummary | nullThe better fix is probably to annotate the untyped
Promiseconstructor call. I'm still confused why TS is allowing anundefinedto to through this codepath.RyanCavanaugh commentedon May 14, 2019
microsoft/vscode@fd1ac75#diff-4a12537872685c49f4dc5c42f1537c45
I don't understand what this change is doing. The only manifestation of the type parameter in
ITreeContextMenuEvent<RenderableMatch | null>iselement: T | null;, so including| nullhere should not have changed anything. There's no error locally when I revert thisRyanCavanaugh commentedon May 14, 2019
microsoft/vscode@fd1ac75#diff-203c27e756d1503a7f55c19fd8440959R268
A simplified version:
This is a correct error; it happens that no one called
set(a, "q", "foo"), but the code doesn't appear to guard against this at all.A preferable fix would be to change the signature of
set / fillPropertyto reject keys that didn't have correspondingstringproperty typesmjbvz commentedon May 15, 2019
Thank you for taking a look. For #31380 (comment), is that TS error or a VS Code error?
I believe the only one that I think is really blocking us then is the d.ts change: #27089
RyanCavanaugh commentedon May 15, 2019
It's a VS Code error IMO. The object has a field that is either surplus in one constituent of the union, or an incorrect type in the other constituent.
mjbvz commentedon May 24, 2019
Closing this as I believe the errors have all be addressed or are by-design
NoelAbrahams commentedon Jun 5, 2019
Matt Bierner (@mjbvz)
Inferring
Tas unknown results in the errorin the following:
Not sure if you are seeing this as a bug. It is certainly rather inconvenient because
hasOwnPropertydoes exist.weswigham commentedon Jun 5, 2019
Pass
undefinedforTand be amazed at howhasOwnPropertydoes not exist. ❤️That's exactly the class of error the constraint change is supposed to catch - you might want to say
T extends object😉NoelAbrahams commentedon Jun 5, 2019
Wesley Wigham (@weswigham) good point. Althought the temptation is to write
(target as {}).hasOwnPropertyas the relation to undefined is not very clear - unless you're a smart arse 😉Thanks