UNPKG

2.4 kBTypeScriptView Raw
1import { LWCErrorInfo } from '../shared/types';
2import { CompilerDiagnosticOrigin, CompilerDiagnostic, CompilerError } from './utils';
3export { CompilerDiagnosticOrigin, CompilerDiagnostic, CompilerError } from './utils';
4export * from './error-info';
5export interface ErrorConfig {
6 messageArgs?: any[];
7 origin?: CompilerDiagnosticOrigin;
8}
9export declare function generateErrorMessage(errorInfo: LWCErrorInfo, args?: any[]): string;
10/**
11 * Generates a compiler diagnostic. This function is used to look up the specified errorInfo
12 * and generate a friendly and consistent diagnostic object. Diagnostic contains
13 * info about the error's code and its origin (filename, line, column) when applicable.
14 *
15 * @param {LWCErrorInfo} errorInfo The object holding the error metadata.
16 * @param {ErrorConfig} config A config object providing any message arguments and origin info needed to create the error.
17 * @return {CompilerDiagnostic}
18 */
19export declare function generateCompilerDiagnostic(errorInfo: LWCErrorInfo, config?: ErrorConfig): CompilerDiagnostic;
20/**
21 * Generates a compiler error. This function is used to look up the specified errorInfo
22 * and generate a friendly and consistent error object. Error object contains info about
23 * the error's code and its origin (filename, line, column) when applicable.
24 *
25 * @param {LWCErrorInfo} errorInfo The object holding the error metadata.
26 * @param {ErrorConfig} config A config object providing any message arguments and origin info needed to create the error.
27 * @return {CompilerError}
28 */
29export declare function generateCompilerError(errorInfo: LWCErrorInfo, config?: ErrorConfig): CompilerError;
30export declare function invariant(condition: boolean, errorInfo: LWCErrorInfo, args?: any[]): void;
31/**
32 * Normalizes a received error into a CompilerError. Adds any provided additional origin info.
33 * @param errorInfo
34 * @param error
35 * @param origin
36 *
37 * @return {CompilerError}
38 */
39export declare function normalizeToCompilerError(errorInfo: LWCErrorInfo, error: any, origin?: CompilerDiagnosticOrigin): CompilerError;
40/**
41 * Normalizes a received error into a CompilerDiagnostic. Adds any provided additional origin info.
42 * @param error
43 * @param origin
44 *
45 * @return {CompilerDiagnostic}
46 */
47export declare function normalizeToDiagnostic(errorInfo: LWCErrorInfo, error: any, origin?: CompilerDiagnosticOrigin): CompilerDiagnostic;