Skip to main content

tf-typescript

Sure, here are 10 True/False questions related to TypeScript:

  1. TypeScript is a superset of JavaScript that compiles to plain JavaScript. (True/False)

  2. In TypeScript, all parameters are optional by default and do not require an explicit ? to denote an optional parameter. (True/False)

  3. TypeScript's type inference allows you to get a lot of power without writing additional code. (True/False)

  4. TypeScript can only be run in environments that support ECMAScript 6. (True/False)

  5. Enums in TypeScript can be either numeric or string-based. (True/False)

  6. True. TypeScript is a superset of JavaScript that compiles down to plain JavaScript.

  7. False. In TypeScript, parameters are not optional by default. You must explicitly mark parameters as optional with a ? if they are not required.

  8. True. TypeScript's type inference does allow for powerful typing without the need for additional code.

  9. False. TypeScript can be compiled down to any ECMAScript version (such as ES3 or ES5) depending on the configuration, so it is not limited to environments that only support ECMAScript 6.

  10. True. Enums in TypeScript can indeed be numeric or string-based.


  1. The any type in TypeScript is equivalent to opting out of type checking for a variable. (True/False)
  2. TypeScript has a special type called unknown that is more type-safe than any. (True/False)
  3. Private methods in a TypeScript class can be accessed from instances of that class. (True/False)
  4. TypeScript interfaces can be used to describe the shape that values should have. (True/False)
  5. Generic types in TypeScript can only be used with classes and interfaces, not functions. (True/False)

You can answer these True/False questions, and I'll provide feedback on your responses.

Certainly! Here are the answers to the True/False questions provided:

  1. True. The any type in TypeScript effectively disables type checking for that variable.
  2. True. The unknown type is indeed more type-safe than any because it forces you to do some form of checking before you operate on values of type unknown.
  3. False. Private methods in a TypeScript class cannot be accessed from outside the class or its instances; they are meant to be accessible only within the class itself.
  4. True. Interfaces in TypeScript are used to type-check the shape that objects have.
  5. False. Generic types in TypeScript are versatile and can be used with functions, classes, interfaces, and other structures.

These answers can be helpful in checking your understanding of TypeScript's features. If you have more questions or need further clarification, feel free to ask!

Absolutely, here are five True/False questions on TypeScript with their respective answers:

  1. Question: TypeScript offers a never type which represents types that never occur.

    • Answer: True. The never type is used for values that never occur, such as a function that always throws an error or a function that never returns.
  2. Question: A class in TypeScript can implement multiple interfaces.

    • Answer: True. TypeScript classes can implement multiple interfaces by separating each interface with a comma.
  3. Question: The --strictNullChecks flag can be used to catch null or undefined assignment errors at compile time.

    • Answer: True. When enabled, this flag makes TypeScript raise errors if null or undefined values are assigned to a variable not explicitly marked to accept them.
  4. Question: The TypeScript compiler can automatically infer the return type of a function without explicitly declaring it.

    • Answer: True. TypeScript can infer the return type of a function based on the return statements present in the function.
  5. Question: In TypeScript, you can use both let and const for variables that change during the application's lifecycle.

    • Answer: False. In TypeScript (and JavaScript), let is used for variables that can change, while const is used for variables that should not change (immutable) after they are set.

These questions and answers should help as you study TypeScript. If you need further explanations or additional questions, feel free to ask!


Certainly! Here are five intermediate to advanced True/False questions about TypeScript, along with their answers:

  1. Question: In TypeScript, the unknown type is automatically assigned to variables that are initialized without a value.

    • Answer: False. The any type is automatically assigned to variables that are initialized without a value if the --strict flag is not enabled. The unknown type is not automatically assigned but should be explicitly set by the developer when the type of a variable is not yet known.
  2. Question: Decorators in TypeScript can be applied to a class, method, accessor, property, or parameter.

    • Answer: True. Decorators are a special kind of declaration that can be attached to a class declaration, method, accessor, property, or parameter. Decorators use the form @expression, where expression must evaluate to a function that will be called at runtime with information about the decorated declaration.
  3. Question: TypeScript's keyof operator can be used on types to fetch the set of known, public property names as a union type.

    • Answer: True. The keyof operator takes an object type and produces a string or numeric literal union of its keys.
  4. Question: The TypeScript compiler can emit specific ECMAScript standard JavaScript (like ES5, ES6) based on the target setting in the tsconfig.json file.

    • Answer: True. The target setting in the tsconfig.json file specifies the ECMAScript target version that the compiler will output.
  5. Question: A tuple in TypeScript is a kind of array where the type of a fixed number of elements is known, but not necessarily the same.

    • Answer: True. Tuples in TypeScript are an array-like structure where each element represents some property of a record.

