Skip to content

Commit

Permalink
chore(win32-def): up
Browse files Browse the repository at this point in the history
  • Loading branch information
waitingsong committed Jun 13, 2024
1 parent e12c84f commit 38a1b81
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions packages/win32-def/src/lib/helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ export function StructType<T extends StructDefType>(
options?: StructCharOptions,
): StructTypeConstructor<T> {
// @ts-ignore
return genInitTyp<T>(input, options)
return genInitTyp(input, options)
}
export function StructFactory<T>(input: StructDefType, options?: StructCharOptions): T {
// @ts-ignore
return new genInitTyp<T>(input, options)()
return (new genInitTyp(input, options)()) as unknown as T
}

function genInitTyp(input: StructDefType, options?: StructCharOptions): StructTypeConstructor {
Expand All @@ -58,14 +58,17 @@ function genInitTyp(input: StructDefType, options?: StructCharOptions): StructTy
&& opts.CharDefs.includes(value)) {

initType[key] = wcharBuffer(opts.maxCharLength)
} else if (
}
else if (
typeof value === 'object'
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
&& value
// This is the same check "ref-napi" does to determine if the type
&& !('size' in value && 'indirection' in value)
&& ! ('size' in value && 'indirection' in value)
) {
initType[key] = genInitTyp(value as StructDefType, options) as StructTypeConstructor
} else {
}
else {
initType[key] = value
}
})
Expand Down

0 comments on commit 38a1b81

Please sign in to comment.