fix(typescript): ArrowFunctionExpression needs parens in TSAsExpression (#1541)

master
Lucas Azzola 2017-05-07 13:03:17 +10:00 committed by Christopher Chedeau
parent 5fd9cd01de
commit e22bd00815
4 changed files with 14 additions and 0 deletions

View File

@ -515,6 +515,7 @@ FPp.needsParens = function() {
case "MemberExpression":
return name === "object";
case "TSAsExpression":
case "BindExpression":
case "TaggedTemplateExpression":
case "UnaryExpression":

View File

@ -0,0 +1,10 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`asOperatorContextualType.ts 1`] = `
// should error
var x = (v => v) as (x: number) => string;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// should error
var x = (v => v) as (x: number) => string;
`;

View File

@ -0,0 +1,2 @@
// should error
var x = (v => v) as (x: number) => string;

View File

@ -0,0 +1 @@
run_spec(__dirname, { parser: "typescript" });