@atlaspack/validator-typescript 2.14.5-canary.138 → 2.14.5-canary.139
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -48,6 +48,7 @@ function _tsUtils() {
|
|
48
48
|
}
|
49
49
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
50
50
|
// eslint-disable-line import/no-extraneous-dependencies
|
51
|
+
|
51
52
|
let langServiceCache = {};
|
52
53
|
var _default = exports.default = new (_plugin().Validator)({
|
53
54
|
async validateAll({
|
@@ -90,7 +91,9 @@ var _default = exports.default = new (_plugin().Validator)({
|
|
90
91
|
return validatorResults;
|
91
92
|
}
|
92
93
|
});
|
93
|
-
async function getConfig(asset, options,
|
94
|
+
async function getConfig(asset, options,
|
95
|
+
// @ts-expect-error TS2304
|
96
|
+
resolveConfigWithPath) {
|
94
97
|
let configNames = ['tsconfig.json'];
|
95
98
|
let tsconfig = await (0, _utils().loadConfig)(asset.fs, asset.filePath, configNames, options.projectRoot);
|
96
99
|
let configPath = await resolveConfigWithPath(configNames, asset.filePath);
|
@@ -116,8 +119,6 @@ function tryCreateLanguageService(config, asset, options) {
|
|
116
119
|
langServiceCache[config.configHash] = {
|
117
120
|
configHost,
|
118
121
|
host,
|
119
|
-
// $FlowFixMe[incompatible-variance]
|
120
|
-
// $FlowFixMe[incompatible-call]
|
121
122
|
service: _typescript().default.createLanguageService(host, _typescript().default.createDocumentRegistry())
|
122
123
|
};
|
123
124
|
}
|
@@ -171,6 +172,8 @@ function getValidateResultFromDiagnostics(filePath, diagnostics) {
|
|
171
172
|
};
|
172
173
|
}
|
173
174
|
}
|
175
|
+
|
176
|
+
// @ts-expect-error TS2345
|
174
177
|
validatorResult.errors.push({
|
175
178
|
origin: '@atlaspack/validator-typescript',
|
176
179
|
message: diagnosticMessage,
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@atlaspack/validator-typescript",
|
3
|
-
"version": "2.14.5-canary.
|
3
|
+
"version": "2.14.5-canary.139+d2fd84977",
|
4
4
|
"license": "(MIT OR Apache-2.0)",
|
5
5
|
"publishConfig": {
|
6
6
|
"access": "public"
|
@@ -9,17 +9,18 @@
|
|
9
9
|
"type": "git",
|
10
10
|
"url": "https://github.com/atlassian-labs/atlaspack.git"
|
11
11
|
},
|
12
|
-
"main": "lib/TypeScriptValidator.js",
|
13
|
-
"source": "src/TypeScriptValidator.
|
12
|
+
"main": "./lib/TypeScriptValidator.js",
|
13
|
+
"source": "./src/TypeScriptValidator.ts",
|
14
|
+
"types": "./lib/TypeScriptValidator.d.ts",
|
14
15
|
"engines": {
|
15
16
|
"node": ">= 16.0.0"
|
16
17
|
},
|
17
18
|
"dependencies": {
|
18
|
-
"@atlaspack/diagnostic": "2.14.1-canary.
|
19
|
-
"@atlaspack/plugin": "2.14.5-canary.
|
20
|
-
"@atlaspack/ts-utils": "2.14.1-canary.
|
21
|
-
"@atlaspack/types": "2.14.5-canary.
|
22
|
-
"@atlaspack/utils": "2.14.5-canary.
|
19
|
+
"@atlaspack/diagnostic": "2.14.1-canary.207+d2fd84977",
|
20
|
+
"@atlaspack/plugin": "2.14.5-canary.139+d2fd84977",
|
21
|
+
"@atlaspack/ts-utils": "2.14.1-canary.207+d2fd84977",
|
22
|
+
"@atlaspack/types": "2.14.5-canary.139+d2fd84977",
|
23
|
+
"@atlaspack/utils": "2.14.5-canary.139+d2fd84977"
|
23
24
|
},
|
24
25
|
"devDependencies": {
|
25
26
|
"typescript": ">=3.0.0"
|
@@ -28,5 +29,8 @@
|
|
28
29
|
"typescript": ">=3.0.0"
|
29
30
|
},
|
30
31
|
"type": "commonjs",
|
31
|
-
"
|
32
|
-
|
32
|
+
"scripts": {
|
33
|
+
"check-ts": "tsc --emitDeclarationOnly --rootDir src"
|
34
|
+
},
|
35
|
+
"gitHead": "d2fd849770fe6305e9c694bd97b1bd905abd9d94"
|
36
|
+
}
|
@@ -1,4 +1,3 @@
|
|
1
|
-
// @flow
|
2
1
|
import type {
|
3
2
|
Asset,
|
4
3
|
ConfigResult,
|
@@ -9,33 +8,32 @@ import type {LanguageService, Diagnostic} from 'typescript'; // eslint-disable-l
|
|
9
8
|
|
10
9
|
import path from 'path';
|
11
10
|
import ts from 'typescript';
|
12
|
-
import {
|
11
|
+
import {DiagnosticCodeFrame, escapeMarkdown} from '@atlaspack/diagnostic';
|
13
12
|
import {hashObject, loadConfig} from '@atlaspack/utils';
|
14
13
|
import {Validator} from '@atlaspack/plugin';
|
15
14
|
import {LanguageServiceHost, ParseConfigHost} from '@atlaspack/ts-utils';
|
16
15
|
|
17
16
|
let langServiceCache: {
|
18
|
-
[configHash: string]: {
|
19
|
-
configHost: ParseConfigHost
|
20
|
-
host: LanguageServiceHost
|
21
|
-
service: LanguageService
|
22
|
-
|
23
|
-
...
|
17
|
+
[configHash: string]: {
|
18
|
+
configHost: ParseConfigHost;
|
19
|
+
host: LanguageServiceHost;
|
20
|
+
service: LanguageService;
|
21
|
+
};
|
24
22
|
} = {};
|
25
23
|
|
26
|
-
type TSValidatorConfig = {
|
27
|
-
filepath:
|
28
|
-
baseDir: string
|
29
|
-
configHash: string
|
30
|
-
tsconfig: ConfigResult | null
|
31
|
-
|
24
|
+
type TSValidatorConfig = {
|
25
|
+
filepath: string | null | undefined;
|
26
|
+
baseDir: string;
|
27
|
+
configHash: string;
|
28
|
+
tsconfig: ConfigResult | null;
|
29
|
+
};
|
32
30
|
|
33
|
-
export default
|
31
|
+
export default new Validator({
|
34
32
|
async validateAll({
|
35
33
|
assets,
|
36
34
|
options,
|
37
35
|
resolveConfigWithPath,
|
38
|
-
}): Promise<Array
|
36
|
+
}): Promise<Array<ValidateResult | null | undefined>> {
|
39
37
|
// Build a collection that of all the LanguageServices related to files that just changed.
|
40
38
|
let servicesToValidate: Set<string> = new Set();
|
41
39
|
await Promise.all(
|
@@ -55,7 +53,7 @@ export default (new Validator({
|
|
55
53
|
);
|
56
54
|
|
57
55
|
// Ask typescript to analyze all changed programs and translate the results into ValidatorResult objects.
|
58
|
-
let validatorResults: Array
|
56
|
+
let validatorResults: Array<ValidateResult | null | undefined> = [];
|
59
57
|
servicesToValidate.forEach((configHash) => {
|
60
58
|
// Make sure that the filesystem being used by the LanguageServiceHost and ParseConfigHost is up-to-date.
|
61
59
|
// (This could change in the context of re-running tests, and probably also for other reasons).
|
@@ -76,12 +74,13 @@ export default (new Validator({
|
|
76
74
|
|
77
75
|
return validatorResults;
|
78
76
|
},
|
79
|
-
})
|
77
|
+
}) as Validator;
|
80
78
|
|
81
79
|
async function getConfig(
|
82
|
-
asset,
|
83
|
-
options,
|
84
|
-
|
80
|
+
asset: Asset,
|
81
|
+
options: PluginOptions,
|
82
|
+
// @ts-expect-error TS2304
|
83
|
+
resolveConfigWithPath: ResolveConfigWithPathFn,
|
85
84
|
): Promise<TSValidatorConfig> {
|
86
85
|
let configNames = ['tsconfig.json'];
|
87
86
|
let tsconfig = await loadConfig(
|
@@ -90,7 +89,7 @@ async function getConfig(
|
|
90
89
|
configNames,
|
91
90
|
options.projectRoot,
|
92
91
|
);
|
93
|
-
let configPath:
|
92
|
+
let configPath: string | null | undefined = await resolveConfigWithPath(
|
94
93
|
configNames,
|
95
94
|
asset.filePath,
|
96
95
|
);
|
@@ -130,8 +129,6 @@ function tryCreateLanguageService(
|
|
130
129
|
langServiceCache[config.configHash] = {
|
131
130
|
configHost,
|
132
131
|
host,
|
133
|
-
// $FlowFixMe[incompatible-variance]
|
134
|
-
// $FlowFixMe[incompatible-call]
|
135
132
|
service: ts.createLanguageService(host, ts.createDocumentRegistry()),
|
136
133
|
};
|
137
134
|
}
|
@@ -141,7 +138,7 @@ function tryCreateLanguageService(
|
|
141
138
|
/** Translates semantic diagnostics (from TypeScript) into a ValidateResult that Parcel understands. */
|
142
139
|
function getValidateResultFromDiagnostics(
|
143
140
|
filePath: string,
|
144
|
-
diagnostics:
|
141
|
+
diagnostics: ReadonlyArray<Diagnostic>,
|
145
142
|
): ValidateResult {
|
146
143
|
let validatorResult = {
|
147
144
|
warnings: [],
|
@@ -159,7 +156,7 @@ function getValidateResultFromDiagnostics(
|
|
159
156
|
: diagnostic.messageText.messageText,
|
160
157
|
);
|
161
158
|
|
162
|
-
let codeframe:
|
159
|
+
let codeframe: DiagnosticCodeFrame | null | undefined;
|
163
160
|
if (file != null && diagnostic.start != null) {
|
164
161
|
let source = file.text || diagnostic.source;
|
165
162
|
if (file.fileName) {
|
@@ -205,6 +202,7 @@ function getValidateResultFromDiagnostics(
|
|
205
202
|
}
|
206
203
|
}
|
207
204
|
|
205
|
+
// @ts-expect-error TS2345
|
208
206
|
validatorResult.errors.push({
|
209
207
|
origin: '@atlaspack/validator-typescript',
|
210
208
|
message: diagnosticMessage,
|
package/tsconfig.json
ADDED