SoftwareTestPilot
LearnCoding RoundsCommunityJobsQA Resources
All questions
BasicTypeScript~10 min

Validate an API user response (TypeScript)

Asked in TypeScript + Playwright API testing interviews

Points available

100/100

Your mission

  1. Read
  2. 2Run
  3. 3Submit
  4. 4Solve

Define a User type with id: number, email: string and active: boolean.

Write isValidUser(data: unknown): boolean that returns true only when all three fields exist with the correct types and the email contains @.

Examples

isValidUser({ id: 1, email: "a@b.com", active: true }) → true
isValidUser({ id: "1", email: "a@b.com", active: true }) → false

Hints

Each hint costs 10 points on a full solve.

Interviewer follow-ups

  • Why aren't TypeScript types enough at runtime?
  • How would a schema library like Zod help?

Ctrl+Enter to run · add Shift to submit

1
2
3
4
5
6
7
8
9
Tab inserts two spaces. Press Escape, then Tab, to leave the editor.
Terminal

$ tsx solution.ts

Run executes the open file. Submit scores solution.ts against hidden tests.

SoftwareTestPilot

Learn QA, prove your skills, connect with testers and grow your career.

Platform
  • Learn
  • Community
  • Jobs
Resources
  • QA Resources
  • Interview Questions
  • QA Tools
  • Articles
  • Products
Company
  • About
  • Contact
  • Authors & Reviewers
  • Editorial Policy
  • Sitemap
© 2026 SoftwareTestPilot. All rights reserved.
Operated by SoftwareTestPilot · Pune, Maharashtra, India · softwaretestingsapiens@gmail.com
PrivacyTermsCookiesDisclaimerRefundsAccessibility