Skip to contentমূল লেখায় যান

Step 04 · SDET roadmapধাপ 04 · SDET roadmap

TypeScript for Testers

This page shows the types that a tester needs, how tsc checks them, and how to run that check next to Node.js and Playwright.

6 min read6 মিনিটে পড়া যায় · 7 sections7টি সেকশন · 9 sources9টি সোর্স · updated Nov 2026আপডেট: Nov 2026

strict catches the missing valuestrict মিসিং ভ্যালু ধরে ফেলে

Turn strictNullChecks on and see a hidden bug turn into a compile error.strictNullChecks চালু করুন আর দেখুন লুকানো bug একটা কম্পাইল এরর হয়ে যায়।

2 min2 মিনিট8 steps8টি ধাপ
  • tsc errorstsc ত্রুটি0
  • Run-time crashesচলার সময় ক্র্যাশ0
  • Flagged before runচলার আগে ধরা0 / 0
tsc checktsc চেকnode runnode চালানusers.tsফাইল users.tstype aliastype aliastsctscstrict onstrict চালুnodenodeno type checkটাইপ চেক নেইtype Role = ...;type Role = ...;interface User {interface User { name: string; name: string; role: Role; role: Role;}}

You’ll learnআপনি শিখবেন

  • How a ? field may be missing? field কীভাবে না থাকতে পারে
  • Node runs code without type checksNode type check ছাড়াই কোড চালায়
  • What strict adds for nullnull-এর জন্য strict কী যোগ করে
  • How narrowing fixes the errornarrowing কীভাবে এরর সারায়
  • Why any hides bugsany কেন bug লুকায়

What it is

TypeScript has all the features of JavaScript, with a type system on top of them Source 1সোর্স 1. A static type system predicts what the code is expected to do before it runs Source 2সোর্স 2, and a static type-checker like TypeScript helps find bugs before the code runs Source 2সোর্স 2. In many cases TypeScript can infer the types by itself, even when the code leaves them out Source 2সোর্স 2.

The checker is tsc, the TypeScript compiler Source 2সোর্স 2. Type annotations, such as person: string on a parameter, describe what types of values a function can be called with Source 2সোর্স 2. Type annotations never change the runtime behaviour of a program Source 2সোর্স 2.

For a tester, this matters because the test tools run TypeScript directly. Playwright reads a TypeScript test, transforms it to JavaScript, and runs it Source 8সোর্স 8. Node.js can run a TypeScript file too Source 7সোর্স 7. Read JavaScript for Testers first.

সহজ English

TypeScript is JavaScript plus types Source 1সোর্স 1. Types let a tool find mistakes before the code runs Source 2সোর্স 2. Often TypeScript works out the types by itself, even when you leave them out Source 2সোর্স 2.

The tool that checks is called tsc Source 2সোর্স 2. A type annotation, like person: string, says what kind of value a function takes Source 2সোর্স 2. Type annotations never change what the program does when it runs Source 2সোর্স 2.

This matters for testers because test tools run TypeScript directly. Playwright turns a TypeScript test into JavaScript and runs it Source 8সোর্স 8. Node.js can run a TypeScript file too Source 7সোর্স 7. Read JavaScript for Testers first.

বাংলা ব্যাখ্যা

TypeScript-এ JavaScript-এর সব feature আছে, আর তার ওপরে একটা type system Source 1সোর্স 1। Static type system কোড চালানোর আগেই অনুমান করে, কোডটা কী করবে বলে আশা করা যায় Source 2সোর্স 2, আর TypeScript-এর মতো static type-checker কোড চালানোর আগেই bug খুঁজে পেতে সাহায্য করে Source 2সোর্স 2। অনেক ক্ষেত্রে type লেখা না থাকলেও TypeScript নিজেই type বের করে নিতে পারে Source 2সোর্স 2।

Check করে tsc, অর্থাৎ TypeScript compiler Source 2সোর্স 2। Type annotation, যেমন parameter-এ person: string, বলে দেয় function-টা কোন type-এর value দিয়ে call করা যায় Source 2সোর্স 2। Type annotation কখনো program চলার সময়ের আচরণ বদলায় না Source 2সোর্স 2।

টেস্টারের জন্য এটা জরুরি, কারণ টেস্ট টুলগুলো TypeScript সরাসরি চালায়। Playwright একটা TypeScript টেস্ট পড়ে, JavaScript-এ রূপান্তর করে চালায় Source 8সোর্স 8। Node.js-ও TypeScript file চালাতে পারে Source 7সোর্স 7। আগে JavaScript for Testers পড়ে নিন।

How it works

সহজ English

বাংলা ব্যাখ্যা

  • Type alias আর interface। Type alias যেকোনো type-এর একটা নাম Source 3সোর্স 3। Interface হলো object type-এর নাম দেওয়ার আরেকটা উপায় Source 3সোর্স 3।
  • Union আর literal type। Union type দুই বা তার বেশি type দিয়ে তৈরি, আর value হতে পারে তাদের যেকোনো একটা Source 3সোর্স 3। Literal type একটা নির্দিষ্ট string বা number-এর নাম Source 3সোর্স 3। Literal-গুলো union-এ মেলালে জানা value-এর একটা নির্দিষ্ট set পাওয়া যায়, যেমন 'tester' | 'developer' Source 3সোর্স 3।
  • Optional property। Property-র নামের পরে ? দিলে property-টা optional হয় Source 3সোর্স 3।
  • readonly। Type-checking-এর সময় TypeScript readonly property-তে লিখতে দেয় না, কিন্তু চলার সময় কিছুই বদলায় না Source 4সোর্স 4।
  • Narrowing। TypeScript typeof-এর মতো চেক বোঝে, আর সেটা দিয়ে একটা branch-এর ভেতরে type সরু করে আনে Source 5সোর্স 5।
  • Generic। Generic component একটা type নয়, অনেক type নিয়ে কাজ করে Source 9সোর্স 9।
  • any। any type-এর value type-check হয় না Source 3সোর্স 3। noImplicitAny flag অপ্রকাশ্য any-কে error বানায় Source 3সোর্স 3।
  • Null check। ডিফল্টভাবে null আর undefined যেকোনো type-এ বসানো যায় Source 2সোর্স 2। strictNullChecks চালু থাকলে value-র method বা property ব্যবহারের আগে এগুলোর জন্য চেক করতে হয় Source 3সোর্স 3। strict flag পুরো strict check-এর পরিবারটা চালু করে Source 6সোর্স 6; এর সবচেয়ে বড় দুটো হলো noImplicitAny আর strictNullChecks Source 2সোর্স 2।

Try it

Save this as users.ts. You need Node.js 22.18 or newer (type stripping is on by default from v22.18.0 and v23.6.0 Source 7সোর্স 7) and TypeScript (npm install -D typescript).

type Role = 'tester' | 'developer';

interface User {
  name: string;
  role: Role;
  email?: string;
}

function label(user: User): string {
  return `${user.name} (${user.role})`;
}

function emailDomain(user: User): string {
  if (user.email === undefined) return 'none';
  return user.email.split('@')[1];
}

const users: User[] = [
  { name: 'Asha', role: 'tester' },
  { name: 'Rafi', role: 'developer', email: 'rafi@example.com' },
];

console.log(users.map(label));
console.log(users.map(emailDomain));
  1. Check it with npx tsc --noEmit --strict users.ts. It finds no errors.
  2. Run it with node users.ts. By default, Node.js runs TypeScript files that contain only erasable TypeScript syntax Source 7সোর্স 7. It prints [ 'Asha (tester)', 'Rafi (developer)' ] and [ 'none', 'example.com' ].
  3. Change Asha's role to 'manager'. tsc now reports Type '"manager"' is not assignable to type 'Role'. But node users.ts still runs and prints Asha (manager). Node.js replaces the TypeScript syntax with whitespace and does no type checking Source 7সোর্স 7.
  4. Put the role back and delete the if (user.email === undefined) line. tsc reports 'user.email' is possibly 'undefined'. node now crashes with TypeError: Cannot read properties of undefined (reading 'split'). This is the bug that the null check exists to catch Source 3সোর্স 3.

সহজ English

Save this as users.ts. You need Node.js 22.18 or newer (type stripping is on by default from v22.18.0 and v23.6.0 Source 7সোর্স 7) and TypeScript (npm install -D typescript).

type Role = 'tester' | 'developer';

interface User {
  name: string;
  role: Role;
  email?: string;
}

function label(user: User): string {
  return `${user.name} (${user.role})`;
}

function emailDomain(user: User): string {
  if (user.email === undefined) return 'none';
  return user.email.split('@')[1];
}

const users: User[] = [
  { name: 'Asha', role: 'tester' },
  { name: 'Rafi', role: 'developer', email: 'rafi@example.com' },
];

console.log(users.map(label));
console.log(users.map(emailDomain));
  1. Check it: npx tsc --noEmit --strict users.ts. No errors.
  2. Run it: node users.ts. By default, Node.js runs TypeScript files that contain only erasable TypeScript syntax Source 7সোর্স 7. You see [ 'Asha (tester)', 'Rafi (developer)' ] and [ 'none', 'example.com' ].
  3. Change Asha's role to 'manager'. tsc says "manager" is not allowed. But node still runs it and prints Asha (manager), because Node.js does not check types Source 7সোর্স 7.
  4. Put the role back, and delete the if (user.email === undefined) line. tsc warns that user.email may be undefined. node now crashes with a TypeError. The null check is there to catch exactly this Source 3সোর্স 3.

বাংলা ব্যাখ্যা

এটা users.ts নামে সেভ করুন। Node.js 22.18 বা নতুন (type stripping ডিফল্টভাবে চালু v22.18.0 ও v23.6.0 থেকে Source 7সোর্স 7) আর TypeScript লাগবে (npm install -D typescript)।

type Role = 'tester' | 'developer';

interface User {
  name: string;
  role: Role;
  email?: string;
}

function label(user: User): string {
  return `${user.name} (${user.role})`;
}

function emailDomain(user: User): string {
  if (user.email === undefined) return 'none';
  return user.email.split('@')[1];
}

const users: User[] = [
  { name: 'Asha', role: 'tester' },
  { name: 'Rafi', role: 'developer', email: 'rafi@example.com' },
];

console.log(users.map(label));
console.log(users.map(emailDomain));
  1. npx tsc --noEmit --strict users.ts দিয়ে check করুন। কোনো error নেই।
  2. node users.ts দিয়ে চালান। ডিফল্টভাবে Node.js সেই TypeScript file চালায়, যেখানে শুধু মুছে ফেলা যায় এমন (erasable) TypeScript syntax আছে Source 7সোর্স 7। Output: [ 'Asha (tester)', 'Rafi (developer)' ] আর [ 'none', 'example.com' ]।
  3. Asha-র role বদলে 'manager' করুন। tsc এবার বলবে Type '"manager"' is not assignable to type 'Role'. কিন্তু node users.ts তবুও চলে আর Asha (manager) দেখায়। Node.js TypeScript syntax-কে whitespace দিয়ে বদলে দেয়, কোনো type check করে না Source 7সোর্স 7।
  4. Role আগের মতো করে if (user.email === undefined) লাইনটা মুছে দিন। tsc বলবে 'user.email' is possibly 'undefined'. আর node এবার TypeError: Cannot read properties of undefined (reading 'split') দিয়ে crash করবে। Null check ঠিক এই bug ধরার জন্যই আছে Source 3সোর্স 3।

How a tester uses it

সহজ English

বাংলা ব্যাখ্যা

  • টেস্টের পাশে tsc চালান। Playwright type check করে না, আর ছোটখাটো compile error থাকলেও টেস্ট চালায়। এর docs পাশাপাশি TypeScript compiler চালাতে বলে Source 8সোর্স 8। CI-তে সেটা হলো npx playwright test-এর আগে npx tsc -p tsconfig.json --noEmit Source 8সোর্স 8।
  • লেখার সময়ই check। Local-এ npx tsc -p tsconfig.json --noEmit -w প্রতিবার সেভ করার সাথে সাথে check করতে থাকে Source 8সোর্স 8।
  • API response-এর type দিন। Interface declaration একটা object-এর আকার বর্ণনা করে Source 1সোর্স 1: টেস্ট যে response body পড়ে, তার প্রতিটার জন্য একটা লিখুন। নেই এমন field পড়লে JavaScript-এ undefined আসে, কিন্তু TypeScript-এ error হয় Source 2সোর্স 2, তাই field-এর নামে ভুল থাকলে check fail করে।
  • তালিকা বন্ধ রাখুন। Allowed role বা status-এর মতো literal type-এর union তালিকার বাইরের যেকোনো value বাতিল করে Source 3সোর্স 3।
  • যা না থাকতে পারে, তা চিহ্নিত করুন। Optional property দেখায় কোন field না-ও থাকতে পারে Source 3সোর্স 3, আর strictNullChecks কোডকে সেগুলো চেক করতে বাধ্য করে Source 3সোর্স 3।
  • Helper আবার ব্যবহার করুন। Generic component একটা type-এর বদলে নানা type নিয়ে কাজ করতে পারে Source 9সোর্স 9।

Common mistakes

সহজ English

