-
Notifications
You must be signed in to change notification settings - Fork 13.2k
Closed
Labels
BugA bug in TypeScriptA bug in TypeScriptFix AvailableA PR has been opened for this issueA PR has been opened for this issue
Milestone
Description
Bug Report
🔎 Search Terms
regression 4.6 4.7 4.8 out as
🕗 Version & Regression Information
This bug is present in "Nightly 4.8.0-dev20220508", it is not in 4.6.2
- This changed between versions 4.6.2 and 4.7.0-dev.20220415 (including 4.8.0-dev.20200508)
⏯ Playground Link
Playground link with relevant code
💻 Code
let out = 5;
const a = (out as number);This is reduced from a larger expression, where the parens are necessary to nest the cast inside a ternary operation.
class Foo {
constructor(
outs: (string | { id: string; start: number })[],
) {
for (const out of outs) {
const { id, start = 1 } =
(out as {id: string}).id !== undefined
? (out as { id: string; start: number })
: parse(out as string);
console.log(id, start);
}
}
}
🙁 Actual behavior
Compiles to
let out = 5;
const a = (as, number) => ;
This looks like the new Optional Variance rules are identifying these parentheses as an arrow function, when they are just nesting the cast.
🙂 Expected behavior
let out = 5;
const a = out;
This is a paren-wrapped cast, not a function declaration.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
BugA bug in TypeScriptA bug in TypeScriptFix AvailableA PR has been opened for this issueA PR has been opened for this issue