Closed
Description
Bug Report
The last line below evaluates to true
but is rejected by TS due to < b, c >
being parsed as a type parameter list:
const a = 1;
const b = 2;
const c = 3;
const d = 4;
(a < b, c > (d)); // Error: c refers to a value, but is being used as a type here
Adapted from rust-lang/rfcs#2527 (comment).
Sorry if this issue was known already.
🔎 Search Terms
turbofish
ambiguity
generics
"refers to a value"
🕗 Version & Regression Information
3.5.1 through 4.5.0-beta
This is the behavior in every version I tried, and I reviewed the FAQ for entries about parsing and generics.
3.33 has a slightly different error message.
Note: when using // @ts-check
on a JS file the only error is that the left side of the comma expression is unused (good).
⏯ Playground Link
💻 Code
const a = 1;
const b = 2;
const c = 3;
const d = 4;
(a < b, c > (d));
// | | ^ Error: e refers to a value, but is being used as a type here
// | ^ Error: c refers to a value, but is being used as a type here
// ^ Error: This expression is not callable
🙁 Actual behavior
-
Errors:
Error: This expression is not callable
Error: c refers to a value, but is being used as a type here
e refers to a value, but is being used as a type here
-
And the AST contains CallExpression
🙂 Expected behavior
- No errors
- The AST contains BinaryExpression with LessThanToken etc. instead of CallExpression.
Metadata
Metadata
Assignees
Labels
No labels