Skip to content

() => string and (): string don't match type #44098

Closed
@SephReed

Description

@SephReed

Bug Report

Playground Link

const foo = () => "foo";
const bar: () => string = foo as Omit<typeof foo, "baz">;

Type 'Omit<() => string, "baz">' is not assignable to type '() => string'.
Type 'Omit<() => string, "baz">' provides no match for the signature '(): string'.

🔎 Search Terms

  • () => string and (): string
  • Omit breaks function type match

🙁 Actual behavior

A () => string has a non-existent property omitted can no longer be assigned to () => string

🙂 Expected behavior

It's the same exact type, nothing has changed by omitting a non-existent property.

Actual use case

https://www.typescriptlang.org/play?#code/JYOwLgpgTgZghgYwgAgJIGEAWdTIN4BQyxyAFAJQBcyAzmFKAOYDcRJkdF1dDILbxeHWgB+LrXpNWAXwIEEAGzg0ayLDhAAJAPYKAJtHwDkABwCuAIwXAEyRhDDIE2UBSMkPT7SDrJtZsGoMFxBkAF4yNzCAPmQAIhhtbTjyZGU0kABPVk8SKAczKFD-R3SAeQBbYDAAHjBMkwhtGD8AgBp4oUgoOOickllZeW9fTF0DKHDkEAgAdzUQnX1oClYx5agAOmcNVeIAen3kCzg9ZGgobSgCdYntkM2ulfJmZEO7JLOLq5vx6HuNJsOGBVgQgA

Metadata

Metadata

Assignees

No one assigned

    Labels

    QuestionAn issue which isn't directly actionable in code

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions