Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update lodash tests for TS 4.8 #61480

Merged
merged 1 commit into from Jul 27, 2022
Merged

Commits on Jul 27, 2022

  1. Update lodash tests for TS 4.8

    Typescript 4.8 now prefers the asserted type in type predicate narrowing
    in the rare case where both types are assignable to each other. Previously it
    preferred the type of the provided parameter.
    
    Usually this is desired, since type predicates
    are essentially type assertions. For example, narrowing `unknown` to a
    specific type is very common. But in _.isFunction, the intent is to
    keep the original signature when narrowing a union:
    
    ```ts
    declare const value: number | (() => void);
    if (_.isFunction(value)) {
       value; // $ExpectType () => void
    }
    ```
    
    Unfortunately functions that return void are assignable to functions
    that return any *and vice versa*, so the new result is that `value` is
    narrowed to isFunctions' return type:
    
    ```ts
    declare const value: number | (() => void);
    if (_.isFunction(value)) {
       value; // $ExpectType (...args: any[]) => any
    }
    ```
    
    I've updated the tests to reflect that. This change doesn't apply to
    functions that return types besides void, but the tests happen to use
    such a function.
    sandersn committed Jul 27, 2022
    Configuration menu
    Copy the full SHA
    7f72912 View commit details
    Browse the repository at this point in the history