TypeScript
0Loading crowd target
0Loading crowd target
7correct to beat the crowd
50 free TypeScript trivia questions with answers — science & nature quiz, new questions added Oct 2026.
TypeScript began as a way to keep very large JavaScript programs under control and is now part of everyday web development. It adds a layer of types on top of JavaScript, checks them before the program runs, and then steps out of the way. That simple idea hides a surprising amount of detail, and a few design decisions that still catch experienced developers out. This TypeScript quiz starts with the basics: where the language came from, how code is compiled, and the syntax for describing values, objects, arrays and classes. It then moves on to the sharper tools of the type system, the built-in utility types, the compiler settings that change how a project is checked, and the editors, frameworks and runtimes that grew up around the language. The questions suit beginners checking what they have learned, developers preparing for an interview, and seasoned programmers who want to see how well they know the language beyond their daily habits. Every answer comes with a short explanation, so a wrong guess still teaches something.
30 of 50 questions with answers and explanations. Play the quiz
Q 01Which company unveiled TypeScript in October 2012 after two years of internal development on the language?
Microsoft
Microsoft built the language because its own teams and its customers were struggling to write very large applications in JavaScript. The first public release was called version 0.8.
Q 02In 2025 TypeScript's team announced a port of its compiler, promising tenfold faster builds, to which language?
Go
Go was chosen for the native compiler, which until then had been written in TypeScript itself and run as ordinary JavaScript.
Q 03What happens to the type annotations in a TypeScript program when the compiler turns it into JavaScript?
They are erased
They are erased, because type annotations are not part of JavaScript. The annotations exist only to catch mistakes before the program runs.
Q 04Which editor's 1.5-million-line TypeScript codebase was checked ten times faster in early tests of the native compiler?
Visual Studio Code
Visual Studio Code is built largely in TypeScript, and a full check of it that had taken 78 seconds finished in under eight with the new compiler.
Q 05Which web framework did Google rewrite from the ground up as a TypeScript-based successor to its JavaScript original?
Angular
Angular replaced the older AngularJS, and the team dropped the JS from the name so that developers could tell the two frameworks apart.
Q 06Which TypeScript type switches off checking for a value, so every property access or call on it is allowed?
any
The any type tells the compiler to stop checking a value altogether. The compiler also falls back on it when it cannot work out a type, which the noImplicitAny option reports as an error.
Q 07Which command, installed by the typescript npm package, checks a .ts file and compiles it into plain JavaScript?
tsc
The tsc command is the TypeScript compiler. Run on hello.ts, it writes a hello.js file beside it that looks much like code a person would have written by hand.
Q 08Which file tells the compiler that a directory is the root of a TypeScript project and lists the options to use?
tsconfig.json
A tsconfig.json file is found automatically: started with no input files, the compiler searches the current directory and then each parent directory in turn until it finds one.
Q 09Which TypeScript feature, written with angle brackets as in Array<string>, lets one function work over many types?
Generics
Generics let a function capture the type it is handed, so an identity function given a string is known to hand a string back, without the checking being switched off.
Q 10Which TypeScript keyword names an object type that can later be re-opened to add new properties?
interface
An interface can be written again under the same name and the two definitions merge, which is how extra fields are added to built-in objects such as Window.
Q 11Which TypeScript keyword defines a set of named constants, such as the directions Up, Down, Left and Right?
enum
An enum counts its members up from zero unless told otherwise. Unlike most TypeScript features, it is a real object that still exists when the program runs.
Q 12Which character sits between two TypeScript types to form a union, so a value may be a string or a boolean?
A vertical bar
A vertical bar joins the member types of a union. The compiler then permits only the operations that are valid for every member, until the code checks which one it has.
Q 13TypeScript annotations put a type after the variable's name, the reverse of Java, with which character between the two?
A colon
Q 21Which single TypeScript compiler option switches on a whole family of tighter type-checking rules at once?
strict
The strict option turns on the whole family together, including noImplicitAny and strictNullChecks, and each member can still be switched off individually.
Q 22In TypeScript, what is a line such as type UserID = string, which gives a type a reusable name, called?
An alias
An alias only names a type and creates nothing new, so two of them describing the same shape are fully interchangeable.
Q 23Which TypeScript feature, written as an @ sign and a name above a class or method, attaches extra behaviour to it?
Decorators
Decorators are functions called with details of whatever they are attached to. TypeScript offered them as an experiment for years before version 5.0 added the design proposed for JavaScript itself.
A colon follows the name, as in let myName: string. TypeScript avoids the types-on-the-left style of C and Java, where the same line would start with the type.
Q 14Which file extension must a TypeScript file have before it can contain JSX, the HTML-like syntax made popular by React?
.tsx
Only this extension tells the compiler to expect JSX. In .tsx files the older angle-bracket way of telling the compiler a value's type is banned, because it would be mistaken for a tag.
Q 15Which TypeScript modifier stops a property from being reassigned, although an object stored in it can still be changed?
readonly
The readonly flag is ignored when two types are compared for compatibility, so the same value can still be changed through a second reference whose type lacks the modifier.
Q 16Which TypeScript keyword labels a class that cannot be instantiated directly and serves only as a base for subclasses?
abstract
An abstract class can leave methods without a body, and a subclass must supply every one of them before objects can be created from it.
Q 17Which TypeScript visibility modifier lets a class member be used by subclasses but hides it from outside code?
protected
A protected member is visible only inside its class and subclasses. A subclass is free to open the door wider, though, by redefining the same member as public.
Q 18Which TypeScript annotation describes an array of numeric values like [1, 2, 3], as shorthand for the longer Array form?
number[]
Writing number[] means exactly the same as Array<number>. The lookalike [number] is a different thing: an array type that holds exactly one element.
Q 19Which kind of TypeScript array type knows exactly how many elements it holds and which type sits at each position?
A tuple
A tuple such as [string, boolean] fixes both length and order, so the compiler reports an error when code reads a position past the end.
Q 20What is it called when TypeScript works out a variable's type from its starting value, with no annotation written?
Inference
Inference means a variable started with the text Alice is treated as a string without a word of annotation. The same goes for default parameter values and for what a function hands back.
Q 24Type definitions from the DefinitelyTyped repository are published to npm under which scope, as in the React package?
@types
The @types scope holds definitions for thousands of libraries, each under the same name as the package it describes, so React's types install as @types/react.
Q 25What is the TypeScript website's online editor, for trying the language in a browser with nothing installed, called?
The Playground
The Playground can also share a piece of code as a link, or hand it on to outside tools such as CodeSandbox and StackBlitz.
Q 26Which Danish engineer, author of Turbo Pascal and lead architect of C#, went on to design TypeScript?
Anders Hejlsberg
Anders Hejlsberg wrote a Pascal compiler for the Nascom microcomputer while still at university, and Borland later licensed it and sold it as Turbo Pascal.
Q 27Which JavaScript runtime, co-created by Node.js founder Ryan Dahl, supports TypeScript files out of the box?
Deno
Deno was unveiled in a 2018 conference talk in which Dahl listed ten things he regretted about the design of Node.js.
Q 28Which TypeScript type accepts every possible value but allows nothing to be done with it until its type is checked?
unknown
The unknown type is the safe counterpart of switching checks off: a value can be stored in it freely, yet calling it or reading a property from it is an error.
Q 29Which TypeScript type describes a function that always throws an exception, so no value ever comes back from it?
never
The never type stands for values that cannot occur. It also appears once every member of a union has been ruled out, which makes it handy for proving that a switch covers each case.
Q 30TypeScript judges two types compatible by comparing their members, not their names: what is this approach called?
Structural typing
Structural typing means an object fits a type whenever it has the required members, with no need to say so in the code. It is often nicknamed duck typing.