Skip to content

Commit

Permalink
Update index.d.ts (#21)
Browse files Browse the repository at this point in the history
  • Loading branch information
lifeiscontent authored Jul 21, 2020
1 parent 8dbd7a7 commit 6183667
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion index.d.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
declare function isPlainObject(o: any): boolean;
declare function isPlainObject(o: any): asserts o is object;

export default isPlainObject;

6 comments on commit 6183667

@gr2m
Copy link

@gr2m gr2m commented on 6183667 Jul 22, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change is causing a TypeScript error now (TypeScript 3.9.7):

An expression of type 'void' cannot be tested for truthiness

Build: https://github.com/octokit/endpoint.js/pull/170/checks?check_run_id=897150799#step:5:15

I wonder what the motivation for that change was?

I'm by no means a TypeScript expert, but from what I've heard, the object type should be avoided

@gr2m
Copy link

@gr2m gr2m commented on 6183667 Jul 22, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ping @lifeiscontent ☝🏼

@TrySound
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gr2m Do you have an idea how to implement proper object assert? I'm not typescript user so can't judge.

@gr2m
Copy link

@gr2m gr2m commented on 6183667 Jul 22, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I'd just leave the boolean type. The method is not checking if o is an object, but if it's a plain object, I don't think you can reproduce that correctly with TypeScript

@TrySound
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Published 4.1.1 with revert. Thanks for pointing to this.

@gr2m
Copy link

@gr2m gr2m commented on 6183667 Jul 24, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot!

Please sign in to comment.