﻿<head><script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-4357510538660394"
     crossorigin="anonymous"></script></head>---
url: /reference/Interface.RolldownMagicString.md
---
# Interface: RolldownMagicString

## Extends

* `RolldownMagicStringBase`

## Properties

### filename

* **Type**: `string` | `null`

#### Inherited from

`RolldownMagicStringBase.filename`

***

### hires

* **Type**: `boolean` | `"boundary"` | `null`

#### Inherited from

`RolldownMagicStringBase.hires`

***

### ignoreList

* **Type**: `boolean`

#### Inherited from

`RolldownMagicStringBase.ignoreList`

***

### indentExclusionRanges

* **Type**: `number`\[] | `number`\[]\[] | `null`

#### Inherited from

`RolldownMagicStringBase.indentExclusionRanges`

***

### isRolldownMagicString

* **Type**: `true`

***

### offset

* **Type**: `number`

#### Inherited from

`RolldownMagicStringBase.offset`

***

### original

* **Type**: `string`

#### Inherited from

`RolldownMagicStringBase.original`

## Methods

### append()

* **Type**: (`args`: \[`content`: `string`]) => `RolldownMagicString`

#### Parameters

##### args

...\[`content`: `string`]

#### Returns

`RolldownMagicString`

#### Inherited from

`RolldownMagicStringBase.append`

***

### appendLeft()

* **Type**: (`args`: \[`index`: `number`, `content`: `string`]) => `RolldownMagicString`

#### Parameters

##### args

...\[`index`: `number`, `content`: `string`]

#### Returns

`RolldownMagicString`

#### Inherited from

`RolldownMagicStringBase.appendLeft`

***

### appendRight()

* **Type**: (`args`: \[`index`: `number`, `content`: `string`]) => `RolldownMagicString`

#### Parameters

##### args

...\[`index`: `number`, `content`: `string`]

#### Returns

`RolldownMagicString`

#### Inherited from

`RolldownMagicStringBase.appendRight`

***

### clone()

* **Type**: (`args`: \[]) => `RolldownMagicString`

#### Parameters

##### args

...\[]

#### Returns

`RolldownMagicString`

#### Inherited from

`RolldownMagicStringBase.clone`

***

### generateDecodedMap()

* **Type**: (`options?`: `BindingSourceMapOptions` | `null`) => `Omit`<`BindingDecodedMap`, `"dropInner"`>

Generates a decoded source map for the transformations applied to this MagicString.
Returns a decoded source map object with mappings as an array of arrays.

#### Parameters

##### options?

`BindingSourceMapOptions` | `null`

#### Returns

`Omit`<`BindingDecodedMap`, `"dropInner"`>

***

### generateMap()

* **Type**: (`options?`: `BindingSourceMapOptions` | `null`) => `Omit`<`BindingSourceMap`, `"dropInner"`>

Generates a source map for the transformations applied to this MagicString.
Returns a source map object with version, file, sources, sourcesContent, names, mappings.

#### Parameters

##### options?

`BindingSourceMapOptions` | `null`

#### Returns

`Omit`<`BindingSourceMap`, `"dropInner"`>

***

### getIndentString()

* **Type**: () => `string`

Returns the guessed indentation string, or `\t` if none is found.

#### Returns

`string`

#### Inherited from

`RolldownMagicStringBase.getIndentString`

***

### hasChanged()

* **Type**: () => `boolean`

#### Returns

`boolean`

#### Inherited from

`RolldownMagicStringBase.hasChanged`

***

### indent()

* **Type**: (`args`: \[`indentor?`: `string` | `null`, `options?`: `BindingIndentOptions` | `null`]) => `RolldownMagicString`

#### Parameters

##### args

...\[`indentor?`: `string` | `null`, `options?`: `BindingIndentOptions` | `null`]

#### Returns

`RolldownMagicString`

#### Inherited from

`RolldownMagicStringBase.indent`

***

### insert()

* **Type**: (`index`: `number`, `content`: `string`) => `void`

Deprecated method that throws an error directing users to use prependRight or appendLeft.
This matches the original magic-string API which deprecated this method.

#### Parameters

##### index

`number`

##### content

`string`

#### Returns

`void`

#### Inherited from

`RolldownMagicStringBase.insert`

***

### isEmpty()

* **Type**: () => `boolean`

#### Returns

`boolean`

#### Inherited from

`RolldownMagicStringBase.isEmpty`

***

### lastChar()

* **Type**: () => `string`

Returns the last character of the generated string, or an empty string if empty.

#### Returns

`string`

#### Inherited from

`RolldownMagicStringBase.lastChar`

***

### lastLine()

* **Type**: () => `string`

Returns the content after the last newline in the generated string.

#### Returns

`string`

#### Inherited from

`RolldownMagicStringBase.lastLine`

***

### length()

* **Type**: () => `number`

#### Returns

`number`

#### Inherited from

`RolldownMagicStringBase.length`

***

### move()

* **Type**: (`args`: \[`start`: `number`, `end`: `number`, `index`: `number`]) => `RolldownMagicString`

#### Parameters

##### args

...\[`start`: `number`, `end`: `number`, `index`: `number`]

#### Returns

`RolldownMagicString`

#### Inherited from

`RolldownMagicStringBase.move`

***

### overwrite()

* **Type**: (`args`: \[`start`: `number`, `end`: `number`, `content`: `string`, `options?`: `BindingOverwriteOptions` | `null`]) => `RolldownMagicString`

#### Parameters

##### args

...\[`start`: `number`, `end`: `number`, `content`: `string`, `options?`: `BindingOverwriteOptions` | `null`]

#### Returns

`RolldownMagicString`

#### Inherited from

`RolldownMagicStringBase.overwrite`

***

### prepend()

