Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

insertSpaceBeforeTypeAnnotation doesn't work with optional parameters / properties #25155

Copy link
Copy link
@jay4ay

Description

@jay4ay
Issue body actions

This is a follow up to #19493

TypeScript Version: 2.9.2

Search Terms: insertSpaceBeforeTypeAnnotation formatter

Code

function RGBtoHSB(param1 : Int, param2?: Int, param3?: Int)
{
}

interface SquareConfig
{
    color : string;
    width?: number;
}

Expected behavior:

With insertSpaceBeforeTypeAnnotation=true, I'd expect this to be formatted as:

function RGBtoHSB(param1 : Int, param2 ?: Int, param3 ?: Int)
{
}

interface SquareConfig
{
    color : string;
    width ?: number;
}

Note the whitespace ( ) before the questionmark (?)

Actual behavior:

But it gets formatted as:

function RGBtoHSB(param1 : Int, param2?: Int, param3?: Int)
{
}

interface SquareConfig
{
    color : string;
    width?: number;
}

Playground Link: http://www.typescriptlang.org/play/#src=function%20RGBtoHSB(param1%20%3A%20Int%2C%20param2%3F%3A%20Int%2C%20param3%3F%3A%20Int)%0D%0A{%0D%0A}%0D%0A%0D%0Ainterface%20SquareConfig%0D%0A{%0D%0A%20color%20%3A%20string%3B%0D%0A%20width%3F%3A%20number%3B%0D%0A}

Related Issues: #19493 #20466

Reactions are currently unavailable

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScriptA bug in TypeScriptDomain: FormatterThe issue relates to the built-in formatterThe issue relates to the built-in formatterHelp WantedYou can do thisYou can do this

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.