You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
if I remove ifNotExists: node.ifNotExists, line no typescript error occurs because ifNotExists property is optional. I was looking for some utility type like build in Required. Sadly Required is not compatible with original T type, in this case it requires node.ifNotExists not to be possibly undefined. Long story short, after all I found out this utility type:
Typescript shows error Property 'ifNotExists' is missing in type '{ kind: "CreateSchemaNode"; schema: IdentifierNode; }' but required in type '{ readonly kind: unknown; readonly schema: unknown; readonly ifNotExists: unknown; }' now. It's not very accurate, because type of all properties is unknown. In case of ifNotExists is initialised with string, Typescript shows Type 'string' is not assignable to type 'boolean | undefined'. error. Which is good enough because Typescript shows missing property and wrong property type errors. The only problem is, it changes OperationNodeTransformer interface, transform methods return type is AllProps<...Node> instead of ...Node, even types are compatible.
I can add it to the library if you agree.
The text was updated successfully, but these errors were encountered:
Hello, it's me again. I was curious how issue #108 should happen. Is there a way how to use typescript to check if all properties are used?
I was looking at
operation-node-transformer.ts
source code mainly. There is used class like this:and OperationNodeTransformer has copy method like this:
if I remove
ifNotExists: node.ifNotExists,
line no typescript error occurs becauseifNotExists
property is optional. I was looking for some utility type like build in Required. Sadly Required is not compatible with original T type, in this case it requiresnode.ifNotExists
not to be possibly undefined. Long story short, after all I found out this utility type:Now when I use the AllProps type like this
Typescript shows error
Property 'ifNotExists' is missing in type '{ kind: "CreateSchemaNode"; schema: IdentifierNode; }' but required in type '{ readonly kind: unknown; readonly schema: unknown; readonly ifNotExists: unknown; }'
now. It's not very accurate, because type of all properties is unknown. In case ofifNotExists
is initialised with string, Typescript showsType 'string' is not assignable to type 'boolean | undefined'.
error. Which is good enough because Typescript shows missing property and wrong property type errors. The only problem is, it changes OperationNodeTransformer interface, transform methods return type is AllProps<...Node> instead of ...Node, even types are compatible.I can add it to the library if you agree.
The text was updated successfully, but these errors were encountered: