Skip to content

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

@brianle1301

Description

@brianle1301

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.

Metadata

Metadata

Assignees

Labels

bugBug or defect

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions