Complete the code to dynamically import the module.
const module = await import([1]);
The import() function requires a string path to the module. So, './myModule' is correct.
Complete the code to import the type MyType from the module.
import type { [1] } from './myModule';
TypeScript is case-sensitive. The type name is MyType exactly as declared.
Fix the error in the dynamic import with type assertion.
const mod = await import('./myModule') as [1];
typeof.When asserting the type of a dynamically imported module, use typeof import('./myModule'), because the import returns a module object.
Fill both blanks to correctly type the dynamically imported function and call it.
const [1] = (await import('./utils')).[2]; const result = await myFunc(5);
The function exported is named myFunc. So both blanks should be myFunc to assign and call it correctly.
Fill all three blanks to dynamically import a module, extract a typed function, and call it with a typed argument.
import type { [1] } from './math'; const { [2] } = await import('./math') as [3]; const output = [2](10);
typeof import() for module typing.First, import the type CalculateFn. Then extract the function calculate from the module. Finally, assert the module type with typeof import('./math').