Skip to content

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

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

Closed
jay4ay opened this issue Jun 22, 2018 · 2 comments · Fixed by #38798
Closed

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

jay4ay opened this issue Jun 22, 2018 · 2 comments · Fixed by #38798
Labels
Bug A bug in TypeScript Domain: Formatter The issue relates to the built-in formatter Help Wanted You can do this
Milestone

Comments

@jay4ay
Copy link

jay4ay commented Jun 22, 2018

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

@ghost ghost added Bug A bug in TypeScript Domain: Formatter The issue relates to the built-in formatter labels Jun 25, 2018
@mhegazy mhegazy added the Help Wanted You can do this label Jul 13, 2018
@mhegazy mhegazy added this to the Community milestone Jul 13, 2018
@Kingwl
Copy link
Contributor

Kingwl commented Jul 13, 2018

seems my fault, i could take a look

@Kingwl
Copy link
Contributor

Kingwl commented Jul 16, 2018

rule NoSpaceAfterQuestionMark match all case that start with question, so other rules cannot be match,
those rules are orthogonal so i cannot add some more predicate to limit that

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in TypeScript Domain: Formatter The issue relates to the built-in formatter Help Wanted You can do this
Projects
None yet
4 participants