Skip to content

Commit

Permalink
Add typescript typings
Browse files Browse the repository at this point in the history
  • Loading branch information
marvinhagemeister committed May 26, 2017
1 parent 19a4404 commit 9043261
Show file tree
Hide file tree
Showing 2 changed files with 77 additions and 0 deletions.
76 changes: 76 additions & 0 deletions index.d.ts
@@ -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;
}
}
1 change: 1 addition & 0 deletions package.json
Expand Up @@ -7,6 +7,7 @@
"main": "dist/magic-string.cjs.js",
"module": "dist/magic-string.es.js",
"jsnext:main": "dist/magic-string.es.js",
"typings": "index.d.ts",
"license": "MIT",
"dependencies": {
"vlq": "^0.2.1"
Expand Down

0 comments on commit 9043261

Please sign in to comment.