web-component-analyzer icon indicating copy to clipboard operation
web-component-analyzer copied to clipboard

Optional fields don't include `undefined` in their type.

Open justinfagnani opened this issue 4 years ago • 2 comments

export class TextField extends HTMLElement {
  size?: 'type'|'large';
}

The type is reported as "type": "\"type\" | \"large\"", but should be "type": "\"type\" | \"large\" | undefined".

justinfagnani avatar Feb 05 '20 02:02 justinfagnani

Is this a problem that you are experiencing when running the CLI or when using the analyzeText function?

Typescript strips undefined and null from the reported type if strictNullChecks is false, and it seems like I forgot to add it to compiler options when calling analyzeText:

https://github.com/runem/web-component-analyzer/blob/d8809c255c5f19b3ba63eafbbec7f0af5791a636/src/analyze/analyze-text.ts#L57-L62

runem avatar Feb 10 '20 13:02 runem

Is this still an issue, or did I fix it by adding strictNullChecks to compiler options for analyzeText?

runem avatar Mar 10 '20 13:03 runem