webdev/typescript

typescript

dz / webdev / typescript

Node Tree

Nodes

declaration_files
content Declaration Files in Typescript
children declaration_files_wikipedia
hyperlink https://www.typescriptlang.org/docs/handbook/declaration-files/introduction.html
location knowledge/typescript.dz:3

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.
location knowledge/typescript.dz:7

discriminant_property
content Discriminant Property: a common property found amongst types in a discriminated union.
parents discriminated_union
location knowledge/typescript.dz:15

function_overloading
content Function Overloading
children overload_signature, implementation_signature
location knowledge/typescript.dz:20

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.
location knowledge/typescript.dz:23

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.
location knowledge/typescript.dz:33

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.
location knowledge/typescript.dz:44

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.
location knowledge/typescript.dz:56

generic_constraint
content Generic Constraint =function stuff<Type extends foo>(arg: Type)=
hyperlink https://www.typescriptlang.org/docs/handbook/2/generics.html#generic-constraints
flashcard (front) what does generic constraint syntax look like?
flashcard (back) =function stuff(arg: Type)=.
location knowledge/typescript.dz:63

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(a: T, b: U) { return [a, b]; }
location knowledge/typescript.dz:69

covariance_contravariance_wiki
content Covariance and Contravariance: wikipedia
parents covariance_contravariance, types/type_theory/polymorphism/subtyping/covariance_contravariance
remarks found while reading typescript handbook
hyperlink https://en.wikipedia.org/wiki/Covariance_and_contravariance_(computer_science)
location knowledge/typescript.dz:75

covariance_contravariance
content Covariance and contravariance: type theory terms describing the relationship between two generic types.
children covariance_contravariance_wiki (more information)
parents types/type_theory/polymorphism/subtyping/covariance_contravariance
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 where Producer expected: Cat is an Animal, covariance. Consumer where Consumer expected: any function that is capable of accepting a Cat must also be capable of accepting an animal, contravariance.
location knowledge/typescript.dz:80

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.
location knowledge/typescript.dz:92

branded_types
content Branded Types
hyperlink https://www.learningtypescript.com/articles/branded-types
location knowledge/typescript.dz:101

typefest
content typefest: A collection of essential TypeScript types
hyperlink https://github.com/sindresorhus/type-fest/
location knowledge/typescript.dz:106

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;)
location knowledge/typescript.dz:110

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"].
location knowledge/typescript.dz:119

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;
location knowledge/typescript.dz:127

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 = T extends Array ? Item : T;
location knowledge/typescript.dz:135

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
location knowledge/typescript.dz:146

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 = { [Property in keyof Type]: boolean; };
location knowledge/typescript.dz:152

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.
location knowledge/typescript.dz:164

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
location knowledge/typescript.dz:174

instance_type
content InstanceType<Type>: constructs a type of a constructor function in =Type=.
hyperlink https://www.typescriptlang.org/docs/handbook/utility-types.html#instancetypetype
location knowledge/typescript.dz:183

abstract
content An abstract method or abstract field is one that hasn't had an implementation yet, and much exist inside of an abstract class
children abstract_vs_virtual_methods (abstract vs virtual methods)
hyperlink https://www.typescriptlang.org/docs/handbook/2/classes.html#abstract-classes-and-members
flashcard (front) What is the "abstract" keyword in typescript?
flashcard (back) An abstract method or abstract field is one that hasn't had an implementation yet, and must exist inside of an abstract class
location knowledge/typescript.dz:188

abstract_vs_virtual_methods
content Abstract methods force derived classes to override the method because there is no base implementation. Virtual methods have a fallback.
parents abstract
flashcard (front) What is the difference between virtual and abstract methods?
flashcard (back) Abstract methods do not have a fallback implementation, while virtual ones have a default. This means any derived class must implement an abstract method.
location knowledge/typescript.dz:198

declaration_files_wikipedia
content Declaration Files (wikipedia article)
parents declaration_files
remarks AKA .d.ts
hyperlink https://en.wikipedia.org/wiki/TypeScript#Declaration_files
location knowledge/typescript.dz:210

satisfies
content satisfies operator
hyperlink https://www.typescriptlang.org/docs/handbook/release-notes/typescript-4-9.html#the-satisfies-operator