fix(typescript): preserve type parameters of import-types (#4656) (#4662)

master
Lynn Smeria 2018-06-11 03:29:10 +02:00 committed by Lucas Azzola
parent 3e0dceda99
commit 61d35dd636
3 changed files with 22 additions and 1 deletions

View File

@ -2940,7 +2940,8 @@ function printPathNoParens(path, options, print, args) {
"import(", "import(",
path.call(print, "argument"), path.call(print, "argument"),
")", ")",
!n.qualifier ? "" : concat([".", path.call(print, "qualifier")]) !n.qualifier ? "" : concat([".", path.call(print, "qualifier")]),
printTypeParameters(path, options, print, "typeParameters")
]); ]);
case "TSLiteralType": case "TSLiteralType":
return path.call(print, "literal"); return path.call(print, "literal");

View File

@ -10,6 +10,10 @@ export let y: import("./foo2").Bar.I = { a: "", b: 0 };
export let shim: typeof import("./foo2") = { export let shim: typeof import("./foo2") = {
Bar: Bar2 Bar: Bar2
}; };
export interface Foo {
bar: import('immutable').Map<string, int>;
}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// ref: https://github.com/Microsoft/TypeScript/pull/22592 // ref: https://github.com/Microsoft/TypeScript/pull/22592
@ -21,6 +25,10 @@ export let shim: typeof import("./foo2") = {
Bar: Bar2 Bar: Bar2
}; };
export interface Foo {
bar: import("immutable").Map<string, int>;
}
`; `;
exports[`import-type.ts 2`] = ` exports[`import-type.ts 2`] = `
@ -33,6 +41,10 @@ export let y: import("./foo2").Bar.I = { a: "", b: 0 };
export let shim: typeof import("./foo2") = { export let shim: typeof import("./foo2") = {
Bar: Bar2 Bar: Bar2
}; };
export interface Foo {
bar: import('immutable').Map<string, int>;
}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// ref: https://github.com/Microsoft/TypeScript/pull/22592 // ref: https://github.com/Microsoft/TypeScript/pull/22592
@ -44,4 +56,8 @@ export let shim: typeof import('./foo2') = {
Bar: Bar2 Bar: Bar2
}; };
export interface Foo {
bar: import('immutable').Map<string, int>;
}
`; `;

View File

@ -7,3 +7,7 @@ export let y: import("./foo2").Bar.I = { a: "", b: 0 };
export let shim: typeof import("./foo2") = { export let shim: typeof import("./foo2") = {
Bar: Bar2 Bar: Bar2
}; };
export interface Foo {
bar: import('immutable').Map<string, int>;
}