One of the files I have is called MyFactory.ts
. Here is its content:
export type CommandFactory = () => string[] | undefined;
export enum FactoryIds {commandFactory : 'commandFactory'}
Now, my goal is to dynamically import this file into another file (let's call it main.ts
) and utilize the CommandFactory
type. Here is what main.ts
looks like:
const Factory = await import('./MyFactory');
const commandFactories : Factory.CommandFactory[] = []; //I encountered an error saying 'Property 'CommandFactory' does not exist on type 'typeof import('MyFactory')'
Although I can access FactoryIds
using Factory.FactoryIds
, I am unable to access CommandFactory
through Factory.CommandFactory
.
I am curious to find out how I can dynamically import the CommandFactory
type in my main.ts
file.