Types Reference
๐ท๏ธ Collection of TypeScript types shared across Lou Codes projects.
Usage
๐ฆ Node
Install @lou.codes/types
as a dependency:
Import as type and use it:
๐ฆ Deno
Import @lou.codes/types
using the npm:
prefix, and use it directly:
Useful links
- ๐ Documentation: TypeDoc generated documentation.
- โณ Changelog: List of changes between versions.
Array
ArrayLike
ฦฌ ArrayLike<Item
, Length
>:
ReadOnlyRecord
<NeverFallback
<Exclude
<Enumerate
<Length
>,
Length
>, number
>, Item
> & { length
: Length
}
An alternative for TypeScriptโs ArrayLike
type, with its type set to unknown
by default. It also makes it shallowly read-only.
Remarks
When working with optional types, having to type ArrayLike<unknown>
every time
gets annoying pretty fast. This type is a drop-in replacement for ArrayLike
,
with the only difference being that the type of the items is set to unknown
by
default.
Example
Type parameters
Name | Type | Description |
---|---|---|
Item | unknown | Type of the items in the array-like object. |
Length | extends number = number | - |
Empty
ฦฌ Empty: EmptyArray
|
EmptyRecord
|
EmptyString
Empty array, object or string.
Remarks
Union type of EmptyArray, EmptyRecord and EmptyString, to signify values that are empty.
Example
See
EmptyArray
ฦฌ EmptyArray: typeof EMPTY_ARRAY
Empty array.
Remarks
This is a type alias for an readonly empty array. Trying to access items on it will give a compile-time error.
Example
Entry
ฦฌ Entry<Key
, Value
>: readonly [key: Key, value: Value]
Entry couple [key, value]
.
Remarks
It is a tuple of two elements, the first one being the key and the second one being the value of an objectโs property.
Example
Type parameters
Name | Type | Description |
---|---|---|
Key | PropertyKey | Objectโs properties type. |
Value | unknown | Objectโs values type. |
EntryKey
ฦฌ EntryKey<Input
>: Input
[0
]
Key of an Entry.
Remarks
Util type to get the key of an Entry.
Example
See
Type parameters
Name | Type | Description |
---|---|---|
Input | extends Entry | Entry type. |
EntryOf
Object or array Entry.
Remarks
Get the Entry type out of an object or array.
Example
See
Type parameters
Name | Type | Description |
---|---|---|
Type | extends object | Object or array type. |
EntryValue
ฦฌ EntryValue<Input
>: Input
[1
]
Value of an Entry.
Remarks
Util type to get the value of an Entry.
Example
See
Type parameters
Name | Type | Description |
---|---|---|
Input | extends Entry | Entry type. |
Head
ฦฌ Head<Input
>:
HeadAndTail
<Input
>[0
]
Initial value of an ArrayLike
.
Remarks
Given a type argument (an ArrayLike
), this returns the type of the item in
index 0
.
Example
See
Type parameters
Name | Type | Description |
---|---|---|
Input | extends ArrayLike | ArrayLike value (such as Array or string ). |
HeadAndTail
ฦฌ HeadAndTail<Input
>: Input
extends readonly [head: infer HeadItem,
tail: infer TailItems] ? readonly [head: HeadItem, tail: TailItems] : Input
extends `${infer FirstCharacter}${infer RestOfString}` ? readonly [head:
FirstCharacter, tail: RestOfString] : Input
extends
EmptyArray
|
EmptyString
? readonly [head: undefined,
tail: Input] : readonly [head: Maybe<Input[number]>, tail: Input]
Get a couple with the head and tail types of an ArrayLike
.
Remarks
Given a type argument (an ArrayLike
), this returns a couple with the type of
the item in index 0
first, and the rest of the ArrayLike
after.
Example
See
Type parameters
Name | Type | Description |
---|---|---|
Input | extends ArrayLike | Input ArrayLike . |
Initial
ฦฌ Initial<Input
>:
InitialAndLast
<Input
>[0
]
Initial values of an ArrayLike
(omitting the last).
Remarks
Given a type argument (an ArrayLike
), this returns the type of the items from
the start of the ArrayLike
until the before to last item.
Example
See
Type parameters
Name | Type | Description |
---|---|---|
Input | extends ArrayLike | ArrayLike value (such as Array or string ). |
InitialAndLast
ฦฌ InitialAndLast<Input
>: Input
extends readonly [โฆ(infer
InitialItems), infer LastItem] ? readonly [initial: InitialItems, last:
LastItem] : Input
extends EmptyArray
|
EmptyString
? readonly [initial: Input,
last: undefined] : Input
extends `${infer FirstCharacter}${infer
RestOfString}` ? readonly [initial: `${RestOfString extends EmptyString ?
EmptyString : FirstCharacter}${Head<InitialAndLast<RestOfString>>}`, last:
`${RestOfString extends EmptyString ? FirstCharacter :
Last<RestOfString>}`] : readonly [initial: Input, last:
Maybe<Input[number]>]
Get a couple with the initial and last types of an ArrayLike.
Remarks
Given a ArrayLike, this returns a couple with the type of all items from the start until the item before last, and then the last.
Example
See
Type parameters
Name | Type | Description |
---|---|---|
Input | extends ArrayLike | Input ArrayLike . |
KeyOf
ฦฌ KeyOf<Type
>: Type
extends
ArrayLike
?
NeverFallback
<Just
<Exclude
<Partial
<Type
>["length"
],
Type
["length"
]>>, number
> : `${Exclude<keyof Type, symbol>}`
Generic key for either object or array.
Remarks
Type to represent the type of the key in an array or object. It automatically
omits symbol
keys from objects, and uses number
for arrays with dynamic
length
.
Example
Type parameters
Name | Type | Description |
---|---|---|
Type | extends object | Object or array type. |
Last
ฦฌ Last<Input
>:
InitialAndLast
<Input
>[1
]
Last value of an ArrayLike
.
Remarks
Type of the last character of a string or the last element of an array.
Example
See
Type parameters
Name | Type | Description |
---|---|---|
Input | extends ArrayLike | The input ArrayLike . |
MaybeEmpty
ฦฌ MaybeEmpty<Input
>: Either
<Input
,
Input
extends ReadOnlyArray
?
EmptyArray
: Input
extends string
?
EmptyString
: Input
extends
ReadOnlyRecord
?
EmptyRecord
: undefined
>
Creates an union of the given type with a possible โemptyโ value.
Remarks
This type is useful to make clear that we expect a possible empty value.
Example
See
Type parameters
Name | Description |
---|---|
Input | Type to unite with itโs empty counterpart. |
NotEmpty
ฦฌ NotEmpty<Type
>: Exclude
<Type
,
Empty
>
Type for a non-empty ArrayLike
, object
or string
.
Remarks
This type is useful for cases where you want to ensure that a value is not
empty. For example, if you have an array that should always have at least one
element, you could type it as NotEmpty<ArrayLike<ElementType>>
.
Example
See
Type parameters
Name | Type | Description |
---|---|---|
Type | extends ArrayLike | object | string | The type to check. |
ReadOnlyArray
ฦฌ ReadOnlyArray<Item
>: ReadonlyArray
<Item
>
An alternative for TypeScriptโs ReadonlyArray
type, with its type set to
unknown
by default.
Remarks
Thereโs already a native ReadonlyArray
type, but this type has a default type
parameter to make it easier to use when the type of an array is unknown
.
Example
Type parameters
Name | Type | Description |
---|---|---|
Item | unknown | Type of the items in the array. |
Reducer
Reducer/Folder function.
Remarks
Type to represent a folder/reducer unary function that takes an item and an accumulator something of the type of the accumulator.
Example
See
Type parameters
Name | Description |
---|---|
Item | Type of the items to reduce. |
Accumulator | Type of the accumulator/output. |
Tail
ฦฌ Tail<Input
>:
HeadAndTail
<Input
>[1
]
Last values of an ArrayLike (omitting the first).
Remarks
Type of the last items of an ArrayLike
, excluding the first item in said
ArrayLike.
Example
See
Type parameters
Name | Type | Description |
---|---|---|
Input | extends ArrayLike | Type of the array to get the tail. |
ValueOf
Generic key for either object or array.
Remarks
This type is used to get the type of the values in a collection (items of an
ArrayLike
or properties of a Record
).
Example
See
Type parameters
Name | Type | Description |
---|---|---|
Type | extends object | Object or array type. |
Common
Awaitable
ฦฌ Awaitable<Type
>: PromiseLike
<Type
> | Type
A value that might be coming from a Promise
.
Remarks
Union type useful when you want to accept both Promise
and non-Promise
for a
given type, both โawaitableโ.
Example
See
Type parameters
Name | Type | Description |
---|---|---|
Type | unknown | The type to await. |
Either
ฦฌ Either<Right
, Left
>: Right
| Left
Value that can be something or something else.
Remarks
Union type useful for cases where a value might be of one type or another. By
convention we use Right
for the โsuccessโ type and Left
for the error.
Example
Type parameters
Name | Description |
---|---|
Right | The โcorrectโ type. |
Left | The โerrorโ type. |
Falsy
ฦฌ Falsy: EmptyString
|
HTMLAllCollection
| Nullish
| 0
| 0n
|
false
Types that evaluates to false
in JS.
Remarks
Union type of the values that evaluate to false
in JavaScript. Due to
TypeScript type limitations NaN
canโt be included.
Example
See
JSONValue
ฦฌ JSONValue: Exclude
<Primitive
,
bigint
| symbol
| undefined
> |
ReadonlyArray
<JSONValue
> | {
[property: string]
: JSONValue
; }
Possible parsed JSON value.
Remarks
Following the JSON specification, the result of a JSON.parse
call can be one
of a given set of types. This type is a union of all of those types.
Example
See
Just
ฦฌ Just<Input
>: Exclude
<Input
, undefined
>
Excludes undefined
of a type union.
Remarks
Every now and then a type is possibly undefined
, this type gets rid of the
undefined
in the union.
Example
See
Type parameters
Name |
---|
Input |
Maybe
Value that can be undefined
.
Remarks
Union type useful for cases where a value might be undefined
, and provides a
simple way to express this in TypeScript. For example, the return type of a
function that returns a string
or undefined
could be typed as
Maybe<string>
.
Example
See
Type parameters
Name | Description |
---|---|
Input | The type of the value to make optional. |
NeverFallback
ฦฌ NeverFallback<MaybeNever
, Fallback
>:
Single
<MaybeNever
> extends
Single
<never
> ? Fallback
: MaybeNever
Takes a value that could be never
, and if it is never
it goes to the
Fallback
value.
Remarks
There are some scenarios where a value can end up being of type never
, this
works sorta like the the ??
operator, but for never
.
Example
See
Type parameters
Name | Description |
---|---|
MaybeNever | The type that may or may not be never . |
Fallback | The fallback type to use if MaybeNever is never . |
Nullish
ฦฌ Nullish: Maybe
<null
>
Nullish value (either null
or undefined
).
Remarks
This type is useful for cases where a value might be null
or undefined
,
generally meant to be dealt with using the ??
operator.
Example
See
Primitive
Valid JavaScript primitives.
Remarks
This type is a union of all the valid JavaScript primitives, including null
,
undefined
, boolean
, number
, bigint
, string
, and symbol
.
Example
See
Replace
ฦฌ Replace<Type
, Keys
, NewType
>: Omit
<Type
, Keys
> & {
readonly [Property in Keys]: NewType }
Intersection that replaces the type of some keys in given object type.
Remarks
Intersection type to replace all the given keys of an object type with a new type.
Example
Type parameters
Name | Type | Description |
---|---|---|
Type | extends object | Type to replace the type of some keys in. |
Keys | extends keyof Type | Keys to replace the type of. |
NewType | NewType | New type to replace the old type with. |
Single
ฦฌ Single<Type
>: readonly [single: Type]
Tuple of length 1 (AKA Monuple).
Remarks
Tuple with a single element on it, useful when doing optional types that compare
to never
.
Example
Type parameters
Name | Description |
---|---|
Type | Type of the single element. |
Strigifiable
ฦฌ Strigifiable: Exclude
<Primitive
,
symbol
>
Values that can be stringified.
Remarks
Type to represent all values that can be stringified, all primitives excluding
symbol
: string
, number
, bigint
, boolean
, undefined
, and null
.
Example
See
Truthy
ฦฌ Truthy<Type
>: Exclude
<Type
, Falsy
>
Excludes all Falsy values of the given Type.
Remarks
Type to represent all values of the given Type that are not
Falsy. If all types are
Falsy, the result is never
.
Example
See
Type parameters
Name | Type | Description |
---|---|---|
Type | unknown | Type to exclude Falsy values from. |
TypeOfDictionary
ฦฌ TypeOfDictionary: Object
typeof
dictionary.
Remarks
Dictionary of types and their typeof
values, including the proposed but never
added type "null"
for null
.
Example
See
Type declaration
Name | Type | Description |
---|---|---|
bigint | bigint | TypeOfDictionary key for BigInt |
boolean | boolean | TypeOfDictionary key for Boolean |
function | Function | TypeOfDictionary key for Function |
null | null | TypeOfDictionary key for null |
number | number | TypeOfDictionary key for Number |
object | object | TypeOfDictionary key for Object |
string | string | TypeOfDictionary key for String |
symbol | symbol | TypeOfDictionary key for Symbol |
undefined | undefined | TypeOfDictionary key for undefined |
TypeOfValue
ฦฌ TypeOfValue:
KeyOf
<TypeOfDictionary
>
Possible type values returned by typeof
.
Remarks
Type to represent the possible values returned by typeof
, including the
proposed but never added type "null"
for null
.
Example
See
Unbound
ฦฌ Unbound<Type
>: Type
extends ReadonlyArray
<infer Item> ? {
[Property in keyof ReadonlyArray<Item>]: ReadonlyArray<Item>[Property]
extends Function ? Function : ReadonlyArray<Item>[Property] } : { [Property
in keyof Type]: Type[Property] extends Function ? Function : Type[Property] }
Type that replaces adds the this: void
argument to all the methods in the
given Type
.
Remarks
This type is used when the unbound of all methods is automated.
Example
Type parameters
Name | Type | Description |
---|---|---|
Type | unknown | Type to be unbounded. |
Date
DayOfMonth
ฦฌ DayOfMonth: Range
<1
, 31
>
Day of the month values in numeric format (from 1
to 31
).
Remarks
Stricter than number
type for day of the month values, limited to valid values
from 1
to 31
, and giving type errors otherwise.
Example
See
DayOfWeek
ฦฌ DayOfWeek: Enumerate
<6
>
Day of the week values in numeric format (from 0
to 6
).
Remarks
Stricter than number
type for day of the week values, limited to valid values
from 0
to 6
, and giving type errors otherwise.
Example
See
Hours
ฦฌ Hours: Enumerate
<23
>
Hours values in numeric format (from 0
to 23
).
Remarks
Stricter than number
type for hour values, limited to valid values from 0
to
23
, and giving type errors otherwise.
Example
See
ISODate
ฦฌ ISODate: `${ISOYear}-${ISOMonth}-${ISODayOfMonth}T${MultiDigitNumberString}:${MultiDigitNumberString}:${MultiDigitNumberString}.${MultiDigitNumberString}Z`
String representing an ISO date.
Remarks
This type is a string representing an ISO 8601 format of a date (returned by
Date#toISOString
). It uses
MultiDigitNumberString because the
type complexity using better types is too hight.
Example
See
ISODayOfMonth
ฦฌ ISODayOfMonth: `0${Exclude<Digit, 0>}` | `${1 | 2}${Digit}` | `3${Enumerate<1>}`
Day of the month values in string format ("01"
to "31"
).
Remarks
Union type stricter than string
type for day of the month values, limited to
valid values from "01"
to "31"
, and giving type errors otherwise.
Example
See
ISOHours
ฦฌ ISOHours: `${Enumerate<1>}${Digit}` | `2${Enumerate<3>}`
Hours values in string format (from "00"
to "23"
).
Remarks
Union type stricter than string
type for hour values, limited to valid values
from "00"
to "23"
, and giving type errors otherwise.
Example
See
ISOMilliseconds
ฦฌ ISOMilliseconds: `${Digit}${Digit}${Digit}`
ISO milliseconds values in string format (from "000"
to "999"
).
Remarks
Stricter than string
type for millisecond values, limited to valid values from
"000"
to "999"
, and giving type errors otherwise.
Example
See
ISOMinutes
ฦฌ ISOMinutes: `${Enumerate<5>}${Digit}`
ISO minutes values in string format (from "00"
to "59"
).
Remarks
Stricter than string
type for minute values, limited to valid values from
"00"
to "59"
, and giving type errors otherwise.
Example
See
ISOMonth
ฦฌ ISOMonth: `0${Exclude<Digit, 0>}` | `1${Enumerate<2>}`
ISO Month values in string format (from "01"
to "12"
).
Remarks
Union type stricter than string
type for month values, limited to valid values
from "01"
to "12"
, and giving type errors otherwise.
Example
See
ISOSeconds
ฦฌ ISOSeconds: `${Enumerate<5>}${Digit}`
ISO seconds values in string format (from "00"
to "59"
).
Remarks
Stricter than string
type for seconds values, limited to valid values from
"00"
to "59"
, and giving type errors otherwise.
Example
See
ISOYear
ฦฌ ISOYear: `${EmptyString | โ-00โ}${MultiDigitNumberString}`
ISO year values in string format.
Remarks
Stricter than string
type for year values, limited to valid values from
"-271821"
to "275760"
, and giving type errors otherwise.
Example
See
Milliseconds
ฦฌ Milliseconds: Enumerate
<999
>
ISO milliseconds values in number format (from 0
to 999
).
Remarks
Stricter than number
type for millisecond values, limited to valid values from
0
to 999
, and giving type errors otherwise.
Example
See
Minutes
ฦฌ Minutes: Enumerate
<59
>
ISO minutes values in number format (from 0
to 59
).
Remarks
Stricter than number
type for minute values, limited to valid values from 0
to 59
, and giving type errors otherwise.
Example
See
Month
ฦฌ Month: Enumerate
<11
>
ISO Month values in number format (from 0
to 11
).
Remarks
Stricter than number
type for month values, limited to valid values from 0
to 11
, and giving type errors otherwise.
Example
See
Seconds
ฦฌ Seconds: Enumerate
<59
>
ISO seconds values in number format (from 0
to 59
).
Remarks
Stricter than number
type for seconds values, limited to valid values from 0
to 59
, and giving type errors otherwise.
Example
See
Function
Class
ฦฌ Class<Arguments
, Instance
>: (โฆconstructorArguments
: Arguments
)
=> Instance
A generic type for classes.
Remarks
This type is a generic constructor function, mainly used when wrapping classes.
Example
See
Type parameters
Name | Type | Description |
---|---|---|
Arguments | extends ReadOnlyArray = ReadOnlyArray | Arguments of the class constructor. |
Instance | unknown | Instance of the class. |
Type declaration
โข (...constructorArguments
): Instance
Parameters
Name | Type |
---|---|
...constructorArguments | Arguments |
Returns
Instance
Filter
ฦฌ Filter<Input
>: Unary
<Input
,
boolean
>
Unary function that returns a boolean
.
Remarks
This type is useful for cases where a function needs to check if a certain condition holds for an input value.
Example
See
Param
The input value to check.
Type parameters
Name | Description |
---|---|
Input | The type of the input value. |
Predicate
ฦฌ Predicate<Input
, Predicated
>: (input
: Input
) => input is
Predicated
Unary function that returns a boolean
and infers a given type for its
argument.
Remarks
This type is useful for cases where a function needs to check if a certain
condition holds for an input value. For example, the type of a filtering
function that filters strings in an array of strings and numbers could look like
Predicate<string | number, string>
.
Example
Type parameters
Name | Type | Description |
---|---|---|
Input | Input | The type of the input value. |
Predicated | extends Input = Input | The subset of Input for which the predicate holds. |
Type declaration
โธ (input
): input is Predicated
Parameters
Name | Type | Description |
---|---|---|
input | Input | The input value to check. |
Returns
input is Predicated
ReadOnlyArguments
ฦฌ ReadOnlyArguments<Input
>: Input
extends (โฆ_arguments
: infer
Arguments) => infer _Output ? Readonly
<Arguments
> : never
Read-only alternative to TypeScriptโs Parameters
Remarks
This type extracts the parameters of a function as a read-only tuple, similar to
Parameters
, but with the added benefit of making the parameters read-only.
Example
See
- Function
- ReadOnlyArray
Type parameters
Name | Type | Description |
---|---|---|
Input | extends Function | Function to extract parameters from. |
Reducer
Reducer/Folder function.
Remarks
Type to represent a folder/reducer unary function that takes an item and an accumulator something of the type of the accumulator.
Example
See
Type parameters
Name | Description |
---|---|
Item | Type of the items to reduce. |
Accumulator | Type of the accumulator/output. |
Tagger
ฦฌ Tagger<Output
, Expressions
>: (templateStrings
:
TemplateStringsArray
, โฆexpressions
: Expressions
) => Output
Tag function for tagged templates.
Remarks
Type to represent a tag function for tagged templates, which takes a
TemplateStringArray
and any number of expressions, and returns a value of type
Output
(string
by default).
Example
See
Type parameters
Name | Type | Description |
---|---|---|
Output | string | Type of the output value. |
Expressions | extends ReadOnlyArray = ReadOnlyArray | Type of the expressions. |
Type declaration
โธ (templateStrings
, ...expressions
): Output
Parameters
Name | Type |
---|---|
templateStrings | TemplateStringsArray |
...expressions | Expressions |
Returns
Output
Unary
ฦฌ Unary<Input
, Output
>: (input
: Input
) => Output
Unary function.
Remarks
Type to represent a function that takes a single argument, ideal for currying.
Example
See
- Function
- Single
Type parameters
Name | Description |
---|---|
Input | Type of the input value. |
Output | Type of the output value. |
Type declaration
โธ (input
): Output
Parameters
Name | Type |
---|---|
input | Input |
Returns
Output
UnaryInput
ฦฌ UnaryInput<UnaryFunction
>: UnaryFunction
extends
Unary
<infer Input, infer _Output> ? Input
:
never
Unary function input type.
Remarks
This type is used to get the input type of a Unary function.
Example
See
Type parameters
Name | Type | Description |
---|---|---|
UnaryFunction | extends Unary <never , unknown > | Type of the unary function to get the input type of. |
UnaryOutput
ฦฌ UnaryOutput<UnaryFunction
>: UnaryFunction
extends
Unary
<infer _Input, infer Output> ? Output
:
never
Unary function output type.
Remarks
This type is used to get the output type of a Unary function.
Example
See
Type parameters
Name | Type | Description |
---|---|---|
UnaryFunction | extends Unary <never , unknown > | Type of the unary function to get the output type of. |
HTML
HTMLElementTagAttributeMap
ฦฌ HTMLElementTagAttributeMap:
ReadOnlyRecord
<`${string}-${string}`,
HTMLElementTagGlobalAttributes
>
& { a
:
HTMLElementTagGlobalAttributes
& { download?
: string
; href?
: string
; hreflang?
: string
;
ping?
: string
; referrerpolicy?
: string
; rel?
: string
; target?
:
string
; type?
: string
} ; abbr
:
HTMLElementTagGlobalAttributes
; address
:
HTMLElementTagGlobalAttributes
; area
:
HTMLElementTagGlobalAttributes
& { accesskey?
: string
; alt?
: string
; coords?
: string
;
download?
: string
; href?
: string
; hreflang?
: string
; ping?
:
string
; rel?
: string
; shape?
: string
; target?
: string
;
type?
: string
} ; article
:
HTMLElementTagGlobalAttributes
; aside
:
HTMLElementTagGlobalAttributes
; audio
:
HTMLElementTagGlobalAttributes
& { autoplay?
: string
; controls?
: string
; crossorigin?
: string
;
loop?
: string
; mediagroup?
: string
; muted?
: string
; preload?
:
string
; src?
: string
} ; b
:
HTMLElementTagGlobalAttributes
; base
:
HTMLElementTagGlobalAttributes
& { href?
: string
; target?
: string
} ; bdi
:
HTMLElementTagGlobalAttributes
; bdo
:
HTMLElementTagGlobalAttributes
& { dir?
: string
} ; blockquote
:
HTMLElementTagGlobalAttributes
& { cite?
: string
} ; body
:
HTMLElementTagGlobalAttributes
& { alink?
: string
; background?
: string
; bgcolor?
: string
;
bottommargin?
: string
; leftmargin?
: string
; link?
: string
;
onafterprint?
: string
; onbeforeprint?
: string
; onbeforeunload?
:
string
; onblur?
: string
; onerror?
: string
; onfocus?
: string
;
onhashchange?
: string
; onlanguagechange?
: string
; onload?
: string
; onmessage?
: string
; onoffline?
: string
; ononline?
: string
;
onpagehide?
: string
; onpageshow?
: string
; onpopstate?
: string
;
onredo?
: string
; onresize?
: string
; onstorage?
: string
;
onundo?
: string
; onunload?
: string
; rightmargin?
: string
;
text?
: string
; topmargin?
: string
; vlink?
: string
} ; br
:
HTMLElementTagGlobalAttributes
& { clear?
: string
} ; button
:
HTMLElementTagGlobalAttributes
& { autocomplete?
: string
; autofocus?
: string
; disabled?
: string
; form?
: string
; formaction?
: string
; formenctype?
: string
;
formmethod?
: string
; formnovalidate?
: string
; formtarget?
: string
; name?
: string
; type?
: string
; value?
: string
} ; canvas
:
HTMLElementTagGlobalAttributes
& { height?
: string
; moz-opaque?
: string
; width?
: string
} ;
caption
:
HTMLElementTagGlobalAttributes
& { align?
: string
} ; cite
:
HTMLElementTagGlobalAttributes
; code
:
HTMLElementTagGlobalAttributes
; col
:
HTMLElementTagGlobalAttributes
& { align?
: string
; span?
: string
} ; colgroup
:
HTMLElementTagGlobalAttributes
& { align?
: string
; span?
: string
} ; data
:
HTMLElementTagGlobalAttributes
& { value?
: string
} ; datalist
:
HTMLElementTagGlobalAttributes
; dd
:
HTMLElementTagGlobalAttributes
& { nowrap?
: string
} ; del
:
HTMLElementTagGlobalAttributes
& { cite?
: string
; datetime?
: string
} ; details
:
HTMLElementTagGlobalAttributes
& { open?
: string
} ; dfn
:
HTMLElementTagGlobalAttributes
; dialog
:
HTMLElementTagGlobalAttributes
& { open?
: string
} ; div
:
HTMLElementTagGlobalAttributes
; dl
:
HTMLElementTagGlobalAttributes
; dt
:
HTMLElementTagGlobalAttributes
; em
:
HTMLElementTagGlobalAttributes
; embed
:
HTMLElementTagGlobalAttributes
& { height?
: string
; src?
: string
; type?
: string
; width?
:
string
} ; fieldset
:
HTMLElementTagGlobalAttributes
& { disabled?
: string
; form?
: string
; name?
: string
} ;
figcaption
:
HTMLElementTagGlobalAttributes
; figure
:
HTMLElementTagGlobalAttributes
; footer
:
HTMLElementTagGlobalAttributes
; form
:
HTMLElementTagGlobalAttributes
& { accept?
: string
; accept-charset?
: string
; action?
: string
;
autocapitalize?
: string
; autocomplete?
: string
; enctype?
: string
;
method?
: string
; name?
: string
; novalidate?
: string
; target?
:
string
} ; h1
:
HTMLElementTagGlobalAttributes
; h2
:
HTMLElementTagGlobalAttributes
; h3
:
HTMLElementTagGlobalAttributes
; h4
:
HTMLElementTagGlobalAttributes
; h5
:
HTMLElementTagGlobalAttributes
; h6
:
HTMLElementTagGlobalAttributes
; head
:
HTMLElementTagGlobalAttributes
& { profile?
: string
} ; header
:
HTMLElementTagGlobalAttributes
; hgroup
:
HTMLElementTagGlobalAttributes
; hr
:
HTMLElementTagGlobalAttributes
& { align?
: string
; color?
: string
; noshade?
: string
; size?
:
string
; width?
: string
} ; html
:
HTMLElementTagGlobalAttributes
& { manifest?
: string
; version?
: string
; xmlns?
: string
} ; i
:
HTMLElementTagGlobalAttributes
; iframe
:
HTMLElementTagGlobalAttributes
& { allow?
: string
; allowfullscreen?
: string
; allowpaymentrequest?
:
string
; csp?
: string
; height?
: string
; importance?
: string
;
name?
: string
; referrerpolicy?
: string
; sandbox?
: string
;
seamless?
: string
; src?
: string
; srcdoc?
: string
; width?
:
string
} ; img
:
HTMLElementTagGlobalAttributes
& { alt?
: string
; crossorigin?
: string
; decoding?
: string
;
height?
: string
; importance?
: string
; intrinsicsize?
: string
;
ismap?
: string
; loading?
: string
; referrerpolicy?
: string
;
sizes?
: string
; src?
: string
; srcset?
: string
; usemap?
:
string
; width?
: string
} ; input
:
HTMLElementTagGlobalAttributes
& { accept?
: string
; alt?
: string
; autocomplete?
: string
;
autofocus?
: string
; checked?
: string
; dirname?
: string
;
disabled?
: string
; form?
: string
; formaction?
: string
;
formenctype?
: string
; formmethod?
: string
; formnovalidate?
: string
; formtarget?
: string
; height?
: string
; inputmode?
: string
;
list?
: string
; max?
: string
; maxlength?
: string
; min?
: string
; minlength?
: string
; multiple?
: string
; name?
: string
;
pattern?
: string
; placeholder?
: string
; readonly?
: string
;
required?
: string
; size?
: string
; src?
: string
; step?
: string
; type?
: string
; value?
: string
; width?
: string
} ; ins
:
HTMLElementTagGlobalAttributes
& { cite?
: string
; datetime?
: string
} ; kbd
:
HTMLElementTagGlobalAttributes
; label
:
HTMLElementTagGlobalAttributes
& { for?
: string
; form?
: string
} ; legend
:
HTMLElementTagGlobalAttributes
; li
:
HTMLElementTagGlobalAttributes
& { type?
: string
; value?
: string
} ; link
:
HTMLElementTagGlobalAttributes
& { as?
: string
; crossorigin?
: string
; href?
: string
;
hreflang?
: string
; importance?
: string
; integrity?
: string
;
media?
: string
; referrerpolicy?
: string
; rel?
: string
; sizes?
:
string
; title?
: string
; type?
: string
} ; main
:
HTMLElementTagGlobalAttributes
; map
:
HTMLElementTagGlobalAttributes
& { name?
: string
} ; mark
:
HTMLElementTagGlobalAttributes
; menu
:
HTMLElementTagGlobalAttributes
; meta
:
HTMLElementTagGlobalAttributes
& { charset?
: string
; content?
: string
; http-equiv?
: string
;
name?
: string
; scheme?
: string
} ; meter
:
HTMLElementTagGlobalAttributes
& { form?
: string
; high?
: string
; low?
: string
; max?
: string
; min?
: string
; optimum?
: string
; value?
: string
} ; nav
:
HTMLElementTagGlobalAttributes
; noscript
:
HTMLElementTagGlobalAttributes
; object
:
HTMLElementTagGlobalAttributes
& { archive?
: string
; border?
: string
; classid?
: string
;
codebase?
: string
; codetype?
: string
; data?
: string
; declare?
:
string
; form?
: string
; height?
: string
; name?
: string
;
standby?
: string
; tabindex?
: string
; type?
: string
;
typemustmatch?
: string
; usemap?
: string
; width?
: string
} ; ol
:
HTMLElementTagGlobalAttributes
& { compact?
: string
; reversed?
: string
; start?
: string
;
type?
: string
} ; optgroup
:
HTMLElementTagGlobalAttributes
& { disabled?
: string
; label?
: string
} ; option
:
HTMLElementTagGlobalAttributes
& { disabled?
: string
; label?
: string
; selected?
: string
;
value?
: string
} ; output
:
HTMLElementTagGlobalAttributes
& { for?
: string
; form?
: string
; name?
: string
} ; p
:
HTMLElementTagGlobalAttributes
; param
:
HTMLElementTagGlobalAttributes
& { name?
: string
; type?
: string
; value?
: string
; valuetype?
:
string
} ; picture
:
HTMLElementTagGlobalAttributes
; pre
:
HTMLElementTagGlobalAttributes
& { cols?
: string
; width?
: string
; wrap?
: string
} ; progress
:
HTMLElementTagGlobalAttributes
& { max?
: string
; value?
: string
} ; q
:
HTMLElementTagGlobalAttributes
& { cite?
: string
} ; rb
:
HTMLElementTagGlobalAttributes
; rp
:
HTMLElementTagGlobalAttributes
; rt
:
HTMLElementTagGlobalAttributes
; ruby
:
HTMLElementTagGlobalAttributes
; s
:
HTMLElementTagGlobalAttributes
; samp
:
HTMLElementTagGlobalAttributes
; script
:
HTMLElementTagGlobalAttributes
& { async?
: string
; charset?
: string
; crossorigin?
: string
;
defer?
: string
; integrity?
: string
; nomodule?
: string
; nonce?
:
string
; referrerpolicy?
: string
; src?
: string
; text?
: string
;
type?
: string
} ; section
:
HTMLElementTagGlobalAttributes
; select
:
HTMLElementTagGlobalAttributes
& { autocomplete?
: string
; autofocus?
: string
; disabled?
: string
; form?
: string
; multiple?
: string
; name?
: string
; required?
:
string
; size?
: string
} ; slot
:
HTMLElementTagGlobalAttributes
& { name?
: string
} ; small
:
HTMLElementTagGlobalAttributes
; source
:
HTMLElementTagGlobalAttributes
& { media?
: string
; sizes?
: string
; src?
: string
; srcset?
:
string
; type?
: string
} ; span
:
HTMLElementTagGlobalAttributes
; strong
:
HTMLElementTagGlobalAttributes
; style
:
HTMLElementTagGlobalAttributes
& { media?
: string
; nonce?
: string
; scoped?
: string
; title?
:
string
; type?
: string
} ; sub
:
HTMLElementTagGlobalAttributes
; summary
:
HTMLElementTagGlobalAttributes
; sup
:
HTMLElementTagGlobalAttributes
; table
:
HTMLElementTagGlobalAttributes
& { align?
: string
; border?
: string
} ; tbody
:
HTMLElementTagGlobalAttributes
& { align?
: string
} ; td
:
HTMLElementTagGlobalAttributes
& { abbr?
: string
; align?
: string
; axis?
: string
; bgcolor?
:
string
; colspan?
: string
; headers?
: string
; rowspan?
: string
}
; template
:
HTMLElementTagGlobalAttributes
; textarea
:
HTMLElementTagGlobalAttributes
& { autocapitalize?
: string
; autocomplete?
: string
; autofocus?
:
string
; cols?
: string
; dirname?
: string
; disabled?
: string
;
form?
: string
; inputmode?
: string
; maxlength?
: string
;
minlength?
: string
; name?
: string
; placeholder?
: string
;
readonly?
: string
; required?
: string
; rows?
: string
;
spellcheck?
: string
; wrap?
: string
} ; tfoot
:
HTMLElementTagGlobalAttributes
& { align?
: string
} ; th
:
HTMLElementTagGlobalAttributes
& { abbr?
: string
; align?
: string
; axis?
: string
; bgcolor?
:
string
; colspan?
: string
; headers?
: string
; rowspan?
: string
;
scope?
: string
; sorted?
: string
} ; thead
:
HTMLElementTagGlobalAttributes
& { align?
: string
} ; time
:
HTMLElementTagGlobalAttributes
& { datetime?
: string
} ; title
:
HTMLElementTagGlobalAttributes
; tr
:
HTMLElementTagGlobalAttributes
& { align?
: string
} ; track
:
HTMLElementTagGlobalAttributes
& { default?
: string
; kind?
: string
; label?
: string
; src?
:
string
; srclang?
: string
} ; u
:
HTMLElementTagGlobalAttributes
; ul
:
HTMLElementTagGlobalAttributes
& { compact?
: string
} ; var
:
HTMLElementTagGlobalAttributes
; video
:
HTMLElementTagGlobalAttributes
& { autoplay?
: string
; controls?
: string
; crossorigin?
: string
;
height?
: string
; loop?
: string
; mediagroup?
: string
; muted?
:
string
; poster?
: string
; preload?
: string
; src?
: string
;
width?
: string
} ; wbr
:
HTMLElementTagGlobalAttributes
}
Map of HTML element tag attributes.
Remarks
If you need the type of the HTML attributes of an HTML element, this is it.
Example
See
HTMLElementTagGlobalAttributes
ฦฌ HTMLElementTagGlobalAttributes: Object
Global HTML attributes.
Remarks
If you need the type of all HTML attributes, this is it.
Example
See
Type declaration
Name | Type | Description |
---|---|---|
accesskey (optional) | string | Provides a hint for generating a keyboard shortcut for the current element. This attribute consists of a space-separated list of characters. The browser should use the first one that exists on the computer keyboard layout. --- References See MDN Reference |
aria-activedescendant (optional) | string | Identifies the currently active element when DOM focus is on a composite widget, textbox , group , or application . --- References See WAI-ARIA Reference |
aria-atomic (optional) | string | Indicates whether assistive technologies will present all, or only parts of, the changed region based on the change notifications defined by the aria-relevant attribute. --- References See WAI-ARIA Reference |
aria-autocomplete (optional) | string | Indicates whether inputting text could trigger display of one or more predictions of the userโs intended value for an input and specifies how predictions would be presented if they are made. --- References See WAI-ARIA Reference |
aria-busy (optional) | string | Indicates an element is being modified and that assistive technologies MAY want to wait until the modifications are complete before exposing them to the user. --- References See WAI-ARIA Reference |
aria-checked (optional) | string | Indicates the current โcheckedโ state of checkboxes, radio buttons, and other widgets. See related aria-pressed and aria-selected . --- References See WAI-ARIA Reference |
aria-colcount (optional) | string | Defines the total number of columns in a table , grid , or treegrid . See related aria-colindex . --- References See WAI-ARIA Reference |
aria-colindex (optional) | string | Defines an elementโs column index or position with respect to the total number of columns within a table , grid , or treegrid . See related aria-colcount and aria-colspan . --- References See WAI-ARIA Reference |
aria-colspan (optional) | string | Defines the number of columns spanned by a cell or gridcell within a table , grid , or treegrid . See related aria-colindex and aria-rowspan . --- References See WAI-ARIA Reference |
aria-controls (optional) | string | Identifies the element (or elements) whose contents or presence are controlled by the current element. See related aria-owns . --- References See WAI-ARIA Reference |
aria-current (optional) | string | Indicates the element that represents the current item within a container or set of related elements. --- References See WAI-ARIA Reference |
aria-describedby (optional) | string | Identifies the element (or elements) that describes the object. See related aria-labelledby . --- References See WAI-ARIA Reference |
aria-details (optional) | string | Identifies the element that provides a detailed, extended description for the object. See related aria-describedby . |
aria-disabled (optional) | string | Indicates that the element is perceivable but disabled, so it is not editable or otherwise operable. See related aria-hidden and aria-readonly . --- References See WAI-ARIA Reference |
aria-dropeffect (optional) | string | [Deprecated in ARIA 1.1] Indicates what functions can be performed when a dragged object is released on the drop target. --- References See WAI-ARIA Reference |
aria-errormessage (optional) | string | Identifies the element that provides an error message for the object. See related aria-invalid and aria-describedby . --- References See WAI-ARIA Reference |
aria-expanded (optional) | string | Indicates whether the element, or another grouping element it controls, is currently expanded or collapsed. --- References See WAI-ARIA Reference |
aria-flowto (optional) | string | Identifies the next element (or elements) in an alternate reading order of content which, at the userโs discretion, allows assistive technology to override the general default of reading in document source order. --- References See WAI-ARIA Reference |
aria-grabbed (optional) | string | [Deprecated in ARIA 1.1] Indicates an elementโs โgrabbedโ state in a drag-and-drop operation. --- References See WAI-ARIA Reference |
aria-haspopup (optional) | string | Indicates the availability and type of interactive popup element, such as menu or dialog, that can be triggered by an element. --- References See WAI-ARIA Reference |
aria-hidden (optional) | string | Indicates whether the element is exposed to an accessibility API. See related aria-disabled . --- References See WAI-ARIA Reference |
aria-invalid (optional) | string | Indicates the entered value does not conform to the format expected by the application. See related aria-errormessage . --- References See WAI-ARIA Reference |
aria-keyshortcuts (optional) | string | Indicates keyboard shortcuts that an author has implemented to activate or give focus to an element. |
aria-label (optional) | string | Defines a string value that labels the current element. See related aria-labelledby . --- References See WAI-ARIA Reference |
aria-labelledby (optional) | string | Identifies the element (or elements) that labels the current element. See related aria-describedby . --- References See WAI-ARIA Reference |
aria-level (optional) | string | Defines the hierarchical level of an element within a structure. --- References See WAI-ARIA Reference |
aria-live (optional) | string | Indicates that an element will be updated, and describes the types of updates the user agents, assistive technologies, and user can expect from the live region. --- References See WAI-ARIA Reference |
aria-modal (optional) | string | Indicates whether an element is modal when displayed. --- References See WAI-ARIA Reference |
aria-multiline (optional) | string | Indicates whether a text box accepts multiple lines of input or only a single line. --- References See WAI-ARIA Reference |
aria-multiselectable (optional) | string | Indicates that the user may select more than one item from the current selectable descendants. --- References See WAI-ARIA Reference |
aria-orientation (optional) | string | Indicates whether the elementโs orientation is horizontal, vertical, or unknown/ambiguous. --- References See WAI-ARIA Reference |
aria-owns (optional) | string | Identifies an element (or elements) in order to define a visual, functional, or contextual parent/child relationship between DOM elements where the DOM hierarchy cannot be used to represent the relationship. See related aria-controls . --- References See WAI-ARIA Reference |
aria-placeholder (optional) | string | Defines a short hint (a word or short phrase) intended to aid the user with data entry when the control has no value. A hint could be a sample value or a brief description of the expected format. --- References See WAI-ARIA Reference |
aria-posinset (optional) | string | Defines an elementโs number or position in the current set of listitems or treeitems. Not required if all elements in the set are present in the DOM. See related aria-setsize . --- References See WAI-ARIA Reference |
aria-pressed (optional) | string | Indicates the current โpressedโ state of toggle buttons. See related aria-checked and aria-selected . --- References See WAI-ARIA Reference |
aria-readonly (optional) | string | Indicates that the element is not editable, but is otherwise operable. See related aria-disabled . --- References See WAI-ARIA Reference |
aria-relevant (optional) | string | Indicates what notifications the user agent will trigger when the accessibility tree within a live region is modified. See related aria-atomic . --- References See WAI-ARIA Reference |
aria-required (optional) | string | Indicates that user input is required on the element before a form may be submitted. --- References See WAI-ARIA Reference |
aria-roledescription (optional) | string | Defines a human-readable, author-localized description for the role of an element. --- References See WAI-ARIA Reference |
aria-rowcount (optional) | string | Defines the total number of rows in a table , grid , or treegrid . See related aria-rowindex . --- References See WAI-ARIA Reference |
aria-rowindex (optional) | string | Defines an elementโs row index or position with respect to the total number of rows within a table , grid , or treegrid . See related aria-rowcount and aria-rowspan . --- References See WAI-ARIA Reference |
aria-rowspan (optional) | string | Defines the number of rows spanned by a cell or gridcell within a table , grid , or treegrid . See related aria-rowindex and aria-colspan . --- References See WAI-ARIA Reference |
aria-selected (optional) | string | Indicates the current โselectedโ state of various widgets. See related aria-checked and aria-pressed . --- References See WAI-ARIA Reference |
aria-setsize (optional) | string | Defines the number of items in the current set of listitems or treeitems. Not required if all elements in the set are present in the DOM. See related aria-posinset . --- References See WAI-ARIA Reference |
aria-sort (optional) | string | Indicates if items in a table or grid are sorted in ascending or descending order. --- References See WAI-ARIA Reference |
aria-valuemax (optional) | string | Defines the maximum allowed value for a range widget. --- References See WAI-ARIA Reference |
aria-valuemin (optional) | string | Defines the minimum allowed value for a range widget. --- References See WAI-ARIA Reference |
aria-valuenow (optional) | string | Defines the current value for a range widget. See related aria-valuetext . --- References See WAI-ARIA Reference |
aria-valuetext (optional) | string | Defines the human readable text alternative of aria-valuenow for a range widget. --- References See WAI-ARIA Reference |
autocapitalize (optional) | string | Controls whether and how text input is automatically capitalized as it is entered/edited by the user. It can have the following values: _ off or none , no autocapitalization is applied (all letters default to lowercase) _ on or sentences , the first letter of each sentence defaults to a capital letter; all other letters default to lowercase _ words , the first letter of each word defaults to a capital letter; all other letters default to lowercase _ characters , all letters should default to uppercase --- References See MDN Reference |
class (optional) | string | A space-separated list of the classes of the element. Classes allows CSS and JavaScript to select and access specific elements via the class selectors or functions like the method Document.getElementsByClassName() . --- References See MDN Reference |
contenteditable (optional) | string | An enumerated attribute indicating if the element should be editable by the user. If so, the browser modifies its widget to allow editing. The attribute must take one of the following values: _ true or the empty string, which indicates that the element must be editable; _ false , which indicates that the element must not be editable. --- References See MDN Reference |
contextmenu (optional) | string | The [**id**](#attr-id) of a <menu> to use as the contextual menu for this element. --- References See MDN Reference |
dir (optional) | string | An enumerated attribute indicating the directionality of the elementโs text. It can have the following values: _ ltr , which means left to right and is to be used for languages that are written from the left to the right (like English); _ rtl , which means right to left and is to be used for languages that are written from the right to the left (like Arabic); * auto , which lets the user agent decide. It uses a basic algorithm as it parses the characters inside the element until it finds a character with a strong directionality, then it applies that directionality to the whole element. --- References See MDN Reference |
draggable (optional) | string | An enumerated attribute indicating whether the element can be dragged, using the Drag and Drop API. It can have the following values: _ true , which indicates that the element may be dragged _ false , which indicates that the element may not be dragged. --- References See MDN Reference |
dropzone (optional) | string | An enumerated attribute indicating what types of content can be dropped on an element, using the Drag and Drop API. It can have the following values: _ copy , which indicates that dropping will create a copy of the element that was dragged _ move , which indicates that the element that was dragged will be moved to this new location. * link , will create a link to the dragged data. |
exportparts (optional) | string | Used to transitively export shadow parts from a nested shadow tree into a containing light tree. --- References See MDN Reference |
hidden (optional) | string | A Boolean attribute indicates that the element is not yet, or is no longer, relevant. For example, it can be used to hide elements of the page that canโt be used until the login process has been completed. The browser wonโt render such elements. This attribute must not be used to hide content that could legitimately be shown. --- References See MDN Reference |
id (optional) | string | Defines a unique identifier (ID) which must be unique in the whole document. Its purpose is to identify the element when linking (using a fragment identifier), scripting, or styling (with CSS). --- References See MDN Reference |
inputmode (optional) | string | Provides a hint to browsers as to the type of virtual keyboard configuration to use when editing this element or its contents. Used primarily on <input> elements, but is usable on any element while in [contenteditable](https://developer.mozilla.org/docs/Web/HTML/Global_attributes#attr-contenteditable) mode. --- References See MDN Reference |
is (optional) | string | Allows you to specify that a standard HTML element should behave like a registered custom built-in element (see Using custom elements for more details). --- References See MDN Reference |
itemid (optional) | string | The unique, global identifier of an item. --- References See MDN Reference |
itemprop (optional) | string | Used to add properties to an item. Every HTML element may have an itemprop attribute specified, where an itemprop consists of a name and value pair. --- References See MDN Reference |
itemref (optional) | string | Properties that are not descendants of an element with the itemscope attribute can be associated with the item using an itemref . It provides a list of element ids (not itemid s) with additional properties elsewhere in the document. --- References See MDN Reference |
itemscope (optional) | string | itemscope (usually) works along with [itemtype](https://developer.mozilla.org/docs/Web/HTML/Global_attributes#attr-itemtype) to specify that the HTML contained in a block is about a particular item. itemscope creates the Item and defines the scope of the itemtype associated with it. itemtype is a valid URL of a vocabulary (such as schema.org) that describes the item and its properties context. --- References See MDN Reference |
itemtype (optional) | string | Specifies the URL of the vocabulary that will be used to define itemprop s (item properties) in the data structure. [itemscope](https://developer.mozilla.org/docs/Web/HTML/Global_attributes#attr-itemscope) is used to set the scope of where in the data structure the vocabulary set by itemtype will be active. --- References See MDN Reference |
lang (optional) | string | Helps define the language of an element: the language that non-editable elements are in, or the language that editable elements should be written in by the user. The attribute contains one โlanguage tagโ (made of hyphen-separated โlanguage subtagsโ) in the format defined in Tags for Identifying Languages (BCP47). xml:lang
has priority over it. --- References See MDN Reference |
onabort (optional) | string | The loading of a resource has been aborted. |
onblur (optional) | string | An element has lost focus (does not bubble). |
oncanplay (optional) | string | The user agent can play the media, but estimates that not enough data has been loaded to play the media up to its end without having to stop for further buffering of content. |
oncanplaythrough (optional) | string | The user agent can play the media up to its end without having to stop for further buffering of content. |
onchange (optional) | string | The change event is fired for , |
onclick (optional) | string | A pointing device button has been pressed and released on an element. |
oncontextmenu (optional) | string | The right button of the mouse is clicked (before the context menu is displayed). |
ondblclick (optional) | string | A pointing device button is clicked twice on an element. |
ondrag (optional) | string | An element or text selection is being dragged (every 350ms). |
ondragend (optional) | string | A drag operation is being ended (by releasing a mouse button or hitting the escape key). |
ondragenter (optional) | string | A dragged element or text selection enters a valid drop target. |
ondragleave (optional) | string | A dragged element or text selection leaves a valid drop target. |
ondragover (optional) | string | An element or text selection is being dragged over a valid drop target (every 350ms). |
ondragstart (optional) | string | The user starts dragging an element or text selection. |
ondrop (optional) | string | An element is dropped on a valid drop target. |
ondurationchange (optional) | string | The duration attribute has been updated. |
onemptied (optional) | string | The media has become empty; for example, this event is sent if the media has already been loaded (or partially loaded), and the load() method is called to reload it. |
onended (optional) | string | Playback has stopped because the end of the media was reached. |
onerror (optional) | string | A resource failed to load. |
onfocus (optional) | string | An element has received focus (does not bubble). |
onformchange (optional) | string | - |
onforminput (optional) | string | - |
oninput (optional) | string | The value of an element changes or the content of an element with the attribute contenteditable is modified. |
oninvalid (optional) | string | A submittable element has been checked and doesnโt satisfy its constraints. |
onkeydown (optional) | string | A key is pressed down. |
onkeypress (optional) | string | A key is pressed down and that key normally produces a character value (use input instead). |
onkeyup (optional) | string | A key is released. |
onload (optional) | string | A resource and its dependent resources have finished loading. |
onloadeddata (optional) | string | The first frame of the media has finished loading. |
onloadedmetadata (optional) | string | The metadata has been loaded. |
onloadstart (optional) | string | Progress has begun. |
onmousedown (optional) | string | A pointing device button (usually a mouse) is pressed on an element. |
onmouseenter (optional) | string | A pointing device is moved onto the element that has the listener attached. |
onmouseleave (optional) | string | A pointing device is moved off the element that has the listener attached. |
onmousemove (optional) | string | A pointing device is moved over an element. |
onmouseout (optional) | string | A pointing device is moved off the element that has the listener attached or off one of its children. |
onmouseover (optional) | string | A pointing device is moved onto the element that has the listener attached or onto one of its children. |
onmouseup (optional) | string | A pointing device button is released over an element. |
onmousewheel (optional) | string | - |
onpause (optional) | string | Playback has been paused. |
onplay (optional) | string | Playback has begun. |
onplaying (optional) | string | Playback is ready to start after having been paused or delayed due to lack of data. |
onpointercancel (optional) | string | The pointer is unlikely to produce any more events. |
onpointerdown (optional) | string | The pointer enters the active buttons state. |
onpointerenter (optional) | string | Pointing device is moved inside the hit-testing boundary. |
onpointerleave (optional) | string | Pointing device is moved out of the hit-testing boundary. |
onpointerlockchange (optional) | string | The pointer was locked or released. |
onpointerlockerror (optional) | string | It was impossible to lock the pointer for technical reasons or because the permission was denied. |
onpointermove (optional) | string | The pointer changed coordinates. |
onpointerout (optional) | string | The pointing device moved out of hit-testing boundary or leaves detectable hover range. |
onpointerover (optional) | string | The pointing device is moved into the hit-testing boundary. |
onpointerup (optional) | string | The pointer leaves the active buttons state. |
onprogress (optional) | string | In progress. |
onratechange (optional) | string | The playback rate has changed. |
onreadystatechange (optional) | string | The readyState attribute of a document has changed. |
onreset (optional) | string | A form is reset. |
onresize (optional) | string | The document view has been resized. |
onscroll (optional) | string | The document view or an element has been scrolled. |
onseeked (optional) | string | A seek operation completed. |
onseeking (optional) | string | A seek operation began. |
onselect (optional) | string | Some text is being selected. |
onshow (optional) | string | A contextmenu event was fired on/bubbled to an element that has a contextmenu attribute |
onstalled (optional) | string | The user agent is trying to fetch media data, but data is unexpectedly not forthcoming. |
onsubmit (optional) | string | A form is submitted. |
onsuspend (optional) | string | Media data loading has been suspended. |
ontimeupdate (optional) | string | The time indicated by the currentTime attribute has been updated. |
onvolumechange (optional) | string | The volume has changed. |
onwaiting (optional) | string | Playback has stopped because of a temporary lack of data. |
part (optional) | string | A space-separated list of the part names of the element. Part names allows CSS to select and style specific elements in a shadow tree via the ::part pseudo-element. --- References See MDN Reference |
role (optional) | string | - |
slot (optional) | string | Assigns a slot in a shadow DOM shadow tree to an element: An element with a slot attribute is assigned to the slot created by the <slot> element whose [name](https://developer.mozilla.org/docs/Web/HTML/Element/slot#attr-name) attributeโs value matches that slot attributeโs value. --- References See MDN Reference |
spellcheck (optional) | string | An enumerated attribute defines whether the element may be checked for spelling errors. It may have the following values: _ true , which indicates that the element should be, if possible, checked for spelling errors; _ false , which indicates that the element should not be checked for spelling errors. --- References See MDN Reference |
style (optional) | string | Contains CSS styling declarations to be applied to the element. Note that it is recommended for styles to be defined in a separate file or files. This attribute and the <style> element have mainly the purpose of allowing for quick styling, for example for testing purposes. --- References See MDN Reference |
tabindex (optional) | string | An integer attribute indicating if the element can take input focus (is focusable), if it should participate to sequential keyboard navigation, and if so, at what position. It can take several values: _ a negative value means that the element should be focusable, but should not be reachable via sequential keyboard navigation; _ 0 means that the element should be focusable and reachable via sequential keyboard navigation, but its relative order is defined by the platform convention; * a positive value means that the element should be focusable and reachable via sequential keyboard navigation; the order in which the elements are focused is the increasing value of the tabindex. If several elements share the same tabindex, their relative order follows their relative positions in the document. --- References See MDN Reference |
title (optional) | string | Contains a text representing advisory information related to the element it belongs to. Such information can typically, but not necessarily, be presented to the user as a tooltip. --- References See MDN Reference |
translate (optional) | string | An enumerated attribute that is used to specify whether an elementโs attribute values and the values of its Text node children are to be translated when the page is localized, or whether to leave them unchanged. It can have the following values: _ empty string and yes , which indicates that the element will be translated. _ no , which indicates that the element will not be translated. --- References See MDN Reference |
Iterables
IsomorphicIterable
ฦฌ IsomorphicIterable<Item
>: Readonly
<AsyncIterable
<Item
> |
Iterable
<Item
>>
Value might be an AsyncIterable
or just an Iterable
(read-only).
Remarks
Union type useful when you want to accept both AsyncIterable
and Iterable
values, which is generally in asynchronous functions that can loop over
@@asyncIterator or
@@iterator values.
Example
See
Type parameters
Name | Type | Description |
---|---|---|
Item | unknown | Type of the items in the iterable. |
IsomorphicIterableItem
ฦฌ IsomorphicIterableItem<SourceIterable
>: SourceIterable
extends
IsomorphicIterable
<infer Item> ?
Item
: never
Type of the items of an IsomorphicIterable
.
Remarks
Sometimes we have to get the item type out of an IsomorphicIterable
. This type
is meant to be used where inference is not an option.
Example
See
Type parameters
Name | Type | Description |
---|---|---|
SourceIterable | extends IsomorphicIterable | IsomorphicIterable type to get the item type from.` |
IsomorphicIterableIterator
ฦฌ IsomorphicIterableIterator<Item
>:
Readonly
<AsyncIterableIterator
<Item
> | IterableIterator
<Item
>>
Value might be an AsyncIterableIterator
or just an IterableIterator
(read-only).
Remarks
This is just an read-only alternative to AsyncIterableIterator
or
IterableIterator
to avoid unwanted mutations.
Example
Type parameters
Name | Type | Description |
---|---|---|
Item | unknown | Type of the items in the AsyncIterableIterator or IterableIterator . |
IsomorphicIterator
ฦฌ IsomorphicIterator<Item
, Return
, Next
>:
Readonly
<AsyncIterator
<Item
, Return
, Next
> | Iterator
<Item
,
Return
, Next
>>
Value might be an AsyncIterator
or just an Iterator
(read-only).
Remarks
This is just an read-only alternative to AsyncIterator
or Iterator
to avoid
unwanted mutations.
Example
Type parameters
Name | Type | Description |
---|---|---|
Item | unknown | Type of the items in the AsyncIterator or Iterator . |
Return | void | Type of the return value in the AsyncIterator or Iterator . |
Next | void | Type of the next value in the AsyncIterator or Iterator . |
ReadOnlyIterable
ฦฌ ReadOnlyIterable<Item
>: Readonly
<Iterable
<Item
>>
Read-only Iterable
.
Remarks
This is just an read-only alternative to Iterable
to avoid unwanted mutations.
Example
Type parameters
Name | Type | Description |
---|---|---|
Item | unknown | Type of the items in the Iterable . |
ReadOnlyIterableIterator
ฦฌ ReadOnlyIterableIterator<Item
>:
Readonly
<IterableIterator
<Item
>>
Read-only IterableIterator
.
Remarks
This is just an read-only alternative to IterableIterator
to avoid unwanted
mutations.
Type parameters
Name | Type | Description |
---|---|---|
Item | unknown | Type of the items in the IterableIterator . |
ReadOnlyIterator
ฦฌ ReadOnlyIterator<Item
, Return
, Next
>:
Readonly
<Iterator
<Item
, Return
, Next
>>
Read-only Iterator
.
Remarks
This is just an read-only alternative to Iterator
to avoid unwanted mutations.
Type parameters
Name | Type | Description |
---|---|---|
Item | unknown | Type of the items in the Iterator . |
Return | void | Type of the return value in the Iterator . |
Next | void | Type of the next value in the Iterator . |
Number
Digit
ฦฌ Digit: Enumerate
<9
>
Valid digits (0
to 9
).
Remarks
The idea with this type is to use it to construct others based on it, like for
example Digit2
for 00
to 99
.
Example
See
Enumerate
ฦฌ Enumerate<To
, Accumulator
>: Accumulator
["length"
] extends To
? Accumulator
[number
] | To
:
Enumerate
<To
, [โฆAccumulator,
Accumulator
["length"
]]>
Union of numbers from 0 to To
Remarks
Recursively generates a type with an union of numbers from 0 to Length - 1. This has the same limit TypeScript has for recursive types.
Example
Type parameters
Name | Type | Description |
---|---|---|
To | extends number | Last number of the union (starts at 0). |
Accumulator | extends ReadonlyArray <number > = [] | Accumulator for the recursion (for internal use). |
MultiDigitNumberString
ฦฌ MultiDigitNumberString: `${bigint}${bigint}`
String with more than 1 number on it.
Remarks
This type is useful when a given string will need more than one number on it.
Example
Numeric
ฦฌ Numeric: bigint
| number
Types to represent numbers.
Remarks
The Numeric
type is a union of number
and bigint
. It is useful for cases
where a value could be either a regular JavaScript number or a BigInt.
Example
Radix
ฦฌ Radix: Range
<2
, 36
>
Valid radix values (from 2
to 36
).
Remarks
The Radix
type is useful when working with number bases other than decimal.
The radix defines the base of the number system being used. For example, a
binary system has a radix of 2
, a decimal system has a radix of 10
, and a
hexadecimal system has a radix of 16
. The Radix
type can be used to ensure
that a given radix value is within the valid range of 2
to 36
.
Example
See
Range
Generates a range of numbers using Enumerate
with given Length
and omitting
the first From
numbers.
Remarks
This type is equivalent to an array of numbers where the first From
elements
are excluded and the length of the array is Length - From
. The idea is to use
it to generate a range of numbers from the given From
, and of the given
Length
.
Example
See
Type parameters
Name | Type |
---|---|
From | extends number |
To | extends number |
Object
Empty
ฦฌ Empty: EmptyArray
|
EmptyRecord
|
EmptyString
Empty array, object or string.
Remarks
Union type of EmptyArray, EmptyRecord and EmptyString, to signify values that are empty.
Example
See
EmptyRecord
ฦฌ EmptyRecord:
ReadOnlyRecord
<PropertyKey
, never
>
Empty record (object).
Remarks
This is a type alias for an empty readonly record. Accessing properties gives
undefined
.
Example
See
Entry
ฦฌ Entry<Key
, Value
>: readonly [key: Key, value: Value]
Entry couple [key, value]
.
Remarks
It is a tuple of two elements, the first one being the key and the second one being the value of an objectโs property.
Example
Type parameters
Name | Type | Description |
---|---|---|
Key | PropertyKey | Objectโs properties type. |
Value | unknown | Objectโs values type. |
EntryKey
ฦฌ EntryKey<Input
>: Input
[0
]
Key of an Entry.
Remarks
Util type to get the key of an Entry.
Example
See
Type parameters
Name | Type | Description |
---|---|---|
Input | extends Entry | Entry type. |
EntryOf
Object or array Entry.
Remarks
Get the Entry type out of an object or array.
Example
See
Type parameters
Name | Type | Description |
---|---|---|
Type | extends object | Object or array type. |
EntryValue
ฦฌ EntryValue<Input
>: Input
[1
]
Value of an Entry.
Remarks
Util type to get the value of an Entry.
Example
See
Type parameters
Name | Type | Description |
---|---|---|
Input | extends Entry | Entry type. |
KeyOf
ฦฌ KeyOf<Type
>: Type
extends
ArrayLike
?
NeverFallback
<Just
<Exclude
<Partial
<Type
>["length"
],
Type
["length"
]>>, number
> : `${Exclude<keyof Type, symbol>}`
Generic key for either object or array.
Remarks
Type to represent the type of the key in an array or object. It automatically
omits symbol
keys from objects, and uses number
for arrays with dynamic
length
.
Example
Type parameters
Name | Type | Description |
---|---|---|
Type | extends object | Object or array type. |
MaybeEmpty
ฦฌ MaybeEmpty<Input
>: Either
<Input
,
Input
extends ReadOnlyArray
?
EmptyArray
: Input
extends string
?
EmptyString
: Input
extends
ReadOnlyRecord
?
EmptyRecord
: undefined
>
Creates an union of the given type with a possible โemptyโ value.
Remarks
This type is useful to make clear that we expect a possible empty value.
Example
See
Type parameters
Name | Description |
---|---|
Input | Type to unite with itโs empty counterpart. |
NotEmpty
ฦฌ NotEmpty<Type
>: Exclude
<Type
,
Empty
>
Type for a non-empty ArrayLike
, object
or string
.
Remarks
This type is useful for cases where you want to ensure that a value is not
empty. For example, if you have an array that should always have at least one
element, you could type it as NotEmpty<ArrayLike<ElementType>>
.
Example
See
Type parameters
Name | Type | Description |
---|---|---|
Type | extends ArrayLike | object | string | The type to check. |
ReadOnlyRecord
ฦฌ ReadOnlyRecord<Key
, Value
>: Readonly
<Record
<Key
, Value
>>
Read-only record.
Remarks
Thereโs already a native Readonly
and Record
type, but this type has default
type parameters to make it easier to use when the type of a record is unknown
.
Example
Type parameters
Name | Type | Description |
---|---|---|
Key | extends PropertyKey = PropertyKey | Type of the keys in the record. |
Value | unknown | Type of the values in the record. |
ValueOf
Generic key for either object or array.
Remarks
This type is used to get the type of the values in a collection (items of an
ArrayLike
or properties of a Record
).
Example
See
Type parameters
Name | Type | Description |
---|---|---|
Type | extends object | Object or array type. |
RegExp
RegularExpression
ฦฌ RegularExpression: `/${string}/${RegularExpressionFlags}`
String representing a regular expression.
Remarks
Safer than string
and simpler than RegExp
type to represent a regular
expression. It RegularExpression
to enforce flags to always have u
and have
a consistent order.
Example
See
RegularExpressionFlags
ฦฌ RegularExpressionFlags: `${MaybeEmpty<โgโ>}${MaybeEmpty<โiโ>}${MaybeEmpty<โmโ>}${MaybeEmpty<โsโ>}u`
Possible combinations of regular expression flags (with mandatory u
flag).
Remarks
Type union stricter than string
type for RegExp flags. The unicode flag is
mandatory to ensure unicode characters are always supported.
Example
See
String
Empty
ฦฌ Empty: EmptyArray
|
EmptyRecord
|
EmptyString
Empty array, object or string.
Remarks
Union type of EmptyArray, EmptyRecord and EmptyString, to signify values that are empty.
Example
See
EmptyString
ฦฌ EmptyString: typeof EMPTY_STRING
Empty string.
Remarks
This type is a string with no characters on it (length 0
).
EmptyString.
Example
Head
ฦฌ Head<Input
>:
HeadAndTail
<Input
>[0
]
Initial value of an ArrayLike
.
Remarks
Given a type argument (an ArrayLike
), this returns the type of the item in
index 0
.
Example
See
Type parameters
Name | Type | Description |
---|---|---|
Input | extends ArrayLike | ArrayLike value (such as Array or string ). |
HeadAndTail
ฦฌ HeadAndTail<Input
>: Input
extends readonly [head: infer HeadItem,
tail: infer TailItems] ? readonly [head: HeadItem, tail: TailItems] : Input
extends `${infer FirstCharacter}${infer RestOfString}` ? readonly [head:
FirstCharacter, tail: RestOfString] : Input
extends
EmptyArray
|
EmptyString
? readonly [head: undefined,
tail: Input] : readonly [head: Maybe<Input[number]>, tail: Input]
Get a couple with the head and tail types of an ArrayLike
.
Remarks
Given a type argument (an ArrayLike
), this returns a couple with the type of
the item in index 0
first, and the rest of the ArrayLike
after.
Example
See
Type parameters
Name | Type | Description |
---|---|---|
Input | extends ArrayLike | Input ArrayLike . |
Initial
ฦฌ Initial<Input
>:
InitialAndLast
<Input
>[0
]
Initial values of an ArrayLike
(omitting the last).
Remarks
Given a type argument (an ArrayLike
), this returns the type of the items from
the start of the ArrayLike
until the before to last item.
Example
See
Type parameters
Name | Type | Description |
---|---|---|
Input | extends ArrayLike | ArrayLike value (such as Array or string ). |
InitialAndLast
ฦฌ InitialAndLast<Input
>: Input
extends readonly [โฆ(infer
InitialItems), infer LastItem] ? readonly [initial: InitialItems, last:
LastItem] : Input
extends EmptyArray
|
EmptyString
? readonly [initial: Input,
last: undefined] : Input
extends `${infer FirstCharacter}${infer
RestOfString}` ? readonly [initial: `${RestOfString extends EmptyString ?
EmptyString : FirstCharacter}${Head<InitialAndLast<RestOfString>>}`, last:
`${RestOfString extends EmptyString ? FirstCharacter :
Last<RestOfString>}`] : readonly [initial: Input, last:
Maybe<Input[number]>]
Get a couple with the initial and last types of an ArrayLike.
Remarks
Given a ArrayLike, this returns a couple with the type of all items from the start until the item before last, and then the last.
Example
See
Type parameters
Name | Type | Description |
---|---|---|
Input | extends ArrayLike | Input ArrayLike . |
Last
ฦฌ Last<Input
>:
InitialAndLast
<Input
>[1
]
Last value of an ArrayLike
.
Remarks
Type of the last character of a string or the last element of an array.
Example
See
Type parameters
Name | Type | Description |
---|---|---|
Input | extends ArrayLike | The input ArrayLike . |
LocaleIdentifier
ฦฌ LocaleIdentifier: "eo"
| "yue-Hant-HK"
|
LocaleString
<"af"
,
`${โNโ | โZโ}A`> | LocaleString
<"ak"
, "GH"
> | LocaleString
<"am"
, "ET"
> | LocaleString
<"ar"
, `${โAโ
| โYโ}E` | "BH"
| "DZ"
| `E${โGโ | โHโ | โRโ}` | `I${โLโ |
โQโ}` | "JO"
| "KW"
| `I${โBโ | โYโ}` | `M${โAโ | โRโ}` |
"OM"
| "PS"
| "QA"
|
`S${โAโ | โDโ | โOโ | โSโ | โYโ}` | `T${โDโ | โNโ}`> |
LocaleString
<"as"
, "IN"
> |
LocaleString
<"asa"
, "TZ"
> |
LocaleString
<"az"
,
LocaleString
<"Cyrl"
| "Latn"
,
"AZ"
>> | LocaleString
<"be"
,
"BY"
> | LocaleString
<"bem"
, "ZM"
>
| LocaleString
<"bez"
, "TZ"
> |
LocaleString
<"bg"
, "BG"
> |
LocaleString
<"bm"
, "ML"
> |
LocaleString
<"bn"
, "BD"
| "IN"
> |
LocaleString
<"bo"
,
`${โCโ | โIโ}N`> | LocaleString
<"bs"
, "BA"
> | LocaleString
<"ca"
, "ES"
> | LocaleString
<"cgg"
, "UG"
> | LocaleString
<"chr"
, "US"
> | LocaleString
<"cs"
, "CZ"
> | LocaleString
<"cy"
, "GB"
> | LocaleString
<"da"
, "DK"
> | LocaleString
<"dav"
, "KE"
> | LocaleString
<"de"
, "AT"
| `${โBโ
| โDโ}E` | "CH"
|
`L${โIโ | โUโ}`> | LocaleString
<"ebu"
, "KE"
> | LocaleString
<"ee"
, "GH"
| "TG"
> | LocaleString
<"el"
, "CY"
| "GR"
> | LocaleString
<"en"
, `A${โSโ
| โUโ}` | `B${โEโ | โWโ | โZโ}` | "CA"
| `G${โBโ | โUโ}` |
"HK"
| "IE"
| `I${โLโ | โNโ}` | "JM"
| `M${โHโ | โPโ | โTโ
| โUโ}` | `N${โAโ | โZโ}` | `P${โHโ | โKโ}` | "SG"
| "TT"
|
`U${โMโ | โSโ}` | "VI"
| `Z${โAโ | โWโ}`> |
LocaleString
<"es"
, "419"
| "AR"
|
"BO"
| `C${โLโ | โOโ | โRโ}` | "DO"
| `E${โCโ | โSโ}` |
`G${โQโ | โTโ}` | "HN"
| "MX"
| "NI"
| `P${โAโ | โEโ |
โRโ | โYโ}` | "SV"
|
`U${โSโ | โYโ}` | "VE"
> | LocaleString
<"et"
, "EE"
> | LocaleString
<"eu"
, "ES"
> | LocaleString
<"fa"
, "AF"
| "IR"
> | LocaleString
<"ff"
, "SN"
> | LocaleString
<"fi"
, "FI"
> | LocaleString
<"fil"
, "PH"
> | LocaleString
<"fo"
, "FO"
> | LocaleString
<"fr"
, `B${โEโ
| โFโ | โIโ | โJโ | โLโ}` |
`C${โAโ | โDโ | โFโ | โGโ | โHโ | โIโ | โMโ}` | "DJ"
| "FR"
| `G${โAโ
| โNโ | โPโ | โQโ}` | "KM"
| "LU"
|
`M${โCโ | โFโ | โGโ | โLโ | โQโ}` | "NE"
| `R${โEโ | โWโ}` |
"SN"
|
`T${โDโ | โGโ}`> | LocaleString
<"ga"
, "IE"
> | LocaleString
<"gl"
, "ES"
> | LocaleString
<"gsw"
, "CH"
> | LocaleString
<"gu"
, "IN"
> | LocaleString
<"guz"
, "KE"
> | LocaleString
<"gv"
, "GB"
> | LocaleString
<"ha"
, LocaleString
<"Latn"
, "GH"
| `N${โEโ
| โGโ}`>> | LocaleString
<"haw"
,
"US"
> | LocaleString
<"he"
, "IL"
>
| LocaleString
<"hi"
, "IN"
> |
LocaleString
<"hr"
, "HR"
> |
LocaleString
<"hu"
, "HU"
> |
LocaleString
<"hy"
, "AM"
> |
LocaleString
<"id"
, "ID"
> |
LocaleString
<"ig"
, "NG"
> |
LocaleString
<"ii"
, "CN"
> |
LocaleString
<"is"
, "IS"
> |
LocaleString
<"it"
, "CH"
| "IT"
> |
LocaleString
<"ja"
, "JP"
> |
LocaleString
<"jmc"
, "TZ"
> |
LocaleString
<"ka"
, "GE"
> |
LocaleString
<"kab"
, "DZ"
> |
LocaleString
<"kam"
, "KE"
> |
LocaleString
<"kde"
, "TZ"
> |
LocaleString
<"kea"
, "CV"
> |
LocaleString
<"khq"
, "ML"
> |
LocaleString
<"ki"
, "KE"
> |
LocaleString
<"kk"
,
LocaleString
<"Cyrl"
, "KZ"
>> |
LocaleString
<"kl"
, "GL"
> |
LocaleString
<"kln"
, "KE"
> |
LocaleString
<"km"
, "KH"
> |
LocaleString
<"kn"
, "IN"
> |
LocaleString
<"ko"
, "KR"
> |
LocaleString
<"kok"
, "IN"
> |
LocaleString
<"kw"
, "GB"
> |
LocaleString
<"lag"
, "TZ"
> |
LocaleString
<"lg"
, "UG"
> |
LocaleString
<"lt"
, "LT"
> |
LocaleString
<"luo"
, "KE"
> |
LocaleString
<"luy"
, "KE"
> |
LocaleString
<"lv"
, "LV"
> |
LocaleString
<"mas"
, "KE"
| "TZ"
>
| LocaleString
<"mer"
, "KE"
> |
LocaleString
<"mfe"
, "MU"
> |
LocaleString
<"mg"
, "MG"
> |
LocaleString
<"mk"
, "MK"
> |
LocaleString
<"ml"
, "IN"
> |
LocaleString
<"mr"
, "IN"
> |
LocaleString
<"ms"
, "BN"
| "MY"
> |
LocaleString
<"mt"
, "MT"
> |
LocaleString
<"my"
, "MM"
> |
LocaleString
<"naq"
, "NA"
> |
LocaleString
<"nb"
, "NO"
> |
LocaleString
<"nd"
, "ZW"
> |
LocaleString
<"ne"
, "IN"
| "NP"
> |
LocaleString
<"nl"
, "BE"
| "NL"
> |
LocaleString
<"nn"
, "NO"
> |
LocaleString
<"nyn"
, "UG"
> |
LocaleString
<"om"
, "ET"
| "KE"
> |
LocaleString
<"or"
, "IN"
> |
LocaleString
<"pa"
,
LocaleString
<"Arab"
, "PK"
> |
LocaleString
<"Guru"
, "IN"
>> |
LocaleString
<"pl"
, "PL"
> |
LocaleString
<"ps"
, "AF"
> |
LocaleString
<"pt"
, "BR"
| "GW"
|
"MZ"
| "PT"
> | LocaleString
<"rm"
,
"CH"
> | LocaleString
<"ro"
, "MD"
|
"RO"
> | LocaleString
<"rof"
, "TZ"
>
| LocaleString
<"ru"
, "MD"
| "RU"
| "UA"
> | LocaleString
<"rw"
,
"RW"
> | LocaleString
<"rwk"
, "TZ"
>
| LocaleString
<"saq"
, "KE"
> |
LocaleString
<"seh"
, "MZ"
> |
LocaleString
<"ses"
, "ML"
> |
LocaleString
<"sg"
, "CF"
> |
LocaleString
<"shi"
,
LocaleString
<"Latn"
| "Tfng"
,
"MA"
>> | LocaleString
<"si"
,
"LK"
> | LocaleString
<"sk"
, "SK"
>
| LocaleString
<"sl"
, "SI"
> |
LocaleString
<"sn"
, "ZW"
> |
LocaleString
<"so"
, "DJ"
| "ET"
|
"KE"
| "SO"
> | LocaleString
<"sq"
,
"AL"
> | LocaleString
<"sr"
,
LocaleString
<"Cyrl"
| "Latn"
, "BA"
| "ME"
| "RS"
>> |
LocaleString
<"sv"
, "FI"
| "SE"
> |
LocaleString
<"sw"
, "KE"
| "TZ"
> |
LocaleString
<"ta"
, "IN"
| "LK"
> |
LocaleString
<"te"
, "IN"
> |
LocaleString
<"teo"
, "KE"
| "UG"
>
| LocaleString
<"th"
, "TH"
> |
LocaleString
<"ti"
,
`E${โRโ | โTโ}`> | LocaleString
<"to"
, "TO"
> | LocaleString
<"tr"
, "TR"
> | LocaleString
<"tzm"
, LocaleString
<"Latn"
, "MA"
>> | LocaleString
<"uk"
, "UA"
> | LocaleString
<"ur"
, "IN"
| "PK"
> | LocaleString
<"uz"
, LocaleString
<"Arab"
, "AF"
> | LocaleString
<"Cyrl"
| "Latn"
, "UZ"
>> | LocaleString
<"vi"
, "VN"
> | LocaleString
<"vun"
, "TZ"
> | LocaleString
<"xog"
, "UG"
> | LocaleString
<"yo"
, "NG"
> | LocaleString
<"zh"
, LocaleString
<`Han${โsโ
| โtโ}`, "HK"
| "MO"
> |
LocaleString
<"Hans"
, "CN"
| "SG"
>
| LocaleString
<"Hant"
, "TW"
>> |
LocaleString
<"zu"
, "ZA"
>
Locale identifiers (language-country).
Remarks
When using i18n tools, this is a stricter union type than string
to handle the
locale identifiers.
Example
See
LocaleString
ฦฌ LocaleString<LanguageCode
, CountryCodes
, Separator
>:
`${LanguageCode}${MaybeEmpty<`${Separator}${CountryCodes}`>}`
String for locales such as โen-USโ.
Remarks
This type mainly exists to make LocaleIdentifier a little bit easier to the eyes.
Example
See
Type parameters
Name | Type | Description |
---|---|---|
LanguageCode | extends MultiCharacterString | 2 character language code. |
CountryCodes | extends MultiCharacterString | Union of country codes. |
Separator | extends "-" | "_" = "-" | - |
MaybeEmpty
ฦฌ MaybeEmpty<Input
>: Either
<Input
,
Input
extends ReadOnlyArray
?
EmptyArray
: Input
extends string
?
EmptyString
: Input
extends
ReadOnlyRecord
?
EmptyRecord
: undefined
>
Creates an union of the given type with a possible โemptyโ value.
Remarks
This type is useful to make clear that we expect a possible empty value.
Example
See
Type parameters
Name | Description |
---|---|
Input | Type to unite with itโs empty counterpart. |
MultiCharacterString
ฦฌ MultiCharacterString: `${string}${string}`
String with more than 1 character on it.
Deprecated
Not actually deprecated, this type doesnโt do anything yet.
Remarks
This type will be useful when a given string will need more than one character
on it. Sadly this type doesnโt work because TypeScript considers ""
a string,
so "" + "" === string
, same for "f" + ""
which is not a multi character
string.
Example
MultiDigitNumberString
ฦฌ MultiDigitNumberString: `${bigint}${bigint}`
String with more than 1 number on it.
Remarks
This type is useful when a given string will need more than one number on it.
Example
NotEmpty
ฦฌ NotEmpty<Type
>: Exclude
<Type
,
Empty
>
Type for a non-empty ArrayLike
, object
or string
.
Remarks
This type is useful for cases where you want to ensure that a value is not
empty. For example, if you have an array that should always have at least one
element, you could type it as NotEmpty<ArrayLike<ElementType>>
.
Example
See
Type parameters
Name | Type | Description |
---|---|---|
Type | extends ArrayLike | object | string | The type to check. |
Tagger
ฦฌ Tagger<Output
, Expressions
>: (templateStrings
:
TemplateStringsArray
, โฆexpressions
: Expressions
) => Output
Tag function for tagged templates.
Remarks
Type to represent a tag function for tagged templates, which takes a
TemplateStringArray
and any number of expressions, and returns a value of type
Output
(string
by default).
Example
See
Type parameters
Name | Type | Description |
---|---|---|
Output | string | Type of the output value. |
Expressions | extends ReadOnlyArray = ReadOnlyArray | Type of the expressions. |
Type declaration
โธ (templateStrings
, ...expressions
): Output
Parameters
Name | Type |
---|---|
templateStrings | TemplateStringsArray |
...expressions | Expressions |
Returns
Output
Tail
ฦฌ Tail<Input
>:
HeadAndTail
<Input
>[1
]
Last values of an ArrayLike (omitting the first).
Remarks
Type of the last items of an ArrayLike
, excluding the first item in said
ArrayLike.
Example
See
Type parameters
Name | Type | Description |
---|---|---|
Input | extends ArrayLike | Type of the array to get the tail. |