Skip to content

Potential regression in 4.2 - Calling .map on T[] | Y[] is now callable but leads to an implicit any errorΒ #42646

Closed
@tom-sherman

Description

@tom-sherman

Bug Report

πŸ”Ž Search Terms

expression not callable union arrays

πŸ•— Version & Regression Information

This changed between versions 4.1.3 and 4.2 beta

⏯ Playground Link

https://www.typescriptlang.org/play?ts=4.1.3#code/CYUwxgNghgTiAEYD2A7AzgF3gDwFzxQFcBbAIxBgG0BdeAH3kxgEsUBzGgKE+wDpioABwAUAM3gBeAHzxRASiA

https://www.typescriptlang.org/play?ts=4.2.0-beta#code/CYUwxgNghgTiAEYD2A7AzgF3gDwFzxQFcBbAIxBgG0BdeAH3kxgEsUBzGgKE+wDpioABwAUAM3gBeAHzxRASiA

πŸ’» Code

declare const x: number[] | string[]

x.map(f => f)

πŸ™ Actual behavior

.map is now callable but f as an implicit type of any, leading to an implicit any error.

πŸ™‚ Expected behavior

The current behaviour in 4.1.3 is to mark the map() call as not callable as well as f should have an implicit any type.

I don't know if this is a regression but I'm raising it because this change in behaviour is not documented in the release notes.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions