15 - Tooling/Config (React+TS Ecosystem) Flashcards

tsconfig strictness, bundlers (Vite/Webpack), lint/typecheck/test boundaries, env vars, CI parity, build/debug tooling, and common config review pitfalls. (80 cards)

1
Q

Deck 15 - Tooling/Config (React+TS Ecosystem) (objective)

A

Goal: review and debug React+TS tooling like a senior: tsconfig, bundlers, linting, tests, env vars, builds, and dependency hygiene.
You learn: what/why (under the hood), common breakages, and evaluator-grade review wording.
Output style: PASS/PARTIAL/FAIL + 2-3 issues + fix approach.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Mental model: what tsconfig controls.

A

tsconfig controls TypeScript type checking + emit settings.
Why: it defines strictness, module resolution, and what code TS outputs (if emitting).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Mental model: bundler vs TypeScript compiler.

A

Bundler (Vite/Webpack) builds and serves your app.
TS compiler checks types; bundler transpiles (often via esbuild/swc) and may not enforce full type checking unless configured.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Mental model: dev server vs production build.

A

Dev server optimizes for fast reload; production build optimizes for size/perf.
Bugs can appear only in prod (minification, tree-shaking, different env vars).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Mental model: module resolution (Node vs bundler).

A

Resolution strategy impacts how imports are found (paths, extensions, package.json exports).
Misconfig causes ‘module not found’ or wrong entry selection.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Mental model: ESM vs CJS (why it matters).

A

ESM uses import/export; CJS uses require/module.exports.
Mixing can break tooling; bundlers handle it but some libs/configs are sensitive.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Mental model: dependency graph + lockfile.

A

package.json declares direct deps; lockfile pins transitive deps.
Lockfile changes can alter runtime even if your code did not change.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Mental model: tree-shaking (high level).

A

Bundlers remove unused exports when code is ESM and side-effects are known.
Poorly structured imports can prevent tree-shaking and bloat bundles.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Mental model: source maps (why you care).

A

Source maps map bundled code back to original sources.
Essential for debugging production errors and stack traces.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Mental model: environment variables are build-time in the browser.

A

Client env vars get baked into the bundle.
Never put secrets in client env vars; treat them as public.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Mental model: lint vs typecheck vs tests.

A

Lint: style/some correctness. Typecheck: TS compile-time safety. Tests: runtime behavior.
All three catch different classes of issues.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Mental model: transpilation does not equal type safety.

A

esbuild/swc can transpile TS without type checking.
Senior: ensure CI runs tsc –noEmit (or equivalent) to enforce types.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Mental model: hydration/SSR differences (tooling angle).

A

SSR requires consistent render output; some libraries behave differently on server.
Config (target, polyfills) can affect runtime compatibility.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Mental model: browser targets affect output.

A

Build targets control what syntax/polyfills are emitted.
Wrong targets can break older browsers or bloat bundles unnecessarily.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Mental model: workspace/monorepo tooling risk.

A

Multiple packages can create version mismatches and duplicate deps.
Review peerDeps and ensure single React version to avoid hooks errors.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Mental model: why ‘Invalid hook call’ happens.

A

Common causes: multiple React copies, mismatched react/react-dom versions, or improper bundling.
Tooling review: check lockfile and dependency tree.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

Mental model: bundler plugins are code execution.

A

Plugins run during build; they can introduce security and stability risks.
Prefer trusted plugins and pin versions.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

Mental model: config changes can be breaking changes.

A

tsconfig/eslint/vite config changes can change behavior without touching app code.
Reviewer: demand rationale and ensure CI proves safety.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

Mental model: why CI parity matters.

A

Local builds can differ from CI due to Node version, env vars, or caching.
Pin Node versions and keep scripts deterministic.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

Mental model: minimize build-time magic.

A

Complex config increases fragility.
Senior: keep config small, documented, and tested in CI.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q

tsconfig: strict mode (why).

A

strict enables many safety checks (nulls, implicit any, etc.).
Senior: treat strictness as correctness; relax only with explicit, justified exceptions.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
22
Q

tsconfig: strictNullChecks (impact).

A

Forces you to handle null/undefined explicitly.
Prevents runtime crashes in React (data loads asynchronously).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
23
Q

tsconfig: noImplicitAny (impact).

A

Prevents implicit any from spreading.
Senior: reduces type holes that cause runtime errors.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
24
Q

