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

Generic arguments are lost when using import types #4656

Closed
aengl opened this issue Jun 8, 2018 · 3 comments
Closed

Generic arguments are lost when using import types #4656

aengl opened this issue Jun 8, 2018 · 3 comments
Labels
lang:typescript Issues affecting TypeScript-specific constructs (not general JS issues) locked-due-to-inactivity Please open a new issue and fill out the template instead of commenting. priority:high Code is printed in a way that alters the AST, breaks syntax, or is a significant regression. Urgent! status:has pr Issues with an accompanying pull request. These issues will probably be fixed soon! type:bug Issues identifying ugly output, or a defect in the program

Comments

@aengl
Copy link
Contributor

aengl commented Jun 8, 2018

Prettier 1.13.4
Playground link

--parser typescript

Input:

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

Output:

declare interface Foo {
  bar: import("immutable").Map;
}

Expected behavior:
Generic arguments <string, int> should not be stripped.

If this turns out to be complicated, I'd be happy to contribute code myself. Let me know! 😃

@ikatyang ikatyang added type:bug Issues identifying ugly output, or a defect in the program priority:high Code is printed in a way that alters the AST, breaks syntax, or is a significant regression. Urgent! lang:typescript Issues affecting TypeScript-specific constructs (not general JS issues) labels Jun 8, 2018
@ikatyang
Copy link
Member

ikatyang commented Jun 8, 2018

I guess you meant you'd like to contribute if it's not complicated, you just need to print the missing typeParameters here:

case "TSLastTypeNode": // TSImportType
return concat([
!n.isTypeOf ? "" : "typeof ",
"import(",
path.call(print, "argument"),
")",
!n.qualifier ? "" : concat([".", path.call(print, "qualifier")])
]);

and add a test case in tests/typescript_import_type/import-type.ts then yarn test -u.

See also https://github.com/prettier/prettier/blob/master/CONTRIBUTING.md.

@aengl
Copy link
Contributor Author

aengl commented Jun 8, 2018

Happy to help in either case, actually. Thanks for the pointers, I'll work on a PR this weekend.

@aengl
Copy link
Contributor Author

aengl commented Jun 10, 2018

PR: #4662

@azz azz added the status:has pr Issues with an accompanying pull request. These issues will probably be fixed soon! label Jun 10, 2018
@azz azz closed this as completed in #4662 Jun 11, 2018
@lock lock bot added the locked-due-to-inactivity Please open a new issue and fill out the template instead of commenting. label Sep 9, 2018
@lock lock bot locked as resolved and limited conversation to collaborators Sep 9, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
lang:typescript Issues affecting TypeScript-specific constructs (not general JS issues) locked-due-to-inactivity Please open a new issue and fill out the template instead of commenting. priority:high Code is printed in a way that alters the AST, breaks syntax, or is a significant regression. Urgent! status:has pr Issues with an accompanying pull request. These issues will probably be fixed soon! type:bug Issues identifying ugly output, or a defect in the program
Projects
None yet
Development

No branches or pull requests

3 participants