decaffeinate
Version:
Move your CoffeeScript source to modern JavaScript.
73 lines (67 loc) • 2.13 kB
TypeScript
interface Suggestion {
suggestionCode: string;
message: string;
}
declare class PatchError extends Error {
readonly message: string;
readonly source: string;
readonly start: number;
readonly end: number;
constructor(message: string, source: string, start: number, end: number);
toString(): string;
/**
* Due to babel's inability to simulate extending native types, we have our
* own method for determining whether an object is an instance of
* `PatchError`.
*
* @see http://stackoverflow.com/a/33837088/549363
*/
static detect(error: Error): error is PatchError;
static prettyPrint(error: PatchError): string;
}
interface IO {
readonly stdin: NodeJS.ReadableStream;
readonly stdout: NodeJS.WritableStream;
readonly stderr: NodeJS.WritableStream;
}
/**
* Run the script with the user-supplied arguments.
*/
declare function run(args: ReadonlyArray<string>, io?: IO): Promise<number>;
interface Options {
filename?: string;
useCS2?: boolean;
runToStage?: string | null;
literate?: boolean;
disableSuggestionComment?: boolean;
noArrayIncludes?: boolean;
useJSModules?: boolean;
looseJSModules?: boolean;
safeImportFunctionIdentifiers?: Array<string>;
preferLet?: boolean;
loose?: boolean;
looseDefaultParams?: boolean;
looseForExpressions?: boolean;
looseForOf?: boolean;
looseIncludes?: boolean;
looseComparisonNegation?: boolean;
disallowInvalidConstructors?: boolean;
optionalChaining?: boolean;
logicalAssignment?: boolean;
nullishCoalescing?: boolean;
bare?: boolean;
}
interface ConversionResult {
code: string;
}
interface StageResult {
code: string;
suggestions: Array<Suggestion>;
}
/**
* Convert CoffeeScript source code into modern JavaScript preserving comments
* and formatting.
*/
declare function convert(source: string, options?: Options): ConversionResult;
declare function modernizeJS(source: string, options?: Options): ConversionResult;
export { ConversionResult, PatchError, StageResult, convert, modernizeJS, run };