Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue

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

💻 Code

declare const x: number[] | string[] => 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.

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:11 (3 by maintainers)

github_iconTop GitHub Comments

weswighamcommented, Feb 4, 2021

every and filter have multiple overloads (with differing numbers of type parameters) which makes the union call difficult to resolve, while map only has one overload, so combining the signatures is much more straightforward.

thorn0commented, Aug 26, 2022

An isolated real-world case to demo how this issue is a pain: playground

import * as Babel from "@babel/types";
import { TSESTree } from "@typescript-eslint/typescript-estree";
type Node = Babel.Node | TSESTree.Node;

declare const node: Node;

if (
    (node.type === "GenericTypeAnnotation" || node.type === "TSTypeReference") &&
    (!node.typeParameters ||
        node.typeParameters.params.length <= 2 && node.typeParameters.params.every(n => true))
) { }

every causes the following error:

This expression is not callable.
  Each member of the union type '{ <S extends TSType>(predicate: (value: TSType, index: number, array: TSType[]) => value is S, thisArg?: any): this is S[]; (predicate: (value: TSType, index: number, array: TSType[]) => unknown, thisArg?: any): boolean; <S extends TSType>(predicate: (value: TSType, index: number, array: TSType[]) => value is S, thi...' has signatures, but none of those signatures are compatible with each other.(2349)
Read more comments on GitHub >

github_iconTop Results From Across the Web

'this' implicitly has type 'any' because it does not have a type ...
json , I get this error for the following code: 'this' implicitly has type 'any' because it does not have a type annotation....
Read more >
Chapter 7: Correlation and Simple Linear Regression
A correlation exists between two variables when one of them is related to the other in some way. A scatterplot is the best...
Read more >
Applied linear statistical models.djvu - University of Florida
Regression analysis. 2. Mathematical statistics. I. Kutner, Michael H. Applied linear regression models. II. Title. III. Series. QA278.2.K87 2005.
Read more >
Multicollinearity in Regression Analysis: Problems, Detection ...
Multicollinearity is when independent variables in a regression model are correlated. I explore its problems, testing your model for it, and solutions.
Read more >
Practical Regression and Anova using R
A basic knowledge of data analysis is presumed. Some linear algebra and calculus is also required. The emphasis of this text is on...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Post

No results found

github_iconTop Related Hashnode Post

No results found