'Use TS Compiler API to Determine if Interface property signature allows undefined (eg prop1?: string;)
I am using the TypeScript Compiler API to harvest Interface details so I can create database tables. Works well but I would like to identify whether fields are nullable, or in TS jargon, have a type guard like string|undefined.
Eg
export default interface IAccount{
name: string;
description?: string;
}
I would like to be able to identify property "description" as string|undefined and hence, "nullable". I can access the node text via the compiler API and find "?" but is there a better way?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