বাংলা ব্যাখ্যা

  • সবুজ run-এ ভরসা করা। ছোটখাটো type error থাকলেও Playwright টেস্ট চালায় Source 8সোর্স 8, আর Node.js কোনো type check করে না Source 7সোর্স 7। Playwright-এর docs যেমন বলে, tsc-ও চালান Source 8সোর্স 8।
  • Error চাপা দিতে any। any type-এর value type-check হয় না Source 3সোর্স 3। তার বদলে type ঠিক করুন।
  • strict বন্ধ রাখা। strictNullChecks ছাড়া null আর undefined যেকোনো type-এ বসানো যায়, আর এগুলো সামলাতে ভুলে যাওয়া অসংখ্য bug-এর কারণ Source 2সোর্স 2। Try it-এর ধাপ 4-এ এমন একটা দেখা গেছে: চলার সময় TypeError।
  • ভাবা যে type চলার সময় ডেটা চেক করে। Type annotation কখনো চলার সময়ের আচরণ বদলায় না Source 2সোর্স 2। API response-এর shape টেস্টে assertion দিয়ে চেক করুন।
  • readonly-কে সুরক্ষা ভাবা। readonly শুধু type-checking-এর সময় চেক হয়; চলার সময় কিছু বদলায় না Source 4সোর্স 4।

What a tester can check

Tutorial advice

This list is the tutorial's own advice, not a fact from a source.

  • A type-check step. Does CI run tsc --noEmit, and does a type error fail the build?
  • strict. Is strict on in the tsconfig.json of the tests?
  • any. How many any types are in the test code, and does each one have a reason?
  • Response types. Do the API tests describe their response bodies with interfaces or types?
  • Closed lists. Are statuses and roles unions of literal types, not plain strings?
  • Runtime checks. Does each test still assert on the real data, not only on the types?

সহজ English

Tutorial advice

This list is the tutorial's own advice, not a fact from a source.

  • Type check. Does CI run tsc --noEmit, and does an error stop the build?
  • strict. Is strict turned on for the tests?
  • any. How many any types are there, and does each have a reason?
  • Response types. Do API tests describe the response bodies?
  • Closed lists. Are statuses and roles lists of exact values?
  • Real checks. Do the tests still check the real data?

বাংলা ব্যাখ্যা

Tutorial advice

এই তালিকা টিউটোরিয়ালের নিজের পরামর্শ, কোনো source থেকে নেওয়া তথ্য নয়।

  • Type-check-এর ধাপ। CI কি tsc --noEmit চালায়, আর type error হলে কি build fail হয়?
  • strict। টেস্টের tsconfig.json-এ কি strict চালু?
  • any। টেস্ট কোডে কতগুলো any আছে, আর প্রতিটার কি কোনো কারণ আছে?
  • Response type। API টেস্টগুলো কি interface বা type দিয়ে response body বর্ণনা করে?
  • বন্ধ তালিকা। Status আর role কি literal type-এর union, সাধারণ string নয়?
  • চলার সময়ের চেক। প্রতিটা টেস্ট কি শুধু type নয়, আসল ডেটার ওপরও assert করে?

Key words

TermMeaning
TypeScriptJavaScript with a type system on top.
tscThe TypeScript compiler, the tool that checks the types.
Type annotationA type such as person: string on a parameter, which describes what values the function can be called with; it does not change how the code runs.
Type aliasA name for any type: type Role = ....
InterfaceA name for an object type.
Union typeA value that may be any one of two or more types.
Literal typeOne exact string or number used as a type.
Optional propertyA property marked with ? that may be missing.
anyA type that is not checked.
strictThe flag that turns on the strict family of checks, including strictNullChecks.
NarrowingTypeScript working out a more exact type after a check such as typeof.
Type strippingNode.js removing the types and running the code, with no type check.
  1. [1]
    TypeScript for JavaScript Programmers

    TypeScript (Microsoft) · accessed 2026-11-15দেখা হয়েছে: 2026-11-15

  2. [2]
    The Basics

    TypeScript (Microsoft) · accessed 2026-11-15দেখা হয়েছে: 2026-11-15

  3. [3]
    Everyday Types

    TypeScript (Microsoft) · accessed 2026-11-15দেখা হয়েছে: 2026-11-15

  4. [4]
    Object Types

    TypeScript (Microsoft) · accessed 2026-11-15দেখা হয়েছে: 2026-11-15

  5. [5]
    Narrowing

    TypeScript (Microsoft) · accessed 2026-11-15দেখা হয়েছে: 2026-11-15

  6. [6]
    TSConfig Option: strict

    TypeScript (Microsoft) · accessed 2026-11-15দেখা হয়েছে: 2026-11-15

  7. [7]
    Modules: TypeScript

    Node.js (OpenJS Foundation) · accessed 2026-11-15দেখা হয়েছে: 2026-11-15

  8. [8]
    TypeScript

    Playwright (Microsoft) · accessed 2026-11-15দেখা হয়েছে: 2026-11-15

  9. [9]
    Generics

    TypeScript (Microsoft) · accessed 2026-11-15দেখা হয়েছে: 2026-11-15