Skip to content

[isolatedDeclarations] missing parentheses for function type on a parameter property that is marked as optional #12668

@bradzacher

Description

@bradzacher

Repro

export class Foo {
  constructor(
    public one?: () => void,
    protected two?: () => void,
    private three?: () => void,
  ) {}
}

playground

Expected

export declare class Foo {
    one?: (() => void) | undefined;
    protected two?: (() => void) | undefined;
    private three?;
    constructor(one?: (() => void) | undefined, two?: (() => void) | undefined, three?: (() => void) | undefined);
}

TS playground

Actual

export declare class Foo {
	one?: () => void | undefined;
	protected two?: () => void | undefined;
	private three?;
	constructor(one?: () => void | undefined, two?: () => void | undefined, three?: () => void | undefined);
}

Note that none of the function types were wrapped with parentheses -- which causes the type to change from (() => void) | undefined to () => (void | undefined).

Metadata

Metadata

Assignees

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions