TypeScript Expert
What is transpilation?
Select the correct answer
Transpilation is the process of bundling multiple JavaScript files into one.
Transpilation is the process of debugging TypeScript code.
Transpilation is the process of minifying JavaScript code.
Transpilation is the process of converting TypeScript code to JavaScript code.
What is a generic type in TypeScript?
Select the correct answer
A generic type in TypeScript is used for error handling.
A generic type in TypeScript is a type that can only be a string or number.
A generic type in TypeScript is used to define specific types of variables.
A generic type in TypeScript allows a type to be a parameter when defining classes, interfaces, and functions.
What are triple-slash directives?
Select the correct answer
Triple-slash directives in TypeScript are comments that contain a single XML tag used to provide additional information to the compiler.
Triple-slash directives in TypeScript are comments for declaring global variables.
Triple-slash directives in TypeScript are used to handle errors.
Triple-slash directives in TypeScript are used for defining types.
What is an abstract class in TypeScript, and how is it different from a regular class?
Select the correct answer
An abstract class in TypeScript is a class that cannot be instantiated and is meant to be subclassed.
An abstract class in TypeScript is a class that cannot extend other classes.
An abstract class in TypeScript is used for defining interfaces.
An abstract class in TypeScript is a class that has only static methods.
Explain "module resolution" in TypeScript.
Select the correct answer
Module resolution in TypeScript is the process the compiler uses to find the actual location of modules.
Module resolution in TypeScript is the process of defining module types.
Module resolution in TypeScript is the process of handling async operations.
Module resolution in TypeScript is the process of managing state.
Explain the symbol type in TypeScript.
Select the correct answer
The symbol type in TypeScript is used for defining arrays.
The symbol type in TypeScript is used for string manipulation.
The symbol type in TypeScript is a primitive data type that represents a unique identifier.
The symbol type in TypeScript is a data type for storing numbers.
What is the difference between extends and implements in TypeScript?
Select the correct answer
The extends keyword in TypeScript is used for class inheritance, whereas implements is used to implement interfaces.
The extends keyword in TypeScript is used for creating arrays, whereas implements is used for object creation.
The extends keyword in TypeScript is used for function overloading, whereas implements is used for type assertions.
The extends keyword in TypeScript is used for variable declaration, whereas implements is used for function declarations.
What are namespaces in TypeScript?
Select the correct answer
Namespaces in TypeScript are used to create modules.
Namespaces in TypeScript are used for error handling.
Namespaces in TypeScript are used to define new types.
Namespaces in TypeScript are used to organize code into logical groups and prevent name collisions.
Name the two primary types of modules in TypeScript?
Select the correct answer
The two primary types of modules in TypeScript are global modules and local modules.
The two primary types of modules in TypeScript are synchronous modules and asynchronous modules.
The two primary types of modules in TypeScript are ES6 modules and CommonJS modules.
The two primary types of modules in TypeScript are class modules and function modules.
Explain modules in TypeScript.
Select the correct answer
Modules in TypeScript are used to organize code into reusable pieces.
Modules in TypeScript are used to define types.
Modules in TypeScript are a way to declare variables.
Modules in TypeScript are used for error handling.
What is an anonymous function in TypeScript?
Select the correct answer
An anonymous function in TypeScript is a function with a static keyword.
An anonymous function in TypeScript is a function that does not have a name.
An anonymous function in TypeScript is a function declared with the var keyword.
An anonymous function in TypeScript is a function that returns a boolean.
Explain the as const assertion in TypeScript.
Select the correct answer
The as const assertion in TypeScript ensures that the type of a value is a literal type.
The as const assertion in TypeScript converts a type to any.
The as const assertion in TypeScript makes a variable immutable.
The as const assertion in TypeScript is used to declare constants.
Explain the concept of "declaration files" in TypeScript.
Select the correct answer
Declaration files in TypeScript provide type information about JavaScript libraries to TypeScript.
Declaration files in TypeScript are used to configure the TypeScript compiler.
Declaration files in TypeScript are used for managing project dependencies.
Declaration files in TypeScript are a way to define custom types.
Explain the purpose of the "key remapping" feature in mapped types in TypeScript.
Select the correct answer
Key remapping in mapped types in TypeScript is a method for importing modules.
Key remapping in mapped types in TypeScript is a feature for handling asynchronous operations.
Key remapping in mapped types in TypeScript is used to define optional properties.
Key remapping in mapped types in TypeScript allows the keys of a type to be transformed during the creation of a new type.
What is the purpose of "string literal types" in TypeScript?
Select the correct answer
String literal types in TypeScript are types whose value is a specific string.
String literal types in TypeScript are used to define string arrays.
String literal types in TypeScript are types that can hold any string value.
String literal types in TypeScript are used to define enum values.
What is "type-safe nullish coalescing" in TypeScript?
Select the correct answer
Type-safe nullish coalescing in TypeScript is a method for error handling.
Type-safe nullish coalescing in TypeScript is used for strict null checks.
Type-safe nullish coalescing in TypeScript converts all null values to empty strings.
Type-safe nullish coalescing in TypeScript ensures that null or undefined values are handled safely.
What is meant by contextual typing?
Select the correct answer
Contextual typing in TypeScript is the process by which the compiler infers types based on the context of the code.
Contextual typing in TypeScript is a feature for importing modules.
Contextual typing in TypeScript is the process of defining custom types.
Contextual typing in TypeScript is used to handle asynchronous programming.
What is the Omit utility type in TypeScript?
Select the correct answer
The Omit utility type in TypeScript is used to define arrays.
The Omit utility type in TypeScript converts a type into a union type.
The Omit utility type in TypeScript makes all properties of a type optional.
The Omit utility type in TypeScript constructs a type by excluding certain properties from another type.
What is the Partial utility type in TypeScript?
Select the correct answer
The Partial utility type in TypeScript is used to define arrays.
The Partial utility type in TypeScript removes all properties of a type.
The Partial utility type in TypeScript converts a type into a union type.
The Partial utility type in TypeScript makes all properties of a type optional.
What is the purpose of the unknown type in TypeScript?
Select the correct answer
The unknown type in TypeScript represents a value that could be of any type but is more type-safe than any.
The unknown type in TypeScript is used for variables that are null or undefined.
The unknown type in TypeScript is used for defining constants.
The unknown type in TypeScript is used exclusively for arrays.
What is the purpose of noImplicitAny?
Select the correct answer
The noImplicitAny flag in TypeScript allows the use of any type without errors.
The noImplicitAny flag in TypeScript ensures that all variables have an explicit type.
The noImplicitAny flag in TypeScript is used to enable strict null checks.
The noImplicitAny flag in TypeScript allows implicit casting between types.
Explain the purpose of type predicates in TypeScript.
Select the correct answer
Type predicates in TypeScript are functions that return a boolean indicating the type of a variable.
Type predicates in TypeScript are used to declare types.
Type predicates in TypeScript are tools for debugging.
Type predicates in TypeScript are methods for importing modules.
Explain the concept of "recursive types" in TypeScript.
Select the correct answer
Recursive types in TypeScript are types used for async functions.
Recursive types in TypeScript are types that can be null or undefined.
Recursive types in TypeScript are types that reference themselves.
Recursive types in TypeScript are types that inherit from other types.
What is the "non-nullable assertion operator" (!) in TypeScript?
Select the correct answer
The non-nullable assertion operator (!) in TypeScript is used to import modules.
The non-nullable assertion operator (!) in TypeScript tells the compiler that a value is not null or undefined.
The non-nullable assertion operator (!) in TypeScript is used to declare constants.
The non-nullable assertion operator (!) in TypeScript is used for creating loops.
Explain the concept of discriminated unions in TypeScript.
Select the correct answer
Discriminated unions in TypeScript are used to handle errors.
Discriminated unions in TypeScript are unions with a common property used to distinguish between them.
Discriminated unions in TypeScript are used to define enums.
Discriminated unions in TypeScript are used for asynchronous programming.
What are distributive conditional types?
Select the correct answer
Distributive conditional types in TypeScript distribute a conditional type over a union type.
Distributive conditional types in TypeScript are used to define array types.
Distributive conditional types in TypeScript are a type of error handling.
Distributive conditional types in TypeScript are used for module imports.
What are "conditional types" in TypeScript?
Select the correct answer
Conditional types in TypeScript are used to define enums.
Conditional types in TypeScript are a type of error handling.
Conditional types in TypeScript are used to create optional parameters.
Conditional types in TypeScript allow for type selection based on a condition.
What is the purpose of keyof in TypeScript
Select the correct answer
The keyof keyword in TypeScript is used to get the keys of an object type.
The keyof keyword in TypeScript is used to declare dynamic properties.
The keyof keyword in TypeScript is used to import modules.
The keyof keyword in TypeScript is used to create new types.
What are mixins?
Select the correct answer
Mixins in TypeScript are used to style components.
Mixins in TypeScript are a way to create reusable code by combining multiple classes.
Mixins in TypeScript are a way to manage state.
Mixins in TypeScript are a type of module import.
What is optional chaining in TypeScript?
Select the correct answer
Optional chaining in TypeScript is used to declare optional variables.
Optional chaining in TypeScript is a method for error handling.
Optional chaining in TypeScript is used to create optional function parameters.
Optional chaining in TypeScript allows for the safe access of nested object properties.
What is void, and when to use the void type?
Select the correct answer
Void in TypeScript is used for error handling.
Void in TypeScript represents a type that can be anything.
Void in TypeScript represents the absence of a return value from a function.
Void in TypeScript represents a null value.
How does TypeScript handle asynchronous programming?
Select the correct answer
TypeScript handles asynchronous programming by automatically converting all functions to async.
TypeScript handles asynchronous programming with a special async keyword.
TypeScript handles asynchronous programming with only callback functions.
TypeScript handles asynchronous programming with promises, async/await syntax, and observables.
What are mapped types in TypeScript?
Select the correct answer
Mapped types in TypeScript create new types by transforming properties.
Mapped types in TypeScript are used for mapping URLs to components.
Mapped types in TypeScript are used to configure the TypeScript compiler.
Mapped types in TypeScript are used to manage project dependencies.
What are intersection types in TypeScript, and how do they differ from union types?
Select the correct answer
Intersection types in TypeScript combine multiple types into one.
Intersection types in TypeScript are used to define numeric arrays.
Intersection types in TypeScript are used for asynchronous programming.
Intersection types in TypeScript are used to create read-only properties.
What is a union type in TypeScript?
Select the correct answer
A union type in TypeScript is a method for error handling.
A union type in TypeScript allows a variable to be one of several types.
A union type in TypeScript is used for combining multiple interfaces.
A union type in TypeScript is a special type for handling numbers and strings together.
What is the null and undefined type in TypeScript?
Select the correct answer
In TypeScript, null and undefined are types that represent the absence of a value.
In TypeScript, null and undefined are types used for error handling.
In TypeScript, null and undefined are types that represent zero and empty string.
In TypeScript, null and undefined are types that represent boolean values.
What is strict mode in TypeScript?
Select the correct answer
Strict mode in TypeScript is a set of type-checking options that ensure more robust code.
Strict mode in TypeScript is used to enforce strict naming conventions.
Strict mode in TypeScript enables runtime type checking.
Strict mode in TypeScript is used for optimizing code performance.
What is an enum in TypeScript.
Select the correct answer
An enum in TypeScript is a way of defining named constants.
An enum in TypeScript is a syntax for creating classes.
An enum in TypeScript is a data type for storing arrays.
An enum in TypeScript is used to define environment variables.
Explain the never type in TypeScript.
Select the correct answer
The never type in TypeScript represents null and undefined values.
The never type in TypeScript represents a type that can be anything.
The never type in TypeScript is used for declaring global variables.
The never type in TypeScript represents values that never occur.
Explain what tuples are TypeScript.
Select the correct answer
Tuples in TypeScript are objects with dynamic properties.
Tuples in TypeScript are arrays with a fixed number of elements of specified types.
Tuples in TypeScript are classes with multiple inheritance.
Tuples in TypeScript are functions that return multiple values.
How can a class constant be implemented in TypeScript?
Select the correct answer
A class constant can be implemented using the static keyword in TypeScript.
A class constant can be implemented using the const keyword in TypeScript.
A class constant can be implemented using the readonly keyword in TypeScript.
A class constant can be implemented using the private keyword in TypeScript.
What is a type guard in TypeScript, and how does it help narrow down types?
Select the correct answer
A type guard is a debugging tool in TypeScript.
A type guard is a function that determines if a variable is of a specific type, helping to narrow down types in TypeScript.
A type guard is used to secure TypeScript applications from hacking.
A type guard is a syntax error detector in TypeScript.
Explain the difference between interface and type alias in TypeScript.
Select the correct answer
Interfaces are used for creating instances, and type aliases are used for importing modules.
Interfaces are used for managing state, and type aliases are used for routing.
Interfaces are used for styling components, and type aliases are used for database connections.
Interfaces define a contract for a structure, whereas type aliases can define primitive types, union types, and tuples.
What are TypeScript decorators?
Select the correct answer
TypeScript decorators are used to style components.
TypeScript decorators are special types of declarations that can be attached to a class, method, accessor, property, or parameter.
TypeScript decorators are used to configure the TypeScript compiler.
TypeScript decorators are used to create private methods.
What is the as keyword used for in TypeScript?
Select the correct answer
The as keyword is used to import modules.
The as keyword is used for type assertions in TypeScript.
The as keyword is used to create asynchronous functions.
The as keyword is used to declare static variables.
What is the any type in TypeScript, and when should you use it?
Select the correct answer
The any type in TypeScript is used when you want to disable type checking for a variable.
The any type in TypeScript is used exclusively for numbers.
The any type in TypeScript is used for functions returning strings.
The any type in TypeScript is used to declare arrays only.
Explain what type inference is in TypeScript.
Select the correct answer
Type inference is the process of converting JavaScript to TypeScript.
Type inference is a feature to suggest variable names in TypeScript.
Type inference is the act of debugging type errors in TypeScript.
Type inference is the ability of the TypeScript compiler to automatically deduce types.
Can TypeScript be used for the backend?
Select the correct answer
Yes, TypeScript can be used for backend development using Node.js.
Yes, but it requires a special compiler.
No, TypeScript does not support backend features.
No, TypeScript is only for frontend development.
What is TSX?
Select the correct answer
TSX stands for TypeScript XML and is used for embedding XML in TypeScript.
TSX is a testing framework for TypeScript applications.
TSX is a type of stylesheet used in TypeScript.
TSX is a database query language for TypeScript.
What is the use of the tsconfig.json file?
Select the correct answer
It is used to set up a testing framework.
It is used to manage project dependencies.
It is used to define environment variables for Node.js.
It is used to configure TypeScript compiler options.
Name the access modifiers supported in TypeScript.
Select the correct answer
protected, private, static, and final.
public, private, default, and static.
public, protected, default, and final.
public, private, protected, and readonly.
Define static typing.
Select the correct answer
A method of overloading functions in JavaScript.
A system where variables are checked at runtime.
A typing system used exclusively for dynamic languages.
A type system where types are checked at compile time.
What is TypeScript?
Select the correct answer
A library for managing state in React applications.
A framework for building mobile applications.
A database management system.
A strongly typed superset of JavaScript that compiles to plain JavaScript.