Skip to content

Commit 782a0dc

Browse files
authored
Merge pull request #255 from contentful/fix/to-plain-object-typing
fix(types): toPlainObject return type
2 parents e49871d + 061238a commit 782a0dc

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)