Programming

TypeScript Fundamentals - Programming

This TypeScript Fundamentals test evaluates your understanding of core TypeScript concepts and basic type system features.

Duration

Complete at your own pace or within the time limit

Questions

Multiple choice with one correct answer

Accuracy

Expert-reviewed questions with clear answer keys

Results

Instant detailed breakdown by topic area

TypeScript Fundamentals
Question 1/of
0%
00:00
Category
Difficulty:Medium

Loading Questions...

Preparing your assessment. This will only take a moment.

About This Test

This test evaluates your grasp of TypeScript fundamentals and essential type system concepts.

The test measures your foundational knowledge of TypeScript's type system, including primitive types, type annotations, and basic type inference. It assesses your understanding of how TypeScript extends JavaScript with static typing and compile-time error checking.

Questions focus on type annotations, basic generics, union and intersection types, and understanding TypeScript's compilation process. Each question reinforces core concepts with practical examples you'll encounter in everyday TypeScript development.

Use results to identify fundamental gaps and build a strong foundation for advanced TypeScript learning. Mastering fundamentals accelerates your progress toward intermediate and expert-level concepts.

What This Test Covers

Basic Types and Annotations

Annotating variables and functions with types like string, number, boolean, arrays, and tuples, plus any, unknown, void, and how TypeScript checks them at compile time.

Interfaces and Type Aliases

Describing the shape of objects with interfaces and type aliases, optional and readonly properties, and choosing between them for modeling data structures.

Union and Literal Types

Combining types with unions, restricting values with literal types, using enums, and narrowing a union to a specific type inside conditional branches.

Functions and Type Inference

Typing parameters and return values, optional and default parameters, and how TypeScript infers types automatically so you annotate only where needed.

Sample Questions

A few real questions from this test, with answers and explanations. Take the full test above for the complete set.

Which syntax correctly declares a variable annotated as a string in TypeScript?

Answer: let name: string = "Ada";

TypeScript type annotations follow the identifier with a colon and the type, so 'let name: string' declares name as a string.

What is the correct type annotation for an array of numbers in TypeScript?

Answer: number[]

An array of numbers is written 'number[]' (or the equivalent 'Array'). '[number]' is a tuple of exactly one number.

What does the type 'string | number' describe?

Answer: A value that is either a string or a number

The vertical bar creates a union type, meaning the value can be any one of the listed types, in this case either a string or a number.

Which interface correctly declares an optional 'age' property of type number?

Answer: interface User { age?: number; }

An optional property is marked with a question mark after the property name, as in 'age?: number', making it allowed to be absent or undefined.

Which type describes a tuple whose first element is a string and second element is a number?

Answer: [string, number]

A tuple type uses square brackets with a fixed sequence of element types, so '[string, number]' is a two-element tuple of a string then a number.

Frequently Asked Questions

Find answers to common questions about this assessment

Both describe the shape of data. Interfaces are designed for objects and can be reopened and merged across declarations, and are often used for class contracts. Type aliases can name any type including unions, intersections, and primitives. For simple object shapes they are interchangeable, so many teams pick one style and stay consistent.

any turns off type checking, so you can do anything with the value and lose safety. unknown is the safe counterpart: you can hold any value, but you must narrow or check its type before using it. Prefer unknown when a value's type is genuinely uncertain so the compiler still forces you to be careful.

No, browsers and Node run JavaScript, not TypeScript. The TypeScript compiler, tsc, checks your types and then strips them out, emitting plain JavaScript that runs anywhere. The types exist only during development and compilation, so they add safety without any runtime cost or performance overhead in the final output.

Narrowing is when TypeScript refines a broad type to a more specific one based on checks in your code. For example, inside an if that tests typeof value equals string, the compiler treats value as a string in that branch. Narrowing with typeof, truthiness, and equality checks lets you safely handle union types.

TypeScript is a superset of JavaScript, so valid JavaScript is valid TypeScript. Learning from scratch means first understanding JavaScript basics like variables, functions, and objects, then adding types, interfaces, generics, and enums on top. You can compile TypeScript to plain JavaScript, so existing knowledge transfers directly while you gradually add type safety to catch errors earlier.

The official TypeScript handbook is a thorough free resource you can read online or save, covering types, interfaces, generics, and configuration. Many learning platforms offer structured TypeScript fundamentals courses with exercises. For React TypeScript specifically, the React documentation shows typing components and hooks. Practice by converting a small JavaScript project to TypeScript file by file.

No account is required. You can take the test immediately. Optionally provide an email to save your results.

There is no pass/fail threshold. The test measures your knowledge level and provides detailed feedback for improvement.

For knowledge tests, we recommend answering without external help to get an accurate assessment. Practice exercises are designed for learning, so references are acceptable.

Our questions are written for structured educational practice and can give a useful snapshot of your current knowledge in the tested topics.

Ready to Test Your Knowledge?

Start the assessment now and discover your strengths