Closed bengry closed 3 years ago
Would it make sense if the code generation also just added the // @ts-ignore
comment as well?
this.contacts = void 0;
is required for the SFieldProps
attribute to be readable when the field is not set (or at least it was when I wrote this).
Would it make sense if the code generation also just added the
// @ts-ignore
comment as well?
this.contacts = void 0;
is required for theSFieldProps
attribute to be readable when the field is not set (or at least it was when I wrote this).
Not sure that's needed really, since both ways (1. putting a @ts-ignore
, 2. putting an !
after the class member declaration) achieves the same thing. IMO the latter is less extreme - since a @ts-ignore
ignores TS errors for the entire line, putting an !
is just telling TS "this field will be initialized, don't worry about checking for that).
Putting !
on the field declarations is also a common practice in other, similar scenarios - like TypeORM entity declarations or NestJS DTO objects.
I didn't remove the this.contacts = void 0;
, those are fine to be kept, as long as you put the !
on the field declarations.
The generated types should be "strict" compatible in the v3 RC now.
Currently when using
ts-force-gen
it generates class properties that are not initialized in a way that's [currently] statically analyzable by the TS compiler.In addition, the
reference
property ofSFieldProperties
is sometimes generated asundefined
.This is fine in projects that don't use
"strictNullChecks": true
(or"strict": true
, which includes it).This RP aims to fix issues and allow using strict mode in TS projects that want to use
ts-force
, without needing to further exit their generated files byts-gen-force
or by patchingts-force
.The current alternative we use is to patch
ts-force
usingpatch-package
:and to add
@ts-ignore
on all property initializations in generated classes. e.g.: