Skip to content

Generic type resolving broken in typescript@next #44453

@awerlogus

Description

@awerlogus

Bug Report

🔎 Search Terms generic type resolve

🕗 Version & Regression Information 4.4.0-dev.20210605

💻 Code

/** @template T @typedef {T | undefined} Option */

/** @type {<T1, T2>(x: Option<T1>, y: T2) => T1 | T2} */
const a = (x, y) => x !== undefined ? x : y

// Making 'number | undefined' value
/** @type {{ prop?: number }} */
const b = { prop: 1 }
const { prop } = b

// 4.3: number
// 4.4: number | undefined
const c = a(prop, 2)

🙁 Actual behavior

undefined is a part of generic T1

🙂 Expected behavior

undefined is excluded from generic T1

Metadata

Metadata

Assignees

No one assigned

    Labels

    DuplicateAn existing issue was already created

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions