-
-
Notifications
You must be signed in to change notification settings - Fork 538
Expand file tree
/
Copy pathindex.ts
More file actions
68 lines (65 loc) · 1.65 KB
/
index.ts
File metadata and controls
68 lines (65 loc) · 1.65 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
import * as core from '@vue/language-core';
import { posix as path } from 'path-browserify';
import * as ts from 'typescript';
import { createCheckerBase } from './lib/checker';
import type { MetaCheckerOptions } from './lib/types';
export * from './lib/types';
export function createCheckerByJson(
rootDir: string,
json: any,
checkerOptions: MetaCheckerOptions = {},
) {
rootDir = rootDir.replace(/\\/g, '/');
return createCheckerBase(
ts,
() => {
const commandLine = core.createParsedCommandLineByJson(ts, ts.sys, rootDir, json);
const { fileNames } = ts.parseJsonConfigFileContent(
json,
ts.sys,
rootDir,
{},
undefined,
undefined,
core.getAllExtensions(commandLine.vueOptions)
.map(extension => ({
extension: extension.slice(1),
isMixedContent: true,
scriptKind: ts.ScriptKind.Deferred,
})),
);
return [commandLine, fileNames];
},
checkerOptions,
rootDir,
);
}
export function createChecker(
tsconfig: string,
checkerOptions: MetaCheckerOptions = {},
) {
tsconfig = tsconfig.replace(/\\/g, '/');
return createCheckerBase(
ts,
() => {
const commandLine = core.createParsedCommandLine(ts, ts.sys, tsconfig);
const { fileNames } = ts.parseJsonSourceFileConfigFileContent(
ts.readJsonConfigFile(tsconfig, ts.sys.readFile),
ts.sys,
path.dirname(tsconfig),
{},
tsconfig,
undefined,
core.getAllExtensions(commandLine.vueOptions)
.map(extension => ({
extension: extension.slice(1),
isMixedContent: true,
scriptKind: ts.ScriptKind.Deferred,
})),
);
return [commandLine, fileNames];
},
checkerOptions,
path.dirname(tsconfig),
);
}