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

Add interfaces used by rollup #131

Merged
merged 3 commits into from Mar 12, 2018
Merged
Changes from 2 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
18 changes: 11 additions & 7 deletions index.d.ts
Expand Up @@ -11,30 +11,32 @@ export interface SourceMapOptions {
}

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

toString(): string;
toUrl(): string;
}

export class Bundle {
indentExclusionRanges: ExclusionRange | Array<ExclusionRange>;
constructor(options?: BundleOptions);
addSource(source: MagicString | { filename?: string, content: MagicString }): Bundle;
append(str: string, options: BundleOptions): 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;
trimLines(): Bundle;
trim(charType?: string): Bundle;
trimStart(charType?: string): Bundle;
trimEnd(charType?: string): Bundle;
}

export type ExclusionRange = [ number, number ];
Expand All @@ -55,6 +57,8 @@ export interface OverwriteOptions {
}

export default class MagicString {
indentExclusionRanges: Array<ExclusionRange>;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks to me like this could also be ExclusionRange | Array<ExclusionRange>, same as elsewhere. (Sneakily, clone uses indentExclusionRanges.slice(), which works with either a single range or an array of ranges.) Could you use the more general type here? (I may also be misreading it, but it looks like MagicString.indent handles either case.)


constructor(str: string, options?: MagicStringOptions);
addSourcemapLocation(char: number): void;
append(content: string): MagicString;
Expand Down