Buscar
Estás en modo de exploración. debe iniciar sesión para usar MEMORY

   Inicia sesión para empezar

TypeScript


🇬🇧
In Inglés
Creado:
TypeScript


Public
Creado por:
John Pencola


0 / 5  (0 calificaciones)



» To start learning, click login

1 / 25

[Front]


What type will TypeScript infer for "age"?

const age = 6

[Back]


6 

Because the age variable is a const, it is the most specific type TypeScript can associate with it.


Practique preguntas conocidas

Manténgase al día con sus preguntas pendientes

Completa 5 preguntas para habilitar la práctica

Exámenes

Examen: pon a prueba tus habilidades

Modo de examen no disponible

Aprenda nuevas preguntas

Modos dinámicos

InteligenteMezcla inteligente de todos los modos
PersonalizadoUtilice la configuración para ponderar los modos dinámicos

Modo manual [beta]

Seleccione sus propios tipos de preguntas y respuestas
Modos específicos

Aprende con fichas

TypeScript - Marcador

El propietario del curso ha desactivado la visibilidad pública de la tabla de clasificación de este curso.


TypeScript - Detalles

Niveles:

Preguntas:

27 preguntas
🇬🇧🇬🇧
What type will TypeScript infer for "age"? const age = 6
6 Because the age variable is a const, it is the most specific type TypeScript can associate with it.
What are the two key parts of Object type definitions?
1. The names of the properties that are (or may be) present 2. The types of those properties
Put into words what an index signature is useful for.
Index signatures are used to describe the type of a key used to retrieve an object when working with dictionaries.
When would a literal type be used?
For allowing an exact value which a string, number, or boolean must have. e.g., const constantString = "Hello World"
What is the basic rule for TypeScript's structural type system?
X is compatible with y if y has at least the same members as x. interface Pet { name: string; } let pet: Pet; // dog's inferred type is { name: string; owner: string; } let dog = { name: "Lassie", owner: "Rudd Weatherwax" }; pet = dog;
What is this type called? type TrafficLight = CanCross | ShouldStop;
Union Remember: it is either a value of type X or of type Y
What is this type called? type Foo = A & B;
Intersection Remember: It is a value that is simultaneously of type A and B
How would you rewrite this function to be generic without using "any"? function identity(arg: any): any { return arg }
By using generic type-parameters function identity<T>(arg: <T>): <T> { return arg }
What issue does TypeScript's excess property checking address?
Throws an error when using an object literal that has a property that does not exist in the type that the function expects, meaning there's no way to safely access the property later on.
What are three ways to fix an error about excess property checking?
1. Remove the excess property 2. Add the property to the function argument type 3. Create a variable to hold the value, and pass the variable (instead of the object literal) into the function
Define a tuple.
A multi-element, ordered data structure, where the position of each item has some special meaning or convention
What is the difference between nominal and structural type systems? Describe how this applies to type checking.
Nominal type systems are about names. Structural ones are about structure or shape. The type equivalence check on a function call checks whether the argument is an instance of a class of a given name if nominal. With structural, it doesn't care about which constructor its argument came from, only whether it has the necessary properties.
How do type aliases help address the complexity of many properties on a type?
1. Define a more meaningful name for the type 2. Declare the particulars of the type in a single place 3. Allows import and export of this type from modules
What are type guards?
Expressions which, when used with a control flow statement (e.g., instanceof), allow us to have a more specific type for a particular value