fix(typescript): fix unstable optional method (#1770)

master
Lucas Azzola 2017-05-28 00:24:54 +10:00 committed by Christopher Chedeau
parent 59a760c5d8
commit 91bcde9859
4 changed files with 11 additions and 1 deletions

View File

@ -2354,7 +2354,7 @@ function genericPrintNoParens(path, options, print, args) {
case "TSMethodSignature":
parts.push(
path.call(print, "name"),
n.questionToken ? "?" : "",
n.questionToken && !n.name.optional ? "?" : "",
printFunctionTypeParameters(path, options, print),
printFunctionParams(path, print, options)
);

View File

@ -0,0 +1,8 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`type_literal_optional_method.ts 1`] = `
var v: { e?(): number };
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
var v: { e?(): number };
`;

View File

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

View File

@ -0,0 +1 @@
var v: { e?(): number };