tsconfig: noUncheckedIndexedAccess (why useful).

A

Indexing returns T | undefined.
Prevents ‘cannot read property’ bugs when keys are missing.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
tsconfig: exactOptionalPropertyTypes (what it changes).
Distinguishes 'prop?: T' from 'prop: T | undefined' in assignability. Can surface subtle optional prop bugs; adopt with care.
26
tsconfig: jsx setting (react-jsx).
Modern React uses jsx: react-jsx. Why: no need to import React for JSX in newer setups (depending on tooling).
27
tsconfig: lib and DOM types.
Include 'DOM' lib for browser APIs. Wrong lib config can break types for fetch, URL, etc.
28
tsconfig: moduleResolution (bundler/node).
Controls import resolution. Mismatch with bundler can cause typecheck success but runtime failure (or vice versa).
29
tsconfig: baseUrl/paths (pitfall).
Paths aliases require bundler config too. If only TS knows paths, runtime imports fail.
30
tsconfig: isolatedModules (why).
Required for transpilers that compile file-by-file. Catches patterns that break isolated transpilation.
31
tsconfig: skipLibCheck (tradeoff).
Speeds builds by skipping type checking of .d.ts. Can hide dependency type issues; often acceptable but know the tradeoff.
32
tsconfig: incremental (benefit).
Speeds repeated typechecks by caching. Useful in CI for large repos if cache persists.
33
tsconfig: target (impact).
Controls emitted JS syntax. Too low increases bundle size; too high can break older browsers.
34
tsconfig: module (ESNext).
Bundlers prefer ESNext for better tree-shaking. Let bundler handle final format.
35
tsconfig: noEmit for apps (pattern).
In many React apps, bundler handles emit. Run 'tsc --noEmit' in CI to enforce type safety.
36
tsconfig: types / typeRoots pitfalls.
Overriding types can hide global typings. Be cautious; ensure needed types (jest, node) are included only where appropriate.
37
tsconfig: separate configs for app vs tests (pattern).
Use tsconfig.app.json and tsconfig.test.json. Why: different globals and module systems; reduces conflicts.
38
tsconfig: resolveJsonModule (when).
Allows importing JSON. Use carefully; treat JSON as data, and validate if untrusted.
39
tsconfig: allowJs/checkJs (when).
Useful during migration from JS. checkJs adds type checking to JS files; can increase noise if enabled without plan.
40
tsconfig: downlevelIteration (when needed).
Needed for correct iteration semantics when targeting older JS. Rare for modern browser targets but appears in some setups.
41
Vite vs Webpack (high level).
Vite uses native ESM in dev and bundles for prod; fast HMR. Webpack is highly configurable and widely used; often heavier to tune.
42
Common Vite config pitfalls.
1) path aliases not mirrored in tsconfig 2) env vars prefix rules 3) SSR vs client differences 4) dependency optimization issues.
43
Env vars in Vite (rule).
Client env vars must start with VITE_. Never store secrets; assume anything in client bundle is public.
44
CRA vs Vite migration risk areas.
Differences in env var naming, polyfills, Jest config, and import handling. Ensure scripts and CI typecheck/test steps remain equivalent.
45
ESLint + TypeScript (best practice).
Use @typescript-eslint. Avoid conflicting rules between ESLint and TS; run lint in CI.
46
Prettier vs ESLint (division of labor).
Prettier handles formatting; ESLint handles correctness/style rules. Avoid fighting tools; use eslint-config-prettier if needed.
47
Husky/lint-staged (workflow).
Runs checks pre-commit. Good for hygiene, but keep it fast; do heavy checks in CI.
48
Jest vs Vitest (high level).
Vitest is Vite-native and fast; Jest is widely used with a mature ecosystem. Match tooling to build system and team needs.
49
RTL config: jsdom vs browser reality.
jsdom simulates DOM but not layout/paint. Avoid tests that rely on real layout; use e2e tests for that.
50
Test flakiness sources.
Timers, network, async waiting, global state leakage. Fix: deterministic mocks, fake timers carefully, and clean up between tests.
51
MSW (why used).
Intercepts network requests at runtime for tests/dev. Encourages realistic API mocks and reduces brittle mocking.
52
Source maps in production (tradeoff).
Helps debugging but can expose source. Use hidden source maps or restrict access when needed.
53
Bundle analysis (why).
Identify big dependencies and code-splitting opportunities. Use analyzer tools to confirm improvements.
54
Code splitting (when).
Split routes or heavy components. Avoid over-splitting that harms UX (waterfalls).
55
Polyfills (modern approach).
Prefer targeting modern browsers when possible. If supporting older browsers, add polyfills intentionally and document.
56
Gotcha: relying on bundler to typecheck.
FAIL - Some bundlers transpile TS without type checking. Add 'tsc --noEmit' (or equivalent) to CI to enforce types.
57
Gotcha: path aliases only configured in tsconfig.
FAIL - Typecheck passes but runtime import fails. Mirror aliases in bundler config and verify via production build.
58
Gotcha: secrets in client env vars.
FAIL - Client env vars are public. Move secret to server/secret store; only expose non-sensitive config in client.
59
Gotcha: disabling strict to 'fix' errors.
PARTIAL - Reduces safety. Prefer fixing types; if unavoidable, scope exception and document rationale.
60
Gotcha: skipLibCheck hides dependency type errors.
PARTIAL - Acceptable for speed sometimes, but it can mask issues. Consider enabling for release branches or when debugging types.
61
Gotcha: duplicate React versions -> invalid hook call.
FAIL - Multiple React copies break hooks. Deduplicate and align react/react-dom versions; inspect lockfile and npm ls react.
62
Gotcha: major dependency upgrade with no plan.
FAIL - Major bumps can break runtime. Require CI green, smoke tests, and changelog review for breaking changes.
63
Gotcha: enabling exactOptionalPropertyTypes without rollout plan.
PARTIAL - Can cause widespread assignability changes. Roll out gradually and fix call sites with explicit undefined handling.
64
Gotcha: ESLint and Prettier fighting.
PARTIAL - Tool conflict wastes time. Use eslint-config-prettier and keep formatting in Prettier.
65
Gotcha: flaky tests due to missing awaits.
FAIL - Async UI updates require findBy/waitFor and userEvent.setup(). Missing awaits causes flakes.
66
Gotcha: using jsdom for layout assertions.
PARTIAL - jsdom lacks real layout/paint. Use e2e tests for layout/visual checks.
67
Gotcha: prod-only bug from minification/tree-shaking.
PARTIAL - Reproduce with production build. Ensure sideEffects flags and imports are correct; avoid relying on import side effects.
68
Gotcha: shipping source maps publicly unintentionally.
PARTIAL - Consider hidden source maps or access control. Balance debugging needs with IP exposure.
69
Gotcha: CI Node version mismatch.
FAIL - Pin Node version (engines/.nvmrc) and match CI. Differences can break builds and lockfiles.
70
Gotcha: mixing ESM/CJS incorrectly.
PARTIAL - Can break tooling. Align package.json type, config file extensions, and module settings.
71
Mini-drill: verdict on missing typecheck in CI.
FAIL - Pipeline does not enforce type safety. Add 'tsc --noEmit' to CI and treat type errors as blockers.
72
Mini-drill: reviewer wording for secrets in env.
FAIL - Client env vars are public. Move secrets server-side; expose only public config.
73
Mini-drill: reviewer wording for alias mismatch.
FAIL - Aliases work in TS but not at runtime. Mirror in bundler config and verify with a production build.
74
Mini-drill: reviewer wording for strictness change.
PARTIAL - Lowering strictness reduces correctness guarantees. Prefer fixing types; if necessary, scope and document the relaxation.
75
Mini-drill: reviewer wording for dependency bump.
SUGGESTION: Please note rationale (security/feature), link changelog, confirm CI + smoke tests, and call out any major version bumps.
76
Mini-drill: why tsc --noEmit matters if build works.
Because transpilation can succeed while type assumptions are wrong. Type errors often become runtime bugs in async React flows.
77
Mini-drill: when to split tsconfig.
Split when app/tests need different globals/module systems (DOM vs node, jest/vitest globals). Avoid polluted global types.
78
Mini-drill: what to check for invalid hook call.
Check duplicate React installs, mismatched versions, and monorepo duplication. Inspect lockfile and run npm ls react.
79
Mini-drill: what to ask for on config PR.
Ask for rationale, impacted scripts, CI evidence (build/typecheck/test), and dev workflow notes. Keep config diffs minimal.
80
Mini-drill: quickest triage for 'module not found'.
Check path/case sensitivity, tsconfig paths vs bundler aliases, package.json exports, and lockfile integrity. Re-run clean install.