The extended interface appears to be lacking the implementation of parent members

I am facing an issue with two interfaces

export interface IComponent{
    type: ComponentType;
    name: string;
    isEnabled:boolean;
}

export interface IAudioComponent extends IComponent {
    source: string;
    volume: number;
    loop: boolean;
    playbackRate: number;
}

When attempting to log an IAudioComponent in my VueComponent as shown below

  data() {
    return {
      _componentGroup: this.componentGroup as IComponentGroup,
      _focussedComponent: this.componentGroup.components[0] as IComponent,
    };
  },
  computed: {
    focussedComponentType() {
      console.log(this.$data._focussedComponent);
      return this.$data._focussedComponent.type;
    }
  },

The output displayed in the DOM is as follows

{__ob__: Observer}
loop: (...)
name: (...)
playbackRate: (...)
volume: (...)
__ob__: Observer {value: {…}, dep: Dep, vmCount: 0}
get loop: ƒ reactiveGetter()
set loop: ƒ reactiveSetter(newVal)
get name: ƒ reactiveGetter()
set name: ƒ reactiveSetter(newVal)
get playbackRate: ƒ reactiveGetter()
set playbackRate: ƒ reactiveSetter(newVal)
get volume: ƒ reactiveGetter()
set volume: ƒ reactiveSetter(newVal)
__proto__: Object

This output raises the question of why it does not include the properties type, name, and isEnabled?

The Typescript documentation example suggests that this should work correctly

https://www.typescriptlang.org/docs/handbook/interfaces.html#extending-interfaces

Answer №1

It appears that there are some questionable type assertions being made in this code snippet:

_componentGroup: the variable 'componentGroup' is asserted as type IComponentGroup,
_focussedComponent: the first component in 'componentGroup.components' array is asserted as type IComponent,

It's important to note that these assertions simply declare the object types without actually modifying the objects themselves. If the objects don't truly match those declared types, they may not possess the properties defined in the interface.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

The type 'FileUpload[][]' cannot be assigned to the type 'AngularFireList<FileUpload[]>'

I'm currently working on an Angular application integrated with Firebase for the purpose of uploading images to the database and retrieving them as well. upload-file.service.ts import {Injectable} from '@angular/core'; import {AngularFireD ...

Creating a replica of a Parse Server object

I've been struggling to clone Parse objects without affecting the original ones. Despite trying various methods like Parse.Object.clone() and converting to JSON, I haven't found a working solution. I came across some recommendations online but no ...

Angular ng-if directive contains a specific class

I am trying to create a directive that will only be active when an element has a specific class. I have tried the following code: <feedback-analytics ng-if="$('#analyticTab').hasClass('active')"></feedback-analytics> Unfor ...

Mastering the art of integrating a multi-step form in React

While developing a multi-step form in my React 17.0.1 application using Typescript version 4.1.2, I came across this helpful guide: https://dev.to/sametweb/how-to-create-multi-step-forms-in-react-3km4 The guide was clear up to step 6, which I decided to s ...

Is it possible to single out a specific cell with the smart-table feature?

While the smart-table documentation provides instructions on selecting a row of data, it does not cover selecting an individual cell (the intersection of a row and a column). Upon further research, I came across this discussion where the project owner men ...

Integrating Dialogflow with a Heroku JavaScript application

After extensive research, I delved into the realm of integrating DialogFlow requests with a webhook hosted on platforms like Heroku. With both Heroku and nodeJS impeccably installed on my system, I diligently followed the heroku tutorial to kickstart the p ...

Having difficulty persisting login session in Vue

When logging in via Google on my login page, I am able to retrieve the user parameters. However, when I refresh the page, the parameters are not saved. Here is the code snippet: export default { name: "App", data() { return { isLog ...

Display a visual progress indicator during audio recording

I am currently using the MediaRecorder functionality to capture audio and I would like to display a progress bar showing the recording process. Here is the code snippet from my recorder template: <p id="countdowntimer">Current Status: Beginning in& ...

Display and conceal different sections using hyperlinks

Hey there, I'm back with another issue related to this code snippet on jsfiddle: https://jsfiddle.net/4qq6xnfr/9/. The problem I'm facing is that when I click on one of the 5 links in the first column, a second div appears with 3 links. Upon clic ...

Executing an external HTTP request within an ExpressJS middleware prior to rendering the response

Currently, I am facing a challenge while trying to utilize Express middleware for a login request. The default route generates an external URL that redirects to /login?code={login-code}. This URL triggers an external HTTP request to obtain the user_id and ...

Issue with the Backbone view's collection

I am currently learning the backbone framework and am facing an issue with my view. I am trying to gather user input from a form, use that data to update a collection, and then redirect the user. However, I am repeatedly encountering an undefined error, sp ...

struggling to determine the connection status between tables (Many-to-many or one-to-one)

Seeking assistance: I am working with two tables (member, event) where each member attends multiple events and each event has multiple attendees. Do these relationships represent a many-to-many or one-to-one relationship? ...

The React component is failing to display updated data from the Redux store

I've been working with React and Redux, trying to update my counter value in the React view. I can successfully log the latest state of my Redux store, but the changes are not reflecting in my React view. const counter = (state = 0, action) => { ...

angular directive to receive an object

When I have a table and click on a row, the information is supposed to be displayed in a different component using the @input decorator. However, instead of displaying the correct result in my other component, I am getting [object Object]. table.html < ...

Ordering dates by week in AngularJS 1

Currently, I have a list of objects: [{ name: one, date: 2017-09-18 }, { name: two, date: 2017-09-11 }, { name: three, date: 2017-09-13 }] I am looking to organize this list by week. Perhaps like the following structure: { 1week(or , m ...

What is the process for accessing someone's birthday information using the Facebook API?

Working on integrating Facebook login and successfully retrieving user details such as first_name, email, etc. However, encountering an issue with fetching the birthday information. When attempting to call for birthday using the code snippet below, no data ...

What is the process of changing a number to the double data type in JavaScript or TypeScript?

Within a single input field, users can enter various numbers such as 12, 12.1, 12.30, and 12.34. The challenge is to pass this value in a service call where only the value can be sent as a number but with two decimal points. let a = input //a will be a ty ...

Having trouble importing the hash-set module in TypeScript/SystemJS?

In the midst of developing an Aurelia project with TypeScript to generate JavaScript, I decided to incorporate another custom library called 'hash-set' (installed using jspm install npm:hash-set --save). However, I encountered difficulties in act ...

I'm having trouble accessing my namespace in TypeScript because it hasn't been properly

After obtaining Visual Studio Community 2015 along with Node.js Tools, I decided to create a "Blank Node.js Console Application" Typescript project. Within this project, I added another TypeScript file named TypeScript1.ts. In this file, I defined the fol ...

Utilize auto-suggestion feature for populating dynamically created input fields with information sourced from the

I have searched through numerous questions on stackoverflow related to my issue, but I was unable to apply any of them to solve my problem. Therefore, I am providing the files that I have been working with. I have successfully implemented autocomplete fe ...