-
Notifications
You must be signed in to change notification settings - Fork 13.2k
Closed
Labels
BugA bug in TypeScriptA bug in TypeScriptFixedA PR has been merged for this issueA PR has been merged for this issue
Milestone
Description
TypeScript Version: 2.9.0-dev.20180407
Search Terms: destructuring computed
Code
let { [Symbol.iterator]: destructured } = []; // destructured is any
let elementAccess = [][Symbol.iterator]; // elementAccess is type () => IterableIterator<never>
declare function get<T>(): T;
let { [get<'prop'>()]: computed } = get<{ prop: string }>(); // computed is any
let { prop } = get<{ prop: string }>(); // prop is stringExpected behavior:
destructured has the same type as elementAccess; computed has the same type as prop.
Actual behavior:
Destructuring with computed property always results in any.
Related Issues:
#17566 but that one is only about index signatures
Metadata
Metadata
Assignees
Labels
BugA bug in TypeScriptA bug in TypeScriptFixedA PR has been merged for this issueA PR has been merged for this issue