jumpinjackie / jsdoc-typescript-plugin

Experimental JSDoc plugin to generate TypeScript definition files (.d.ts) from JSDoc-annotated source
34 stars 7 forks source link

undefined as part of a union type doesn't seem to transfer as being optional #72

Closed jumpinjackie closed 8 years ago

jumpinjackie commented 8 years ago

If a union type includes undefined, the type as a whole should be implied as being optional.

Take the layers property of the OverviewMap options:

https://github.com/openlayers/ol3/blob/v3.18.2/externs/olx.js#L1170

This is currently being emitted as:

layers: ol.layer.Layer[]|ol.Collection<ol.layer.Layer>

when it should've been emitted as

layers?: ol.layer.Layer[]|ol.Collection<ol.layer.Layer>

jumpinjackie commented 8 years ago

It's only happening on that particular case, other cases are properly turned into optional properties.

EDIT: It's a false positive. An override declaration was being written out,.