-
-
Notifications
You must be signed in to change notification settings - Fork 184
Expand file tree
/
Copy pathdiagnostics.ts
More file actions
61 lines (48 loc) · 2.67 KB
/
diagnostics.ts
File metadata and controls
61 lines (48 loc) · 2.67 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
import * as ts from "typescript";
import { createSerialDiagnosticFactory } from "../utils";
const createDiagnosticFactory = <TArgs extends any[]>(
getMessage: (...args: TArgs) => string,
category: ts.DiagnosticCategory = ts.DiagnosticCategory.Error
) => createSerialDiagnosticFactory((...args: TArgs) => ({ messageText: getMessage(...args), category }));
export const couldNotResolveRequire = createDiagnosticFactory(
(requirePath: string, containingFile: string) =>
`Could not resolve lua source files for require path '${requirePath}' in file ${containingFile}.`
);
export const couldNotReadDependency = createDiagnosticFactory(
(dependency: string) => `Could not read content of resolved dependency ${dependency}.`
);
export const toLoadItShouldBeTranspiled = createDiagnosticFactory(
(kind: string, transform: string) =>
`To load "${transform}" ${kind} it should be transpiled or "ts-node" should be installed.`
);
export const couldNotResolveFrom = createDiagnosticFactory(
(kind: string, transform: string, base: string) => `Could not resolve "${transform}" ${kind} from "${base}".`
);
export const shouldHaveAExport = createDiagnosticFactory(
(kind: string, transform: string, importName: string) =>
`"${transform}" ${kind} should have a "${importName}" export.`
);
export const transformerShouldBeATsTransformerFactory = createDiagnosticFactory(
(transform: string) =>
`"${transform}" transformer should be a ts.TransformerFactory or an object with ts.TransformerFactory values.`
);
export const couldNotFindBundleEntryPoint = createDiagnosticFactory(
(entryPoint: string) => `Could not find bundle entry point '${entryPoint}'. It should be a file in the project.`
);
export const luaBundleEntryIsRequired = createDiagnosticFactory(
() => "'luaBundleEntry' is required when 'luaBundle' is enabled."
);
export const usingLuaBundleWithInlineMightGenerateDuplicateCode = createSerialDiagnosticFactory(() => ({
category: ts.DiagnosticCategory.Warning,
messageText:
"Using 'luaBundle' with 'luaLibImport: \"inline\"' might generate duplicate code. " +
"It is recommended to use 'luaLibImport: \"require\"'.",
}));
export const cannotBundleLibrary = createDiagnosticFactory(
() =>
'Cannot bundle projects with "buildmode": "library". Projects including the library can still bundle (which will include external library files).'
);
export const unsupportedJsxEmit = createDiagnosticFactory(() => 'JSX is only supported with "react" jsx option.');
export const pathsWithoutBaseUrl = createDiagnosticFactory(
() => "When configuring 'paths' in tsconfig.json, the option 'baseUrl' must also be provided."
);