Skip to content

Fix handling of new keyword and call signatures and improve type parameter formatting #1491

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

Merged
merged 3 commits into from
May 3, 2017

Conversation

azz
Copy link
Member

@azz azz commented May 3, 2017

  • Fix interface<T> {}
  • Support new <T>(): any and new <T> => any
  • Support <T>() => any and <T>(): any
  • Refactor type parameter formatting to use the same code as flow.
  • Add custom tests for long lines.

@azz azz added type:bug Issues identifying ugly output, or a defect in the program lang:typescript Issues affecting TypeScript-specific constructs (not general JS issues) labels May 3, 2017
@azz azz changed the title Fix handling of new keyword [TypeScript] Fix handling of new keyword and call signatures May 3, 2017
@azz azz changed the title [TypeScript] Fix handling of new keyword and call signatures Fix handling of new keyword and call signatures May 3, 2017
@azz azz changed the title Fix handling of new keyword and call signatures Fix handling of new keyword and call signatures and improve type parameter formatting May 3, 2017
@azz azz requested a review from vjeux May 3, 2017 12:11
@azz azz added the type:enhancement A potential new feature to be added, or an improvement to how we print something label May 3, 2017
@@ -0,0 +1,13 @@
interface Interface {
<
Voila,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Love it 😄

function printTypeParameters(path, options, print, paramsKey) {
const n = path.getValue();

// In flow, Foo<> is acceptable. In TypeScript, it's a syntax error.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it's a syntax error, shouldn't we never get here in the first place?

@@ -1,3 +1,4 @@
node_modules
npm-debug.log
/test.js
/.vscode
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you could configure your editor to add trailing empty lines that would be great!

@@ -3,6 +3,6 @@
exports[`cunstructorType.ts 1`] = `
var d: new(x: number) => void;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
var d: new(x: number) => void;
var d: new (x: number) => void;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is the whitespace here intended?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. new is a keyword, so the space helps distinguish it from a method.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, I just wanted to make sure that it wasn't a mistake.

@vjeux vjeux merged commit aeeaffc into prettier:master May 3, 2017
@azz azz deleted the bug/ts-misc branch May 8, 2017 12:26
@lock lock bot added the locked-due-to-inactivity Please open a new issue and fill out the template instead of commenting. label Jan 20, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Jan 20, 2019
@fisker fisker removed the type:bug Issues identifying ugly output, or a defect in the program label Mar 3, 2025
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. type:enhancement A potential new feature to be added, or an improvement to how we print something
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants