fix(typescript): print typeParameters on TSMethodSignature (#1523)
This commit is contained in:
1 parent
c689f2a0e7
commit
b23c16d05d
3 files changed
+45
-4
No files matched your search
+7
-4
@@ -2185,9 +2185,8 @@ function genericPrintNoParens(path, options, print, args) {
|
||||
case "TSMethodSignature":
|
||||
parts.push(
|
||||
path.call(print, 'name'),
|
||||
"(",
|
||||
join(", ", path.map(print, "parameters")),
|
||||
")"
|
||||
printTypeParameters(path, options, print, "typeParameters"),
|
||||
printFunctionParams(path, print, options)
|
||||
)
|
||||
|
||||
if (n.typeAnnotation) {
|
||||
@@ -2636,7 +2635,11 @@ function printFunctionTypeParameters(path, options, print) {
|
||||
function printFunctionParams(path, print, options, expandArg) {
|
||||
var fun = path.getValue();
|
||||
// namedTypes.Function.assert(fun);
|
||||
var paramsField = fun.type === "TSFunctionType" ? "parameters" : "params";
|
||||
var paramsField = (fun.type === "TSFunctionType" ||
|
||||
fun.type === "TSMethodSignature")
|
||||
? "parameters"
|
||||
: "params";
|
||||
|
||||
var printed = path.map(print, paramsField);
|
||||
|
||||
if (fun.defaults) {
|
||||
|
||||
@@ -6,3 +6,30 @@ var results = number[];
|
||||
var results = number[];
|
||||
|
||||
`;
|
||||
|
||||
exports[`functionOverloadsOnGenericArity1.ts 1`] = `
|
||||
// overloading on arity not allowed
|
||||
interface C {
|
||||
f<T>(): string;
|
||||
f<T, U>(): string;
|
||||
|
||||
<T>(): string;
|
||||
<T, U>(): string;
|
||||
|
||||
new <T>(): string;
|
||||
new <T, U>(): string;
|
||||
}
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
// overloading on arity not allowed
|
||||
interface C {
|
||||
f<T>(): string,
|
||||
f<T, U>(): string,
|
||||
|
||||
<T>(): string,
|
||||
<T, U>(): string,
|
||||
|
||||
new <T>(): string,
|
||||
new <T, U>(): string
|
||||
}
|
||||
|
||||
`;
|
||||
@@ -0,0 +1,11 @@
|
||||
// overloading on arity not allowed
|
||||
interface C {
|
||||
f<T>(): string;
|
||||
f<T, U>(): string;
|
||||
|
||||
<T>(): string;
|
||||
<T, U>(): string;
|
||||
|
||||
new <T>(): string;
|
||||
new <T, U>(): string;
|
||||
}
|
||||
Reference in new issue
Block a user