Skip to content

Generated declaration file for constructor nullable parameter property is non-nullable #15872

@patsissons

Description

@patsissons

TypeScript Version: 2.2.2

Code

// typescript code
export class Foo {
  constructor(public bar?: string) {
  }
}
// generated declaration
export declare class Foo {
    bar: string;
    constructor(bar?: string);
}

Expected behavior:
Foo.bar should be typed as string | undefined

Actual behavior:
Foo.bar is typed as string

Our declaration is no longer compatible with the source that generated it.

Metadata

Metadata

Assignees

Labels

BugA bug in TypeScriptFixedA PR has been merged for this issue

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