1. Make all props optional:
Partial<T> flips every property in T to optional—perfect for patch/update payloads.
type User = { id: string; name: string };
type UserUpdate = Partial<User>; // { id?: string; name?: string }Get the Preplance app for a seamless learning experience. Practice offline, get daily streaks, and stay ahead with real-time interview updates.
Get it on
Google Play
4.9/5 Rating on Store
Infosys · Typescript
Practice Typescript questions specifically asked in Infosys interviews – ideal for online test preparation, technical rounds and final HR discussions.
Questions
6
Tagged for this company + subject
Company
Infosys
View company-wise questions
Subject
Typescript
Explore topic-wise practice
Go through each question and its explanation. Use this page for targeted revision just before your Infosys Typescript round.
Partial<T> flips every property in T to optional—perfect for patch/update payloads.
type User = { id: string; name: string };
type UserUpdate = Partial<User>; // { id?: string; name?: string }For complete preparation, combine this company + subject page with full company-wise practice and subject-wise practice. You can also explore other companies and topics from the links below.
public (default) is visible everywhere, private is only inside the class, protected is inside the class and its subclasses, readonly prevents reassignment of that property after construction.
class User {
public id: string;
protected role: string = 'user';
private secret = 'shh';
readonly createdAt = new Date();
constructor(id: string){ this.id = id; }
}First look for community typings on DefinitelyTyped (`@types/...`). If none exist, write your own `.d.ts` declaration file for the library.
// Install typings:
// npm i -D @types/lodash
// Or create: types/my-lib/index.d.ts
declare module 'my-lib' { export function doThing(): void }Partial turns every property into an optional one. Handy for update DTOs and patch operations.
type User = { id: string; name: string };
type UserUpdate = Partial<User>; // { id?: string; name?: string }Use a colon after the variable name to add a type annotation. `let` is block-scoped and reassignable; `const` is block-scoped and not reassignable; `var` is function-scoped and generally avoided due to hoisting quirks.
let count: number = 0; const name: string = 'Ava'; var legacy: boolean = false; // function-scoped
Optional elements go after the element’s type using `?` inside the tuple type, e.g., `[A, B?]`. Standalone `[number?]` is not valid, and parentheses variants are not TypeScript syntax.
type MaybeLabel = [id: number, label?: string]; const a: MaybeLabel = [1]; const b: MaybeLabel = [2, 'two'];