forked from TypeScriptToLua/TypeScriptToLua
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdiagnostics.ts
More file actions
88 lines (76 loc) · 2.79 KB
/
Copy pathdiagnostics.ts
File metadata and controls
88 lines (76 loc) · 2.79 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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
import * as ts from "typescript";
import { TranspileError } from "./TranspileError";
export const transpileError = (error: TranspileError) => ({
file: error.node.getSourceFile(),
start: error.node.getStart(),
length: error.node.getWidth(),
category: ts.DiagnosticCategory.Error,
code: 0,
source: "typescript-to-lua",
messageText: error.message,
});
export const tstlOptionsAreMovingToTheTstlObject = (tstl: Record<string, any>) => ({
file: undefined,
start: undefined,
length: undefined,
category: ts.DiagnosticCategory.Warning,
code: 0,
source: "typescript-to-lua",
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 = <Args extends any[]>(
code: number,
getMessage: (...args: Args) => string
) => (...args: Args): ts.Diagnostic => ({
file: undefined,
start: undefined,
length: undefined,
category: ts.DiagnosticCategory.Error,
code,
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 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 optionBuildMustBeFirstCommandLineArgument = createCommandLineError(
6369,
() => "Option '--build' must be the first command line argument."
);