Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from Jun 11, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/language-js/printer-estree.js
Expand Up @@ -2941,7 +2941,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>;
}