Closed
Description
TypeScript Version:
nightly (1.9.0-beta-20160521-3)
When creating a class, if a parameter is added to the constructor as optional and given an accessor (such as private), the compiler generates it as an optional class member in the .d.ts file which then throws a syntax error.
Expected Behavior
Either field would be added to the class and set with the optional parameter, meaning it could be null or undefined or a syntax error is displayed at compile time.
Actual behavior:
Parameter is added as an optional class field resulting in an error.
Example class declaration:
export class Foo {
constructor(private someValue?: any) { }
}
What The Compiler Produces in the Resulting .d.ts:
class Foo {
private someValue?;
}
and the following error:
Error TS1112 A class member cannot be declared optional.