Skip to content

Improve typings for 'toJSONDeep' function #1995

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 26, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/language/__tests__/toJSONDeep.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import isObjectLike from '../../jsutils/isObjectLike';
* Deeply transforms an arbitrary value to a JSON-safe value by calling toJSON
* on any nested value which defines it.
*/
export default function toJSONDeep<T>(value: T): T {
export default function toJSONDeep(value: mixed): mixed {
if (!isObjectLike(value)) {
return value;
}
Expand All @@ -20,7 +20,7 @@ export default function toJSONDeep<T>(value: T): T {
return value.map(toJSONDeep);
}

const result: any = {};
const result = Object.create(null);
for (const prop of Object.keys(value)) {
result[prop] = toJSONDeep(value[prop]);
}
Expand Down