1. Get union of keys of T:
keyof T produces a string (or symbol) union of property names, commonly paired with indexed access like T[K].
type User = { id: string; name: string };
type Keys = keyof User; // 'id' | 'name'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
Oracle · Typescript
Practice Typescript questions specifically asked in Oracle interviews – ideal for online test preparation, technical rounds and final HR discussions.
Questions
7
Tagged for this company + subject
Company
Oracle
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 Oracle Typescript round.
keyof T produces a string (or symbol) union of property names, commonly paired with indexed access like T[K].
type User = { id: string; name: string };
type Keys = keyof User; // 'id' | 'name'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.
`readonly` prevents reassignment of tuple elements and disallows mutating methods. It does not deep-freeze nested object values—it’s a type-level immutability.
const t: readonly [number, string] = [1, 'a']; // t[0] = 2; // ❌ cannot assign to read-only element
Classic Node style is error-first: the first arg is an error or null, and the second is the result. This matches many fs and net APIs.
type NodeCallback<T> = (err: NodeJS.ErrnoException | null, result: T) => void;
Abstract classes can include implemented methods plus abstract methods that subclasses must provide. You cannot instantiate an abstract class directly.
abstract class Shape {
abstract area(): number;
describe(){ return 'I am a shape'; }
}
class Square extends Shape { constructor(public s: number){ super(); }
area(){ return this.s * this.s; }
}Split your code into buildable subprojects. Turn on `composite` and reference projects so TS can reuse build info and type check faster.
// packages/a/tsconfig.json
{
"compilerOptions": { "composite": true, "outDir": "dist" },
"include": ["src"]
}
// root tsconfig: {
// "references": [{ "path": "packages/a" }, { "path": "packages/b" }]
// }Parameters<T> gives you the tuple of argument types for a function type T.
function f(a: string, b: number) {}
type P = Parameters<typeof f>; // [string, number]A question mark after the property name marks it optional. The property may be omitted. With `exactOptionalPropertyTypes`, TypeScript distinguishes “missing” from “present but undefined,” giving tighter checks.
type Org = { name: string; desc: string; est?: number }
const a: Org = { name: 'GfG', desc: 'CS portal' } // est omitted
const b: Org = { name: 'GfG', desc: 'CS', est: 2008 }