Update tsep and apply breaking changes (#3455)
parent
76c5d91ce6
commit
dc91108453
|
@ -50,7 +50,7 @@
|
||||||
"semver": "5.4.1",
|
"semver": "5.4.1",
|
||||||
"string-width": "2.1.1",
|
"string-width": "2.1.1",
|
||||||
"typescript": "2.6.2",
|
"typescript": "2.6.2",
|
||||||
"typescript-eslint-parser": "9.0.1",
|
"typescript-eslint-parser": "10.0.0",
|
||||||
"unicode-regex": "1.0.1",
|
"unicode-regex": "1.0.1",
|
||||||
"unified": "6.1.6"
|
"unified": "6.1.6"
|
||||||
},
|
},
|
||||||
|
|
|
@ -179,7 +179,7 @@ function massageAST(ast, parent) {
|
||||||
// (TypeScript) bypass TSParenthesizedType
|
// (TypeScript) bypass TSParenthesizedType
|
||||||
if (
|
if (
|
||||||
ast.type === "TSParenthesizedType" &&
|
ast.type === "TSParenthesizedType" &&
|
||||||
ast.typeAnnotation.type === "TypeAnnotation"
|
ast.typeAnnotation.type === "TSTypeAnnotation"
|
||||||
) {
|
) {
|
||||||
return newObj.typeAnnotation.typeAnnotation;
|
return newObj.typeAnnotation.typeAnnotation;
|
||||||
}
|
}
|
||||||
|
|
|
@ -373,12 +373,13 @@ FastPath.prototype.needsParens = function(options) {
|
||||||
case "TSParenthesizedType": {
|
case "TSParenthesizedType": {
|
||||||
const grandParent = this.getParentNode(1);
|
const grandParent = this.getParentNode(1);
|
||||||
if (
|
if (
|
||||||
(parent.type === "TypeParameter" ||
|
(parent.type === "TSTypeParameter" ||
|
||||||
|
parent.type === "TypeParameter" ||
|
||||||
parent.type === "VariableDeclarator" ||
|
parent.type === "VariableDeclarator" ||
|
||||||
parent.type === "TypeAnnotation" ||
|
parent.type === "TSTypeAnnotation" ||
|
||||||
parent.type === "GenericTypeAnnotation" ||
|
parent.type === "GenericTypeAnnotation" ||
|
||||||
parent.type === "TSTypeReference") &&
|
parent.type === "TSTypeReference") &&
|
||||||
(node.typeAnnotation.type === "TypeAnnotation" &&
|
(node.typeAnnotation.type === "TSTypeAnnotation" &&
|
||||||
node.typeAnnotation.typeAnnotation.type !== "TSFunctionType" &&
|
node.typeAnnotation.typeAnnotation.type !== "TSFunctionType" &&
|
||||||
grandParent.type !== "TSTypeOperator")
|
grandParent.type !== "TSTypeOperator")
|
||||||
) {
|
) {
|
||||||
|
|
|
@ -2033,6 +2033,7 @@ function genericPrintNoParens(path, options, print, args) {
|
||||||
// Type Annotations for Facebook Flow, typically stripped out or
|
// Type Annotations for Facebook Flow, typically stripped out or
|
||||||
// transformed away before printing.
|
// transformed away before printing.
|
||||||
case "TypeAnnotation":
|
case "TypeAnnotation":
|
||||||
|
case "TSTypeAnnotation":
|
||||||
if (n.typeAnnotation) {
|
if (n.typeAnnotation) {
|
||||||
return path.call(print, "typeAnnotation");
|
return path.call(print, "typeAnnotation");
|
||||||
}
|
}
|
||||||
|
@ -2160,7 +2161,9 @@ function genericPrintNoParens(path, options, print, args) {
|
||||||
);
|
);
|
||||||
|
|
||||||
let needsColon =
|
let needsColon =
|
||||||
isArrowFunctionTypeAnnotation && parent.type === "TypeAnnotation";
|
isArrowFunctionTypeAnnotation &&
|
||||||
|
(parent.type === "TypeAnnotation" ||
|
||||||
|
parent.type === "TSTypeAnnotation");
|
||||||
|
|
||||||
// Sadly we can't put it inside of FastPath::needsColon because we are
|
// Sadly we can't put it inside of FastPath::needsColon because we are
|
||||||
// printing ":" as part of the expression and it would put parenthesis
|
// printing ":" as part of the expression and it would put parenthesis
|
||||||
|
@ -2168,7 +2171,8 @@ function genericPrintNoParens(path, options, print, args) {
|
||||||
const needsParens =
|
const needsParens =
|
||||||
needsColon &&
|
needsColon &&
|
||||||
isArrowFunctionTypeAnnotation &&
|
isArrowFunctionTypeAnnotation &&
|
||||||
parent.type === "TypeAnnotation" &&
|
(parent.type === "TypeAnnotation" ||
|
||||||
|
parent.type === "TSTypeAnnotation") &&
|
||||||
parentParent.type === "ArrowFunctionExpression";
|
parentParent.type === "ArrowFunctionExpression";
|
||||||
|
|
||||||
if (isObjectTypePropertyAFunction(parent)) {
|
if (isObjectTypePropertyAFunction(parent)) {
|
||||||
|
@ -2295,6 +2299,7 @@ function genericPrintNoParens(path, options, print, args) {
|
||||||
// If there's a leading comment, the parent is doing the indentation
|
// If there's a leading comment, the parent is doing the indentation
|
||||||
const shouldIndent =
|
const shouldIndent =
|
||||||
parent.type !== "TypeParameterInstantiation" &&
|
parent.type !== "TypeParameterInstantiation" &&
|
||||||
|
parent.type !== "TSTypeParameterInstantiation" &&
|
||||||
parent.type !== "GenericTypeAnnotation" &&
|
parent.type !== "GenericTypeAnnotation" &&
|
||||||
parent.type !== "TSTypeReference" &&
|
parent.type !== "TSTypeReference" &&
|
||||||
parent.type !== "FunctionTypeParam" &&
|
parent.type !== "FunctionTypeParam" &&
|
||||||
|
@ -2452,8 +2457,21 @@ function genericPrintNoParens(path, options, print, args) {
|
||||||
]);
|
]);
|
||||||
case "TypeParameterDeclaration":
|
case "TypeParameterDeclaration":
|
||||||
case "TypeParameterInstantiation":
|
case "TypeParameterInstantiation":
|
||||||
|
case "TSTypeParameterDeclaration":
|
||||||
|
case "TSTypeParameterInstantiation":
|
||||||
return printTypeParameters(path, options, print, "params");
|
return printTypeParameters(path, options, print, "params");
|
||||||
|
|
||||||
|
case "TSTypeParameter":
|
||||||
case "TypeParameter": {
|
case "TypeParameter": {
|
||||||
|
const parent = path.getParentNode();
|
||||||
|
if (parent.type === "TSMappedType") {
|
||||||
|
parts.push(path.call(print, "name"));
|
||||||
|
if (n.constraint) {
|
||||||
|
parts.push(" in ", path.call(print, "constraint"));
|
||||||
|
}
|
||||||
|
return concat(parts);
|
||||||
|
}
|
||||||
|
|
||||||
const variance = getFlowVariance(n);
|
const variance = getFlowVariance(n);
|
||||||
|
|
||||||
if (variance) {
|
if (variance) {
|
||||||
|
@ -2683,14 +2701,6 @@ function genericPrintNoParens(path, options, print, args) {
|
||||||
"}"
|
"}"
|
||||||
])
|
])
|
||||||
);
|
);
|
||||||
case "TSTypeParameter":
|
|
||||||
parts.push(path.call(print, "name"));
|
|
||||||
|
|
||||||
if (n.constraint) {
|
|
||||||
parts.push(" in ", path.call(print, "constraint"));
|
|
||||||
}
|
|
||||||
|
|
||||||
return concat(parts);
|
|
||||||
case "TSMethodSignature":
|
case "TSMethodSignature":
|
||||||
parts.push(
|
parts.push(
|
||||||
n.accessibility ? concat([n.accessibility, " "]) : "",
|
n.accessibility ? concat([n.accessibility, " "]) : "",
|
||||||
|
@ -4955,7 +4965,7 @@ function sameLocStart(nodeA, nodeB) {
|
||||||
// var f: (a) => void;
|
// var f: (a) => void;
|
||||||
function isTypeAnnotationAFunction(node) {
|
function isTypeAnnotationAFunction(node) {
|
||||||
return (
|
return (
|
||||||
node.type === "TypeAnnotation" &&
|
(node.type === "TypeAnnotation" || node.type === "TSTypeAnnotation") &&
|
||||||
node.typeAnnotation.type === "FunctionTypeAnnotation" &&
|
node.typeAnnotation.type === "FunctionTypeAnnotation" &&
|
||||||
!node.static &&
|
!node.static &&
|
||||||
!sameLocStart(node, node.typeAnnotation)
|
!sameLocStart(node, node.typeAnnotation)
|
||||||
|
@ -5017,7 +5027,8 @@ function shouldHugArguments(fun) {
|
||||||
fun.params[0].type === "ArrayPattern" ||
|
fun.params[0].type === "ArrayPattern" ||
|
||||||
(fun.params[0].type === "Identifier" &&
|
(fun.params[0].type === "Identifier" &&
|
||||||
fun.params[0].typeAnnotation &&
|
fun.params[0].typeAnnotation &&
|
||||||
fun.params[0].typeAnnotation.type === "TypeAnnotation" &&
|
(fun.params[0].typeAnnotation.type === "TypeAnnotation" ||
|
||||||
|
fun.params[0].typeAnnotation.type === "TSTypeAnnotation") &&
|
||||||
isObjectType(fun.params[0].typeAnnotation.typeAnnotation)) ||
|
isObjectType(fun.params[0].typeAnnotation.typeAnnotation)) ||
|
||||||
(fun.params[0].type === "FunctionTypeParam" &&
|
(fun.params[0].type === "FunctionTypeParam" &&
|
||||||
isObjectType(fun.params[0].typeAnnotation)) ||
|
isObjectType(fun.params[0].typeAnnotation)) ||
|
||||||
|
|
|
@ -4411,9 +4411,9 @@ typedarray@^0.0.6:
|
||||||
version "0.0.6"
|
version "0.0.6"
|
||||||
resolved "https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777"
|
resolved "https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777"
|
||||||
|
|
||||||
typescript-eslint-parser@9.0.1:
|
typescript-eslint-parser@10.0.0:
|
||||||
version "9.0.1"
|
version "10.0.0"
|
||||||
resolved "https://registry.yarnpkg.com/typescript-eslint-parser/-/typescript-eslint-parser-9.0.1.tgz#1497a565d192ca2a321bc5bbf89dcab0a2da75e8"
|
resolved "https://registry.yarnpkg.com/typescript-eslint-parser/-/typescript-eslint-parser-10.0.0.tgz#82b550253659c311c2e4a4d18311b94dd08a36d7"
|
||||||
dependencies:
|
dependencies:
|
||||||
lodash.unescape "4.0.1"
|
lodash.unescape "4.0.1"
|
||||||
semver "5.4.1"
|
semver "5.4.1"
|
||||||
|
|
Loading…
Reference in New Issue