1 | // Type definitions for @babel/code-frame 7.0
|
2 | // Project: https://github.com/babel/babel/tree/master/packages/babel-code-frame, https://babeljs.io
|
3 | // Definitions by: Mohsen Azimi <https://github.com/mohsen1>
|
4 | // Forbes Lindesay <https://github.com/ForbesLindesay>
|
5 | // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
6 |
|
7 | export interface SourceLocation {
|
8 | start: { line: number; column?: number | undefined };
|
9 | end?: { line: number; column?: number | undefined } | undefined;
|
10 | }
|
11 | export function codeFrameColumns(
|
12 | rawLines: string,
|
13 | location: SourceLocation,
|
14 | options?: BabelCodeFrameOptions
|
15 | ): string;
|
16 |
|
17 | export interface BabelCodeFrameOptions {
|
18 | /** Syntax highlight the code as JavaScript for terminals. default: false */
|
19 | highlightCode?: boolean | undefined;
|
20 | /** The number of lines to show above the error. default: 2 */
|
21 | linesAbove?: number | undefined;
|
22 | /** The number of lines to show below the error. default: 3 */
|
23 | linesBelow?: number | undefined;
|
24 | /**
|
25 | * Forcibly syntax highlight the code as JavaScript (for non-terminals);
|
26 | * overrides highlightCode.
|
27 | * default: false
|
28 | */
|
29 | forceColor?: boolean | undefined;
|
30 | /**
|
31 | * Pass in a string to be displayed inline (if possible) next to the
|
32 | * highlighted location in the code. If it can't be positioned inline,
|
33 | * it will be placed above the code frame.
|
34 | * default: nothing
|
35 | */
|
36 | message?: string | undefined;
|
37 | }
|
38 |
|
39 | /**
|
40 | * Generate errors that contain a code frame that point to source locations.
|
41 | *
|
42 | * @param rawLines Raw lines to frame
|
43 | * @param lineNumber Line number (1 indexed)
|
44 | * @param colNumber Column number
|
45 | * @param options Additional options
|
46 | *
|
47 | * @returns Framed code
|
48 | */
|
49 | export default function codeFrame(
|
50 | rawLines: string,
|
51 | lineNumber: number,
|
52 | colNumber: number,
|
53 | options?: BabelCodeFrameOptions
|
54 | ): string;
|