typescript
dz / webdev / typescriptNode Tree
- generic_parameter_default
- template_literal_types
- excess_property_checking
- declaration_files
- covariance_contravariance
- discriminated_union
- indexed_access_type
- typefest
- conditional_types
- keyof
- branded_types
- typeof
- distributive_conditional_types
- generic_constraint
- identity_function
- function_overloading
Nodes
declaration_files | |
content | Declaration Files in Typescript |
hyperlink | https://www.typescriptlang.org/docs/handbook/declaration-files/introduction.html |
discriminated_union | |
content | Discriminated Union: When every type in a union contains a common property, and can narrow out the fields in the union. |
children | discriminant_property |
hyperlink | https://www.typescriptlang.org/docs/handbook/2/narrowing.html#discriminated-unions |
flashcard (front) | What is a discriminated union? |
flashcard (back) | A discriminated union happens when every type in a union contains a common property. |
discriminant_property | |
content | Discriminant Property: a common property found amongst types in a discriminated union. |
parents | discriminated_union |
function_overloading | |
content | Function Overloading |
children | overload_signature, implementation_signature |
overload_signature | |
content | overload signature: in function overloading, these are function signatures that specify the various overloads |
children | implementation_signature (overload signatures must be compatible with the,implementation signature) |
parents | function_overloading |
flashcard (front) | What is an overload signature? |
flashcard (back) | Overload signatures are used in the context of function overloading in typescript. They refer to the function signatures that define the various input parameter combinations. |
implementation_signature | |
content | Implementation Signature: the function signature below the overload signatures |
parents | function_overloading, overload_signature |
flashcard (front) | What is an implementation signature? |
flashcard (back) | In function overloading, the implementation signature is the function signature below the overload signatures. |
excess_property_checking | |
content | Excess Property Checking: an special check that typescript performs on object literals. If there are properties that the "target type" object literal doesn't have, an error will be produced. This sort of error would typically fail silently in JavaScript. |
hyperlink | https://www.typescriptlang.org/docs/handbook/2/objects.html#excess-property-checks |
flashcard (front) | What is excess property checking in typescript? |
flashcard (back) | excess property checking is a check performed on object literals, and will check for properties not in the target object literal. |
identity_function | |
content | Identity Function: "hello world" of generics, a function that will return back whatever it is passed in. |
hyperlink | https://www.typescriptlang.org/docs/handbook/2/generics.html#hello-world-of-generics |
flashcard (front) | What is the identity function? |
flashcard (back) | A function that will return back whatever it is passed in. |
generic_constraint | |
content | Generic Constraint =function stuff<Type extends foo>(arg: Type)= |
flashcard (front) | what does generic constraint syntax look like? |
flashcard (back) |
=function stuff |
generic_parameter_default | |
content | Generic Parameter Default: by providing default values, generic parameters can be optional. |
flashcard (front) | What is an example of using default generic parameters? |
flashcard (back) |
function foo |
covariance_contravariance_wiki | |
content | Covariance and Contravariance: wikipedia |
parents | covariance_contravariance |
remarks | found while reading typescript handbook |
hyperlink | https://en.wikipedia.org/wiki/Covariance_and_contravariance_(computer_science) |
covariance_contravariance | |
content | Covariance and contravariance: type theory terms describing the relationship between two generic types. |
children | covariance_contravariance_wiki (more information) |
hyperlink | https://www.typescriptlang.org/docs/handbook/2/generics.html#variance-annotations |
flashcard (front) | what is an example of covariance and contravariance? |
flashcard (back) |
Producer |
keyof | |
content | keyof: operator that takes in an object type and produces a string or numeric union of its keys. |
children | mapped_types (typically uses a union of PropertyKey's made via keyof) |
remarks | ex: Point = {x: number; y: number}; type P = keyof Point; P is equivalent to Type P = "x" | "y"; |
flashcard (front) | What is the "keyof" operator? |
flashcard (back) | The keyof operator in typescript takes in an object, and produces a union of its keys. |
branded_types | |
content | Branded Types |
hyperlink | https://www.learningtypescript.com/articles/branded-types |
typefest | |
content | typefest: A collection of essential TypeScript types |
hyperlink | https://github.com/sindresorhus/type-fest/ |
typeof | |
content | typeof operator: previously defined in javascript, typeof extends this operator so it can be used in a type context to refer to the type of a variable or property |
hyperlink | https://www.typescriptlang.org/docs/handbook/2/typeof-types.html |
flashcard (front) | what is the "typeof" operator (in TypeScript)? |
flashcard (back) | The typeof operator can be used to refer to the type of variable or property. (ex: let s = "hello"; let n: typeof s;) |
indexed_access_type | |
content | indexed access type: used to look up the specific property of a type. ex: Age = Person["age"]. |
hyperlink | https://www.typescriptlang.org/docs/handbook/2/indexed-access-types.html |
flashcard (front) | What is indexed access type? |
flashcard (back) | In typescript, is notation used to look up a specific property of a type. ex: Age = Person["age"]. |
conditional_types | |
content | Conditional Types: help describe the relation between the types of inputs and outputs. |
children | infer (used with) |
hyperlink | https://www.typescriptlang.org/docs/handbook/2/conditional-types.html |
flashcard (front) | What is a conditional type? |
flashcard (back) | Conditional types help describe the relation between types of inputs and outputs. Syntax: Dog extends Animal ? number : string; |
infer | |
content | Infer keyword: can be used with conditional types to infer from types compared against in the true branch. ex: type Flatten<T> = T extends Array<infer Item> ? Item : T; |
parents | conditional_types |
hyperlink | https://www.typescriptlang.org/docs/handbook/2/conditional-types.html#inferring-within-conditional-types |
flashcard (front) | What is the infer keyword? |
flashcard (back) |
The infer keyword can be used to infer types in conditional type expressions. Ex: type Flatten |
distributive_conditional_types | |
content | Distributive Conditional Types: Occurs a union is passed into a conditional type. It maps over each member type in the union. |
hyperlink | https://www.typescriptlang.org/docs/handbook/2/conditional-types.html#distributive-conditional-types |
mapped_types | |
content | mapped types: generic type which uses a union of PropertyKeys (frequently via a keyof) to iterate through keys to create a type |
children | as |
parents | keyof |
hyperlink | https://www.typescriptlang.org/docs/handbook/2/mapped-types.html#mapping-modifiers |
flashcard (front) | What is a mapped type? |
flashcard (back) |
A generic type which uses a union of PropertyKeys (via keyof usually) to iterate through keys to create a type. ex type OptionsFlag |
as | |
content | as keyword: used to remap keys in mapped types. ex: type MappedTypeWithNewProperties<Type> = { [Property in keyof Type as NewKeyType]: Type[Property]; } |
parents | mapped_types |
hyperlink | https://www.typescriptlang.org/docs/handbook/2/mapped-types.html#key-remapping-via-as |
flashcard (front) | what is the 'as' keyword? |
flashcard (back) | The 'as' keyword is used to remap keys in mapped types. |
template_literal_types | |
content | template literal types: types built on string literal types, using the same syntax as template literal strings in javascript. |
children | javascript/template_literals (typescript template literals use the same,javascript syntax for string template literals) |
hyperlink | https://www.typescriptlang.org/docs/handbook/2/template-literal-types.html |
flashcard (front) | what are template literal types? |
flashcard (back) | Types built on string literal types, using the same syntax as javascript template literal strings |