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
Encountered an issue, where typescript-is is unable to parse and produce a createEquals for the following type:
import{createEquals}from"typescript-is"interfaceIBlogPost{id: number;title: string;body: string;}interfaceIComment{postId: number;comment: string;}interfaceITableTypes{"BlogPosts": IBlogPost;"BlogComments": IComment;}typeIInsertRequest={[keyinkeyofITableTypes]: {command: "insert",table: key,value: ITableTypes[key]}}[keyofITableTypes];constisInsertRequest=createEquals<IInsertRequest>();// Failed to transform node at ^^^^^^^^^^^^^^^^^^^// Unbound type parameter, missing type node
Meantime, that type definition IInsertRequest doesn't trip up TS or VS Code:
// TypeScript is happy with the following object creations // and can parse/type/intellisense them correctlyconstrequest1: IInsertRequest={command: "insert",table: "BlogPosts",value: {id: 1,title: "title",body: "body",}}constrequest2: IInsertRequest={command: "insert",table: "BlogComments",value: {postId: 1,comment: "comment",}}
Appreciate your help taking a look at this. Is there something I'm doing wrong? Can I write this differently for it to compile and produce the appropriate equality function?
If curious, the way I'm intending to use that createEquals result is to take a random object (e.g. sent via API) and check to see if it's a valid insertion request (payload specifies a known table name and the corresponding value of the appropriate type for that table). Something like this:
functioninsert(request: any){// coming from an http request, etc.if(isInsertRequest(request)){const{ table, value }=request;// INSERT INTO {table} VALUES {value}}}
The text was updated successfully, but these errors were encountered:
Love this library. Thank you!
Encountered an issue, where
typescript-is
is unable to parse and produce acreateEquals
for the following type:Meantime, that type definition
IInsertRequest
doesn't trip up TS or VS Code:Appreciate your help taking a look at this. Is there something I'm doing wrong? Can I write this differently for it to compile and produce the appropriate equality function?
If curious, the way I'm intending to use that
createEquals
result is to take a random object (e.g. sent via API) and check to see if it's a valid insertion request (payload specifies a known table name and the corresponding value of the appropriate type for that table). Something like this:The text was updated successfully, but these errors were encountered: