Skip to main content

102 docs tagged with "TS Syntax"

View All Tags

!snippet Object-as-Record

!snippet Object-as-Record. Topics on: ; semicolon separated interface for Object-as-Record, , comma separated interface for Object-as-Record. Read more: JS, T

!snippet Typed Interface

!snippet Typed Interface. Topics on: use an interface to define type of object, use interface to annotate class instance. Read more: JS, TS, TS Syntax, Type, Ba

!snippet Typed Rest Parameter

!snippet Typed Rest Parameter. Topics on: . Read more: JS, TS, TS Syntax, Type, Base Type, Function Type, Typed Rest Parameter|FullStack Wiki by Roger J

.d.ts

.d.ts is defined as: TS declaration/definition file. Topics on: . Read more: JS, TS, TS Syntax, Modules TS, Dts|FullStack Wiki by Roger J

.tsx

.tsx is defined as: TS implementation file with JSX. Topics on: . Read more: JS, TS, TS Syntax, Modules TS, Tsx, JSX|FullStack Wiki by Roger J

{ useSelector }

{ useSelector }. Topics on: by default state: unknown, no communication from redux to react, requires manual config, does not know type of data in store. Read m

actionCreators

actionCreators. Topics on: . Read more: JS, TS, TS Syntax, TS With React, Add Use Ref With Types, TS Redux, Create Typed Custom Hooks, Action Creators| Dev Wiki

add types to event handlers

add types to event handlers. Topics on: type inference only applies to inline JSX, mouse hover inline event prop to get copy-paste correct event type auto-infer

add useRef() with types

add useRef() with types. Topics on: Fix by add <HTMLInputElement>, alt+click HTMLInputElement to see other HTML element types - assign relevant element type dep

Alias

Alias is defined as: custom Type to store & reuse Type Annotation & improve Readability. Topics on: type. Read more: JS, TS, TS Syntax, Type, Compound Type, Ali

Angle Bracket Notation

Angle Bracket Notation is defined as: <> Type Expression to define Generic Type Placeholder. Topics on: . Read more: JS, TS, TS Syntax, Type, Type Annotation, A

any

any is defined as: (default) untyped anonymous Type, can be literally anything. Topics on: any is bad because TSC is unable to do any type-checking. Read more:

Array

Array is defined as: TS Extended Type for Array. Topics on: CAPITAL Array NOT array, default JS: typeof [] === 'object', List, Tuple, TS annotate the following

ASU

ASU is defined as: Arbitrary # Same type Unkown names. Topics on: . Read more: JS, TS, TS Syntax, Type, Base Type, Typed Object, Interface, Dictionary, ASU|Wiki

Base Type

Base Type. Topics on: set, Top Type, any, unknown, void, never, Typed Object, enum, Function Type, Typed Classes, Numeric Literal Type, String Literal Type, Arr

bottom type

bottom type is defined as: empty Type set to match nothing but itself; never. Topics on: . Read more: JS, TS, TS Syntax, Type, Base Type, Never, Bottom Type, Se

combineReducers

combineReducers. Topics on: export type RootState, create type for reducers which will be used to add type to hooks such as useSelector. Read more: JS, TS, TS S

Compound Type

Compound Type is defined as: Combo Type of 2+ Basic Types via & or | Type Operator. Topics on: Alias, Union Type, Intersection Type, Mapped Type. Read more:

Computed Enum Member

Computed Enum Member is defined as: Enum Member initialized via arbitrary Expression. Topics on: . Read more: JS, TS, TS Syntax, Type, Base Type, Enum, Enum Mem

Constant Enum Member

Constant Enum Member is defined as: Enum Member initialized via Expression, result computed at Compile Time. Topics on: . Read more: JS, TS, TS Syntax, Type, Ba

Create TS Redux File Structure

Create TS Redux File Structure. Topics on: . Read more: JS, TS, TS Syntax, TS With React, Add Use Ref With Types, TS Redux|FullStack Wiki by Roger J

Create Typed Custom Hooks

Create Typed Custom Hooks. Topics on: actionCreators, useActions(), useTypedSelector(). Read more: JS, TS, TS Syntax, TS With React, Add Use Ref With Types, TS

Creating project

Creating project. Topics on: using NPM to CRA new react-typescript app, using yarn to create new react-typescript app, create TS files based on JSX, MUST use .t

Decorator

Decorator. Topics on: . Read more: JS, TS, TS Syntax|FullStack Wiki by Roger J

Def interface for props

Def interface for props. Topics on: names & types defined in Child, TS checks Child receiving correct named & typed prop, TS checks Parent provides correct prop

DefinitelyTyped

DefinitelyTyped is defined as: 💀defunct Software Repository & search engine for 3rd party .d.ts - !deprecated since package repos now include type definitions

Dictionary

Dictionary is defined as: Object with ASU arbitrary # properties with same type & unknown names (at Compile Time). Topics on: ASU. Read more: JS, TS, TS Syntax,

Discriminated Union

Discriminated Union is defined as: Union Type with overlapping property of different values. Topics on: Discriminant. Read more: JS, TS, TS Syntax, Type, Compou

enum

enum is defined as: Enumerated set of named constants Type. default numbered. optional string member assign via =. Topics on: Numeric Enum, each enum member has

enum Design Pattern

enum Design Pattern. Topics on: Enum Bit Patterns (12.4.1), enum to group constants, nested under same namespace, enum for more descriptive alternative to boole

Enum Member

Enum Member is defined as: Name & Value pair of enum. Topics on: Member Definition, Literal Enum Member, Constant Enum Member, Computed Enum Member. Read more:

export type RootState

export type RootState. Topics on: . Read more: JS, TS, TS Syntax, TS With React, Add Use Ref With Types, TS Redux, Combine Reducers, Export Type Root State|Wiki

Function Overload

Function Overload is defined as: Design Pattern to reuse multiple versions of same function with various Function Signature. Topics on: Overload Signature, Func

Function Signature

Function Signature is defined as: Type Annotation to define function I/O. Topics on: Types, return value, method modifiers, Parameter. Read more: JS, TS, TS Syn

Function Type

Function Type is defined as: Type to annotate Methods & Callback Function with implicit return of any. Topics on: use function type annotations to, use ': void'

Generic Type

Generic Type is defined as: factory for Types, defined using Angle Bracket Notation, to annotate with Generic Type Placeholder for TSC to infer & fill in. Topic

Generic Type Parameter

Generic Type Parameter is defined as: (convention to use) single uppercase character for Generic Type Parameter. Topics on: . Read more: JS, TS, TS Syntax, Gene

Generic Type Placeholder

Generic Type Placeholder. Topics on: . Read more: JS, TS, TS Syntax, Generics, Generic Type, Generic Type Placeholder|FullStack Wiki by Roger J

Generic Type Variable

Generic Type Variable is defined as: special Variable that works on Types instead of Values. Topics on: . Read more: JS, TS, TS Syntax, Generics, Variable, Type

Generics

Generics is defined as: generic (algebraic) placeholder to work with any variety of Types, but allow Type Inference to catch specific Type. Topics on: Generics

implements?

implements?. Topics on: makes sure class implements interface, checks all props qualify, invert dependency and make sure other input classes satisfy arg params,

Index Signature

Index Signature is defined as: TS Syntax to express Dictionary with arbitrary key map to value. Topics on: . Read more: JS, TS, TS Syntax, Type, Base Type, Type

Initializer

Initializer is defined as: Value assigned to Enum Member name. Topics on: can omit Enum Member Initializer for first Enum Member (defaults to zero) || if previo

interface

interface is defined as: Type to define Object shape & behavior blueprint. Topics on: use Interface to Type Object as either Record or Dictionary, Record, Dicti

Intersection Type

Intersection Type is defined as: Compound Type to merge via & Type Operator to express Type as being ALL of Type set. Topics on: Intersection Type related to

List

List is defined as: Array with sequence of same Type elements & variable length. Topics on: Array List Type Expression let arr1: number[] = [1,2,3];, Array Lis

Literal Enum Member

Literal Enum Member is defined as: Enum Member with Initializer either explicitly initialized via number/string Literal | omitted Initializer (implicit value).

Member Definition

Member Definition is defined as: Assign Initializer value as Enum Member, inside enum via = operator. Topics on: Initializer, !convention to name Enum Member wi

method modifiers

method modifiers. Topics on: public, static, prototype. Read more: JS, TS, TS Syntax, Type, Base Type, Function Type, Function Overload, Function Signature|Wiki

Modules & TS

