Generic type variables
Wrap<
Opening
, ...>
Wrap<
Opening
, ...>
Opening
extends
string
=
string
Opening
extends
string
=
string
A generic type variable constrained by the string
, by default of the value captured from the provided opening
indicates the opening type of a new Wrap
instance.
class Wrap<
Opening extends string = string, // <--- Declare generic type variable Opening.
Text extends string = ``,
Closing extends string = string
> extends String {
...
constructor(
opening: Opening, // <--- Capture generic type variable Opening.
closing: Closing,
text: Text = '' as Text
) { ... }
...
}
Wrap<...,
Text
, ...>
Wrap<...,
Text
, ...>
Text
extends
string
=
``
Text
extends
string
=
``
A generic type variable constrained by the string
, by default of the value captured from the provided text
indicates the text type of a new Wrap
instance.
class Wrap<
Opening extends string = string,
Text extends string = ``, // <--- Declare generic type variable Text.
Closing extends string = string
> extends String {
...
constructor(
opening: Opening,
closing: Closing,
text: Text = '' as Text // <--- Capture generic type variable Text.
) { ... }
...
}
Wrap<...,
Closing
>
Wrap<...,
Closing
>
Closing
extends
string
=
string
Closing
extends
string
=
string
A generic type variable constrained by the string
, by default of the value captured from the provided closing
indicates the closing type of a new Wrap
instance.
class Wrap<
Opening extends string = string,
Text extends string = ``,
Closing extends string = string // <--- Declare generic type variable Closing.
> extends String {
...
constructor(
opening: Opening,
closing: Closing, // <--- Capture generic type variable Closing.
text: Text = '' as Text
) { ... }
...
}
Last updated
Was this helpful?