-
Notifications
You must be signed in to change notification settings - Fork 293
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
Fix walkObject
to work with module namespace objects
#1368
Conversation
🦋 Changeset detectedLatest commit: 3919a1c The changes in this PR will be included in the next version bump. This PR includes changesets to release 15 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
7747cac
to
c56cfe5
Compare
@@ -11,7 +11,7 @@ export function walkObject<T extends Walkable, MapTo>( | |||
fn: (value: Primitive, path: Array<string>) => MapTo, | |||
path: Array<string> = [], | |||
): MapLeafNodes<T, MapTo> { | |||
const clone = obj.constructor(); | |||
const clone = {} as any; |
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.
The types are a bit gnarly here, clone
was any
before this change, so this just keeps the status quo.
ec52892
to
49ac0dd
Compare
Thank you everyone 👏 |
Fixes #1360.
walkObject
doesn't work on module namespace objects when running insidevite-node
. This is because module namespace objects don't have aconstructor
function.This "bug" has gone unnoticed for a long time because
esbuild
was modifying the export in some way that made it work, butvite-node
doesn't seem to do this.I don't think we need to use
constructor
anymore sincewalkObject
is constrained to only work on objects, at least as far as the type signature is concerned.