Skip to content

Commit 061238a

Browse files
committed
fix(types): toPlainObject return type
1 parent e49871d commit 061238a

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/to-plain-object.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,16 @@ import copy from 'fast-copy'
66
* @param data - Any plain JSON response returned from the API
77
* @return Enhanced object with toPlainObject method
88
*/
9-
export default function toPlainObject(data: unknown) {
9+
export default function toPlainObject<T = Record<string, unknown>, R = T>(
10+
data: T
11+
): T & {
12+
/**
13+
* Returns this entity as a plain JS object
14+
*/
15+
toPlainObject(): R
16+
} {
17+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
18+
// @ts-expect-error
1019
return Object.defineProperty(data, 'toPlainObject', {
1120
enumerable: false,
1221
configurable: false,

0 commit comments

Comments
 (0)