jsii 5.9.44-dev.0 → 6.0.0-dev.0
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.
- package/README.md +73 -289
- package/lib/assembler.js +95 -46
- package/lib/assembler.js.map +1 -1
- package/lib/case.js +13 -10
- package/lib/case.js.map +1 -1
- package/lib/common/find-utils.js +35 -2
- package/lib/common/find-utils.js.map +1 -1
- package/lib/common/symbol-id.js +39 -7
- package/lib/common/symbol-id.js.map +1 -1
- package/lib/compiler.js +51 -8
- package/lib/compiler.js.map +1 -1
- package/lib/directives.js +48 -16
- package/lib/directives.js.map +1 -1
- package/lib/docs.js +36 -4
- package/lib/docs.js.map +1 -1
- package/lib/helpers.js +38 -4
- package/lib/helpers.js.map +1 -1
- package/lib/jsii-diagnostic.js +524 -497
- package/lib/jsii-diagnostic.js.map +1 -1
- package/lib/literate.js +35 -2
- package/lib/literate.js.map +1 -1
- package/lib/main.js +40 -7
- package/lib/main.js.map +1 -1
- package/lib/project-info.d.ts +1 -1
- package/lib/project-info.js +41 -11
- package/lib/project-info.js.map +1 -1
- package/lib/support.js +7 -4
- package/lib/support.js.map +1 -1
- package/lib/transforms/deprecated-remover.js +65 -23
- package/lib/transforms/deprecated-remover.js.map +1 -1
- package/lib/transforms/deprecation-warnings.js +50 -10
- package/lib/transforms/deprecation-warnings.js.map +1 -1
- package/lib/transforms/runtime-info.js +36 -2
- package/lib/transforms/runtime-info.js.map +1 -1
- package/lib/tsconfig/compiler-options.js +40 -5
- package/lib/tsconfig/compiler-options.js.map +1 -1
- package/lib/tsconfig/rulesets/configurable-options.js +10 -1
- package/lib/tsconfig/rulesets/configurable-options.js.map +1 -1
- package/lib/tsconfig/rulesets/deprecated-options.js +16 -1
- package/lib/tsconfig/rulesets/deprecated-options.js.map +1 -1
- package/lib/tsconfig/rulesets/generated.public.js +7 -2
- package/lib/tsconfig/rulesets/generated.public.js.map +1 -1
- package/lib/tsconfig/rulesets/jsii-configured-options.js +0 -1
- package/lib/tsconfig/rulesets/jsii-configured-options.js.map +1 -1
- package/lib/tsconfig/rulesets/minimal.public.js +4 -1
- package/lib/tsconfig/rulesets/minimal.public.js.map +1 -1
- package/lib/tsconfig/rulesets/strict.public.js +12 -9
- package/lib/tsconfig/rulesets/strict.public.js.map +1 -1
- package/lib/tsconfig/tsconfig-validator.js +9 -3
- package/lib/tsconfig/tsconfig-validator.js.map +1 -1
- package/lib/tsconfig/validator.d.ts +5 -0
- package/lib/tsconfig/validator.js +26 -16
- package/lib/tsconfig/validator.js.map +1 -1
- package/lib/type-analysis.js +39 -3
- package/lib/type-analysis.js.map +1 -1
- package/lib/type-reference.js +34 -1
- package/lib/type-reference.js.map +1 -1
- package/lib/type-tracker.js +35 -4
- package/lib/type-tracker.js.map +1 -1
- package/lib/type-visitor.js +34 -1
- package/lib/type-visitor.js.map +1 -1
- package/lib/utils.js +37 -2
- package/lib/utils.js.map +1 -1
- package/lib/validator.js +49 -11
- package/lib/validator.js.map +1 -1
- package/lib/version.d.ts +3 -3
- package/lib/version.js +2 -2
- package/lib/version.js.map +1 -1
- package/lib/warnings.js +34 -1
- package/lib/warnings.js.map +1 -1
- package/package.json +6 -8
- package/releases.json +3 -2
package/lib/jsii-diagnostic.js
CHANGED
|
@@ -1,22 +1,43 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
if (
|
|
4
|
-
|
|
5
|
-
if (
|
|
6
|
-
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
if (
|
|
11
|
-
|
|
12
|
-
};
|
|
13
|
-
var
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
14
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
36
|
exports.JsiiDiagnostic = exports.Code = void 0;
|
|
16
37
|
exports.configureCategories = configureCategories;
|
|
17
|
-
const spec = require("@jsii/spec");
|
|
38
|
+
const spec = __importStar(require("@jsii/spec"));
|
|
18
39
|
const case_1 = require("case");
|
|
19
|
-
const ts = require("typescript");
|
|
40
|
+
const ts = __importStar(require("typescript"));
|
|
20
41
|
const deprecation_warnings_1 = require("./transforms/deprecation-warnings");
|
|
21
42
|
const utils_1 = require("./utils");
|
|
22
43
|
/**
|
|
@@ -26,6 +47,8 @@ const utils_1 = require("./utils");
|
|
|
26
47
|
* warnings as errors, or to suppress certain undesirable warnings.
|
|
27
48
|
*/
|
|
28
49
|
class Code {
|
|
50
|
+
code;
|
|
51
|
+
name;
|
|
29
52
|
/**
|
|
30
53
|
* @internal
|
|
31
54
|
*/
|
|
@@ -83,6 +106,14 @@ class Code {
|
|
|
83
106
|
return category === name || specific === name;
|
|
84
107
|
});
|
|
85
108
|
}
|
|
109
|
+
static byCode = new Map();
|
|
110
|
+
static byName = new Map();
|
|
111
|
+
// eslint-disable-next-line @typescript-eslint/explicit-member-accessibility
|
|
112
|
+
#defaultCategory;
|
|
113
|
+
// eslint-disable-next-line @typescript-eslint/explicit-member-accessibility
|
|
114
|
+
#category;
|
|
115
|
+
// eslint-disable-next-line @typescript-eslint/explicit-member-accessibility
|
|
116
|
+
#formatter;
|
|
86
117
|
/**
|
|
87
118
|
* Registers a new diagnostic code.
|
|
88
119
|
*
|
|
@@ -94,14 +125,8 @@ class Code {
|
|
|
94
125
|
constructor(code, name, defaultCategory, formatter) {
|
|
95
126
|
this.code = code;
|
|
96
127
|
this.name = name;
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
// eslint-disable-next-line @typescript-eslint/explicit-member-accessibility
|
|
100
|
-
_Code_category.set(this, void 0);
|
|
101
|
-
// eslint-disable-next-line @typescript-eslint/explicit-member-accessibility
|
|
102
|
-
_Code_formatter.set(this, void 0);
|
|
103
|
-
__classPrivateFieldSet(this, _Code_defaultCategory, defaultCategory, "f");
|
|
104
|
-
__classPrivateFieldSet(this, _Code_formatter, formatter, "f");
|
|
128
|
+
this.#defaultCategory = defaultCategory;
|
|
129
|
+
this.#formatter = formatter;
|
|
105
130
|
if (code in Code.byCode) {
|
|
106
131
|
throw new Error(`Attempted to create two instances of ${this.constructor.name} with code ${code}`);
|
|
107
132
|
}
|
|
@@ -117,13 +142,13 @@ class Code {
|
|
|
117
142
|
* category.
|
|
118
143
|
*/
|
|
119
144
|
get isError() {
|
|
120
|
-
return
|
|
145
|
+
return this.#defaultCategory === ts.DiagnosticCategory.Error;
|
|
121
146
|
}
|
|
122
147
|
/**
|
|
123
148
|
* The diagnostic category this particular code is filed as.
|
|
124
149
|
*/
|
|
125
150
|
get category() {
|
|
126
|
-
return
|
|
151
|
+
return this.#category ?? this.#defaultCategory;
|
|
127
152
|
}
|
|
128
153
|
/**
|
|
129
154
|
* Update the diagnostic category for this particular code. If `isError` is
|
|
@@ -136,7 +161,7 @@ class Code {
|
|
|
136
161
|
if (this.isError && newValue !== ts.DiagnosticCategory.Error) {
|
|
137
162
|
throw new Error(`Illegal attempt to override category of error ${this.code} to ${ts.DiagnosticCategory[newValue]}`);
|
|
138
163
|
}
|
|
139
|
-
|
|
164
|
+
this.#category = newValue;
|
|
140
165
|
}
|
|
141
166
|
/**
|
|
142
167
|
* Creates a new `JsiiDiagnostic` message without any source code location
|
|
@@ -149,7 +174,7 @@ class Code {
|
|
|
149
174
|
* for the `location` parameter whenever possible.
|
|
150
175
|
*/
|
|
151
176
|
createDetached(...args) {
|
|
152
|
-
return new JsiiDiagnostic(this,
|
|
177
|
+
return new JsiiDiagnostic(this, this.#formatter(...args));
|
|
153
178
|
}
|
|
154
179
|
/**
|
|
155
180
|
* Creates a new `JsiiDiagnostic` message with source code location denoted
|
|
@@ -159,17 +184,459 @@ class Code {
|
|
|
159
184
|
* @param args the arguments to the message formatter.
|
|
160
185
|
*/
|
|
161
186
|
create(location, ...args) {
|
|
162
|
-
return new JsiiDiagnostic(this,
|
|
187
|
+
return new JsiiDiagnostic(this, this.#formatter(...args), location);
|
|
163
188
|
}
|
|
164
189
|
}
|
|
165
190
|
exports.Code = Code;
|
|
166
|
-
_Code_defaultCategory = new WeakMap(), _Code_category = new WeakMap(), _Code_formatter = new WeakMap();
|
|
167
|
-
Code.byCode = new Map();
|
|
168
|
-
Code.byName = new Map();
|
|
169
191
|
/**
|
|
170
192
|
* A jsii-specific diagnostic entry.
|
|
171
193
|
*/
|
|
172
194
|
class JsiiDiagnostic {
|
|
195
|
+
//////////////////////////////////////////////////////////////////////////////
|
|
196
|
+
// 0001 => 0999 -- PACKAGE METADATA PROBLEMS
|
|
197
|
+
static JSII_0001_PKG_MISSING_DESCRIPTION = Code.suggestion({
|
|
198
|
+
code: 1,
|
|
199
|
+
formatter: () => 'A "description" field should be specified in "package.json"',
|
|
200
|
+
name: 'metadata/package-json-missing-description',
|
|
201
|
+
});
|
|
202
|
+
static JSII_0002_PKG_MISSING_HOMEPAGE = Code.suggestion({
|
|
203
|
+
code: 2,
|
|
204
|
+
formatter: () => 'A "homepage" field should be specified in "package.json"',
|
|
205
|
+
name: 'metadata/package-json-missing-homepage',
|
|
206
|
+
});
|
|
207
|
+
static JSII_0003_MISSING_README = Code.warning({
|
|
208
|
+
code: 3,
|
|
209
|
+
formatter: () => 'There is no "README.md" file. It is required in order to generate valid PyPI (Python) packages.',
|
|
210
|
+
name: 'metadata/missing-readme',
|
|
211
|
+
});
|
|
212
|
+
static JSII_0004_COULD_NOT_FIND_ENTRYPOINT = Code.error({
|
|
213
|
+
code: 4,
|
|
214
|
+
formatter: (mainFile) => `Could not find "main" file: ${mainFile}`,
|
|
215
|
+
name: 'metadata/could-not-find-entrypoint',
|
|
216
|
+
});
|
|
217
|
+
static JSII_0005_MISSING_PEER_DEPENDENCY = Code.warning({
|
|
218
|
+
code: 5,
|
|
219
|
+
formatter: (assm, reference) => `The type "${reference}" is exposed in the public API of this module. ` +
|
|
220
|
+
`Therefore, the module "${assm}" must also be defined under "peerDependencies". ` +
|
|
221
|
+
'This will be auto-corrected unless --no-fix-peer-dependencies was specified.',
|
|
222
|
+
name: 'metadata/missing-peer-dependency',
|
|
223
|
+
});
|
|
224
|
+
// NOTE: currently not possible to change the severity of this code,
|
|
225
|
+
// as it's being emitted before the overrides have been loaded
|
|
226
|
+
static JSII_0006_MISSING_DEV_DEPENDENCY = Code.warning({
|
|
227
|
+
code: 6,
|
|
228
|
+
formatter: (dependencyName, peerRange, minVersion, actual) => `A "peerDependency" on "${dependencyName}" at "${peerRange}" means you ` +
|
|
229
|
+
`should take a "devDependency" on "${dependencyName}" at "${minVersion}" ` +
|
|
230
|
+
`(found ${JSON.stringify(actual)})`,
|
|
231
|
+
name: 'metadata/missing-dev-dependency',
|
|
232
|
+
});
|
|
233
|
+
static JSII_0007_MISSING_WARNINGS_EXPORT = Code.error({
|
|
234
|
+
code: 7,
|
|
235
|
+
formatter: () => 'If you are compiling with --add-deprecation-warnings and your package.json ' +
|
|
236
|
+
`declares subpath exports, you must include { "./${deprecation_warnings_1.WARNINGSCODE_FILE_NAME}": "./${deprecation_warnings_1.WARNINGSCODE_FILE_NAME}" } ` +
|
|
237
|
+
'in the set of exports.',
|
|
238
|
+
name: 'metadata/missing-warnings-export',
|
|
239
|
+
});
|
|
240
|
+
//////////////////////////////////////////////////////////////////////////////
|
|
241
|
+
// 1000 => 1999 -- TYPESCRIPT LANGUAGE RESTRICTIONS
|
|
242
|
+
static JSII_1000_NO_CONST_ENUM = Code.error({
|
|
243
|
+
code: 1000,
|
|
244
|
+
formatter: () => 'Exported "const enum" declarations are not allowed',
|
|
245
|
+
name: 'typescript-restrictions/no-const-enum',
|
|
246
|
+
});
|
|
247
|
+
static JSII_1001_TYPE_HAS_NO_SYMBOL = Code.error({
|
|
248
|
+
code: 1001,
|
|
249
|
+
formatter: () => 'Non-primitive types without a symbol cannot be processed.',
|
|
250
|
+
name: 'typescript-restrictions/type-has-no-symbol',
|
|
251
|
+
});
|
|
252
|
+
static JSII_1002_UNSPECIFIED_PROMISE = Code.error({
|
|
253
|
+
code: 1002,
|
|
254
|
+
formatter: () => 'Un-specified promise type. Specify it using "Promise<T>"',
|
|
255
|
+
name: 'typescript-restrictions/unspecified-promise',
|
|
256
|
+
});
|
|
257
|
+
static JSII_1003_UNSUPPORTED_TYPE = Code.error({
|
|
258
|
+
code: 1003,
|
|
259
|
+
formatter: (messageText) => messageText,
|
|
260
|
+
name: 'typescript-restrictions/unsupported-type',
|
|
261
|
+
});
|
|
262
|
+
static JSII_1004_DUPLICATE_ENUM_VALUE = Code.error({
|
|
263
|
+
code: 1004,
|
|
264
|
+
formatter: (enumValue, enumMemberNames) => `Value ${enumValue} is used for multiple enum values: ${enumMemberNames.join(', ')}`,
|
|
265
|
+
name: 'typescript-restrictions/duplicate-enum-value',
|
|
266
|
+
});
|
|
267
|
+
static JSII_1005_SEPARATE_WRITE_TYPE = Code.error({
|
|
268
|
+
code: 1005,
|
|
269
|
+
formatter: () => 'Visible property signatures cannot use a separate write type. Use the same type as the getter.',
|
|
270
|
+
name: 'typescript-restrictions/separate-write-type',
|
|
271
|
+
});
|
|
272
|
+
static JSII_1006_GENERIC_TYPE = Code.error({
|
|
273
|
+
code: 1006,
|
|
274
|
+
formatter: () => 'Generic types are not supported because semantics are not uniform in target languages.',
|
|
275
|
+
name: 'typescript-restriction/generic-type',
|
|
276
|
+
});
|
|
277
|
+
static JSII_1007_NEVER_TYPE = Code.error({
|
|
278
|
+
code: 1007,
|
|
279
|
+
formatter: () => 'The "never" type is not allowed because it cannot be represented in target languages.',
|
|
280
|
+
name: 'typescript-restriction/no-never-type',
|
|
281
|
+
});
|
|
282
|
+
static JSII_1008_ONLY_INTERFACE_INTERSECTION = Code.error({
|
|
283
|
+
code: 1008,
|
|
284
|
+
formatter: (type) => `Found non-interface type in type intersection: ${type}`,
|
|
285
|
+
name: 'typescript-restriction/only-interface-intersection',
|
|
286
|
+
});
|
|
287
|
+
static JSII_1009_INTERSECTION_ONLY_INPUT = Code.error({
|
|
288
|
+
code: 1009,
|
|
289
|
+
formatter: (location) => `Intersection types may only be used as inputs, but ${location} is used as output`,
|
|
290
|
+
name: 'typescript-restriction/intersection-only-input',
|
|
291
|
+
});
|
|
292
|
+
static JSII_1010_INTERSECTION_NOT_IN_CTOR = Code.error({
|
|
293
|
+
code: 1010,
|
|
294
|
+
formatter: () => `Intersection types cannot be used as constructor arguments`,
|
|
295
|
+
name: 'typescript-restriction/intersection-no-ctor',
|
|
296
|
+
});
|
|
297
|
+
static JSII_1011_INTERSECTION_MEMBER_DIFFERENT = Code.error({
|
|
298
|
+
code: 1011,
|
|
299
|
+
formatter: (member, type1, reason1, type2, reason2) => `Member ${member} is different between types in a type intersection: ${type1} (${reason1}) and ${type2} (${reason2})`,
|
|
300
|
+
name: 'typescript-restriction/intersection-member-different',
|
|
301
|
+
});
|
|
302
|
+
static JSII_1012_ONLY_CONST_ENUM_MEMBERS = Code.error({
|
|
303
|
+
code: 1012,
|
|
304
|
+
formatter: () => 'Only constant enum members are allowed',
|
|
305
|
+
name: 'typescript-restrictions/only-const-enum-members',
|
|
306
|
+
});
|
|
307
|
+
static JSII_1999_UNSUPPORTED = Code.error({
|
|
308
|
+
code: 1999,
|
|
309
|
+
formatter: ({ what, alternative, suggestInternal, }) => `${what} are not supported in jsii APIs.${alternative ? ` Consider using ${alternative} instead.` : ''}${suggestInternal
|
|
310
|
+
? ` This declaration must${alternative ? ' otherwise' : ''} be marked "@internal" or "@jsii ignore".`
|
|
311
|
+
: ''}`,
|
|
312
|
+
name: 'typescript-restrictions/unsupported',
|
|
313
|
+
});
|
|
314
|
+
//////////////////////////////////////////////////////////////////////////////
|
|
315
|
+
// 2000 => 2999 -- INCORRECT USE OF THE @jsii DIRECTIVE
|
|
316
|
+
static JSII_2000_MISSING_DIRECTIVE_ARGUMENT = Code.warning({
|
|
317
|
+
code: 2000,
|
|
318
|
+
formatter: () => 'Missing argument to @jsii directive. Refer to the jsii compiler documentation for more information.',
|
|
319
|
+
name: 'jsii-directive/missing-argument',
|
|
320
|
+
});
|
|
321
|
+
static JSII_2100_STRUCT_ON_NON_INTERFACE = Code.warning({
|
|
322
|
+
code: 2100,
|
|
323
|
+
formatter: () => 'The "@jsii struct" directive is only applicable to interface declarations.',
|
|
324
|
+
name: 'jsii-directive/struct-on-non-interface',
|
|
325
|
+
});
|
|
326
|
+
static JSII_2999_UNKNOWN_DIRECTIVE = Code.warning({
|
|
327
|
+
code: 2999,
|
|
328
|
+
formatter: (text) => `Unknown @jsii directive: ${JSON.stringify(text)}. Refer to the jsii compiler documentation for more information.`,
|
|
329
|
+
name: 'jsii-directive/unknown',
|
|
330
|
+
});
|
|
331
|
+
//////////////////////////////////////////////////////////////////////////////
|
|
332
|
+
// 3000 => 3999 -- TYPE MODEL COHERENCE
|
|
333
|
+
static JSII_3000_EXPORTED_API_USES_HIDDEN_TYPE = Code.error({
|
|
334
|
+
code: 3000,
|
|
335
|
+
formatter: (badFqn) => `Exported APIs cannot use un-exported type "${badFqn}"`,
|
|
336
|
+
name: 'type-model/exported-api-cannot-use-unexported-type',
|
|
337
|
+
});
|
|
338
|
+
static JSII_3001_EXPOSED_INTERNAL_TYPE = Code.error({
|
|
339
|
+
code: 3001,
|
|
340
|
+
formatter: (symbol, isThisType, typeUse) => `Type ${isThisType ? `"this" (aka: "${symbol.name}")` : `"${symbol.name}"`} cannot be used as the ${typeUse} because it is private or @internal`,
|
|
341
|
+
name: 'type-model/use-of-internal-type',
|
|
342
|
+
});
|
|
343
|
+
static JSII_3002_USE_OF_UNEXPORTED_FOREIGN_TYPE = Code.error({
|
|
344
|
+
code: 3002,
|
|
345
|
+
formatter: (fqn, typeUse, pkg) => `Type "${fqn}" cannot be used as a ${typeUse} because it is not exported from ${pkg.name}`,
|
|
346
|
+
name: 'type-model/unexported-foreign-type',
|
|
347
|
+
});
|
|
348
|
+
static JSII_3003_SYMBOL_IS_EXPORTED_TWICE = Code.error({
|
|
349
|
+
code: 3003,
|
|
350
|
+
formatter: (ns1, ns2) => `Symbol is exported under two distinct submodules: ${ns1} and ${ns2}`,
|
|
351
|
+
name: 'type-model/symbol-is-exported-twice',
|
|
352
|
+
});
|
|
353
|
+
static JSII_3004_INVALID_SUPERTYPE = Code.error({
|
|
354
|
+
code: 3004,
|
|
355
|
+
formatter: (clause, badDeclaration) => {
|
|
356
|
+
return `Illegal ${clauseType(clause.token)} clause for an exported API: ${ts.SyntaxKind[badDeclaration.kind]}`;
|
|
357
|
+
function clauseType(token) {
|
|
358
|
+
switch (token) {
|
|
359
|
+
case ts.SyntaxKind.ExtendsKeyword:
|
|
360
|
+
return 'extends';
|
|
361
|
+
case ts.SyntaxKind.ImplementsKeyword:
|
|
362
|
+
return 'implements';
|
|
363
|
+
default:
|
|
364
|
+
return ts.SyntaxKind[token];
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
},
|
|
368
|
+
name: 'type-model/invalid-supertype',
|
|
369
|
+
});
|
|
370
|
+
static JSII_3005_TYPE_USED_AS_INTERFACE = Code.error({
|
|
371
|
+
code: 3005,
|
|
372
|
+
formatter: (badType) => `Type "${spec.describeTypeReference(badType)}" cannot be used as an interface`,
|
|
373
|
+
name: 'type-model/type-used-as-interface',
|
|
374
|
+
});
|
|
375
|
+
static JSII_3006_TYPE_USED_AS_CLASS = Code.error({
|
|
376
|
+
code: 3006,
|
|
377
|
+
formatter: (badType) => `Type "${spec.describeTypeReference(badType)}" cannot be used as a class`,
|
|
378
|
+
name: 'type-model/type-used-as-class',
|
|
379
|
+
});
|
|
380
|
+
static JSII_3007_ILLEGAL_STRUCT_EXTENSION = Code.error({
|
|
381
|
+
code: 3007,
|
|
382
|
+
formatter: (offender, struct) => `Attempt to extend or implement struct "${struct.fqn}" from "${offender.fqn}"`,
|
|
383
|
+
name: 'type-model/illegal-struct-extension',
|
|
384
|
+
});
|
|
385
|
+
static JSII_3008_STRUCT_PROPS_MUST_BE_READONLY = Code.error({
|
|
386
|
+
code: 3008,
|
|
387
|
+
formatter: (propName, struct) => `The "${propName}" property of struct "${struct.fqn}" must be "readonly". Rename "${struct.fqn}" to "I${struct.name}" if it is meant to be a behavioral interface.`,
|
|
388
|
+
name: 'type-model/struct-props-must-be-readonly',
|
|
389
|
+
});
|
|
390
|
+
static JSII_3009_OPTIONAL_PARAMETER_BEFORE_REQUIRED = Code.error({
|
|
391
|
+
code: 3009,
|
|
392
|
+
formatter: (param, nextParam) => `Parameter "${param.name}" cannot be optional, as it precedes required parameter "${nextParam.name}"`,
|
|
393
|
+
name: 'type-model/optional-parameter-before-required',
|
|
394
|
+
});
|
|
395
|
+
static JSII_3999_INCOHERENT_TYPE_MODEL = Code.error({
|
|
396
|
+
code: 3999,
|
|
397
|
+
formatter: (messageText) => messageText,
|
|
398
|
+
name: 'type-model/incoherent-type-model',
|
|
399
|
+
});
|
|
400
|
+
//////////////////////////////////////////////////////////////////////////////
|
|
401
|
+
// 4000 => 4999 -- TYPESCRIPT & JSII CONFIG ERRORS
|
|
402
|
+
static JSII_4000_FAILED_TSCONFIG_VALIDATION = Code.error({
|
|
403
|
+
code: 4000,
|
|
404
|
+
formatter: (config, ruleSet, violations) => {
|
|
405
|
+
return `Typescript compiler options in "${config}" are not passing validation against rule set "${ruleSet}", found the following rule violations:\n${violations
|
|
406
|
+
.map((v) => ` - ${v.field}: ${v.message}`)
|
|
407
|
+
.join('\n')}`;
|
|
408
|
+
},
|
|
409
|
+
name: 'typescript-config/invalid-tsconfig',
|
|
410
|
+
});
|
|
411
|
+
static JSII_4009_DISABLED_TSCONFIG_VALIDATION = Code.warning({
|
|
412
|
+
code: 4009,
|
|
413
|
+
formatter: (config) => `Validation of typescript config "${config}" is disabled. This is intended for experimental setups only. Compilation might fail or produce incompatible artifacts.`,
|
|
414
|
+
name: 'typescript-config/disabled-tsconfig-validation',
|
|
415
|
+
});
|
|
416
|
+
static JSII_4010_SUBMODULE_NAMESPACE_CONFLICT = Code.warning({
|
|
417
|
+
code: 4010,
|
|
418
|
+
formatter: (language, namespace, modules) => `Multiple modules emit to the same ${language} namespace "${namespace}": ${modules.join(', ')}`,
|
|
419
|
+
name: 'jsii-config/submodule-conflict',
|
|
420
|
+
});
|
|
421
|
+
//////////////////////////////////////////////////////////////////////////////
|
|
422
|
+
// 5000 => 5999 -- LANGUAGE COMPATIBILITY ERRORS
|
|
423
|
+
static JSII_5000_JAVA_GETTERS = Code.error({
|
|
424
|
+
code: 5000,
|
|
425
|
+
formatter: (badName, typeName) => `Methods and properties cannot have names like "getXxx": those conflict with Java property getters. Rename "${typeName}.${badName}"`,
|
|
426
|
+
name: 'language-compatibility/potential-java-getter-conflict',
|
|
427
|
+
});
|
|
428
|
+
static JSII_5001_JAVA_SETTERS = Code.error({
|
|
429
|
+
code: 5001,
|
|
430
|
+
formatter: (badName, typeName) => `Methods and properties cannot have names like "setXxx": those conflict with Java property setters. Rename "${typeName}.${badName}"`,
|
|
431
|
+
name: 'language-compatibility/potential-java-setter-conflict',
|
|
432
|
+
});
|
|
433
|
+
static JSII_5002_OVERRIDE_CHANGES_VISIBILITY = Code.error({
|
|
434
|
+
code: 5002,
|
|
435
|
+
formatter: (newElement, action, newValue, oldValue) => `"${newElement}" changes visibility to ${newValue} when ${action}. Change it to ${oldValue}`,
|
|
436
|
+
name: 'language-compatibility/override-changes-visibility',
|
|
437
|
+
});
|
|
438
|
+
static JSII_5003_OVERRIDE_CHANGES_RETURN_TYPE = Code.error({
|
|
439
|
+
code: 5003,
|
|
440
|
+
formatter: (newElement, action, newValue, oldValue) => `"${newElement}" changes the return type to "${newValue}" when ${action}. Change it to "${oldValue}"`,
|
|
441
|
+
name: 'language-compatibility/override-changes-return-type',
|
|
442
|
+
});
|
|
443
|
+
static JSII_5004_OVERRIDE_CHANGES_PROP_TYPE = Code.error({
|
|
444
|
+
code: 5004,
|
|
445
|
+
formatter: (newElement, action, newType, oldType) => `"${newElement}" changes the property type to "${spec.describeTypeReference(newType)}" when ${action}. Change it to "${spec.describeTypeReference(oldType)}"`,
|
|
446
|
+
name: 'language-compatibility/override-changes-property-type',
|
|
447
|
+
});
|
|
448
|
+
static JSII_5005_OVERRIDE_CHANGES_PARAM_COUNT = Code.error({
|
|
449
|
+
code: 5005,
|
|
450
|
+
formatter: (newElement, action, newCount, oldCount) => `"${newElement}" has ${newCount} parameters when ${action}. It should accept ${oldCount} parameters`,
|
|
451
|
+
name: 'language-compatibility/override-changes-param-count',
|
|
452
|
+
});
|
|
453
|
+
static JSII_5006_OVERRIDE_CHANGES_PARAM_TYPE = Code.error({
|
|
454
|
+
code: 5006,
|
|
455
|
+
formatter: (newElement, action, newParam, oldParam) => `"${newElement}" changes the type of parameter "${newParam.name}" to ${spec.describeTypeReference(newParam.type)} when ${action}. Change it to ${spec.describeTypeReference(oldParam.type)}`,
|
|
456
|
+
name: 'language-compatibility/override-changes-param-type',
|
|
457
|
+
});
|
|
458
|
+
static JSII_5007_OVERRIDE_CHANGES_VARIADIC = Code.error({
|
|
459
|
+
code: 5007,
|
|
460
|
+
formatter: (newElement, action, newVariadic = false, oldVariadic = false) => `"${newElement}" turns ${newVariadic ? 'variadic' : 'non variadic'} when ${action}. Make it ${oldVariadic ? 'variadic' : 'non-variadic'}`,
|
|
461
|
+
name: 'language-compatibility/override-changes-variadic',
|
|
462
|
+
});
|
|
463
|
+
static JSII_5008_OVERRIDE_CHANGES_PARAM_OPTIONAL = Code.error({
|
|
464
|
+
code: 5008,
|
|
465
|
+
formatter: (newElement, action, newParam, oldParam) => `"${newElement}" turns parameter "${newParam.name}" ${newParam.optional ? 'optional' : 'required'} when ${action}. Make it ${oldParam.optional ? 'optional' : 'required'}`,
|
|
466
|
+
name: 'language-compatibility/override-changes-param-optional',
|
|
467
|
+
});
|
|
468
|
+
static JSII_5009_OVERRIDE_CHANGES_PROP_OPTIONAL = Code.error({
|
|
469
|
+
code: 5009,
|
|
470
|
+
formatter: (newElement, action, newOptional = false, oldOptional = false) => `"${newElement}" turns ${newOptional ? 'optional' : 'required'} when ${action}. Make it ${oldOptional ? 'optional' : 'required'}`,
|
|
471
|
+
name: 'language-compatibility/override-changes-prop-optional',
|
|
472
|
+
});
|
|
473
|
+
static JSII_5010_OVERRIDE_CHANGES_MUTABILITY = Code.error({
|
|
474
|
+
code: 5010,
|
|
475
|
+
formatter: (newElement, action, newReadonly = false, oldReadonly = false) => `"${newElement}" turns ${newReadonly ? 'readonly' : 'mutable'} when ${action}. Make it ${oldReadonly ? 'readonly' : 'mutable'}`,
|
|
476
|
+
name: 'language-compatibility/override-changes-mutability',
|
|
477
|
+
});
|
|
478
|
+
static JSII_5011_SUBMODULE_NAME_CONFLICT = Code.error({
|
|
479
|
+
code: 5011,
|
|
480
|
+
formatter: (submoduleName, typeName, reserved) => `Submodule "${submoduleName}" conflicts with "${typeName}, as different languages could represent it as: ${reserved
|
|
481
|
+
.map((x) => `"${x}"`)
|
|
482
|
+
.join(', ')}"`,
|
|
483
|
+
name: 'language-compatibility/submodule-name-conflicts',
|
|
484
|
+
});
|
|
485
|
+
static JSII_5012_NAMESPACE_IN_TYPE = Code.error({
|
|
486
|
+
code: 5012,
|
|
487
|
+
formatter: (typeName, namespaceName) => `All entities nested under a type (e.g: "${typeName}") must be concrete types, but "${namespaceName}" is a namespace. This structure cannot be supported in all languages (e.g: Java)`,
|
|
488
|
+
name: 'language-compatibility/namespace-in-type',
|
|
489
|
+
});
|
|
490
|
+
static JSII_5013_STATIC_INSTANCE_CONFLICT = Code.error({
|
|
491
|
+
code: 5013,
|
|
492
|
+
formatter: (member, type) => `Member "${member}" of class "${type.fqn}" has both a static and an instance delcaration`,
|
|
493
|
+
name: 'language-compatibility/static-instance-conflict',
|
|
494
|
+
});
|
|
495
|
+
static JSII_5014_INHERITED_STATIC_CONFLICT = Code.error({
|
|
496
|
+
code: 5014,
|
|
497
|
+
formatter: (member, type, baseMember, baseType) => `${member.static ? 'Static' : 'Instance'} member "${member.name}" of class "${type.fqn}" conflicts with ${baseMember.static ? 'static' : 'instance'} member in ancestor "${baseType.fqn}"`,
|
|
498
|
+
name: 'language-compatibility/inherited-static-conflict',
|
|
499
|
+
});
|
|
500
|
+
static JSII_5015_REDECLARED_INTERFACE_MEMBER = Code.error({
|
|
501
|
+
code: 5015,
|
|
502
|
+
formatter: (memberName, iface) => `Interface "${iface.fqn}" re-declares member "${memberName}". This is not supported as it results in invalid C#.`,
|
|
503
|
+
name: 'language-compatibility/redeclared-interface-member',
|
|
504
|
+
});
|
|
505
|
+
static JSII_5016_PROHIBITED_MEMBER_NAME = Code.error({
|
|
506
|
+
code: 5016,
|
|
507
|
+
formatter: (badName) => `Members cannot be named "${badName}" as it conflicts with synthetic declarations in some languages.`,
|
|
508
|
+
name: 'language-compatibility/prohibited-member-name',
|
|
509
|
+
});
|
|
510
|
+
static JSII_5017_POSITIONAL_KEYWORD_CONFLICT = Code.error({
|
|
511
|
+
code: 5017,
|
|
512
|
+
formatter: (badName) => `Parameter name "${badName}" is also the name of a property in a struct parameter. Rename the positional parameter.`,
|
|
513
|
+
name: 'language-compatibility/positional-keyword-conflict',
|
|
514
|
+
});
|
|
515
|
+
static JSII_5018_RESERVED_WORD = Code.warning({
|
|
516
|
+
code: 5018,
|
|
517
|
+
formatter: (badName, languages) => `"${badName}" is a reserved word in ${languages.join(', ')}. Using this name may cause problems when generating language bindings. Consider a different name.`,
|
|
518
|
+
name: 'language-compatibility/reserved-word',
|
|
519
|
+
});
|
|
520
|
+
static JSII_5019_MEMBER_TYPE_NAME_CONFLICT = Code.warning({
|
|
521
|
+
code: 5019,
|
|
522
|
+
formatter: (memberKind, memberSymbol, declaringType) => `The ${memberKind} name "${memberSymbol.name}" conflicts with the declaring ${declaringType.kind} "${declaringType.name}". This will result in renaming the ${declaringType.kind} to "_${declaringType.name}" in C#. Consider renaming "${memberSymbol.name}".`,
|
|
523
|
+
name: 'language-compatibility/member-name-conflicts-with-type-name',
|
|
524
|
+
});
|
|
525
|
+
static JSII_5020_STATIC_MEMBER_CONFLICTS_WITH_NESTED_TYPE = Code.error({
|
|
526
|
+
code: 5020,
|
|
527
|
+
formatter: (nestingType, staticMember, nestedType) => `The static member "${nestingType.name}.${staticMember.name}" has the same PascalCased representation as nested type "${nestingType.name}.${nestedType.name}". This would result in invalid code in Go.`,
|
|
528
|
+
name: 'language-compatibility/static-member-name-conflicts-with-nested-type',
|
|
529
|
+
});
|
|
530
|
+
static JSII_5021_ABSTRACT_CLASS_MISSING_PROP_IMPL = Code.error({
|
|
531
|
+
code: 5021,
|
|
532
|
+
formatter: (intf, cls, prop) => `A declaration of "${intf.name}.${prop}" is missing on class "${cls.name}". Declare the property as "public abstract" if you want to defer it to subclasses.`,
|
|
533
|
+
name: 'language-compatibility/abstract-class-missing-prop-impl',
|
|
534
|
+
});
|
|
535
|
+
//////////////////////////////////////////////////////////////////////////////
|
|
536
|
+
// 6000 => 6999 -- RESERVED
|
|
537
|
+
//////////////////////////////////////////////////////////////////////////////
|
|
538
|
+
// 7000 => 7999 -- DOCUMENTATION ERRORS
|
|
539
|
+
static JSII_7000_NON_EXISTENT_PARAMETER = Code.warning({
|
|
540
|
+
code: 7000,
|
|
541
|
+
formatter: (method, param) => `Documentation for method "${method.name}" refers to non-existent @param "${param}"`,
|
|
542
|
+
name: 'documentation/non-existent-parameter',
|
|
543
|
+
});
|
|
544
|
+
static JSII_7001_ILLEGAL_HINT = Code.error({
|
|
545
|
+
code: 7001,
|
|
546
|
+
formatter: (hint, ...valid) => `Illegal use of "@${hint}" hint. It is only valid on ${valid.join(', ')}.`,
|
|
547
|
+
name: 'documentation/illegal-hint',
|
|
548
|
+
});
|
|
549
|
+
static JSII_7999_DOCUMENTATION_ERROR = Code.error({
|
|
550
|
+
code: 7999,
|
|
551
|
+
formatter: (messageText) => messageText,
|
|
552
|
+
name: 'documentation/documentation-error',
|
|
553
|
+
});
|
|
554
|
+
//////////////////////////////////////////////////////////////////////////////
|
|
555
|
+
// 8000 => 8999 -- JSII STYLE ENFORCEMENT
|
|
556
|
+
static JSII_8000_PASCAL_CASED_TYPE_NAMES = Code.error({
|
|
557
|
+
code: 8000,
|
|
558
|
+
formatter: (badName, expectedName = (0, case_1.pascal)(badName)) => `Type names must be PascalCased. Rename "${badName}" to "${expectedName}"`,
|
|
559
|
+
name: 'code-style/type-names-must-use-pascal-case',
|
|
560
|
+
});
|
|
561
|
+
static JSII_8001_ALL_CAPS_ENUM_MEMBERS = Code.error({
|
|
562
|
+
code: 8001,
|
|
563
|
+
formatter: (badName, typeName) => `Enum members must be ALL_CAPS. Rename "${typeName}.${badName}" to "${(0, case_1.constant)(badName)}"`,
|
|
564
|
+
name: 'code-style/enum-members-must-use-all-caps',
|
|
565
|
+
});
|
|
566
|
+
static JSII_8002_CAMEL_CASED_MEMBERS = Code.error({
|
|
567
|
+
code: 8002,
|
|
568
|
+
formatter: (badName, typeName) => `Method and property (unless they are static readonly) names must use camelCase. Rename "${typeName}.${badName}" to "${(0, case_1.camel)(badName)}"`,
|
|
569
|
+
name: 'code-style/member-names-must-use-camel-case',
|
|
570
|
+
});
|
|
571
|
+
static JSII_8003_STATIC_CONST_CASING = Code.error({
|
|
572
|
+
code: 8003,
|
|
573
|
+
formatter: (badName, typeName) => `Static constant names must use ALL_CAPS, PascalCase, or camelCase. Rename "${typeName}.${badName}" to "${(0, case_1.constant)(badName)}"`,
|
|
574
|
+
name: 'code-style/static-readonly-property-casing',
|
|
575
|
+
});
|
|
576
|
+
static JSII_8004_SUBMOULE_NAME_CASING = Code.error({
|
|
577
|
+
code: 8004,
|
|
578
|
+
formatter: (badName) => `Submodule namespaces must be camelCased or snake_cased. Rename "${badName}" to ${(0, case_1.camel)(badName)}`,
|
|
579
|
+
name: 'code-style/submodule-name-casing',
|
|
580
|
+
});
|
|
581
|
+
static JSII_8005_INTERNAL_UNDERSCORE = Code.error({
|
|
582
|
+
code: 8005,
|
|
583
|
+
formatter: (badName) => `Members marked with @internal must have a name starting with "_". Rename "${badName}" to "_${badName}"`,
|
|
584
|
+
name: 'code-style/internal-members-underscore-prefix',
|
|
585
|
+
});
|
|
586
|
+
static JSII_8006_UNDERSCORE_INTERNAL = Code.error({
|
|
587
|
+
code: 8006,
|
|
588
|
+
formatter: (badName) => `Members with a name starting with "_" (e.g: "${badName}") must be marked @internal`,
|
|
589
|
+
name: 'code-style/underscored-members-must-be-internal',
|
|
590
|
+
});
|
|
591
|
+
static JSII_8007_BEHAVIORAL_INTERFACE_NAME = Code.error({
|
|
592
|
+
code: 8007,
|
|
593
|
+
formatter: (badName) => `Interface contains behavior. Rename "${badName}" to "I${badName}"`,
|
|
594
|
+
name: 'code-style/behavioral-interface-name',
|
|
595
|
+
});
|
|
596
|
+
//////////////////////////////////////////////////////////////////////////////
|
|
597
|
+
// 9000 => 9999 -- SURPRISING ERRORS & INFORMATIONAL MESSAGES
|
|
598
|
+
static JSII_9000_UNKNOWN_MODULE = Code.error({
|
|
599
|
+
code: 9000,
|
|
600
|
+
formatter: (moduleName) => `Encountered use of module that is not declared in "dependencies" or "peerDependencies": "${moduleName}"`,
|
|
601
|
+
name: 'miscellaneous/unknown-module',
|
|
602
|
+
});
|
|
603
|
+
static JSII_9001_TYPE_NOT_FOUND = Code.error({
|
|
604
|
+
code: 9001,
|
|
605
|
+
formatter: (typeRef) => `Type not found in the corresponding assembly: "${typeRef.fqn}"`,
|
|
606
|
+
name: 'miscellaneous/type-not-found',
|
|
607
|
+
});
|
|
608
|
+
static JSII_9002_UNRESOLVEABLE_TYPE = Code.error({
|
|
609
|
+
code: 9002,
|
|
610
|
+
formatter: (reference) => `Type "${reference}" is part of the public API but not exported (@internal or not exported from the package.json "main" file). Either export it or add @internal explicitly if you want this to be a hidden base class.`,
|
|
611
|
+
name: 'miscellaneous/unresolveable-type',
|
|
612
|
+
});
|
|
613
|
+
static JSII_9003_UNRESOLVEABLE_MODULE = Code.error({
|
|
614
|
+
code: 9003,
|
|
615
|
+
formatter: (location) => `Unable to resolve module location "${location}"`,
|
|
616
|
+
name: 'miscellaneous/unresolveable-module',
|
|
617
|
+
});
|
|
618
|
+
static JSII_9004_UNABLE_TO_COMPUTE_SIGNATURE = Code.error({
|
|
619
|
+
code: 9004,
|
|
620
|
+
formatter: (methodName, type) => `Unable to compute signature for method "${methodName}" of "${type.fqn}"`,
|
|
621
|
+
name: 'miscellaneous/unable-to-compute-signature',
|
|
622
|
+
});
|
|
623
|
+
static JSII_9996_UNNECESSARY_TOKEN = Code.message({
|
|
624
|
+
code: 9996,
|
|
625
|
+
formatter: () => 'Unnecessary token, consider removing it',
|
|
626
|
+
name: 'miscellaneous/unnecessary-token',
|
|
627
|
+
});
|
|
628
|
+
static JSII_9997_UNKNOWN_ERROR = Code.error({
|
|
629
|
+
code: 9997,
|
|
630
|
+
formatter: (error) => `Unknown error: ${error.message} -- ${error.stack}`,
|
|
631
|
+
name: 'miscellaneous/unknown-error',
|
|
632
|
+
});
|
|
633
|
+
static JSII_9998_UNSUPPORTED_NODE = Code.message({
|
|
634
|
+
code: 9998,
|
|
635
|
+
formatter: (kindOrMessage) => typeof kindOrMessage === 'string'
|
|
636
|
+
? kindOrMessage
|
|
637
|
+
: `Unsupported ${ts.SyntaxKind[kindOrMessage]} node. This declaration will not be accessible from other languages.`,
|
|
638
|
+
name: 'miscellaneous/unsupported-node',
|
|
639
|
+
});
|
|
173
640
|
//////////////////////////////////////////////////////////////////////////////
|
|
174
641
|
/**
|
|
175
642
|
* Determines whether a `Diagnostic` instance is a `JsiiDiagnostic` or not.
|
|
@@ -178,17 +645,34 @@ class JsiiDiagnostic {
|
|
|
178
645
|
static isJsiiDiagnostic(diag) {
|
|
179
646
|
return diag.domain === JsiiDiagnostic.DOMAIN;
|
|
180
647
|
}
|
|
648
|
+
//////////////////////////////////////////////////////////////////////////////
|
|
649
|
+
static JSII_9999_RELATED_INFO = Code.suggestion({
|
|
650
|
+
code: 9999,
|
|
651
|
+
formatter: (messageText) => messageText,
|
|
652
|
+
name: 'miscellaneous/related-info',
|
|
653
|
+
});
|
|
654
|
+
//////////////////////////////////////////////////////////////////////////////
|
|
655
|
+
/**
|
|
656
|
+
* This symbol unequivocally identifies the `JsiiDiagnostic` domain.
|
|
657
|
+
*/
|
|
658
|
+
static DOMAIN = Symbol('jsii');
|
|
659
|
+
domain = JsiiDiagnostic.DOMAIN;
|
|
660
|
+
category;
|
|
661
|
+
code = utils_1.JSII_DIAGNOSTICS_CODE;
|
|
662
|
+
jsiiCode;
|
|
663
|
+
messageText;
|
|
664
|
+
file;
|
|
665
|
+
start;
|
|
666
|
+
length;
|
|
667
|
+
relatedInformation = new Array();
|
|
668
|
+
// eslint-disable-next-line @typescript-eslint/explicit-member-accessibility
|
|
669
|
+
#formatted;
|
|
181
670
|
/**
|
|
182
671
|
* Creates a new `JsiiDiagnostic` with the provided properties.
|
|
183
672
|
*
|
|
184
673
|
* @internal
|
|
185
674
|
*/
|
|
186
675
|
constructor(code, messageText, location) {
|
|
187
|
-
this.domain = JsiiDiagnostic.DOMAIN;
|
|
188
|
-
this.code = utils_1.JSII_DIAGNOSTICS_CODE;
|
|
189
|
-
this.relatedInformation = new Array();
|
|
190
|
-
// eslint-disable-next-line @typescript-eslint/explicit-member-accessibility
|
|
191
|
-
_JsiiDiagnostic_formatted.set(this, void 0);
|
|
192
676
|
this.category = code.category;
|
|
193
677
|
this.jsiiCode = code.code;
|
|
194
678
|
this.messageText = messageText;
|
|
@@ -204,7 +688,7 @@ class JsiiDiagnostic {
|
|
|
204
688
|
this.relatedInformation.push(JsiiDiagnostic.JSII_9999_RELATED_INFO.create(node, message));
|
|
205
689
|
}
|
|
206
690
|
// Clearing out #formatted, as this would no longer be the correct string.
|
|
207
|
-
|
|
691
|
+
this.#formatted = undefined;
|
|
208
692
|
return this;
|
|
209
693
|
}
|
|
210
694
|
/**
|
|
@@ -239,7 +723,7 @@ class JsiiDiagnostic {
|
|
|
239
723
|
}
|
|
240
724
|
this.relatedInformation.push(JsiiDiagnostic.JSII_9999_RELATED_INFO.create(node, message));
|
|
241
725
|
// Clearing out #formatted, as this would no longer be the correct string.
|
|
242
|
-
|
|
726
|
+
this.#formatted = undefined;
|
|
243
727
|
return this;
|
|
244
728
|
}
|
|
245
729
|
/**
|
|
@@ -250,470 +734,13 @@ class JsiiDiagnostic {
|
|
|
250
734
|
* makes the error messages really confusing.
|
|
251
735
|
*/
|
|
252
736
|
format(projectRoot) {
|
|
253
|
-
if (
|
|
254
|
-
|
|
737
|
+
if (this.#formatted == null) {
|
|
738
|
+
this.#formatted = (0, utils_1._formatDiagnostic)(this, projectRoot);
|
|
255
739
|
}
|
|
256
|
-
return
|
|
740
|
+
return this.#formatted;
|
|
257
741
|
}
|
|
258
742
|
}
|
|
259
743
|
exports.JsiiDiagnostic = JsiiDiagnostic;
|
|
260
|
-
_JsiiDiagnostic_formatted = new WeakMap();
|
|
261
|
-
//////////////////////////////////////////////////////////////////////////////
|
|
262
|
-
// 0001 => 0999 -- PACKAGE METADATA PROBLEMS
|
|
263
|
-
JsiiDiagnostic.JSII_0001_PKG_MISSING_DESCRIPTION = Code.suggestion({
|
|
264
|
-
code: 1,
|
|
265
|
-
formatter: () => 'A "description" field should be specified in "package.json"',
|
|
266
|
-
name: 'metadata/package-json-missing-description',
|
|
267
|
-
});
|
|
268
|
-
JsiiDiagnostic.JSII_0002_PKG_MISSING_HOMEPAGE = Code.suggestion({
|
|
269
|
-
code: 2,
|
|
270
|
-
formatter: () => 'A "homepage" field should be specified in "package.json"',
|
|
271
|
-
name: 'metadata/package-json-missing-homepage',
|
|
272
|
-
});
|
|
273
|
-
JsiiDiagnostic.JSII_0003_MISSING_README = Code.warning({
|
|
274
|
-
code: 3,
|
|
275
|
-
formatter: () => 'There is no "README.md" file. It is required in order to generate valid PyPI (Python) packages.',
|
|
276
|
-
name: 'metadata/missing-readme',
|
|
277
|
-
});
|
|
278
|
-
JsiiDiagnostic.JSII_0004_COULD_NOT_FIND_ENTRYPOINT = Code.error({
|
|
279
|
-
code: 4,
|
|
280
|
-
formatter: (mainFile) => `Could not find "main" file: ${mainFile}`,
|
|
281
|
-
name: 'metadata/could-not-find-entrypoint',
|
|
282
|
-
});
|
|
283
|
-
JsiiDiagnostic.JSII_0005_MISSING_PEER_DEPENDENCY = Code.warning({
|
|
284
|
-
code: 5,
|
|
285
|
-
formatter: (assm, reference) => `The type "${reference}" is exposed in the public API of this module. ` +
|
|
286
|
-
`Therefore, the module "${assm}" must also be defined under "peerDependencies". ` +
|
|
287
|
-
'This will be auto-corrected unless --no-fix-peer-dependencies was specified.',
|
|
288
|
-
name: 'metadata/missing-peer-dependency',
|
|
289
|
-
});
|
|
290
|
-
// NOTE: currently not possible to change the severity of this code,
|
|
291
|
-
// as it's being emitted before the overrides have been loaded
|
|
292
|
-
JsiiDiagnostic.JSII_0006_MISSING_DEV_DEPENDENCY = Code.warning({
|
|
293
|
-
code: 6,
|
|
294
|
-
formatter: (dependencyName, peerRange, minVersion, actual) => `A "peerDependency" on "${dependencyName}" at "${peerRange}" means you ` +
|
|
295
|
-
`should take a "devDependency" on "${dependencyName}" at "${minVersion}" ` +
|
|
296
|
-
`(found ${JSON.stringify(actual)})`,
|
|
297
|
-
name: 'metadata/missing-dev-dependency',
|
|
298
|
-
});
|
|
299
|
-
JsiiDiagnostic.JSII_0007_MISSING_WARNINGS_EXPORT = Code.error({
|
|
300
|
-
code: 7,
|
|
301
|
-
formatter: () => 'If you are compiling with --add-deprecation-warnings and your package.json ' +
|
|
302
|
-
`declares subpath exports, you must include { "./${deprecation_warnings_1.WARNINGSCODE_FILE_NAME}": "./${deprecation_warnings_1.WARNINGSCODE_FILE_NAME}" } ` +
|
|
303
|
-
'in the set of exports.',
|
|
304
|
-
name: 'metadata/missing-warnings-export',
|
|
305
|
-
});
|
|
306
|
-
//////////////////////////////////////////////////////////////////////////////
|
|
307
|
-
// 1000 => 1999 -- TYPESCRIPT LANGUAGE RESTRICTIONS
|
|
308
|
-
JsiiDiagnostic.JSII_1000_NO_CONST_ENUM = Code.error({
|
|
309
|
-
code: 1000,
|
|
310
|
-
formatter: () => 'Exported "const enum" declarations are not allowed',
|
|
311
|
-
name: 'typescript-restrictions/no-const-enum',
|
|
312
|
-
});
|
|
313
|
-
JsiiDiagnostic.JSII_1001_TYPE_HAS_NO_SYMBOL = Code.error({
|
|
314
|
-
code: 1001,
|
|
315
|
-
formatter: () => 'Non-primitive types without a symbol cannot be processed.',
|
|
316
|
-
name: 'typescript-restrictions/type-has-no-symbol',
|
|
317
|
-
});
|
|
318
|
-
JsiiDiagnostic.JSII_1002_UNSPECIFIED_PROMISE = Code.error({
|
|
319
|
-
code: 1002,
|
|
320
|
-
formatter: () => 'Un-specified promise type. Specify it using "Promise<T>"',
|
|
321
|
-
name: 'typescript-restrictions/unspecified-promise',
|
|
322
|
-
});
|
|
323
|
-
JsiiDiagnostic.JSII_1003_UNSUPPORTED_TYPE = Code.error({
|
|
324
|
-
code: 1003,
|
|
325
|
-
formatter: (messageText) => messageText,
|
|
326
|
-
name: 'typescript-restrictions/unsupported-type',
|
|
327
|
-
});
|
|
328
|
-
JsiiDiagnostic.JSII_1004_DUPLICATE_ENUM_VALUE = Code.error({
|
|
329
|
-
code: 1004,
|
|
330
|
-
formatter: (enumValue, enumMemberNames) => `Value ${enumValue} is used for multiple enum values: ${enumMemberNames.join(', ')}`,
|
|
331
|
-
name: 'typescript-restrictions/duplicate-enum-value',
|
|
332
|
-
});
|
|
333
|
-
JsiiDiagnostic.JSII_1005_SEPARATE_WRITE_TYPE = Code.error({
|
|
334
|
-
code: 1005,
|
|
335
|
-
formatter: () => 'Visible property signatures cannot use a separate write type. Use the same type as the getter.',
|
|
336
|
-
name: 'typescript-restrictions/separate-write-type',
|
|
337
|
-
});
|
|
338
|
-
JsiiDiagnostic.JSII_1006_GENERIC_TYPE = Code.error({
|
|
339
|
-
code: 1006,
|
|
340
|
-
formatter: () => 'Generic types are not supported because semantics are not uniform in target languages.',
|
|
341
|
-
name: 'typescript-restriction/generic-type',
|
|
342
|
-
});
|
|
343
|
-
JsiiDiagnostic.JSII_1007_NEVER_TYPE = Code.error({
|
|
344
|
-
code: 1007,
|
|
345
|
-
formatter: () => 'The "never" type is not allowed because it cannot be represented in target languages.',
|
|
346
|
-
name: 'typescript-restriction/no-never-type',
|
|
347
|
-
});
|
|
348
|
-
JsiiDiagnostic.JSII_1008_ONLY_INTERFACE_INTERSECTION = Code.error({
|
|
349
|
-
code: 1008,
|
|
350
|
-
formatter: (type) => `Found non-interface type in type intersection: ${type}`,
|
|
351
|
-
name: 'typescript-restriction/only-interface-intersection',
|
|
352
|
-
});
|
|
353
|
-
JsiiDiagnostic.JSII_1009_INTERSECTION_ONLY_INPUT = Code.error({
|
|
354
|
-
code: 1009,
|
|
355
|
-
formatter: (location) => `Intersection types may only be used as inputs, but ${location} is used as output`,
|
|
356
|
-
name: 'typescript-restriction/intersection-only-input',
|
|
357
|
-
});
|
|
358
|
-
JsiiDiagnostic.JSII_1010_INTERSECTION_NOT_IN_CTOR = Code.error({
|
|
359
|
-
code: 1010,
|
|
360
|
-
formatter: () => `Intersection types cannot be used as constructor arguments`,
|
|
361
|
-
name: 'typescript-restriction/intersection-no-ctor',
|
|
362
|
-
});
|
|
363
|
-
JsiiDiagnostic.JSII_1011_INTERSECTION_MEMBER_DIFFERENT = Code.error({
|
|
364
|
-
code: 1011,
|
|
365
|
-
formatter: (member, type1, reason1, type2, reason2) => `Member ${member} is different between types in a type intersection: ${type1} (${reason1}) and ${type2} (${reason2})`,
|
|
366
|
-
name: 'typescript-restriction/intersection-member-different',
|
|
367
|
-
});
|
|
368
|
-
JsiiDiagnostic.JSII_1012_ONLY_CONST_ENUM_MEMBERS = Code.error({
|
|
369
|
-
code: 1012,
|
|
370
|
-
formatter: () => 'Only constant enum members are allowed',
|
|
371
|
-
name: 'typescript-restrictions/only-const-enum-members',
|
|
372
|
-
});
|
|
373
|
-
JsiiDiagnostic.JSII_1999_UNSUPPORTED = Code.error({
|
|
374
|
-
code: 1999,
|
|
375
|
-
formatter: ({ what, alternative, suggestInternal, }) => `${what} are not supported in jsii APIs.${alternative ? ` Consider using ${alternative} instead.` : ''}${suggestInternal
|
|
376
|
-
? ` This declaration must${alternative ? ' otherwise' : ''} be marked "@internal" or "@jsii ignore".`
|
|
377
|
-
: ''}`,
|
|
378
|
-
name: 'typescript-restrictions/unsupported',
|
|
379
|
-
});
|
|
380
|
-
//////////////////////////////////////////////////////////////////////////////
|
|
381
|
-
// 2000 => 2999 -- INCORRECT USE OF THE @jsii DIRECTIVE
|
|
382
|
-
JsiiDiagnostic.JSII_2000_MISSING_DIRECTIVE_ARGUMENT = Code.warning({
|
|
383
|
-
code: 2000,
|
|
384
|
-
formatter: () => 'Missing argument to @jsii directive. Refer to the jsii compiler documentation for more information.',
|
|
385
|
-
name: 'jsii-directive/missing-argument',
|
|
386
|
-
});
|
|
387
|
-
JsiiDiagnostic.JSII_2100_STRUCT_ON_NON_INTERFACE = Code.warning({
|
|
388
|
-
code: 2100,
|
|
389
|
-
formatter: () => 'The "@jsii struct" directive is only applicable to interface declarations.',
|
|
390
|
-
name: 'jsii-directive/struct-on-non-interface',
|
|
391
|
-
});
|
|
392
|
-
JsiiDiagnostic.JSII_2999_UNKNOWN_DIRECTIVE = Code.warning({
|
|
393
|
-
code: 2999,
|
|
394
|
-
formatter: (text) => `Unknown @jsii directive: ${JSON.stringify(text)}. Refer to the jsii compiler documentation for more information.`,
|
|
395
|
-
name: 'jsii-directive/unknown',
|
|
396
|
-
});
|
|
397
|
-
//////////////////////////////////////////////////////////////////////////////
|
|
398
|
-
// 3000 => 3999 -- TYPE MODEL COHERENCE
|
|
399
|
-
JsiiDiagnostic.JSII_3000_EXPORTED_API_USES_HIDDEN_TYPE = Code.error({
|
|
400
|
-
code: 3000,
|
|
401
|
-
formatter: (badFqn) => `Exported APIs cannot use un-exported type "${badFqn}"`,
|
|
402
|
-
name: 'type-model/exported-api-cannot-use-unexported-type',
|
|
403
|
-
});
|
|
404
|
-
JsiiDiagnostic.JSII_3001_EXPOSED_INTERNAL_TYPE = Code.error({
|
|
405
|
-
code: 3001,
|
|
406
|
-
formatter: (symbol, isThisType, typeUse) => `Type ${isThisType ? `"this" (aka: "${symbol.name}")` : `"${symbol.name}"`} cannot be used as the ${typeUse} because it is private or @internal`,
|
|
407
|
-
name: 'type-model/use-of-internal-type',
|
|
408
|
-
});
|
|
409
|
-
JsiiDiagnostic.JSII_3002_USE_OF_UNEXPORTED_FOREIGN_TYPE = Code.error({
|
|
410
|
-
code: 3002,
|
|
411
|
-
formatter: (fqn, typeUse, pkg) => `Type "${fqn}" cannot be used as a ${typeUse} because it is not exported from ${pkg.name}`,
|
|
412
|
-
name: 'type-model/unexported-foreign-type',
|
|
413
|
-
});
|
|
414
|
-
JsiiDiagnostic.JSII_3003_SYMBOL_IS_EXPORTED_TWICE = Code.error({
|
|
415
|
-
code: 3003,
|
|
416
|
-
formatter: (ns1, ns2) => `Symbol is exported under two distinct submodules: ${ns1} and ${ns2}`,
|
|
417
|
-
name: 'type-model/symbol-is-exported-twice',
|
|
418
|
-
});
|
|
419
|
-
JsiiDiagnostic.JSII_3004_INVALID_SUPERTYPE = Code.error({
|
|
420
|
-
code: 3004,
|
|
421
|
-
formatter: (clause, badDeclaration) => {
|
|
422
|
-
return `Illegal ${clauseType(clause.token)} clause for an exported API: ${ts.SyntaxKind[badDeclaration.kind]}`;
|
|
423
|
-
function clauseType(token) {
|
|
424
|
-
switch (token) {
|
|
425
|
-
case ts.SyntaxKind.ExtendsKeyword:
|
|
426
|
-
return 'extends';
|
|
427
|
-
case ts.SyntaxKind.ImplementsKeyword:
|
|
428
|
-
return 'implements';
|
|
429
|
-
default:
|
|
430
|
-
return ts.SyntaxKind[token];
|
|
431
|
-
}
|
|
432
|
-
}
|
|
433
|
-
},
|
|
434
|
-
name: 'type-model/invalid-supertype',
|
|
435
|
-
});
|
|
436
|
-
JsiiDiagnostic.JSII_3005_TYPE_USED_AS_INTERFACE = Code.error({
|
|
437
|
-
code: 3005,
|
|
438
|
-
formatter: (badType) => `Type "${spec.describeTypeReference(badType)}" cannot be used as an interface`,
|
|
439
|
-
name: 'type-model/type-used-as-interface',
|
|
440
|
-
});
|
|
441
|
-
JsiiDiagnostic.JSII_3006_TYPE_USED_AS_CLASS = Code.error({
|
|
442
|
-
code: 3006,
|
|
443
|
-
formatter: (badType) => `Type "${spec.describeTypeReference(badType)}" cannot be used as a class`,
|
|
444
|
-
name: 'type-model/type-used-as-class',
|
|
445
|
-
});
|
|
446
|
-
JsiiDiagnostic.JSII_3007_ILLEGAL_STRUCT_EXTENSION = Code.error({
|
|
447
|
-
code: 3007,
|
|
448
|
-
formatter: (offender, struct) => `Attempt to extend or implement struct "${struct.fqn}" from "${offender.fqn}"`,
|
|
449
|
-
name: 'type-model/illegal-struct-extension',
|
|
450
|
-
});
|
|
451
|
-
JsiiDiagnostic.JSII_3008_STRUCT_PROPS_MUST_BE_READONLY = Code.error({
|
|
452
|
-
code: 3008,
|
|
453
|
-
formatter: (propName, struct) => `The "${propName}" property of struct "${struct.fqn}" must be "readonly". Rename "${struct.fqn}" to "I${struct.name}" if it is meant to be a behavioral interface.`,
|
|
454
|
-
name: 'type-model/struct-props-must-be-readonly',
|
|
455
|
-
});
|
|
456
|
-
JsiiDiagnostic.JSII_3009_OPTIONAL_PARAMETER_BEFORE_REQUIRED = Code.error({
|
|
457
|
-
code: 3009,
|
|
458
|
-
formatter: (param, nextParam) => `Parameter "${param.name}" cannot be optional, as it precedes required parameter "${nextParam.name}"`,
|
|
459
|
-
name: 'type-model/optional-parameter-before-required',
|
|
460
|
-
});
|
|
461
|
-
JsiiDiagnostic.JSII_3999_INCOHERENT_TYPE_MODEL = Code.error({
|
|
462
|
-
code: 3999,
|
|
463
|
-
formatter: (messageText) => messageText,
|
|
464
|
-
name: 'type-model/incoherent-type-model',
|
|
465
|
-
});
|
|
466
|
-
//////////////////////////////////////////////////////////////////////////////
|
|
467
|
-
// 4000 => 4999 -- TYPESCRIPT & JSII CONFIG ERRORS
|
|
468
|
-
JsiiDiagnostic.JSII_4000_FAILED_TSCONFIG_VALIDATION = Code.error({
|
|
469
|
-
code: 4000,
|
|
470
|
-
formatter: (config, ruleSet, violations) => {
|
|
471
|
-
return `Typescript compiler options in "${config}" are not passing validation against rule set "${ruleSet}", found the following rule violations:\n${violations
|
|
472
|
-
.map((v) => ` - ${v.field}: ${v.message}`)
|
|
473
|
-
.join('\n')}`;
|
|
474
|
-
},
|
|
475
|
-
name: 'typescript-config/invalid-tsconfig',
|
|
476
|
-
});
|
|
477
|
-
JsiiDiagnostic.JSII_4009_DISABLED_TSCONFIG_VALIDATION = Code.warning({
|
|
478
|
-
code: 4009,
|
|
479
|
-
formatter: (config) => `Validation of typescript config "${config}" is disabled. This is intended for experimental setups only. Compilation might fail or produce incompatible artifacts.`,
|
|
480
|
-
name: 'typescript-config/disabled-tsconfig-validation',
|
|
481
|
-
});
|
|
482
|
-
JsiiDiagnostic.JSII_4010_SUBMODULE_NAMESPACE_CONFLICT = Code.warning({
|
|
483
|
-
code: 4010,
|
|
484
|
-
formatter: (language, namespace, modules) => `Multiple modules emit to the same ${language} namespace "${namespace}": ${modules.join(', ')}`,
|
|
485
|
-
name: 'jsii-config/submodule-conflict',
|
|
486
|
-
});
|
|
487
|
-
//////////////////////////////////////////////////////////////////////////////
|
|
488
|
-
// 5000 => 5999 -- LANGUAGE COMPATIBILITY ERRORS
|
|
489
|
-
JsiiDiagnostic.JSII_5000_JAVA_GETTERS = Code.error({
|
|
490
|
-
code: 5000,
|
|
491
|
-
formatter: (badName, typeName) => `Methods and properties cannot have names like "getXxx": those conflict with Java property getters. Rename "${typeName}.${badName}"`,
|
|
492
|
-
name: 'language-compatibility/potential-java-getter-conflict',
|
|
493
|
-
});
|
|
494
|
-
JsiiDiagnostic.JSII_5001_JAVA_SETTERS = Code.error({
|
|
495
|
-
code: 5001,
|
|
496
|
-
formatter: (badName, typeName) => `Methods and properties cannot have names like "setXxx": those conflict with Java property setters. Rename "${typeName}.${badName}"`,
|
|
497
|
-
name: 'language-compatibility/potential-java-setter-conflict',
|
|
498
|
-
});
|
|
499
|
-
JsiiDiagnostic.JSII_5002_OVERRIDE_CHANGES_VISIBILITY = Code.error({
|
|
500
|
-
code: 5002,
|
|
501
|
-
formatter: (newElement, action, newValue, oldValue) => `"${newElement}" changes visibility to ${newValue} when ${action}. Change it to ${oldValue}`,
|
|
502
|
-
name: 'language-compatibility/override-changes-visibility',
|
|
503
|
-
});
|
|
504
|
-
JsiiDiagnostic.JSII_5003_OVERRIDE_CHANGES_RETURN_TYPE = Code.error({
|
|
505
|
-
code: 5003,
|
|
506
|
-
formatter: (newElement, action, newValue, oldValue) => `"${newElement}" changes the return type to "${newValue}" when ${action}. Change it to "${oldValue}"`,
|
|
507
|
-
name: 'language-compatibility/override-changes-return-type',
|
|
508
|
-
});
|
|
509
|
-
JsiiDiagnostic.JSII_5004_OVERRIDE_CHANGES_PROP_TYPE = Code.error({
|
|
510
|
-
code: 5004,
|
|
511
|
-
formatter: (newElement, action, newType, oldType) => `"${newElement}" changes the property type to "${spec.describeTypeReference(newType)}" when ${action}. Change it to "${spec.describeTypeReference(oldType)}"`,
|
|
512
|
-
name: 'language-compatibility/override-changes-property-type',
|
|
513
|
-
});
|
|
514
|
-
JsiiDiagnostic.JSII_5005_OVERRIDE_CHANGES_PARAM_COUNT = Code.error({
|
|
515
|
-
code: 5005,
|
|
516
|
-
formatter: (newElement, action, newCount, oldCount) => `"${newElement}" has ${newCount} parameters when ${action}. It should accept ${oldCount} parameters`,
|
|
517
|
-
name: 'language-compatibility/override-changes-param-count',
|
|
518
|
-
});
|
|
519
|
-
JsiiDiagnostic.JSII_5006_OVERRIDE_CHANGES_PARAM_TYPE = Code.error({
|
|
520
|
-
code: 5006,
|
|
521
|
-
formatter: (newElement, action, newParam, oldParam) => `"${newElement}" changes the type of parameter "${newParam.name}" to ${spec.describeTypeReference(newParam.type)} when ${action}. Change it to ${spec.describeTypeReference(oldParam.type)}`,
|
|
522
|
-
name: 'language-compatibility/override-changes-param-type',
|
|
523
|
-
});
|
|
524
|
-
JsiiDiagnostic.JSII_5007_OVERRIDE_CHANGES_VARIADIC = Code.error({
|
|
525
|
-
code: 5007,
|
|
526
|
-
formatter: (newElement, action, newVariadic = false, oldVariadic = false) => `"${newElement}" turns ${newVariadic ? 'variadic' : 'non variadic'} when ${action}. Make it ${oldVariadic ? 'variadic' : 'non-variadic'}`,
|
|
527
|
-
name: 'language-compatibility/override-changes-variadic',
|
|
528
|
-
});
|
|
529
|
-
JsiiDiagnostic.JSII_5008_OVERRIDE_CHANGES_PARAM_OPTIONAL = Code.error({
|
|
530
|
-
code: 5008,
|
|
531
|
-
formatter: (newElement, action, newParam, oldParam) => `"${newElement}" turns parameter "${newParam.name}" ${newParam.optional ? 'optional' : 'required'} when ${action}. Make it ${oldParam.optional ? 'optional' : 'required'}`,
|
|
532
|
-
name: 'language-compatibility/override-changes-param-optional',
|
|
533
|
-
});
|
|
534
|
-
JsiiDiagnostic.JSII_5009_OVERRIDE_CHANGES_PROP_OPTIONAL = Code.error({
|
|
535
|
-
code: 5009,
|
|
536
|
-
formatter: (newElement, action, newOptional = false, oldOptional = false) => `"${newElement}" turns ${newOptional ? 'optional' : 'required'} when ${action}. Make it ${oldOptional ? 'optional' : 'required'}`,
|
|
537
|
-
name: 'language-compatibility/override-changes-prop-optional',
|
|
538
|
-
});
|
|
539
|
-
JsiiDiagnostic.JSII_5010_OVERRIDE_CHANGES_MUTABILITY = Code.error({
|
|
540
|
-
code: 5010,
|
|
541
|
-
formatter: (newElement, action, newReadonly = false, oldReadonly = false) => `"${newElement}" turns ${newReadonly ? 'readonly' : 'mutable'} when ${action}. Make it ${oldReadonly ? 'readonly' : 'mutable'}`,
|
|
542
|
-
name: 'language-compatibility/override-changes-mutability',
|
|
543
|
-
});
|
|
544
|
-
JsiiDiagnostic.JSII_5011_SUBMODULE_NAME_CONFLICT = Code.error({
|
|
545
|
-
code: 5011,
|
|
546
|
-
formatter: (submoduleName, typeName, reserved) => `Submodule "${submoduleName}" conflicts with "${typeName}, as different languages could represent it as: ${reserved
|
|
547
|
-
.map((x) => `"${x}"`)
|
|
548
|
-
.join(', ')}"`,
|
|
549
|
-
name: 'language-compatibility/submodule-name-conflicts',
|
|
550
|
-
});
|
|
551
|
-
JsiiDiagnostic.JSII_5012_NAMESPACE_IN_TYPE = Code.error({
|
|
552
|
-
code: 5012,
|
|
553
|
-
formatter: (typeName, namespaceName) => `All entities nested under a type (e.g: "${typeName}") must be concrete types, but "${namespaceName}" is a namespace. This structure cannot be supported in all languages (e.g: Java)`,
|
|
554
|
-
name: 'language-compatibility/namespace-in-type',
|
|
555
|
-
});
|
|
556
|
-
JsiiDiagnostic.JSII_5013_STATIC_INSTANCE_CONFLICT = Code.error({
|
|
557
|
-
code: 5013,
|
|
558
|
-
formatter: (member, type) => `Member "${member}" of class "${type.fqn}" has both a static and an instance delcaration`,
|
|
559
|
-
name: 'language-compatibility/static-instance-conflict',
|
|
560
|
-
});
|
|
561
|
-
JsiiDiagnostic.JSII_5014_INHERITED_STATIC_CONFLICT = Code.error({
|
|
562
|
-
code: 5014,
|
|
563
|
-
formatter: (member, type, baseMember, baseType) => `${member.static ? 'Static' : 'Instance'} member "${member.name}" of class "${type.fqn}" conflicts with ${baseMember.static ? 'static' : 'instance'} member in ancestor "${baseType.fqn}"`,
|
|
564
|
-
name: 'language-compatibility/inherited-static-conflict',
|
|
565
|
-
});
|
|
566
|
-
JsiiDiagnostic.JSII_5015_REDECLARED_INTERFACE_MEMBER = Code.error({
|
|
567
|
-
code: 5015,
|
|
568
|
-
formatter: (memberName, iface) => `Interface "${iface.fqn}" re-declares member "${memberName}". This is not supported as it results in invalid C#.`,
|
|
569
|
-
name: 'language-compatibility/redeclared-interface-member',
|
|
570
|
-
});
|
|
571
|
-
JsiiDiagnostic.JSII_5016_PROHIBITED_MEMBER_NAME = Code.error({
|
|
572
|
-
code: 5016,
|
|
573
|
-
formatter: (badName) => `Members cannot be named "${badName}" as it conflicts with synthetic declarations in some languages.`,
|
|
574
|
-
name: 'language-compatibility/prohibited-member-name',
|
|
575
|
-
});
|
|
576
|
-
JsiiDiagnostic.JSII_5017_POSITIONAL_KEYWORD_CONFLICT = Code.error({
|
|
577
|
-
code: 5017,
|
|
578
|
-
formatter: (badName) => `Parameter name "${badName}" is also the name of a property in a struct parameter. Rename the positional parameter.`,
|
|
579
|
-
name: 'language-compatibility/positional-keyword-conflict',
|
|
580
|
-
});
|
|
581
|
-
JsiiDiagnostic.JSII_5018_RESERVED_WORD = Code.warning({
|
|
582
|
-
code: 5018,
|
|
583
|
-
formatter: (badName, languages) => `"${badName}" is a reserved word in ${languages.join(', ')}. Using this name may cause problems when generating language bindings. Consider a different name.`,
|
|
584
|
-
name: 'language-compatibility/reserved-word',
|
|
585
|
-
});
|
|
586
|
-
JsiiDiagnostic.JSII_5019_MEMBER_TYPE_NAME_CONFLICT = Code.warning({
|
|
587
|
-
code: 5019,
|
|
588
|
-
formatter: (memberKind, memberSymbol, declaringType) => `The ${memberKind} name "${memberSymbol.name}" conflicts with the declaring ${declaringType.kind} "${declaringType.name}". This will result in renaming the ${declaringType.kind} to "_${declaringType.name}" in C#. Consider renaming "${memberSymbol.name}".`,
|
|
589
|
-
name: 'language-compatibility/member-name-conflicts-with-type-name',
|
|
590
|
-
});
|
|
591
|
-
JsiiDiagnostic.JSII_5020_STATIC_MEMBER_CONFLICTS_WITH_NESTED_TYPE = Code.error({
|
|
592
|
-
code: 5020,
|
|
593
|
-
formatter: (nestingType, staticMember, nestedType) => `The static member "${nestingType.name}.${staticMember.name}" has the same PascalCased representation as nested type "${nestingType.name}.${nestedType.name}". This would result in invalid code in Go.`,
|
|
594
|
-
name: 'language-compatibility/static-member-name-conflicts-with-nested-type',
|
|
595
|
-
});
|
|
596
|
-
JsiiDiagnostic.JSII_5021_ABSTRACT_CLASS_MISSING_PROP_IMPL = Code.error({
|
|
597
|
-
code: 5021,
|
|
598
|
-
formatter: (intf, cls, prop) => `A declaration of "${intf.name}.${prop}" is missing on class "${cls.name}". Declare the property as "public abstract" if you want to defer it to subclasses.`,
|
|
599
|
-
name: 'language-compatibility/abstract-class-missing-prop-impl',
|
|
600
|
-
});
|
|
601
|
-
//////////////////////////////////////////////////////////////////////////////
|
|
602
|
-
// 6000 => 6999 -- RESERVED
|
|
603
|
-
//////////////////////////////////////////////////////////////////////////////
|
|
604
|
-
// 7000 => 7999 -- DOCUMENTATION ERRORS
|
|
605
|
-
JsiiDiagnostic.JSII_7000_NON_EXISTENT_PARAMETER = Code.warning({
|
|
606
|
-
code: 7000,
|
|
607
|
-
formatter: (method, param) => `Documentation for method "${method.name}" refers to non-existent @param "${param}"`,
|
|
608
|
-
name: 'documentation/non-existent-parameter',
|
|
609
|
-
});
|
|
610
|
-
JsiiDiagnostic.JSII_7001_ILLEGAL_HINT = Code.error({
|
|
611
|
-
code: 7001,
|
|
612
|
-
formatter: (hint, ...valid) => `Illegal use of "@${hint}" hint. It is only valid on ${valid.join(', ')}.`,
|
|
613
|
-
name: 'documentation/illegal-hint',
|
|
614
|
-
});
|
|
615
|
-
JsiiDiagnostic.JSII_7999_DOCUMENTATION_ERROR = Code.error({
|
|
616
|
-
code: 7999,
|
|
617
|
-
formatter: (messageText) => messageText,
|
|
618
|
-
name: 'documentation/documentation-error',
|
|
619
|
-
});
|
|
620
|
-
//////////////////////////////////////////////////////////////////////////////
|
|
621
|
-
// 8000 => 8999 -- JSII STYLE ENFORCEMENT
|
|
622
|
-
JsiiDiagnostic.JSII_8000_PASCAL_CASED_TYPE_NAMES = Code.error({
|
|
623
|
-
code: 8000,
|
|
624
|
-
formatter: (badName, expectedName = (0, case_1.pascal)(badName)) => `Type names must be PascalCased. Rename "${badName}" to "${expectedName}"`,
|
|
625
|
-
name: 'code-style/type-names-must-use-pascal-case',
|
|
626
|
-
});
|
|
627
|
-
JsiiDiagnostic.JSII_8001_ALL_CAPS_ENUM_MEMBERS = Code.error({
|
|
628
|
-
code: 8001,
|
|
629
|
-
formatter: (badName, typeName) => `Enum members must be ALL_CAPS. Rename "${typeName}.${badName}" to "${(0, case_1.constant)(badName)}"`,
|
|
630
|
-
name: 'code-style/enum-members-must-use-all-caps',
|
|
631
|
-
});
|
|
632
|
-
JsiiDiagnostic.JSII_8002_CAMEL_CASED_MEMBERS = Code.error({
|
|
633
|
-
code: 8002,
|
|
634
|
-
formatter: (badName, typeName) => `Method and property (unless they are static readonly) names must use camelCase. Rename "${typeName}.${badName}" to "${(0, case_1.camel)(badName)}"`,
|
|
635
|
-
name: 'code-style/member-names-must-use-camel-case',
|
|
636
|
-
});
|
|
637
|
-
JsiiDiagnostic.JSII_8003_STATIC_CONST_CASING = Code.error({
|
|
638
|
-
code: 8003,
|
|
639
|
-
formatter: (badName, typeName) => `Static constant names must use ALL_CAPS, PascalCase, or camelCase. Rename "${typeName}.${badName}" to "${(0, case_1.constant)(badName)}"`,
|
|
640
|
-
name: 'code-style/static-readonly-property-casing',
|
|
641
|
-
});
|
|
642
|
-
JsiiDiagnostic.JSII_8004_SUBMOULE_NAME_CASING = Code.error({
|
|
643
|
-
code: 8004,
|
|
644
|
-
formatter: (badName) => `Submodule namespaces must be camelCased or snake_cased. Rename "${badName}" to ${(0, case_1.camel)(badName)}`,
|
|
645
|
-
name: 'code-style/submodule-name-casing',
|
|
646
|
-
});
|
|
647
|
-
JsiiDiagnostic.JSII_8005_INTERNAL_UNDERSCORE = Code.error({
|
|
648
|
-
code: 8005,
|
|
649
|
-
formatter: (badName) => `Members marked with @internal must have a name starting with "_". Rename "${badName}" to "_${badName}"`,
|
|
650
|
-
name: 'code-style/internal-members-underscore-prefix',
|
|
651
|
-
});
|
|
652
|
-
JsiiDiagnostic.JSII_8006_UNDERSCORE_INTERNAL = Code.error({
|
|
653
|
-
code: 8006,
|
|
654
|
-
formatter: (badName) => `Members with a name starting with "_" (e.g: "${badName}") must be marked @internal`,
|
|
655
|
-
name: 'code-style/underscored-members-must-be-internal',
|
|
656
|
-
});
|
|
657
|
-
JsiiDiagnostic.JSII_8007_BEHAVIORAL_INTERFACE_NAME = Code.error({
|
|
658
|
-
code: 8007,
|
|
659
|
-
formatter: (badName) => `Interface contains behavior. Rename "${badName}" to "I${badName}"`,
|
|
660
|
-
name: 'code-style/behavioral-interface-name',
|
|
661
|
-
});
|
|
662
|
-
//////////////////////////////////////////////////////////////////////////////
|
|
663
|
-
// 9000 => 9999 -- SURPRISING ERRORS & INFORMATIONAL MESSAGES
|
|
664
|
-
JsiiDiagnostic.JSII_9000_UNKNOWN_MODULE = Code.error({
|
|
665
|
-
code: 9000,
|
|
666
|
-
formatter: (moduleName) => `Encountered use of module that is not declared in "dependencies" or "peerDependencies": "${moduleName}"`,
|
|
667
|
-
name: 'miscellaneous/unknown-module',
|
|
668
|
-
});
|
|
669
|
-
JsiiDiagnostic.JSII_9001_TYPE_NOT_FOUND = Code.error({
|
|
670
|
-
code: 9001,
|
|
671
|
-
formatter: (typeRef) => `Type not found in the corresponding assembly: "${typeRef.fqn}"`,
|
|
672
|
-
name: 'miscellaneous/type-not-found',
|
|
673
|
-
});
|
|
674
|
-
JsiiDiagnostic.JSII_9002_UNRESOLVEABLE_TYPE = Code.error({
|
|
675
|
-
code: 9002,
|
|
676
|
-
formatter: (reference) => `Type "${reference}" is part of the public API but not exported (@internal or not exported from the package.json "main" file). Either export it or add @internal explicitly if you want this to be a hidden base class.`,
|
|
677
|
-
name: 'miscellaneous/unresolveable-type',
|
|
678
|
-
});
|
|
679
|
-
JsiiDiagnostic.JSII_9003_UNRESOLVEABLE_MODULE = Code.error({
|
|
680
|
-
code: 9003,
|
|
681
|
-
formatter: (location) => `Unable to resolve module location "${location}"`,
|
|
682
|
-
name: 'miscellaneous/unresolveable-module',
|
|
683
|
-
});
|
|
684
|
-
JsiiDiagnostic.JSII_9004_UNABLE_TO_COMPUTE_SIGNATURE = Code.error({
|
|
685
|
-
code: 9004,
|
|
686
|
-
formatter: (methodName, type) => `Unable to compute signature for method "${methodName}" of "${type.fqn}"`,
|
|
687
|
-
name: 'miscellaneous/unable-to-compute-signature',
|
|
688
|
-
});
|
|
689
|
-
JsiiDiagnostic.JSII_9996_UNNECESSARY_TOKEN = Code.message({
|
|
690
|
-
code: 9996,
|
|
691
|
-
formatter: () => 'Unnecessary token, consider removing it',
|
|
692
|
-
name: 'miscellaneous/unnecessary-token',
|
|
693
|
-
});
|
|
694
|
-
JsiiDiagnostic.JSII_9997_UNKNOWN_ERROR = Code.error({
|
|
695
|
-
code: 9997,
|
|
696
|
-
formatter: (error) => `Unknown error: ${error.message} -- ${error.stack}`,
|
|
697
|
-
name: 'miscellaneous/unknown-error',
|
|
698
|
-
});
|
|
699
|
-
JsiiDiagnostic.JSII_9998_UNSUPPORTED_NODE = Code.message({
|
|
700
|
-
code: 9998,
|
|
701
|
-
formatter: (kindOrMessage) => typeof kindOrMessage === 'string'
|
|
702
|
-
? kindOrMessage
|
|
703
|
-
: `Unsupported ${ts.SyntaxKind[kindOrMessage]} node. This declaration will not be accessible from other languages.`,
|
|
704
|
-
name: 'miscellaneous/unsupported-node',
|
|
705
|
-
});
|
|
706
|
-
//////////////////////////////////////////////////////////////////////////////
|
|
707
|
-
JsiiDiagnostic.JSII_9999_RELATED_INFO = Code.suggestion({
|
|
708
|
-
code: 9999,
|
|
709
|
-
formatter: (messageText) => messageText,
|
|
710
|
-
name: 'miscellaneous/related-info',
|
|
711
|
-
});
|
|
712
|
-
//////////////////////////////////////////////////////////////////////////////
|
|
713
|
-
/**
|
|
714
|
-
* This symbol unequivocally identifies the `JsiiDiagnostic` domain.
|
|
715
|
-
*/
|
|
716
|
-
JsiiDiagnostic.DOMAIN = Symbol('jsii');
|
|
717
744
|
function configureCategories(records) {
|
|
718
745
|
for (const [code, category] of Object.entries(records)) {
|
|
719
746
|
const diagCode = Code.lookup(diagnosticCode(code));
|