-
-
Notifications
You must be signed in to change notification settings - Fork 184
Expand file tree
/
Copy pathdiagnostics.ts
More file actions
74 lines (61 loc) · 2.74 KB
/
diagnostics.ts
File metadata and controls
74 lines (61 loc) · 2.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
import * as ts from "typescript";
import { createSerialDiagnosticFactory, createDiagnosticFactoryWithCode } from "../utils";
export const tstlOptionsAreMovingToTheTstlObject = createSerialDiagnosticFactory((tstl: Record<string, any>) => ({
category: ts.DiagnosticCategory.Warning,
messageText:
'TSTL options are moving to the "tstl" object. Adjust your tsconfig to look like\n' +
`"tstl": ${JSON.stringify(tstl, undefined, 4)}`,
}));
export const watchErrorSummary = (errorCount: number): ts.Diagnostic => ({
file: undefined,
start: undefined,
length: undefined,
category: ts.DiagnosticCategory.Message,
code: errorCount === 1 ? 6193 : 6194,
messageText:
errorCount === 1
? "Found 1 error. Watching for file changes."
: `Found ${errorCount} errors. Watching for file changes.`,
});
const createCommandLineError = <TArgs extends any[]>(code: number, getMessage: (...args: TArgs) => string) =>
createDiagnosticFactoryWithCode(code, (...args: TArgs) => ({ messageText: getMessage(...args) }));
export const unknownCompilerOption = createCommandLineError(
5023,
(name: string) => `Unknown compiler option '${name}'.`
);
export const compilerOptionRequiresAValueOfType = createCommandLineError(
5024,
(name: string, type: string) => `Compiler option '${name}' requires a value of type ${type}.`
);
export const compilerOptionCouldNotParseJson = createCommandLineError(
5025,
(name: string, error: string) => `Compiler option '${name}' failed to parse the given JSON value: '${error}'.`
);
export const optionProjectCannotBeMixedWithSourceFilesOnACommandLine = createCommandLineError(
5042,
() => "Option 'project' cannot be mixed with source files on a command line."
);
export const cannotFindATsconfigJsonAtTheSpecifiedDirectory = createCommandLineError(
5057,
(dir: string) => `Cannot find a tsconfig.json file at the specified directory: '${dir}'.`
);
export const theSpecifiedPathDoesNotExist = createCommandLineError(
5058,
(dir: string) => `The specified path does not exist: '${dir}'.`
);
export const compilerOptionExpectsAnArgument = createCommandLineError(
6044,
(name: string) => `Compiler option '${name}' expects an argument.`
);
export const argumentForOptionMustBe = createCommandLineError(
6046,
(name: string, values: string) => `Argument for '${name}' option must be: ${values}.`
);
export const optionCanOnlyBeSpecifiedInTsconfigJsonFile = createCommandLineError(
6064,
(name: string) => `Option '${name}' can only be specified in 'tsconfig.json' file.`
);
export const optionBuildMustBeFirstCommandLineArgument = createCommandLineError(
6369,
() => "Option '--build' must be the first command line argument."
);