UNPKG

1.25 kBTypeScriptView Raw
1// Type definitions for babel-code-frame 6.20
2// Project: https://github.com/babel/babel/tree/master/packages, https://babeljs.io
3// Definitions by: Mohsen Azimi <https://github.com/mohsen1>
4// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
5
6interface BabelCodeFrameOptions {
7 /** Syntax highlight the code as JavaScript for terminals. default: false */
8 highlightCode?: boolean | undefined;
9 /** The number of lines to show above the error. default: 2 */
10 linesBelow?: number | undefined;
11 /** The number of lines to show below the error. default: 3 */
12 linesAbove?: number | undefined;
13 /**
14 * Forcibly syntax highlight the code as JavaScript (for non-terminals);
15 * overrides highlightCode.
16 * default: false
17 */
18 forceColor?: boolean | undefined;
19}
20
21/**
22 * Generate errors that contain a code frame that point to source locations.
23 *
24 * @param rawLines Raw lines to frame
25 * @param lineNumber Line number (1 indexed)
26 * @param colNumber Column number
27 * @param options Additional options
28 *
29 * @returns Framed code
30 */
31declare function codeFrame(
32 rawLines: string,
33 lineNumber: number,
34 colNumber: number,
35 options?: BabelCodeFrameOptions
36): string;
37
38export = codeFrame;