Skip to main content

All Questions

Tagged with
0 votes
1 answer
34 views

Why is inheritance using constructor functions "hard to do properly" (MDN)?

The MDN's article for "Inheritance and the prototype chain", under "Different ways of creating and mutating prototype chains": "With constructor functions", gives the ...
Aayla Secura's user avatar
3 votes
1 answer
68 views

Why objects having instance of a class with private property in prototype throw when accessing private member?

Consider this code: class Klass { #priv = 42 get pub() { return this.#priv } } // these two correctly return 42 console.log(new Klass().pub); console.log((new class extends Klass {})....
Bartosz Gościński's user avatar
-4 votes
2 answers
55 views

I don't want to call the parent constructor. Can we do something about this? [closed]

I am trying to explore JS classes and I am getting error if I am not calling super(). ReferenceError: Must call super constructor in derived class before accessing 'this' or returning from derived ...
Tazeen Khan's user avatar
-2 votes
3 answers
85 views

How to correctly implement a 'Child' class that extends a 'Parent' class and inherits a class field from the latter?

This is my task Implement a Child class that extends the Parent. Add a constructor to the Child class can calls super(). Implement a new function addNewAbilities(newAbility) in the Child class where ...
programmingnoob's user avatar
0 votes
1 answer
37 views

Creating instance of child class in parent method

I have something similar to the following code for a parent and child class: const modify = (data) => { const newData = data // changes newData in some way return newData } class Parent { ...
Sepehr Nazari's user avatar
1 vote
1 answer
113 views

Most pragmatic way to model a type hierarchy in TypeScript

I have an abstract base type and a bunch of subtypes of it. Some of the subtypes are abstract on their own and have further subtypes. I'd like to be able to define polymorphic function, some of which ...
Blue Nebula's user avatar
  • 1,026
0 votes
0 answers
31 views

Is it possible to create an abstract type and make it compatible for inheritance into child type?

Let's say I have an abstract type and function like this. type GenericData = { id: string } export const recv = ( data: GenericData, properties: Props ): GenericData => { return { ...
Z0q's user avatar
  • 1,767
0 votes
0 answers
57 views

I cannot extend the express request interface/type

I have extended the request interface that express.js provided to a custom one that want to use but I am getting an error when I type annotate the request object in the request handler with my custom ...
Mustafa Ahmed's user avatar
0 votes
1 answer
53 views

How to get method names of class and superclass in JavaScript? [duplicate]

Suppose I have a base class A and child class B: class A { a() { return; } } class B extends A { b() { return; } } and I have an instance of B: const b = new B(); ...
suitendaal's user avatar
0 votes
1 answer
74 views

How to inherit js file tax_group.js (account) in odoo 13

I need to add another state to a function in account/static/src/js/ tax_group.js line 94 var displayEditWidget = self._isPurchaseDocument() && this.record.data.state === 'draft' && ...
Paul's user avatar
  • 53
0 votes
0 answers
30 views

How can a static method be called dynamically from an instance method? [duplicate]

I have several classes, each of which should be able to retrieve an existing instance of itself (using an ID) when possible, rather than creating a new instance. For encapsulation and convenience, I ...
David's user avatar
  • 76
2 votes
1 answer
233 views

Typescript get properties of Parent interface from Child interface [duplicate]

very simple question.. yet I dont know. I have following example from code interface A { a:string; } interface B extends A{ b:string; } const b:B = { a:'a', b:'b' } const a:A = ...
StykPohlavsson's user avatar
0 votes
0 answers
25 views

Can function inside a class method inherit the class properties?

Is it possible to make imported module createTaskTabEl to inherit UI class properties? I would like to avoid repetitive passing parameters inside the function. import createTaskTabEl ... class UI { ...
trz's user avatar
  • 23
1 vote
2 answers
256 views

How can I "augment" a JS class with methods from another class, without extending it?

I'm writing an app that manages playlists. Basically, my actual logic looks like //define playlist props class Playlist{ public tracks = []; } class ApiPlaylist extends Playlist{ //fill ...
gordie's user avatar
  • 1,865
0 votes
0 answers
19 views

I'm trying to create a superclass that can return an instance of itself with its initial conditions and pass that functionality on to subclasses

I found a solution while typing out this question, I will still post the question, since I couldn't find anything on this, if that isn't appreciated, I will remove this on request. I've done it for a ...
wexa's user avatar
  • 23

15 30 50 per page
1
2 3 4 5
166