Open visj opened 5 years ago
Our team is also trying to use Closure Compiler JavaScript with TypeScript Language server, and this has been one of the biggest thorns in our side.
Using the JSDoc @property
annotation would allow us to properly annotate the property's optional-ness, but Closure refuses to support support the annotation. I think it's even less likely that they'd support the TypeScript property?:
syntax, since it would mean supporting things like {?property1: ?string, ?property2: string?}
.
Realistically, I think the only thing that could be done from the TypeScript side is to add a compiler option that tells TS to not differentiate between optional properties and required properties that allow undefined
as a value (which is how Closure Compiler works), i.e. consider {property?: string}
and {property: string|undefined}
equivalent.
Steps to Reproduce:
Create a Javascript file:
let a = new A({});