* **Type**: (`args`: \[`content`: `string`]) => `RolldownMagicString`

#### Parameters

##### args

...\[`content`: `string`]

#### Returns

`RolldownMagicString`

#### Inherited from

`RolldownMagicStringBase.prepend`

***

### prependLeft()

* **Type**: (`args`: \[`index`: `number`, `content`: `string`]) => `RolldownMagicString`

#### Parameters

##### args

...\[`index`: `number`, `content`: `string`]

#### Returns

`RolldownMagicString`

#### Inherited from

`RolldownMagicStringBase.prependLeft`

***

### prependRight()

* **Type**: (`args`: \[`index`: `number`, `content`: `string`]) => `RolldownMagicString`

#### Parameters

##### args

...\[`index`: `number`, `content`: `string`]

#### Returns

`RolldownMagicString`

#### Inherited from

`RolldownMagicStringBase.prependRight`

***

### relocate()

* **Type**: (`args`: \[`start`: `number`, `end`: `number`, `to`: `number`]) => `RolldownMagicString`

#### Parameters

##### args

...\[`start`: `number`, `end`: `number`, `to`: `number`]

#### Returns

`RolldownMagicString`

#### Inherited from

`RolldownMagicStringBase.relocate`

***

### remove()

* **Type**: (`args`: \[`start`: `number`, `end`: `number`]) => `RolldownMagicString`

#### Parameters

##### args

...\[`start`: `number`, `end`: `number`]

#### Returns

`RolldownMagicString`

#### Inherited from

`RolldownMagicStringBase.remove`

***

### replace()

* **Type**: (`from`: `string` | `RegExp`, `to`: `string` | [`ReplacementFunction`](TypeAlias.ReplacementFunction.md)) => `this`

Accepts a string or RegExp pattern with a string replacement (`$&`, `$$`,
and `$N` substitutions are supported), or a replacer function invoked like
`String.prototype.replace`.

#### Parameters

##### from

`string` | `RegExp`

##### to

`string` | [`ReplacementFunction`](TypeAlias.ReplacementFunction.md)

#### Returns

`this`

***

### replaceAll()

* **Type**: (`from`: `string` | `RegExp`, `to`: `string` | [`ReplacementFunction`](TypeAlias.ReplacementFunction.md)) => `this`

Accepts a string or RegExp pattern (RegExp must have the global (`g`)
flag) with a string replacement, or a replacer function.

#### Parameters

##### from

`string` | `RegExp`

##### to

`string` | [`ReplacementFunction`](TypeAlias.ReplacementFunction.md)

#### Returns

`this`

***

### replaceRegex()

* **Type**: (`from`: `RegExp`, `to`: `string`) => `number`

Returns the UTF-16 offset past the last match, or -1 if no match was found.
The JS wrapper uses this to update `lastIndex` on the caller's RegExp.
Global/sticky behavior is derived from the regex's own flags.

#### Parameters

##### from

`RegExp`

##### to

`string`

#### Returns

`number`

#### Inherited from

`RolldownMagicStringBase.replaceRegex`

***

### reset()

* **Type**: (`args`: \[`start`: `number`, `end`: `number`]) => `RolldownMagicString`

#### Parameters

##### args

...\[`start`: `number`, `end`: `number`]

#### Returns

`RolldownMagicString`

#### Inherited from

`RolldownMagicStringBase.reset`

***

### slice()

* **Type**: (`start?`: `number` | `null`, `end?`: `number` | `null`) => `string`

Returns the content between the specified UTF-16 code unit positions (JS string indices).
Supports negative indices (counting from the end).

When an index falls in the middle of a surrogate pair, the lone surrogate is
included in the result (matching the original magic-string / JS behavior).
This is done by returning a UTF-16 encoded JS string via `napi_create_string_utf16`.

#### Parameters

##### start?

`number` | `null`

##### end?

`number` | `null`

#### Returns

`string`

#### Inherited from

`RolldownMagicStringBase.slice`

***

### snip()

* **Type**: (`args`: \[`start`: `number`, `end`: `number`]) => `RolldownMagicString`

#### Parameters

##### args

...\[`start`: `number`, `end`: `number`]

#### Returns

`RolldownMagicString`

#### Inherited from

`RolldownMagicStringBase.snip`

***

### toString()

* **Type**: () => `string`

#### Returns

`string`

#### Inherited from

`RolldownMagicStringBase.toString`

***

### trim()

* **Type**: (`args`: \[`charType?`: `string` | `null`]) => `RolldownMagicString`

#### Parameters

##### args

...\[`charType?`: `string` | `null`]

#### Returns

`RolldownMagicString`

#### Inherited from

`RolldownMagicStringBase.trim`

***

### trimEnd()

* **Type**: (`args`: \[`charType?`: `string` | `null`]) => `RolldownMagicString`

#### Parameters

##### args

...\[`charType?`: `string` | `null`]

#### Returns

`RolldownMagicString`

#### Inherited from

`RolldownMagicStringBase.trimEnd`

***

### trimLines()

* **Type**: (`args`: \[]) => `RolldownMagicString`

#### Parameters

##### args

...\[]

#### Returns

`RolldownMagicString`

#### Inherited from

`RolldownMagicStringBase.trimLines`

***

### trimStart()

* **Type**: (`args`: \[`charType?`: `string` | `null`]) => `RolldownMagicString`

#### Parameters

##### args

...\[`charType?`: `string` | `null`]

#### Returns

`RolldownMagicString`

#### Inherited from

`RolldownMagicStringBase.trimStart`

***

### update()

* **Type**: (`args`: \[`start`: `number`, `end`: `number`, `content`: `string`, `options?`: `BindingUpdateOptions` | `null`]) => `RolldownMagicString`

#### Parameters

##### args

...\[`start`: `number`, `end`: