Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #119 from marvinhagemeister/typings
Add typescript typings
- Loading branch information
Showing
2 changed files
with
77 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
declare module "magic-string" { | ||
export interface BundleOptions { | ||
intro?: string; | ||
separator?: string; | ||
} | ||
|
||
export interface SourceMapOptions { | ||
hires: boolean; | ||
file: string; | ||
sources: string[]; | ||
sourcesContent: string; | ||
includeContent: boolean; | ||
names: string[]; | ||
mappings: string[]; | ||
} | ||
|
||
class SourceMap { | ||
constructor(properties: SourceMapOptions); | ||
toString(): string; | ||
toUrl(): string; | ||
} | ||
|
||
export class Bundle { | ||
constructor(options?: BundleOptions); | ||
addSource(source: MagicString | { filename?: string, content: MagicString }): Bundle; | ||
append(str: string, options: BundleOptions): Bundle; | ||
clone(): Bundle; | ||
generateMap(options?: Partial<SourceMapOptions>): SourceMap; | ||
getIndentString(): string; | ||
indent(indentStr: string): Bundle; | ||
prepend(str: string): Bundle; | ||
toString(): string; | ||
trimLines(): string; | ||
trim(charType: string): string; | ||
trimStart(charType: string): Bundle; | ||
trimEnd(charType: string): Bundle; | ||
} | ||
|
||
export interface MagicStringOptions { | ||
filename: string, | ||
indentExclusionRanges: any; // TODO | ||
} | ||
|
||
export interface IndentOptions { | ||
exclude: any; // TODO | ||
indentStart: boolean; | ||
} | ||
|
||
export interface OverwriteOptions { | ||
storeName: boolean; | ||
contentOnly: boolean; | ||
} | ||
|
||
export default class MagicString { | ||
constructor(str: string, options?: MagicStringOptions); | ||
addSourcemapLocation(char: string): void; | ||
append(content: string): MagicString; | ||
appendLeft(index: number, content: string): MagicString; | ||
appendRight(index: number, content: string): MagicString; | ||
clone(): MagicString; | ||
generateMap(options?: Partial<SourceMapOptions>); | ||
getIndentString(): string; | ||
|
||
indent(options?): MagicString; | ||
indent(indentStr: string, options: IndentOptions): MagicString; | ||
|
||
move(start: number, end: number, index: number): MagicString; | ||
overwrite(start: number, end: number, content: string, options: boolean | OverwriteOptions): MagicString; | ||
prepend(content: string): MagicString; | ||
prependLeft(index: number, content: string): MagicString; | ||
prependRight(index: number, content: string): MagicString; | ||
remove(start: number, end: number): MagicString; | ||
slice(start: number, end: number): string; | ||
snip(start: number, end: number): MagicString; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters