What this snippet does
TypeScript resolves the module's type definition during compilation, throwing an error if the dynamically imported export doesn't exist.
Expected output
Compile Error: Property 'subtract' does not exist on type 'typeof import("./math")'.Why practise typing this
Typing advanced modules code builds muscle memory for the symbols and indentation TypeScript uses most, which prose-based typing tests never cover. DevType measures your words per minute and accuracy on this snippet and tracks the individual characters you mistype, so later lessons can target them.
More TypeScript practice
- Typing a dynamic importAdvanced Modules · advanced
- Conditionally loading an analytics moduleAdvanced Modules · advanced
- Using import type for interfacesAdvanced Modules · advanced
- Mixing type and value imports inlineAdvanced Modules · advanced
- Attempting to use a type-only import as a valueAdvanced Modules · advanced
- Default importing a CommonJS moduleAdvanced Modules · advanced