Question presented to candidate:
"We enabled verbatimModuleSyntax in our React app and now App.tsx and our component barrel files fail to compile. Walk me through the errors you expect, how you fix each one, and how you would fix a few hundred files without doing it by hand."
What a strong answer should cover:
- Props types,
FC,ReactNodeand other types needimport typeor an inlinetypemodifier (TS1484); components used in JSX are values and must stay plain imports - Barrel files that re-export props types need
export type { ... }(TS1205) - Over-fixing breaks too: a component imported with
import typeand used in JSX is TS1361, andimport type React, { useState }is TS1363 - The JSX runtime matters: with
jsx: "react-jsx"the compiler addsimport { jsx as _jsx } from "react/jsx-runtime"and an oldimport Reactbecomes an unused import that is still emitted; with classicjsx: "react",Reactmust be a value import - Files that emit CommonJS fail with TS1286; the fix is ESM output, not more
typekeywords - Bulk fixes: the TypeScript quick fix "Fix all with type-only imports", typescript-eslint
consistent-type-importswith--fix, and type-only auto-imports in the editor
Clarifying questions expected:
- Which JSX setting does the project use (
react-jsxor classicreact)? - Does the build emit ESM or CommonJS (
modulesetting andpackage.json"type")?
Code / implementation expected: Yes β a broken component file and its fixed version, plus a barrel file fix.