# Generic type variables

## `Wrap<`<mark style="color:green;">`Opening`</mark>`, ...>` <a href="#wrap-opening" id="wrap-opening"></a>

#### <mark style="color:green;">`Opening`</mark>`extends`<mark style="color:green;">`string`</mark>`=`<mark style="color:green;">`string`</mark>

​A generic type variable constrained by the [`string`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String), by default of the value **captured** from the provided [`opening`](https://wrapper.angular-package.dev/constructor#opening-opening) indicates the opening type of a new [`Wrap`](https://wrapper.angular-package.dev/wrap) instance.

{% code title="wrap.class.ts" %}

```typescript
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
  ) { ... }
  ...
}
```

{% endcode %}

## `Wrap<...,`<mark style="color:green;">`Text`</mark>`, ...>`

#### <mark style="color:green;">`Text`</mark>`extends`<mark style="color:green;">`string`</mark>`=`<mark style="color:green;">` `` `</mark>

​A generic type variable constrained by the [`string`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String), by default of the value **captured** from the provided [`text`](https://wrapper.angular-package.dev/constructor#text-text) indicates the text type of a new [`Wrap`](https://wrapper.angular-package.dev/wrap) instance.

{% hint style="info" %}
The constructor **`text`** parameter is optional, and if not provided, the default value of the generic type variable [`Text`](#wrap-less-than...-text-...greater-than) is not captured, but it's an empty [`string`](https://www.typescriptlang.org/docs/handbook/basic-types.html#string) from the declaration.
{% endhint %}

{% code title="wrap.class.ts" %}

```typescript
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.
  ) { ... }
  ...
}
```

{% endcode %}

## `Wrap<...,`<mark style="color:green;">`Closing`</mark>`>` <a href="#wrap-closing" id="wrap-closing"></a>

#### <mark style="color:green;">`Closing`</mark>`extends`<mark style="color:green;">`string`</mark>`=`<mark style="color:green;">`string`</mark>

​A generic type variable constrained by the [`string`](https://www.typescriptlang.org/docs/handbook/basic-types.html#string), by default of the value **captured** from the provided [`closing`](https://wrapper.angular-package.dev/constructor#closing-closing) indicates the closing type of a new [`Wrap`](https://wrapper.angular-package.dev/wrap) instance.

{% code title="wrap.class.ts" %}

```typescript
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
  ) { ... }
  ...
}
```

{% endcode %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://wrapper.angular-package.dev/wrap/generic-type-variables.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
