Skip to content

Type information lost when destructuring a function result tuple #30379

Closed
@jednano

Description

@jednano

TypeScript Version: 3.4.0-dev.20190313

Search Terms: type information lost during/when/upon/if destructuring a function result tuple

Code

function foo<T = number>(): [T] {
	return [42 as any]
}
const [x] = foo()

Expected behavior:

const x: number

Actual behavior:

const x: any

image

Playground Link

Related Issues: #5416 (an old one)

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScriptFix AvailableA PR has been opened for this issue

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions