TypeScript Technology & Digital Tools 3 — Questions and Answers
Question 1: What does the `paths` option in `tsconfig.json` allow you to configure?
- Output file locations
- Module path aliases for cleaner imports (Correct answer)
- Which files to exclude from compilation
- The location of type declaration files
Correct answer: Module path aliases for cleaner imports
The `paths` option maps import aliases to real file paths, enabling imports like `@utils/helper` instead of relative paths.
Question 2: Which npm package provides TypeScript type definitions for Node.js built-in modules?
- @types/react
- @types/node (Correct answer)
- typescript-node
- node-types
Correct answer: @types/node
`@types/node` ships declaration files for Node.js APIs like `fs`, `path`, and `http`.
Question 3: What is the purpose of the `declaration` compiler option in `tsconfig.json`?
- Enables strict mode
- Generates `.d.ts` type declaration files alongside JavaScript output (Correct answer)
- Disables implicit any errors
- Outputs source maps
Correct answer: Generates `.d.ts` type declaration files alongside JavaScript output
Setting `declaration: true` instructs `tsc` to emit `.d.ts` files so library consumers get full type information.
Question 4: Which Prettier configuration file format is commonly used in TypeScript projects to enforce consistent code formatting?
- .eslintrc.json
- .prettierrc (Correct answer)
- tsconfig.json
- .babelrc
Correct answer: .prettierrc
`.prettierrc` is the standard Prettier configuration file where you define formatting rules like print width and tab width.
Question 5: What happens when you set `noEmit: true` in `tsconfig.json`?
- TypeScript stops checking types
- The compiler performs type checking but does not produce any output files (Correct answer)
- Declaration files are suppressed
- Source maps are disabled
Correct answer: The compiler performs type checking but does not produce any output files
`noEmit: true` runs the type checker without writing JavaScript or declaration files, useful for CI type-checking pipelines.
Question 6: Which Vite plugin enables TypeScript support in a Vite project?
- vite-plugin-eslint
- @vitejs/plugin-react
- vite-tsconfig-paths (Correct answer)
- vite-plugin-typescript
Correct answer: vite-tsconfig-paths
`vite-tsconfig-paths` resolves TypeScript `paths` aliases in Vite, while Vite itself handles TS transpilation natively via esbuild.
Question 7: What is the function of `tsc --noEmit` in a CI/CD pipeline?
- Builds the project for production
- Validates types without producing compiled output, acting as a type-check gate (Correct answer)
- Watches files continuously
- Generates documentation from JSDoc comments
Correct answer: Validates types without producing compiled output, acting as a type-check gate
Running `tsc --noEmit` in CI catches type errors without generating files, keeping the pipeline fast and output-clean.
What does the `paths` option in `tsconfig.json` allow you to configure?