Modules & TS. Topics on: .ts, .tsx, .d.ts, some libraries already include type definition files, most popular libraries have type definition files created, acce

namespace

namespace is defined as: TS Syntax to group related Source Code (mainly for API). Topics on: namespaces in TS previously referred to as 'internal modules'. Read

Narrow

Narrow is defined as: to reduce static type T to a (narrowed down) subset of T. Topics on: . Read more: JS, TS, TS Syntax, Type Guard, Narrow | Full-Stack Wiki

never

never is defined as: bottom type to rep values never observed (or never return from function). Topics on: bottom type, functions that throw Exception or always

Numeric Enum

Numeric Enum is defined as: enum with number as member value. Topics on: numeric enum signature. Read more: JS, TS, TS Syntax, Type, Base Type, Enum, Numeric En

Numeric Literal Type

Numeric Literal Type is defined as: fixed set of specific values for number as Type. Topics on: All numbers (except bigint) are of FP64 integers. Read more: JS,

Object Literal Type

Object Literal Type is defined as: Type Annotation for Object Literal, use for inline anon Object pass as Argument. Topics on: Anonymous Interface, Anonymous Ty

Object Optional Property

Object Optional Property is defined as: ?: Type Annotation to mark optional object property. Topics on: . Read more: JS, TS, TS Syntax, Type, Base Type, Typed

Overload Signature

Overload Signature is defined as: Function Signature with Type annotations but w/o implementation. Topics on: Overload Signature common in API type definition f

Parameter

Parameter is defined as: Variable pass into function to define Function Signature, imports Arguments & act as local variable. Topics on: !differs vs Argument wh

Parameter Default Value

Parameter Default Value is defined as: JS Syntax used to specify default Value for a Parameter if not provided. Topics on: . Read more: JS, TS, TS Syntax, Type

private

private is defined as: JS Keyword & Property Modifier to restrict Method to within class only. Topics on: why use private modifier?. Read more: JS, TS, TS Synta

Private Constructor

Private Constructor is defined as: Constructor Function prepend with private to restrict access to within class, prevent Instantiation with new. Topics on: . Re

Property Modifier

Property Modifier is defined as: TS Syntax to specify property's Type, if optional? & if writable?. Topics on: readonly, Typed Optional Parameter. Read more: JS

props literal

props literal. Topics on: TS does not know this is a React Component - default properties will not register. Read more: JS, TS, TS Syntax, TS With React, TS Rea

protected

protected is defined as: Property Modifier to restrict Method to class or child classes. Topics on: child classes can not overwrite (non-public) modifiers in pa

public

public is defined as: (default) Property Modifier for Methods, callable anywhere. Topics on: can be used to shorten assignment:Can be shortened to. Read more: J

React.FC

