-
Notifications
You must be signed in to change notification settings - Fork 9
chore: Align isObject/isRecord usage #1132
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mrge found 1 issue across 20 files. View it in mrge.io
fa0396d to
873815e
Compare
iframe-sandbox/src/ipc.ts
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: isn't "..." in source redundant here, since isObject(source) already makes sure this is an object and typeof source.<..> would be "undefined" if the key doesn't exist?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's what I thought -- the Record type (where Record<number, unknown> could be an array) allows this but object types do not (and had to add it in a few places) -- maybe there's a better way to do this? but we do sometimes explicitly want an object-like ({}) things and not an array or a record
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We'd get a Property 'intent' does not exist on type 'object' otherwise
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We'd get a
Property 'intent' does not exist on type 'object'otherwise
This is a typescript check, and we check that x is not null (isObject(..)) and TS null is not object (unlike JS) -- usually we want those checks ("property does not exist"), though using isRecord previously allowed any key (TIL as well)
isObject(andisRecord) -- sometimes as "non-array" objects, sometimes including arrays, and the differences betweenobjectandRecordusage.@commontools/utils(originally tracking down a bug for something pulling in too many modules, but was misleading). Deno requires a root export, so a compile time (no exports) or runtime error fires if doing so to avoid inadvertantly pulling in all utilsSummary by mrge
Standardized all isObject and isRecord checks across the codebase by providing consistent utility functions in utils/types, and removed duplicate or inconsistent implementations.