Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Possible 4.3 regression with generic function and rest in object destructuring Β #43941

Copy link
Copy link
@OliverJAsh

Description

@OliverJAsh
Issue body actions

Bug Report

πŸ”Ž Search Terms

πŸ•— Version & Regression Information

  • This changed between versions 4.2 and 4.3 beta

⏯ Playground Link

Playground link with relevant code

πŸ’» Code

type Params = {
    foo: string;
} & ({ tag: 'a'; type: number } | { tag: 'b'; type: string });

const getType = <P extends Params>(params: P) => {
    const {
        // Omit
        foo,

        ...rest
    } = params;

    return rest;
};

declare const params: Params;

switch (params.tag) {
    case 'a': {
        // TS 4.2: number
        // TS 4.3: string | number
        const result = getType(params).type;

        break;
    }
    case 'b': {
        // TS 4.2: string
        // TS 4.3: string | number
        const result = getType(params).type;

        break;
    }
}

πŸ™ Actual behavior

4.3 behaviour should match 4.2 behaviour. See comments in code.

πŸ™‚ Expected behavior

See comments in code.

Reactions are currently unavailable

Metadata

Metadata

Assignees

Labels

Fix AvailableA PR has been opened for this issueA PR has been opened for this issueNeeds InvestigationThis issue needs a team member to investigate its status.This issue needs a team member to investigate its status.

Type

No type
No fields configured for issues without a type.

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions

    Morty Proxy This is a proxified and sanitized view of the page, visit original site.