Skip to content

strict-optional-properties error: Type 'Window & typeof globalThis' is not assignable to type 'Window'Β #44417

Closed
@amcasey

Description

@amcasey

Bug Report

πŸ”Ž Search Terms

strictoptionalproperties, global

⏯ Playground Link

Playground link with relevant code (and enable strictOptionalProperties)

πŸ’» Code

const w: Window = window;

πŸ™ Actual behavior

test.ts:1:7 - error TS2322: Type 'Window & typeof globalThis' is not assignable to type 'Window'.
  Types of property 'ontouchcancel' are incompatible.
    Type '(((this: GlobalEventHandlers, ev: TouchEvent) => any) & ((this: Window, ev: TouchEvent) => any)) | null | undefined' is not assignable to type '((this: GlobalEventHandlers, ev: TouchEvent) => any) | null'.
      Type 'undefined' is not assignable to type '((this: GlobalEventHandlers, ev: TouchEvent) => any) | null'.

1 const w: Window = window;
        ~

πŸ™‚ Expected behavior

Usually, T & U is assignable to T.

Metadata

Metadata

Assignees

Labels

BugA bug in TypeScript

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions