Skip to content

Missing questionToken in emitted Method/PropertyDeclaration #15971

@ikatyang

Description

@ikatyang

TypeScript Version: nightly (2.4.0-dev.20170519)

Code

const code = `
declare class X {
  method?(): void;
  property?: string;
}
type Y = {
  method?(): void;
  property?: string;
}
`;
const parsed = ts.createSourceFile('path/to/somewhere', code, ts.ScriptTarget.Latest, /*setParentNodes */ false);
const emitted = ts.createPrinter().printNode(ts.EmitHint.Unspecified, parsed,'');

Expected behavior:
emitted to be same as code

Actual behavior:
emitted to be

declare class X {
  method(): void; // <-- missing questionToken
  property: string; // <-- missing questionToken
}
type Y = {
  method?(): void;
  property?: string;
}

Metadata

Metadata

Assignees

Labels

BugA bug in TypeScriptFixedA PR has been merged for this issueHelp WantedYou can do this

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions