Skip to content

Commit

Permalink
fix(typescript): preserve type parameters of import-types (#4656) (#4662
Browse files Browse the repository at this point in the history
)
  • Loading branch information
aengl authored and duailibe committed Jun 25, 2018
1 parent 5db4cc2 commit b7eb9af
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/language-js/printer-estree.js
Expand Up @@ -2937,7 +2937,8 @@ function printPathNoParens(path, options, print, args) {
"import(",
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":
return path.call(print, "literal");
Expand Down
16 changes: 16 additions & 0 deletions tests/typescript_import_type/__snapshots__/jsfmt.spec.js.snap
Expand Up @@ -10,6 +10,10 @@ export let y: import("./foo2").Bar.I = { a: "", b: 0 };
export let shim: typeof import("./foo2") = {
Bar: Bar2
};
export interface Foo {
bar: import('immutable').Map<string, int>;
}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// ref: https://github.com/Microsoft/TypeScript/pull/22592
Expand All @@ -21,6 +25,10 @@ export let shim: typeof import("./foo2") = {
Bar: Bar2
};
export interface Foo {
bar: import("immutable").Map<string, int>;
}
`;

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

export interface Foo {
bar: import('immutable').Map<string, int>;
}

0 comments on commit b7eb9af

Please sign in to comment.