All quizzesHard
Compiler API & References
Preview — 3 of 10 questions
What does verbatimModuleSyntax enforce?
javascript
// tsconfig: "verbatimModuleSyntax": true
// File: index.ts
import { User } from './types'; // User is a type-only export
import { fetchUser } from './api'; // fetchUser is a function
export { User }; // (A)?
export { fetchUser }; // (B)?ABoth error — all exports must use export type
BBoth work — TypeScript determines which to erase automatically
C(A) errors — type-only imports must use import type and export type; (B) is fine
D(B) errors — only type exports are allowed with verbatimModuleSyntax
What is the purpose of project references?
javascript
// apps/web/tsconfig.json
{
"compilerOptions": { "composite": true, "outDir": "./dist" },
"references": [
{ "path": "../../packages/types" },
{ "path": "../../packages/ui" }
]
}
// packages/types/tsconfig.json
{
"compilerOptions": {
"composite": true,
"declaration": true,
"outDir": "./dist"
}
}AReferences are just documentation — TypeScript ignores them for compilation
Bcomposite: true is optional when using references
CReferences allow sharing node_modules between packages
DProject references enable incremental builds in monorepos — TypeScript builds referenced projects first and only rebuilds them when changed
What is declarationMap: true useful for?
javascript
{
"compilerOptions": {
"declaration": true,
"declarationMap": true
}
}AdeclarationMap generates a JSON manifest of all exported declarations
BdeclarationMap generates .d.ts.map files that map declaration files back to TypeScript source — enables "Go to Definition" to jump to original .ts source instead of generated .d.ts
CdeclarationMap is a superset of sourceMap — use only one
DdeclarationMap is only needed for external npm packages
Sign up free to play
Answer all 10 questions (7 more), see explanations for every answer, and track your score.