add TSConstructorType (#1367)
* add TSConstructorType * combine condition * combine strings
This commit is contained in:
1 parent
9002379b70
commit
99e4bae321
4 files changed
+20
-1
No files matched your search
+10
-1
@@ -1515,8 +1515,10 @@ function genericPrintNoParens(path, options, print, args) {
|
||||
path.getParentNode().constraint) &&
|
||||
// TypeScript should not have a colon in TSFirstTypeNode nodes
|
||||
// `a is number`
|
||||
// or TSConstructorType nodes
|
||||
!(path.getParentNode().type === "TypeAnnotation" &&
|
||||
path.getParentNode().typeAnnotation.type === 'TSFirstTypeNode')
|
||||
(path.getParentNode().typeAnnotation.type === 'TSFirstTypeNode' ||
|
||||
path.getParentNode().typeAnnotation.type === "TSConstructorType"))
|
||||
) {
|
||||
parts.push(": ");
|
||||
}
|
||||
@@ -1972,6 +1974,13 @@ function genericPrintNoParens(path, options, print, args) {
|
||||
path.call(print, "indexType"),
|
||||
"]"
|
||||
])
|
||||
case "TSConstructorType":
|
||||
return concat([
|
||||
"new(",
|
||||
join(", ", path.map(print, "parameters")),
|
||||
") => ",
|
||||
path.call(print, "typeAnnotation"),
|
||||
])
|
||||
// TODO
|
||||
case "ClassHeritage":
|
||||
// TODO
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`cunstructorType.ts 1`] = `
|
||||
var d: new(x: number) => void;
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
var d: new(x: number) => void;
|
||||
|
||||
`;
|
||||
@@ -0,0 +1 @@
|
||||
var d: new(x: number) => void;
|
||||
@@ -0,0 +1 @@
|
||||
run_spec(__dirname, { parser: "typescript" });
|
||||
Reference in new issue
Block a user