From ade60beb57e55c11f94d926b69d2f37610e91cec Mon Sep 17 00:00:00 2001 From: Felix Kling Date: Wed, 20 Jul 2016 09:44:30 +0200 Subject: [PATCH] Update to ast-types 0.8.18 ... to include `TypeParameter` information (d5ce0400511bdf6b063c13728c4fa09edd9e122d). See also https://github.com/flowtype/flow-codemod/issues/6#issuecomment-233738594 . --- lib/printer.js | 25 +++++++++++++++++++++++++ package.json | 2 +- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/lib/printer.js b/lib/printer.js index 8a18e8c5..9dc9371f 100644 --- a/lib/printer.js +++ b/lib/printer.js @@ -1424,6 +1424,28 @@ function genericPrintNoParens(path, options, print) { fromString(", ").join(path.map(print, "params")), ">" ]); + case "TypeParameter": + switch (n.variance) { + case 'plus': + parts.push('+'); + break; + case 'minus': + parts.push('-'); + break; + default: + } + + parts.push(path.call(print, 'name')); + + if (n.bound) { + parts.push(path.call(print, 'bound')); + } + + if (n['default']) { + parts.push('=', path.call(print, 'default')); + } + + return concat(parts); case "TypeofTypeAnnotation": return concat([ @@ -1437,6 +1459,9 @@ function genericPrintNoParens(path, options, print) { case "VoidTypeAnnotation": return fromString("void", options); + case "NullTypeAnnotation": + return fromString("null", options); + // Unhandled types below. If encountered, nodes of these types should // be either left alone or desugared into AST types that are fully // supported by the pretty-printer. diff --git a/package.json b/package.json index 0ea4b81b..d434286c 100644 --- a/package.json +++ b/package.json @@ -28,7 +28,7 @@ "fs": false }, "dependencies": { - "ast-types": "0.8.17", + "ast-types": "0.8.18", "esprima": "~2.7.1", "private": "~0.1.5", "source-map": "~0.5.0"