React.FC is defined as: const MyApp: React.FC<ChildProps> = ({ color }) ⇒ {. Topics on: TS will know this is a React Functional Component - default properties w

readonly

readonly is defined as: Property Modifier JS Keyword to set Object property as read-only. Topics on: !snippet interface with readonly prop. Read more: JS, TS, T

Record

Record is defined as: Object with fixed number of known named properties & any Type before Compile Time. Topics on: !snippet Object-as-Record. Read more: JS, TS

ReturnType

ReturnType. Topics on: ReturnType<type of *>. Read more: JS, TS, TS Syntax, TS Operators|FullStack Wiki by Roger J

set

set is defined as: (maths concept) collection of distinct things. Topics on: . Read more: JS, TS, TS Syntax, Type, Base Type, Set|FullStack Wiki by Roger J

Singleton

Singleton is defined as: TS Syntax Pattern to ensure exactly only one object instance of a class, using Private Constructor & Static Method. Topics on: . Read m

String Enum

String Enum is defined as: enum with string as member values. Topics on: . Read more: JS, TS, TS Syntax, Type, Base Type, Enum, String|FullStack Wiki by Roger J

String Literal Type

String Literal Type is defined as: fixed set of specific values for string as types. Topics on: . Read more: JS, TS, TS Syntax, Type, Base Type, Set, String

Top Type

Top Type is defined as: universal (super-) Type assignable to any Variable. Topics on: any & unknown are Top Types, !contrast bottom type, any used for output o

TS Keyword

TS Keyword. Topics on: . Read more: JS, TS, TS Syntax|FullStack Wiki by Roger J

TS Operators

TS Operators. Topics on: ReturnType. Read more: JS, TS, TS Syntax, TS Operators|FullStack Wiki by Roger J

TS React Syntax

TS React Syntax. Topics on: fix the following errorconst [names, setNames] = useState<string[]>([]) setNames([...names, 'bob']), React.FC, props literal, Refact

TS Redux

TS Redux. Topics on: Create TS Redux File Structure, switch acts as type guard, define interface per action, removes need for action types, add enum for action

TS Syntax

TS Syntax is defined as: List of typescript keywords, syntax, coding patterns, etc. Topics on: Type, Generics, TS Keyword, Decorator, namespace, Modules & TS, T

TS with React

TS with React. Topics on: Def interface for props, add types to state in component, add types to event handlers, add useRef() with types, TS React Syntax, Creat

Tuple

Tuple is defined as: Array with fixed length & fixed element Type. Topics on: Tuple Type used to distinguish from Array Literal which TSC infers as List, Tuple

Type

Type is defined as: shape & behaviour of data to rep set of values. Topics on: Base Type, Compound Type, Type Assignment, Type Annotation, Type Expression. Read

Type Annotation

Type Annotation is defined as: TS Syntax to annotate Variables with Types. Topics on: Angle Bracket Notation, Type Annotation provide Syntactic Sugar for checki

Type Assertion

Type Assertion is defined as: TS Syntax to override TSC's Type Inference for Static Type of specific Value. Topics on: Type Assertion removes Static Type safety

Type Expression

Type Expression is defined as: TS Syntax evalue to Type, after : || inside Angle Bracket Notation. Topics on: Type Expression can use default JavaScript dynam

Type Guard

Type Guard is defined as: Runtime Type-Check to Narrow Type of Variable. Topics on: Type Guard used when Type too general, requires Narrow, typeof & instanceof

Type Operator

Type Operator is defined as: TS Syntax for built-in operation on Types. Topics on: typeof, keyof, Set Operator Intersection, as. Read more: JS, TS, TS Syntax, T

Type Variable

Type Variable is defined as: One or more Type Variable introduced via Angle Bracket Notation. Topics on: . Read more: JS, TS, TS Syntax, Generics, Angle Bracket

Typed Callback Function

Typed Callback Function is defined as: Type Annotation for Anon Function pass as Argument to function. Topics on: . Read more: JS, TS, TS Syntax, Type, Base Typ

Typed Classes

Typed Classes. Topics on: Singleton, Private Constructor, TS annotate the following class let car: Car = new Car(). Read more: JS, TS, TS Syntax, Type, Base Typ

Typed Classes

Typed Classes. Topics on: Classes exist as both a value and a type, create instance of an object, refer to the object type, custom classes can restrict access t

Typed Object

Typed Object is defined as: Type to ref any non-Primitive; as Record or Dictionary. Topics on: Index Signature, Generic Object Types, TS annotate the following

Typed Rest Parameter

Typed Rest Parameter is defined as: TS Syntax for Rest Parameter which must always be of Type Array. Topics on: !snippet Typed Rest Parameter. Read more: JS, TS

Union Type

Union Type is defined as: Compound Type join by | Type Operator to define each member of Type set can EITHER be. Topics on: Discriminated Union. Read more: JS

unknown

unknown is defined as: Top Type to rep any value but also make it illegal to use (w/o Narrow). Topics on: //@ts-expect-error: Object is of Type 'unknown', unkno

use ': never' for functions that

use ': never' for functions that is defined as: should never complete execution. Topics on: rare use case - only for functions that always never complete execut

use function type annotations to

use function type annotations to. Topics on: def type of arguments params, def type of values returned. Read more: JS, TS, TS Syntax, Type, Base Type, Function

useActions()

useActions() is defined as: Custom Hook to bind actionCreators to Dispatch. Topics on: !refactors code by auto calling dispatch on actionCreators, no need to ty

useTypedSelector()

useTypedSelector() is defined as: Custom Hook var of useSelector() with fixed type annotations. Topics on: . Read more: JS, TS, TS Syntax, TS With React, Add Us

Variadic Tuple

Variadic Tuple is defined as: Tuple Type Annotation using Spread Operator or Rest Parameter, to define varying number of element types. Topics on: . Read more:

void

void is defined as: Type to rep no return value from function. Topics on: !technically default JS implicitly returns undefined, !techincally not allowed to anno