Receiving the following error:
Property 'conf' is absent in the type '{ text: string; label: string; }'.
when trying to access it from this object:
{
//...
digitalSkills: {
skills: [
{
name: '...',
tooltip: {
text: '...',
label: '...'
}
},
{
name: '...',
tooltip: {
text: '...',
label: '...'
}
}
],
//...
}
//...
}
within this configuration:
export interface TooltipConfig {
text:string;
label:string;
conf?:string;
}
export class Tooltip implements TooltipConfig {
text:string;
label:string;
conf:(any);
constructor(c:TooltipConfig) {
this.text = c.text;
this.label = c.label;
c.conf && (this.conf = c.conf);
}
}
export interface Section {
//...
digitalSkills?:{
skills?:{
name:string,
tooltip:Tooltip
}
}
I have other classes with optional parameters declared similarly that work without issue. I am unsure where I went wrong here and how to correct it.
Important to note: I am not interested in a quick fix by simply adding an empty string as an option parameter. I am seeking to understand the root of the problem and the fundamental concept behind it.
This is part of my journey to comprehend TypeScript thoroughly.