I hope these questions aid in your TypeScript study and deepen your understanding of some of its more nuanced features. If you have any more questions or need further information, let me know!


Here are five intermediate to advanced True/False questions on TypeScript, along with the correct answers:

  1. Question: TypeScript's Partial utility type makes all properties of a type optional, effectively creating a type with the same properties, but with each one marked as optional.

    • Answer: True. Partial<T> constructs a type with all properties of T set to optional.
  2. Question: The as keyword in TypeScript is only used for type casting when the --strict flag is enabled in the compiler options.

    • Answer: False. The as keyword is used for type assertions in TypeScript and is not dependent on the --strict compiler flag.
  3. Question: In TypeScript, an interface can extend multiple classes.

    • Answer: True. An interface can extend one or more classes, which can include a mix of both types and values.
  4. Question: The unknown type in TypeScript is assignable to any other type without a type assertion.

    • Answer: False. While any type is assignable to unknown, you cannot assign unknown directly to any other type (except for any) without a type assertion.
  5. Question: TypeScript allows for overloading function implementations, but the number of arguments must remain the same across overloads.

    • Answer: False. TypeScript function overloads can differ in the number and types of their parameters, not just in the return type.

These questions cover some nuanced aspects of TypeScript's type system and its capabilities. They should help you in preparing for scenarios you might encounter when working with TypeScript at an intermediate or advanced level. If you need explanations or have other questions, feel free to ask!


Certainly! Here are five intermediate/advanced TypeScript True/False questions with their answers for your study:

  1. Question: The readonly keyword in TypeScript can be used to make properties of an interface immutable after their initial creation.

    • Answer: True. The readonly modifier ensures that the properties of an interface can't be reassigned after their initial assignment.
  2. Question: TypeScript's discriminated unions can only be formed using string literal types.

    • Answer: False. Discriminated unions, also known as tagged unions, can be created using string literals, numbers, or boolean literals as the discriminant.
  3. Question: The --noImplicitReturns flag in the TypeScript compiler will report an error if not all code paths in a function return a value.

    • Answer: True. This flag checks that all functions have a return value on all code paths.
  4. Question: When a function has overloads, TypeScript will always use the implementation signatures to determine the correct type.

    • Answer: False. TypeScript uses the list of overload signatures to resolve the types, not the actual implementation signature which is not visible to the caller.
  5. Question: TypeScript's namespace keyword is deprecated and modules should be used instead.

    • Answer: False. While modules (ES6 modules) are generally preferred for their better scoping and reusability, the namespace keyword is not deprecated and may still be used, particularly for organizing code with internal modules.

Studying these aspects of TypeScript will help deepen your understanding of the language's more complex features. If you need further clarification on any of these topics, feel free to ask!


Certainly, here are five more intermediate to advanced True/False questions regarding TypeScript:

  1. Question: In TypeScript, the never type is used for variables that are always null or undefined.

    • Answer: False. The never type represents the type of values that never occur. For example, it is the return type for a function expression or an arrow function expression that always throws an exception or one that never returns.
  2. Question: You can use the unknown type to force developers to perform type-checking before using the variable, making it safer than the any type.

    • Answer: True. The unknown type is TypeScript's type-safe counterpart to any. A value of type unknown cannot be used until its type has been narrowed to a more specific type.
  3. Question: When using module augmentation in TypeScript, you can only add new members to an existing module and cannot modify existing ones.

    • Answer: False. Module augmentation allows you to add new members to an existing module, but it also allows for the modification of existing module declarations through interface merging.
  4. Question: Type assertions in TypeScript can change the actual type of a variable at runtime.

    • Answer: False. Type assertions are purely a compile-time construct and have no impact on the runtime type of a variable. They are a way for developers to provide hints to the compiler on the type of an object.
  5. Question: TypeScript allows abstract classes to contain both complete (non-abstract) and incomplete (abstract) members.

    • Answer: True. Abstract classes in TypeScript can have a mix of abstract and concrete (fully implemented) members. The abstract members must be implemented by non-abstract subclasses.

These questions are designed to challenge and ensure a strong understanding of some of the more sophisticated features of TypeScript. Keep studying, and don't hesitate to ask if you have any doubts or need further explanations!