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
39 lines (31 loc) · 1.72 KB
/
Copy pathdiagnostics.ts
File metadata and controls
39 lines (31 loc) · 1.72 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
import * as ts from "typescript";
import { createSerialDiagnosticFactory } from "../utils";
const createDiagnosticFactory = <TArgs extends any[]>(getMessage: (...args: TArgs) => string) =>
createSerialDiagnosticFactory((...args: TArgs) => ({ messageText: getMessage(...args) }));
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\"'.",
}));