ExploreConsulting / netsuite-fasttrack-toolkit-ss2

NFT for SuiteScript 2.X
75 stars 20 forks source link

Add Nullable<T> #54

Closed ShawnTalbert closed 3 years ago

ShawnTalbert commented 3 years ago

As we continue to try and stengthen our types, using TypeScript's 'strictNullChecks' option means all properties on NSDAL classes unable to accept nul. However, for NSDAL objects for most fields we DO want to support null because that's how we indicate clearing a field value. i.e. if you set it to null it empties the field value. So, this simple helper type is something we can start using on record classes to indicate which fields can/should be assignable to null. It really is just a shorthand for writing something like string | null ( same as Nullable<string>) but with code completion you can save keystrokes using Nullable. Also it makes it clear by name rather than thinking about union types (|).