⏱️ Time Left --:-- 🏆 Score 0/31 ❌ Wrong 0/31 🎯 Accuracy - 📊 Answered 0/31 Overall Progress 0% Q1 What is TypeScript and what major advantage does it add over JavaScript? A A. A completely different language that replaces JavaScript in the browser B B. A strongly-typed superset of JavaScript that catches type errors at compile time before the code ever runs in the browser C C. A JavaScript runtime that runs faster than Node.js D D. A CSS-in-JS framework built on top of JavaScript Q2 What is the difference between interface and type in TypeScript? A A. They are completely identical — just two keywords for the same thing B B. interface is only for objects and can be extended/merged; type is more flexible — it can represent primitives, unions, intersections, and tuples but cannot be re-opened for declaration merging C C. type is for classes only; interface is for functions and objects D D. interface compiles to JavaScript; type is erased at compile time only Q3 What is the any type in TypeScript and why should you avoid it? A A. A type that only accepts any primitive value (string, number, boolean) B B. A type that completely opts out of type checking — the variable can be assigned any value and TypeScript will not report errors, defeating the purpose of TypeScript C C. A union type that combines all built-in TypeScript types D D. A type alias for the JavaScript Object type Q4 What is the difference between unknown and any in TypeScript? A A. unknown is the same as any but only for objects B B. Both accept any value, but unknown requires you to perform a type check before using the value, making it the type-safe counterpart to any C C. unknown is for asynchronous values; any is for synchronous ones D D. any is stricter than unknown — you must narrow any before using it Q5 What is a Union Type in TypeScript and how do you define one? A A. A type that combines two object types, merging all their properties B B. A type that allows a value to be one of several specified types, defined using the pipe character: string | number | boolean C C. A way to union two arrays into a single typed array D D. A type that represents the combination of all possible TypeScript types Q6 What is an Intersection Type in TypeScript? A A. A type that represents values that exist in both of two arrays B B. A type that combines multiple types into one using — the resulting type has ALL properties from ALL combined types C C. A type that finds common properties between two interfaces D D. A type used exclusively with generics to constrain type parameters Q7 What are Generics in TypeScript and why are they useful? A A. A way to write CSS-in-TypeScript using generic selectors B B. Type parameters that allow you to write reusable, type-safe functions, classes, and interfaces that work with different types without losing type information C C. Built-in types provided by TypeScript like string, number, and boolean D D. A shorthand for writing generic object types without defining interfaces Q8 What does the readonly modifier do in TypeScript? A A. Makes a file read-only at the operating system level B B. Prevents a property from being reassigned after initialization — a compile-time constraint that enforces immutability C C. Makes an array iterable but not sortable D D. A decorator that marks a class method as non-overridable Q9 What is Type Narrowing in TypeScript? A A. Reducing the number of properties in a type using Pick B B. The process of refining a broader type to a more specific type within a conditional block using type guards like typeof, instanceof, or in C C. Converting a union type into a single specific type using casting D D. Removing optional properties from an interface to make it stricter Q10 What is a Type Guard in TypeScript and how do you write a custom one? A A. A runtime library that validates TypeScript types in production B B. A function with a return type predicate (val is Type) that tells TypeScript to narrow a variable to a specific type inside a conditional block C C. A TypeScript compiler option that enforces strict type checking D D. An interface that guards against null and undefined values automatically Q11 What are TypeScript Utility Types? Name and explain at least three. A A. Helper functions built into TypeScript's standard library for runtime type validation B B. Built-in generic types that transform existing types: Partial<T> makes all properties optional, Required<T> makes all required, Readonly<T> makes all readonly, Pick<T,K> selects properties, Omit<T,K> excludes properties C C. Types generated automatically from database schemas D D. Decorators that modify class behavior at runtime Q12 What does the keyof operator do in TypeScript? A A. Returns the number of keys in an object at runtime B B. Creates a union type of all the keys (property names) of a given type C C. Checks if a key exists in an object using a type guard D D. Iterates over an object's keys in a type-safe for loop Q13 What is the typeof type operator in TypeScript (different from JavaScript's typeof)? A A. Exactly the same as JavaScript's typeof — returns a string at runtime B B. A TypeScript-only type-level operator that extracts the static type of a variable or function, usable in type positions to avoid repeating type definitions C C. An operator that checks if a value is defined at compile time D D. A way to convert a runtime value into a TypeScript type annotation Q14 What are Mapped Types in TypeScript? A A. Types that map JavaScript objects to database records B B. Types that transform the properties of an existing type by iterating over its keys — the foundation of utility types like Partial, Readonly, and Record C C. A way to map array elements to new types using generics D D. Types defined in external .map source files Q15 What are Conditional Types in TypeScript? A A. Types that change at runtime based on user input B B. Type-level if/else expressions: T extends U ? TrueType : FalseType — enabling powerful type transformations based on type relationships C C. Types that are only active when a certain compiler flag is enabled D D. Optional properties that are conditionally included based on other properties Q16 What is the never type in TypeScript and when does it appear? A A. A type used for variables that are never read after assignment B B. A type that represents values that never occur — used for functions that never return (infinite loops, always throw) and for exhaustive type checking C C. A type alias for void that indicates no return value D D. A type that automatically removes itself from unions when not needed Q17 What is the difference between void and never as function return types? A A. void means no return value; never means the same thing — they are interchangeable B B. void means the function returns but produces no useful value (can return undefined); never means the function NEVER returns at all — it always throws or runs forever C C. never is for async functions; void is for synchronous functions D D. void is for arrow functions; never is for regular function declarations Q18 What is an Enum in TypeScript and what are its two types? A A. A generic collection type similar to Set that only accepts unique values B B. A special structure that defines a set of named constants — Numeric enums auto-increment from 0; String enums require explicit string values for each member C C. An enumerable array with built-in TypeScript type safety D D. A TypeScript-only runtime class for defining fixed sets of values Q19 What is a Discriminated Union (Tagged Union) in TypeScript? A A. A union type where TypeScript discriminates which types to include at compile time B B. A union of types that share a common literal property (discriminant) — TypeScript uses that property to narrow the type precisely in switch/if statements C C. A union type that automatically excludes null and undefined D D. A union where each member is a different primitive type Q20 What does the as const assertion do in TypeScript? A A. Converts a variable to a constant at runtime, preventing reassignment B B. Tells TypeScript to infer the narrowest possible literal types for an object or array, making all properties readonly and values literal types instead of general types C C. Casts a type to any and then back to a constant type D D. Marks a function as a constant that cannot be overloaded Q21 What is the satisfies operator introduced in TypeScript 4.9? A A. A runtime operator that checks if a value satisfies an interface B B. A type operator that validates an expression against a type without widening the inferred type — you get both type checking AND the most specific type C C. An alternative to the extends keyword for interface inheritance D D. A way to check if a generic type parameter satisfies a constraint Q22 What are Decorators in TypeScript and what are they used for? A A. CSS class selectors applied to TypeScript components B B. Special annotations (prefixed with @) that attach metadata and modify classes, methods, properties, or parameters — heavily used in frameworks like NestJS and Angular C C. Comments that generate automatic documentation from TypeScript code D D. A TypeScript-only syntax for extending built-in JavaScript classes Q23 What is Declaration Merging in TypeScript? A A. Combining multiple .ts files into a single compiled output file B B. TypeScript's ability to merge multiple declarations with the same name — interfaces with the same name are automatically combined into one; useful for extending third-party types C C. Merging two type aliases using the intersection operator D D. Combining default and named exports from the same module Q24 What is the infer keyword in TypeScript and how is it used? A A. A keyword that tells TypeScript to infer types from JSDoc comments B B. Used inside conditional types to capture and reuse a type that TypeScript matches — enabling extraction of types from other types C C. A compiler directive that enables automatic type inference globally D D. A way to infer generic type parameters from function arguments at call sites Q25 What is a Namespace in TypeScript and when should you use it? A A. A way to organize CSS class names in TypeScript projects B B. An internal module system (using the namespace keyword) for grouping related code — largely superseded by ES Modules but still useful for organizing global type declarations C C. The TypeScript equivalent of JavaScript's module system D D. A decorator that namespaces class properties to avoid conflicts Q26 What is the TypeScript tsconfig.json and what do the strict mode flags enable? A A. A JSON file for configuring ESLint rules in TypeScript projects B B. The TypeScript compiler configuration file — strict mode enables a collection of flags: noImplicitAny, strictNullChecks, strictFunctionTypes, strictPropertyInitialization, and more C C. A file that maps TypeScript types to JavaScript runtime types D D. A build configuration file specific to webpack and TypeScript projects Q27 What is the difference between strictNullChecks: true and strictNullChecks: false? A A. With false, null and undefined throw compile errors; with true they are allowed everywhere B B. With true, null and undefined are their own distinct types and cannot be assigned to other types without explicit handling — with false they are assignable to any type (the pre-TS2 behavior) C C. strictNullChecks only affects function return types, not variable assignments D D. With true, TypeScript removes all null values from compiled JavaScript automatically Q28 What is the Non-null Assertion Operator (!) in TypeScript? A A. A logical NOT operator that flips boolean values B B. A postfix operator that tells TypeScript to treat a value as non-null and non-undefined, bypassing null checks — use with caution C C. A way to assert that two values are not equal at compile time D D. An operator that converts null to undefined automatically Q29 What is Optional Chaining (?.) and Nullish Coalescing (??) in TypeScript? A A. Two syntaxes for declaring optional function parameters B B. Optional chaining safely accesses deeply nested properties (returns undefined instead of throwing if null); nullish coalescing provides a default value only for null/undefined (not for 0 or "") C C. TypeScript-only features not available in modern JavaScript D D. Two operators for comparing nullable types in conditional statements Q30 What is the Awaited<T> utility type in TypeScript? A A. A type that marks a value as already awaited and non-Promise B B. Recursively unwraps the type of a Promise — Awaited<Promise<Promise<string>>> resolves to string C C. A utility type that converts synchronous functions to async ones D D. A type guard that checks if a value is a Promise before awaiting it Q31 What are Template Literal Types in TypeScript 4.1+ and what can they do? A A. A way to write template strings in TypeScript type definitions B B. Types that build new string literal types by combining existing string literals using template literal syntax — enabling powerful string-based type manipulation C C. A runtime feature for creating type-safe template strings with tagged template literals D D. A decorator syntax for attaching type information to string variables 🎉 Quiz Complete! 0Score 0Wrong 0%Accuracy --Time 🔄 Try Again