So I have this class:
export declare class Track {
name: string;
instrument: Instrument;
notes: Note[];
// more
}
I want to access to the Note
class to use it in a variable
export declare class Note implements NoteInterface {
midi: number;
velocity: number;
noteOffVelocity: number;
// more
};
I don't have direct access to it Note
, so it must accessed it via Track
, which can be accessed by using index signatures:
const note: Track['notes']
However this means that note
would be Note[]
and it want note
to be Note
— not an array of Note
s.
How do I achieve this?
CodePudding user response:
You can index the array with number
.
const note: Track['notes'][number]