UNPKG

1.63 kBMarkdownView Raw
1# Installation
2> `npm install --save @types/babel-code-frame`
3
4# Summary
5This package contains type definitions for babel-code-frame (https://github.com/babel/babel/tree/master/packages).
6
7# Details
8Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/babel-code-frame.
9## [index.d.ts](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/babel-code-frame/index.d.ts)
10````ts
11interface BabelCodeFrameOptions {
12 /** Syntax highlight the code as JavaScript for terminals. default: false */
13 highlightCode?: boolean | undefined;
14 /** The number of lines to show above the error. default: 2 */
15 linesBelow?: number | undefined;
16 /** The number of lines to show below the error. default: 3 */
17 linesAbove?: number | undefined;
18 /**
19 * Forcibly syntax highlight the code as JavaScript (for non-terminals);
20 * overrides highlightCode.
21 * default: false
22 */
23 forceColor?: boolean | undefined;
24}
25
26/**
27 * Generate errors that contain a code frame that point to source locations.
28 *
29 * @param rawLines Raw lines to frame
30 * @param lineNumber Line number (1 indexed)
31 * @param colNumber Column number
32 * @param options Additional options
33 *
34 * @returns Framed code
35 */
36declare function codeFrame(
37 rawLines: string,
38 lineNumber: number,
39 colNumber: number,
40 options?: BabelCodeFrameOptions,
41): string;
42
43export = codeFrame;
44
45````
46
47### Additional Details
48 * Last updated: Mon, 06 Nov 2023 22:41:04 GMT
49 * Dependencies: none
50
51# Credits
52These definitions were written by [Mohsen Azimi](https://github.com/mohsen1).
53
\No newline at end of file