UNPKG

2.27 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/babel-code-frame).
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
11export interface SourceLocation {
12 start: { line: number; column?: number | undefined };
13 end?: { line: number; column?: number | undefined } | undefined;
14}
15export function codeFrameColumns(
16 rawLines: string,
17 location: SourceLocation,
18 options?: BabelCodeFrameOptions,
19): string;
20
21export interface BabelCodeFrameOptions {
22 /** Syntax highlight the code as JavaScript for terminals. default: false */
23 highlightCode?: boolean | undefined;
24 /** The number of lines to show above the error. default: 2 */
25 linesAbove?: number | undefined;
26 /** The number of lines to show below the error. default: 3 */
27 linesBelow?: number | undefined;
28 /**
29 * Forcibly syntax highlight the code as JavaScript (for non-terminals);
30 * overrides highlightCode.
31 * default: false
32 */
33 forceColor?: boolean | undefined;
34 /**
35 * Pass in a string to be displayed inline (if possible) next to the
36 * highlighted location in the code. If it can't be positioned inline,
37 * it will be placed above the code frame.
38 * default: nothing
39 */
40 message?: string | undefined;
41}
42
43/**
44 * Generate errors that contain a code frame that point to source locations.
45 *
46 * @param rawLines Raw lines to frame
47 * @param lineNumber Line number (1 indexed)
48 * @param colNumber Column number
49 * @param options Additional options
50 *
51 * @returns Framed code
52 */
53export default function codeFrame(
54 rawLines: string,
55 lineNumber: number,
56 colNumber: number,
57 options?: BabelCodeFrameOptions,
58): string;
59
60````
61
62### Additional Details
63 * Last updated: Mon, 06 Nov 2023 22:41:04 GMT
64 * Dependencies: none
65
66# Credits
67These definitions were written by [Mohsen Azimi](https://github.com/mohsen1), and [Forbes Lindesay](https://github.com/ForbesLindesay).
68
\No newline at end of file