Skip to content

Conversation

@saschanaz
Copy link
Contributor

Fixes #4438 and (maybe) #4486.

Async-await current:

async   function asyncFunction() {
    await
    Promise.resolve("await");
    return await   Promise.resolve("completed");
}

Fix:

async function asyncFunction() {
    await
        Promise.resolve("await");
    return await Promise.resolve("completed");
}

Function type / Constructor type current:

function renderElement(
    renderNode:
    (
    node: Node
    ) => void,
    newNode:
    new (
    name: string
    ) => Node
): void {
}

Fix:

function renderElement(
    renderNode:
        (
            node: Node
        ) => void,
    newNode:
        new (
            name: string
        ) => Node
): void {
}

Parenthesized type current:

function foo(
    bar:
    (
    boolean
    )
) {
}

Fix:

function foo(
    bar:
        (
            boolean
        )
) {
}

Call/Constructor/Method signature current:
(Constructor signature only is covered)

type Foo = {
    (
        call: any
    ): void;
    new (
    constr: any
    ): void;
    method(
        whatever: any
    ): void;
};

Fix:

type Foo = {
    (
        call: any
    ): void;
    new (
        constr: any
    ): void;
    method(
        whatever: any
    ): void;
};

Tagged template string current:

String.raw`foo`
String.raw  `bar${3}`
String.raw
`template`

Fix:

String.raw `foo`
String.raw `bar${3}`
String.raw
    `template`

Type alias current:

type   Alias =
number;

Fix:

type Alias =
    number;

Type union current:

type   Union = number  |  {}
|string

Fix:

type Union = number | {}
    | string
  • Fix parenthesized type formatting
  • Add tests

Copy link
Contributor

Choose a reason for hiding this comment

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

we should also add:

  • ConstructorType
  • ConstructSignature
  • CallSignature
  • ParenthesizedType
  • TaggedTemplateExpression
  • AwaitExpression
  • YieldExpression

Copy link
Contributor

Choose a reason for hiding this comment

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

and add tests for theses :)

@saschanaz saschanaz changed the title Format function type Format function type (and others) Aug 26, 2015
@saschanaz
Copy link
Contributor Author

@mhegazy I think most of the types are now covered except YieldExpression. Do you have an example that is not being properly formatted?

@mhegazy
Copy link
Contributor

mhegazy commented Aug 27, 2015

👍

DanielRosenwasser added a commit that referenced this pull request Aug 27, 2015
@DanielRosenwasser DanielRosenwasser merged commit cabc0ff into microsoft:master Aug 27, 2015
@DanielRosenwasser
Copy link
Member

Thanks @saschanaz!

@mhegazy should this be brought into 1.6 as well?

@saschanaz saschanaz deleted the formatFunctionType branch August 28, 2015 11:09
@microsoft microsoft locked and limited conversation to collaborators Jun 19, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Formatting issue in 1.6

4 participants