Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't use declare module for TypeScript types #127

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
134 changes: 66 additions & 68 deletions index.d.ts
@@ -1,80 +1,78 @@
declare module "magic-string" {
export interface BundleOptions {
intro?: string;
separator?: string;
}
export interface BundleOptions {
intro?: string;
separator?: string;
}

export interface SourceMapOptions {
hires: boolean;
file: string;
source: string;
includeContent: boolean;
}
export interface SourceMapOptions {
hires: boolean;
file: string;
source: string;
includeContent: boolean;
}

export interface SourceMap {
file: string;
sources: string[];
sourcesContent: string;
names: string[];
mappings: string[];
export interface SourceMap {
file: string;
sources: string[];
sourcesContent: string;
names: string[];
mappings: string[];

toString(): string;
toUrl(): string;
}
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 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 type ExclusionRange = [ number, number ];
export type ExclusionRange = [ number, number ];

export interface MagicStringOptions {
filename: string,
indentExclusionRanges: ExclusionRange | Array<ExclusionRange>;
}
export interface MagicStringOptions {
filename: string,
indentExclusionRanges: ExclusionRange | Array<ExclusionRange>;
}

export interface IndentOptions {
exclude: ExclusionRange | Array<ExclusionRange>;
indentStart: boolean;
}
export interface IndentOptions {
exclude: ExclusionRange | Array<ExclusionRange>;
indentStart: boolean;
}

export interface OverwriteOptions {
storeName: boolean;
contentOnly: boolean;
}
export interface OverwriteOptions {
storeName: boolean;
contentOnly: boolean;
}

export default class MagicString {
constructor(str: string, options?: MagicStringOptions);
addSourcemapLocation(char: number): void;
append(content: string): MagicString;
appendLeft(index: number, content: string): MagicString;
appendRight(index: number, content: string): MagicString;
clone(): MagicString;
generateMap(options?: Partial<SourceMapOptions>): SourceMap;
getIndentString(): string;
export default class MagicString {
constructor(str: string, options?: MagicStringOptions);
addSourcemapLocation(char: number): void;
append(content: string): MagicString;
appendLeft(index: number, content: string): MagicString;
appendRight(index: number, content: string): MagicString;
clone(): MagicString;
generateMap(options?: Partial<SourceMapOptions>): SourceMap;
getIndentString(): string;

indent(options?: IndentOptions): MagicString;
indent(indentStr?: string, options?: IndentOptions): MagicString;
indent(options?: IndentOptions): 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;
}
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;
}