Skip to content
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

object.default() broke when object is extended #2348

Closed
brianle1301 opened this issue Apr 11, 2020 · 2 comments
Closed

object.default() broke when object is extended #2348

brianle1301 opened this issue Apr 11, 2020 · 2 comments
Assignees
Labels
bug Bug or defect
Milestone

Comments

@brianle1301
Copy link
Contributor

Support plan

  • which support plan is this issue covered by? (e.g. Community, Core, Plus, or Enterprise): Community
  • is this issue currently blocking your project? (yes/no): no
  • is this issue affecting a production system? (yes/no): no

Context

  • node version: v12.16.1
  • module version with issue: 16.1.8
  • last module version without issue : Not sure
  • environment (e.g. node, browser, native): Node
  • used with (e.g. hapi application, another framework, standalone, ...): standalone
  • any other relevant information:

What are you trying to achieve or the steps to reproduce?

The following snippet throws this.$_super.default is not a function

const J = require("./lib");

const J2 = J.extend({
  type: "object",
  base: J.object(),
  overrides: {
    label(...args) {
      this.$_super.label(...args);
    },
  },
});

console.log(
  J2.object({
    a: J2.number().default(1),
  })
    .default()
    .validate(undefined)
);

What was the result you got?

An error was thrown

What result did you expect?

Shouldn't throw any error. Looks like $_super is reset on every extend() call.

@brianle1301 brianle1301 added the support Questions, discussions, and general support label Apr 11, 2020
@hueniverse hueniverse added bug Bug or defect and removed support Questions, discussions, and general support labels Jul 7, 2020
@hueniverse hueniverse self-assigned this Jul 7, 2020
@hueniverse hueniverse added this to the 17.2.0 milestone Jul 7, 2020
@hueniverse
Copy link
Contributor

$_super was poorly designed. I replaced it with a new solution that scales better. Leaving $_super to prevent extensions using it from breaking but will deprecate it and drop it next major.

@brianle1301
Copy link
Contributor Author

@hueniverse Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Bug or defect
Projects
None yet
Development

No branches or pull requests

2 participants