@typescript-eslint/type-utils 6.0.0-alpha.99 → 6.0.1-alpha.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 +6 -4
- package/_ts4.3/dist/TypeOrValueSpecifier.d.ts +21 -0
- package/_ts4.3/dist/isTypeReadonly.d.ts +27 -0
- package/_ts4.3/dist/typeFlagUtils.d.ts +16 -0
- package/dist/TypeOrValueSpecifier.d.ts +6 -97
- package/dist/TypeOrValueSpecifier.d.ts.map +1 -1
- package/dist/TypeOrValueSpecifier.js +55 -13
- package/dist/TypeOrValueSpecifier.js.map +1 -1
- package/dist/isTypeReadonly.d.ts +6 -97
- package/dist/isTypeReadonly.d.ts.map +1 -1
- package/dist/isTypeReadonly.js +3 -3
- package/dist/isTypeReadonly.js.map +1 -1
- package/dist/predicates.js +1 -1
- package/dist/predicates.js.map +1 -1
- package/dist/typeFlagUtils.d.ts +8 -3
- package/dist/typeFlagUtils.d.ts.map +1 -1
- package/dist/typeFlagUtils.js +10 -4
- package/dist/typeFlagUtils.js.map +1 -1
- package/package.json +11 -11
- package/_ts4.2/dist/TypeOrValueSpecifier.d.ts +0 -112
- package/_ts4.2/dist/isTypeReadonly.d.ts +0 -118
- package/_ts4.2/dist/typeFlagUtils.d.ts +0 -11
- /package/{_ts4.2 → _ts4.3}/dist/containsAllTypesByName.d.ts +0 -0
- /package/{_ts4.2 → _ts4.3}/dist/getConstrainedTypeAtLocation.d.ts +0 -0
- /package/{_ts4.2 → _ts4.3}/dist/getContextualType.d.ts +0 -0
- /package/{_ts4.2 → _ts4.3}/dist/getDeclaration.d.ts +0 -0
- /package/{_ts4.2 → _ts4.3}/dist/getSourceFileOfNode.d.ts +0 -0
- /package/{_ts4.2 → _ts4.3}/dist/getTokenAtPosition.d.ts +0 -0
- /package/{_ts4.2 → _ts4.3}/dist/getTypeArguments.d.ts +0 -0
- /package/{_ts4.2 → _ts4.3}/dist/getTypeName.d.ts +0 -0
- /package/{_ts4.2 → _ts4.3}/dist/index.d.ts +0 -0
- /package/{_ts4.2 → _ts4.3}/dist/isUnsafeAssignment.d.ts +0 -0
- /package/{_ts4.2 → _ts4.3}/dist/predicates.d.ts +0 -0
- /package/{_ts4.2 → _ts4.3}/dist/propertyTypes.d.ts +0 -0
- /package/{_ts4.2 → _ts4.3}/dist/requiresQuoting.d.ts +0 -0
package/README.md
CHANGED
|
@@ -2,11 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
> Type utilities for working with TypeScript within ESLint rules.
|
|
4
4
|
|
|
5
|
+
[](https://www.npmjs.com/package/@typescript-eslint/utils)
|
|
6
|
+
[](https://www.npmjs.com/package/@typescript-eslint/utils)
|
|
7
|
+
|
|
5
8
|
The utilities in this package are separated from `@typescript-eslint/utils` so that that package does not require a dependency on `typescript`.
|
|
6
9
|
|
|
7
|
-
|
|
10
|
+
👉 See **https://typescript-eslint.io/packages/type-utils** for documentation on this package.
|
|
8
11
|
|
|
9
|
-
|
|
10
|
-
You likely don't want to use it directly.
|
|
12
|
+
> See https://typescript-eslint.io for general documentation on typescript-eslint, the tooling that allows you to run ESLint and Prettier on TypeScript code.
|
|
11
13
|
|
|
12
|
-
|
|
14
|
+
<!-- Local path for docs: docs/packages/Type_Utils.mdx -->
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { JSONSchema4 } from '@typescript-eslint/utils/json-schema';
|
|
2
|
+
import type * as ts from 'typescript';
|
|
3
|
+
interface FileSpecifier {
|
|
4
|
+
from: 'file';
|
|
5
|
+
name: string[] | string;
|
|
6
|
+
path?: string;
|
|
7
|
+
}
|
|
8
|
+
interface LibSpecifier {
|
|
9
|
+
from: 'lib';
|
|
10
|
+
name: string[] | string;
|
|
11
|
+
}
|
|
12
|
+
interface PackageSpecifier {
|
|
13
|
+
from: 'package';
|
|
14
|
+
name: string[] | string;
|
|
15
|
+
package: string;
|
|
16
|
+
}
|
|
17
|
+
export type TypeOrValueSpecifier = FileSpecifier | LibSpecifier | PackageSpecifier | string;
|
|
18
|
+
export declare const typeOrValueSpecifierSchema: JSONSchema4;
|
|
19
|
+
export declare function typeMatchesSpecifier(type: ts.Type, specifier: TypeOrValueSpecifier, program: ts.Program): boolean;
|
|
20
|
+
export {};
|
|
21
|
+
//# sourceMappingURL=TypeOrValueSpecifier.d.ts.map
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { JSONSchema4 } from '@typescript-eslint/utils/json-schema';
|
|
2
|
+
import * as ts from 'typescript';
|
|
3
|
+
import type { TypeOrValueSpecifier } from './TypeOrValueSpecifier';
|
|
4
|
+
export interface ReadonlynessOptions {
|
|
5
|
+
readonly treatMethodsAsReadonly?: boolean;
|
|
6
|
+
readonly allow?: TypeOrValueSpecifier[];
|
|
7
|
+
}
|
|
8
|
+
export declare const readonlynessOptionsSchema: {
|
|
9
|
+
type: "object";
|
|
10
|
+
additionalProperties: false;
|
|
11
|
+
properties: {
|
|
12
|
+
treatMethodsAsReadonly: {
|
|
13
|
+
type: "boolean";
|
|
14
|
+
};
|
|
15
|
+
allow: {
|
|
16
|
+
type: "array";
|
|
17
|
+
items: JSONSchema4;
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
export declare const readonlynessOptionsDefaults: ReadonlynessOptions;
|
|
22
|
+
/**
|
|
23
|
+
* Checks if the given type is readonly
|
|
24
|
+
*/
|
|
25
|
+
declare function isTypeReadonly(program: ts.Program, type: ts.Type, options?: ReadonlynessOptions): boolean;
|
|
26
|
+
export { isTypeReadonly };
|
|
27
|
+
//# sourceMappingURL=isTypeReadonly.d.ts.map
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import * as ts from 'typescript';
|
|
2
|
+
/**
|
|
3
|
+
* Gets all of the type flags in a type, iterating through unions automatically.
|
|
4
|
+
*/
|
|
5
|
+
export declare function getTypeFlags(type: ts.Type): ts.TypeFlags;
|
|
6
|
+
/**
|
|
7
|
+
* @param flagsToCheck The composition of one or more `ts.TypeFlags`.
|
|
8
|
+
* @param isReceiver Whether the type is a receiving type (e.g. the type of a
|
|
9
|
+
* called function's parameter).
|
|
10
|
+
* @remarks
|
|
11
|
+
* Note that if the type is a union, this function will decompose it into the
|
|
12
|
+
* parts and get the flags of every union constituent. If this is not desired,
|
|
13
|
+
* use the `isTypeFlag` function from tsutils.
|
|
14
|
+
*/
|
|
15
|
+
export declare function isTypeFlagSet(type: ts.Type, flagsToCheck: ts.TypeFlags, isReceiver?: boolean): boolean;
|
|
16
|
+
//# sourceMappingURL=typeFlagUtils.d.ts.map
|
|
@@ -1,112 +1,21 @@
|
|
|
1
|
+
import type { JSONSchema4 } from '@typescript-eslint/utils/json-schema';
|
|
1
2
|
import type * as ts from 'typescript';
|
|
2
3
|
interface FileSpecifier {
|
|
3
4
|
from: 'file';
|
|
4
|
-
name: string | string
|
|
5
|
+
name: string[] | string;
|
|
5
6
|
path?: string;
|
|
6
7
|
}
|
|
7
8
|
interface LibSpecifier {
|
|
8
9
|
from: 'lib';
|
|
9
|
-
name: string | string
|
|
10
|
+
name: string[] | string;
|
|
10
11
|
}
|
|
11
12
|
interface PackageSpecifier {
|
|
12
13
|
from: 'package';
|
|
13
|
-
name: string | string
|
|
14
|
+
name: string[] | string;
|
|
14
15
|
package: string;
|
|
15
16
|
}
|
|
16
|
-
export type TypeOrValueSpecifier =
|
|
17
|
-
export declare const typeOrValueSpecifierSchema:
|
|
18
|
-
oneOf: ({
|
|
19
|
-
type: string;
|
|
20
|
-
additionalProperties?: undefined;
|
|
21
|
-
properties?: undefined;
|
|
22
|
-
required?: undefined;
|
|
23
|
-
} | {
|
|
24
|
-
type: string;
|
|
25
|
-
additionalProperties: boolean;
|
|
26
|
-
properties: {
|
|
27
|
-
from: {
|
|
28
|
-
type: string;
|
|
29
|
-
const: string;
|
|
30
|
-
};
|
|
31
|
-
name: {
|
|
32
|
-
oneOf: ({
|
|
33
|
-
type: string;
|
|
34
|
-
minItems?: undefined;
|
|
35
|
-
uniqueItems?: undefined;
|
|
36
|
-
items?: undefined;
|
|
37
|
-
} | {
|
|
38
|
-
type: string;
|
|
39
|
-
minItems: number;
|
|
40
|
-
uniqueItems: boolean;
|
|
41
|
-
items: {
|
|
42
|
-
type: string;
|
|
43
|
-
};
|
|
44
|
-
})[];
|
|
45
|
-
};
|
|
46
|
-
path: {
|
|
47
|
-
type: string;
|
|
48
|
-
};
|
|
49
|
-
package?: undefined;
|
|
50
|
-
};
|
|
51
|
-
required: string[];
|
|
52
|
-
} | {
|
|
53
|
-
type: string;
|
|
54
|
-
additionalProperties: boolean;
|
|
55
|
-
properties: {
|
|
56
|
-
from: {
|
|
57
|
-
type: string;
|
|
58
|
-
const: string;
|
|
59
|
-
};
|
|
60
|
-
name: {
|
|
61
|
-
oneOf: ({
|
|
62
|
-
type: string;
|
|
63
|
-
minItems?: undefined;
|
|
64
|
-
uniqueItems?: undefined;
|
|
65
|
-
items?: undefined;
|
|
66
|
-
} | {
|
|
67
|
-
type: string;
|
|
68
|
-
minItems: number;
|
|
69
|
-
uniqueItems: boolean;
|
|
70
|
-
items: {
|
|
71
|
-
type: string;
|
|
72
|
-
};
|
|
73
|
-
})[];
|
|
74
|
-
};
|
|
75
|
-
path?: undefined;
|
|
76
|
-
package?: undefined;
|
|
77
|
-
};
|
|
78
|
-
required: string[];
|
|
79
|
-
} | {
|
|
80
|
-
type: string;
|
|
81
|
-
additionalProperties: boolean;
|
|
82
|
-
properties: {
|
|
83
|
-
from: {
|
|
84
|
-
type: string;
|
|
85
|
-
const: string;
|
|
86
|
-
};
|
|
87
|
-
name: {
|
|
88
|
-
oneOf: ({
|
|
89
|
-
type: string;
|
|
90
|
-
minItems?: undefined;
|
|
91
|
-
uniqueItems?: undefined;
|
|
92
|
-
items?: undefined;
|
|
93
|
-
} | {
|
|
94
|
-
type: string;
|
|
95
|
-
minItems: number;
|
|
96
|
-
uniqueItems: boolean;
|
|
97
|
-
items: {
|
|
98
|
-
type: string;
|
|
99
|
-
};
|
|
100
|
-
})[];
|
|
101
|
-
};
|
|
102
|
-
package: {
|
|
103
|
-
type: string;
|
|
104
|
-
};
|
|
105
|
-
path?: undefined;
|
|
106
|
-
};
|
|
107
|
-
required: string[];
|
|
108
|
-
})[];
|
|
109
|
-
};
|
|
17
|
+
export type TypeOrValueSpecifier = FileSpecifier | LibSpecifier | PackageSpecifier | string;
|
|
18
|
+
export declare const typeOrValueSpecifierSchema: JSONSchema4;
|
|
110
19
|
export declare function typeMatchesSpecifier(type: ts.Type, specifier: TypeOrValueSpecifier, program: ts.Program): boolean;
|
|
111
20
|
export {};
|
|
112
21
|
//# sourceMappingURL=TypeOrValueSpecifier.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TypeOrValueSpecifier.d.ts","sourceRoot":"","sources":["../src/TypeOrValueSpecifier.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,EAAE,MAAM,YAAY,CAAC;AAEtC,UAAU,aAAa;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,GAAG,MAAM,
|
|
1
|
+
{"version":3,"file":"TypeOrValueSpecifier.d.ts","sourceRoot":"","sources":["../src/TypeOrValueSpecifier.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sCAAsC,CAAC;AAGxE,OAAO,KAAK,KAAK,EAAE,MAAM,YAAY,CAAC;AAEtC,UAAU,aAAa;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,EAAE,GAAG,MAAM,CAAC;IACxB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,UAAU,YAAY;IACpB,IAAI,EAAE,KAAK,CAAC;IACZ,IAAI,EAAE,MAAM,EAAE,GAAG,MAAM,CAAC;CACzB;AAED,UAAU,gBAAgB;IACxB,IAAI,EAAE,SAAS,CAAC;IAChB,IAAI,EAAE,MAAM,EAAE,GAAG,MAAM,CAAC;IACxB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,MAAM,oBAAoB,GAC5B,aAAa,GACb,YAAY,GACZ,gBAAgB,GAChB,MAAM,CAAC;AAEX,eAAO,MAAM,0BAA0B,EAAE,WA0FxC,CAAC;AAiEF,wBAAgB,oBAAoB,CAClC,IAAI,EAAE,EAAE,CAAC,IAAI,EACb,SAAS,EAAE,oBAAoB,EAC/B,OAAO,EAAE,EAAE,CAAC,OAAO,GAClB,OAAO,CAuBT"}
|
|
@@ -1,10 +1,35 @@
|
|
|
1
1
|
"use strict";
|
|
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 (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
2
25
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
27
|
};
|
|
5
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
29
|
exports.typeMatchesSpecifier = exports.typeOrValueSpecifierSchema = void 0;
|
|
30
|
+
const typescript_estree_1 = require("@typescript-eslint/typescript-estree");
|
|
7
31
|
const path_1 = __importDefault(require("path"));
|
|
32
|
+
const tsutils = __importStar(require("ts-api-utils"));
|
|
8
33
|
exports.typeOrValueSpecifierSchema = {
|
|
9
34
|
oneOf: [
|
|
10
35
|
{
|
|
@@ -16,7 +41,7 @@ exports.typeOrValueSpecifierSchema = {
|
|
|
16
41
|
properties: {
|
|
17
42
|
from: {
|
|
18
43
|
type: 'string',
|
|
19
|
-
|
|
44
|
+
enum: ['file'],
|
|
20
45
|
},
|
|
21
46
|
name: {
|
|
22
47
|
oneOf: [
|
|
@@ -45,7 +70,7 @@ exports.typeOrValueSpecifierSchema = {
|
|
|
45
70
|
properties: {
|
|
46
71
|
from: {
|
|
47
72
|
type: 'string',
|
|
48
|
-
|
|
73
|
+
enum: ['lib'],
|
|
49
74
|
},
|
|
50
75
|
name: {
|
|
51
76
|
oneOf: [
|
|
@@ -71,7 +96,7 @@ exports.typeOrValueSpecifierSchema = {
|
|
|
71
96
|
properties: {
|
|
72
97
|
from: {
|
|
73
98
|
type: 'string',
|
|
74
|
-
|
|
99
|
+
enum: ['package'],
|
|
75
100
|
},
|
|
76
101
|
name: {
|
|
77
102
|
oneOf: [
|
|
@@ -100,7 +125,10 @@ function specifierNameMatches(type, name) {
|
|
|
100
125
|
if (typeof name === 'string') {
|
|
101
126
|
name = [name];
|
|
102
127
|
}
|
|
103
|
-
|
|
128
|
+
if (name.some(item => item === type.intrinsicName)) {
|
|
129
|
+
return true;
|
|
130
|
+
}
|
|
131
|
+
const symbol = type.aliasSymbol ?? type.getSymbol();
|
|
104
132
|
if (symbol === undefined) {
|
|
105
133
|
return false;
|
|
106
134
|
}
|
|
@@ -108,15 +136,30 @@ function specifierNameMatches(type, name) {
|
|
|
108
136
|
}
|
|
109
137
|
function typeDeclaredInFile(relativePath, declarationFiles, program) {
|
|
110
138
|
if (relativePath === undefined) {
|
|
111
|
-
const cwd = program.getCurrentDirectory()
|
|
112
|
-
return declarationFiles.some(declaration => declaration.fileName
|
|
139
|
+
const cwd = (0, typescript_estree_1.getCanonicalFileName)(program.getCurrentDirectory());
|
|
140
|
+
return declarationFiles.some(declaration => (0, typescript_estree_1.getCanonicalFileName)(declaration.fileName).startsWith(cwd));
|
|
141
|
+
}
|
|
142
|
+
const absolutePath = (0, typescript_estree_1.getCanonicalFileName)(path_1.default.join(program.getCurrentDirectory(), relativePath));
|
|
143
|
+
return declarationFiles.some(declaration => (0, typescript_estree_1.getCanonicalFileName)(declaration.fileName) === absolutePath);
|
|
144
|
+
}
|
|
145
|
+
function typeDeclaredInPackage(packageName, declarationFiles) {
|
|
146
|
+
// Handle scoped packages - if the name starts with @, remove it and replace / with __
|
|
147
|
+
const typesPackageName = '@types/' + packageName.replace(/^@([^/]+)\//, '$1__');
|
|
148
|
+
const matcher = new RegExp(`node_modules/(?:${packageName}|${typesPackageName})/`);
|
|
149
|
+
return declarationFiles.some(declaration => matcher.test(declaration.fileName));
|
|
150
|
+
}
|
|
151
|
+
function typeDeclaredInLib(declarationFiles, program) {
|
|
152
|
+
// Assertion: The type is not an error type.
|
|
153
|
+
// Intrinsic type (i.e. string, number, boolean, etc) - Treat it as if it's from lib.
|
|
154
|
+
if (declarationFiles.length === 0) {
|
|
155
|
+
return true;
|
|
113
156
|
}
|
|
114
|
-
|
|
115
|
-
.join(program.getCurrentDirectory(), relativePath)
|
|
116
|
-
.toLowerCase();
|
|
117
|
-
return declarationFiles.some(declaration => declaration.fileName.toLowerCase() === absolutePath);
|
|
157
|
+
return declarationFiles.some(declaration => program.isSourceFileDefaultLibrary(declaration));
|
|
118
158
|
}
|
|
119
159
|
function typeMatchesSpecifier(type, specifier, program) {
|
|
160
|
+
if (tsutils.isIntrinsicErrorType(type)) {
|
|
161
|
+
return false;
|
|
162
|
+
}
|
|
120
163
|
if (typeof specifier === 'string') {
|
|
121
164
|
return specifierNameMatches(type, specifier);
|
|
122
165
|
}
|
|
@@ -131,10 +174,9 @@ function typeMatchesSpecifier(type, specifier, program) {
|
|
|
131
174
|
case 'file':
|
|
132
175
|
return typeDeclaredInFile(specifier.path, declarationFiles, program);
|
|
133
176
|
case 'lib':
|
|
134
|
-
return declarationFiles
|
|
177
|
+
return typeDeclaredInLib(declarationFiles, program);
|
|
135
178
|
case 'package':
|
|
136
|
-
return
|
|
137
|
-
declaration.fileName.includes(`node_modules/@types/${specifier.package}/`));
|
|
179
|
+
return typeDeclaredInPackage(specifier.package, declarationFiles);
|
|
138
180
|
}
|
|
139
181
|
}
|
|
140
182
|
exports.typeMatchesSpecifier = typeMatchesSpecifier;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TypeOrValueSpecifier.js","sourceRoot":"","sources":["../src/TypeOrValueSpecifier.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"TypeOrValueSpecifier.js","sourceRoot":"","sources":["../src/TypeOrValueSpecifier.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,4EAA4E;AAE5E,gDAAwB;AACxB,sDAAwC;AA0B3B,QAAA,0BAA0B,GAAgB;IACrD,KAAK,EAAE;QACL;YACE,IAAI,EAAE,QAAQ;SACf;QACD;YACE,IAAI,EAAE,QAAQ;YACd,oBAAoB,EAAE,KAAK;YAC3B,UAAU,EAAE;gBACV,IAAI,EAAE;oBACJ,IAAI,EAAE,QAAQ;oBACd,IAAI,EAAE,CAAC,MAAM,CAAC;iBACf;gBACD,IAAI,EAAE;oBACJ,KAAK,EAAE;wBACL;4BACE,IAAI,EAAE,QAAQ;yBACf;wBACD;4BACE,IAAI,EAAE,OAAO;4BACb,QAAQ,EAAE,CAAC;4BACX,WAAW,EAAE,IAAI;4BACjB,KAAK,EAAE;gCACL,IAAI,EAAE,QAAQ;6BACf;yBACF;qBACF;iBACF;gBACD,IAAI,E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AA3BD,oDA2BC"}
|
package/dist/isTypeReadonly.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { JSONSchema4 } from '@typescript-eslint/utils/json-schema';
|
|
1
2
|
import * as ts from 'typescript';
|
|
2
3
|
import type { TypeOrValueSpecifier } from './TypeOrValueSpecifier';
|
|
3
4
|
export interface ReadonlynessOptions {
|
|
@@ -5,107 +6,15 @@ export interface ReadonlynessOptions {
|
|
|
5
6
|
readonly allow?: TypeOrValueSpecifier[];
|
|
6
7
|
}
|
|
7
8
|
export declare const readonlynessOptionsSchema: {
|
|
8
|
-
type:
|
|
9
|
-
additionalProperties:
|
|
9
|
+
type: "object";
|
|
10
|
+
additionalProperties: false;
|
|
10
11
|
properties: {
|
|
11
12
|
treatMethodsAsReadonly: {
|
|
12
|
-
type:
|
|
13
|
+
type: "boolean";
|
|
13
14
|
};
|
|
14
15
|
allow: {
|
|
15
|
-
type:
|
|
16
|
-
items:
|
|
17
|
-
oneOf: ({
|
|
18
|
-
type: string;
|
|
19
|
-
additionalProperties?: undefined;
|
|
20
|
-
properties?: undefined;
|
|
21
|
-
required?: undefined;
|
|
22
|
-
} | {
|
|
23
|
-
type: string;
|
|
24
|
-
additionalProperties: boolean;
|
|
25
|
-
properties: {
|
|
26
|
-
from: {
|
|
27
|
-
type: string;
|
|
28
|
-
const: string;
|
|
29
|
-
};
|
|
30
|
-
name: {
|
|
31
|
-
oneOf: ({
|
|
32
|
-
type: string;
|
|
33
|
-
minItems?: undefined;
|
|
34
|
-
uniqueItems?: undefined;
|
|
35
|
-
items?: undefined;
|
|
36
|
-
} | {
|
|
37
|
-
type: string;
|
|
38
|
-
minItems: number;
|
|
39
|
-
uniqueItems: boolean;
|
|
40
|
-
items: {
|
|
41
|
-
type: string;
|
|
42
|
-
};
|
|
43
|
-
})[];
|
|
44
|
-
};
|
|
45
|
-
path: {
|
|
46
|
-
type: string;
|
|
47
|
-
};
|
|
48
|
-
package?: undefined;
|
|
49
|
-
};
|
|
50
|
-
required: string[];
|
|
51
|
-
} | {
|
|
52
|
-
type: string;
|
|
53
|
-
additionalProperties: boolean;
|
|
54
|
-
properties: {
|
|
55
|
-
from: {
|
|
56
|
-
type: string;
|
|
57
|
-
const: string;
|
|
58
|
-
};
|
|
59
|
-
name: {
|
|
60
|
-
oneOf: ({
|
|
61
|
-
type: string;
|
|
62
|
-
minItems?: undefined;
|
|
63
|
-
uniqueItems?: undefined;
|
|
64
|
-
items?: undefined;
|
|
65
|
-
} | {
|
|
66
|
-
type: string;
|
|
67
|
-
minItems: number;
|
|
68
|
-
uniqueItems: boolean;
|
|
69
|
-
items: {
|
|
70
|
-
type: string;
|
|
71
|
-
};
|
|
72
|
-
})[];
|
|
73
|
-
};
|
|
74
|
-
path?: undefined;
|
|
75
|
-
package?: undefined;
|
|
76
|
-
};
|
|
77
|
-
required: string[];
|
|
78
|
-
} | {
|
|
79
|
-
type: string;
|
|
80
|
-
additionalProperties: boolean;
|
|
81
|
-
properties: {
|
|
82
|
-
from: {
|
|
83
|
-
type: string;
|
|
84
|
-
const: string;
|
|
85
|
-
};
|
|
86
|
-
name: {
|
|
87
|
-
oneOf: ({
|
|
88
|
-
type: string;
|
|
89
|
-
minItems?: undefined;
|
|
90
|
-
uniqueItems?: undefined;
|
|
91
|
-
items?: undefined;
|
|
92
|
-
} | {
|
|
93
|
-
type: string;
|
|
94
|
-
minItems: number;
|
|
95
|
-
uniqueItems: boolean;
|
|
96
|
-
items: {
|
|
97
|
-
type: string;
|
|
98
|
-
};
|
|
99
|
-
})[];
|
|
100
|
-
};
|
|
101
|
-
package: {
|
|
102
|
-
type: string;
|
|
103
|
-
};
|
|
104
|
-
path?: undefined;
|
|
105
|
-
};
|
|
106
|
-
required: string[];
|
|
107
|
-
})[];
|
|
108
|
-
};
|
|
16
|
+
type: "array";
|
|
17
|
+
items: JSONSchema4;
|
|
109
18
|
};
|
|
110
19
|
};
|
|
111
20
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isTypeReadonly.d.ts","sourceRoot":"","sources":["../src/isTypeReadonly.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"isTypeReadonly.d.ts","sourceRoot":"","sources":["../src/isTypeReadonly.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sCAAsC,CAAC;AAExE,OAAO,KAAK,EAAE,MAAM,YAAY,CAAC;AAIjC,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAenE,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,sBAAsB,CAAC,EAAE,OAAO,CAAC;IAC1C,QAAQ,CAAC,KAAK,CAAC,EAAE,oBAAoB,EAAE,CAAC;CACzC;AAED,eAAO,MAAM,yBAAyB;;;;;;;;;;;;CAYf,CAAC;AAExB,eAAO,MAAM,2BAA2B,EAAE,mBAGzC,CAAC;AAsSF;;GAEG;AACH,iBAAS,cAAc,CACrB,OAAO,EAAE,EAAE,CAAC,OAAO,EACnB,IAAI,EAAE,EAAE,CAAC,IAAI,EACb,OAAO,GAAE,mBAAiD,GACzD,OAAO,CAKT;AAED,OAAO,EAAE,cAAc,EAAE,CAAC"}
|
package/dist/isTypeReadonly.js
CHANGED
|
@@ -27,6 +27,7 @@ exports.isTypeReadonly = exports.readonlynessOptionsDefaults = exports.readonlyn
|
|
|
27
27
|
const utils_1 = require("@typescript-eslint/utils");
|
|
28
28
|
const tsutils = __importStar(require("ts-api-utils"));
|
|
29
29
|
const ts = __importStar(require("typescript"));
|
|
30
|
+
const getTypeArguments_1 = require("./getTypeArguments");
|
|
30
31
|
const propertyTypes_1 = require("./propertyTypes");
|
|
31
32
|
const TypeOrValueSpecifier_1 = require("./TypeOrValueSpecifier");
|
|
32
33
|
exports.readonlynessOptionsSchema = {
|
|
@@ -54,9 +55,7 @@ function isTypeReadonlyArrayOrTuple(program, type, options, seenTypes) {
|
|
|
54
55
|
function checkTypeArguments(arrayType) {
|
|
55
56
|
const typeArguments =
|
|
56
57
|
// getTypeArguments was only added in TS3.7
|
|
57
|
-
|
|
58
|
-
? checker.getTypeArguments(arrayType)
|
|
59
|
-
: arrayType.typeArguments ?? [];
|
|
58
|
+
(0, getTypeArguments_1.getTypeArguments)(arrayType, checker);
|
|
60
59
|
// this shouldn't happen in reality as:
|
|
61
60
|
// - tuples require at least 1 type argument
|
|
62
61
|
// - ReadonlyArray requires at least 1 type argument
|
|
@@ -73,6 +72,7 @@ function isTypeReadonlyArrayOrTuple(program, type, options, seenTypes) {
|
|
|
73
72
|
if (checker.isArrayType(type)) {
|
|
74
73
|
const symbol = utils_1.ESLintUtils.nullThrows(type.getSymbol(), utils_1.ESLintUtils.NullThrowsReasons.MissingToken('symbol', 'array type'));
|
|
75
74
|
const escapedName = symbol.getEscapedName();
|
|
75
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-enum-comparison
|
|
76
76
|
if (escapedName === 'Array') {
|
|
77
77
|
return 2 /* Readonlyness.Mutable */;
|
|
78
78
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isTypeReadonly.js","sourceRoot":"","sources":["../src/isTypeReadonly.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,oDAAuD;
|
|
1
|
+
{"version":3,"file":"isTypeReadonly.js","sourceRoot":"","sources":["../src/isTypeReadonly.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,oDAAuD;AAEvD,sDAAwC;AACxC,+CAAiC;AAEjC,yDAAsD;AACtD,mDAA0D;AAE1D,iEAGgC;AAgBnB,QAAA,yBAAyB,GAAG;IACvC,IAAI,EAAE,QAAQ;IACd,oBAAoB,EAAE,KAAK;IAC3B,UAAU,EAAE;QACV,sBAAsB,EAAE;YACtB,IAAI,EAAE,SAAS;SAChB;QACD,KAAK,EAAE;YACL,IAAI,EAAE,OAAO;YACb,KAAK,EAAE,iDAA0B;SAClC;KACF;CACoB,CAAC;A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QACA,qCAA6B;KAC9B;IAED,MAAM,eAAe,GAAG,0BAA0B,CAChD,OAAO,EACP,IAAI,EACJ,OAAO,EACP,SAAS,CACV,CAAC;IACF,IAAI,eAAe,qCAA6B,EAAE;QAChD,OAAO,eAAe,CAAC;KACxB;IAED,MAAM,gBAAgB,GAAG,oBAAoB,CAC3C,OAAO,EACP,IAAI,EACJ,OAAO,EACP,SAAS,CACV,CAAC;IACF,0BAA0B,CAAC,IACzB,gBAAgB,qCAA6B,EAC7C;QACA,OAAO,gBAAgB,CAAC;KACzB;IAED,MAAM,IAAI,KAAK,CAAC,gBAAgB,CAAC,CAAC;AACpC,CAAC;AAED;;GAEG;AACH,SAAS,cAAc,CACrB,OAAmB,EACnB,IAAa,EACb,UAA+B,mCAA2B;IAE1D,OAAO,CACL,sBAAsB,CAAC,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,GAAG,EAAE,CAAC;qCACpC,CACtB,CAAC;AACJ,CAAC;AAEQ,wCAAc"}
|
package/dist/predicates.js
CHANGED
|
@@ -132,7 +132,7 @@ var AnyType;
|
|
|
132
132
|
AnyType[AnyType["Any"] = 0] = "Any";
|
|
133
133
|
AnyType[AnyType["AnyArray"] = 1] = "AnyArray";
|
|
134
134
|
AnyType[AnyType["Safe"] = 2] = "Safe";
|
|
135
|
-
})(AnyType
|
|
135
|
+
})(AnyType || (exports.AnyType = AnyType = {}));
|
|
136
136
|
/**
|
|
137
137
|
* @returns `AnyType.Any` if the type is `any`, `AnyType.AnyArray` if the type is `any[]` or `readonly any[]`,
|
|
138
138
|
* otherwise it returns `AnyType.Safe`.
|
package/dist/predicates.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"predicates.js","sourceRoot":"","sources":["../src/predicates.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,kDAA0B;AAC1B,sDAAwC;AACxC,+CAAiC;AAEjC,yDAAsD;AACtD,mDAA8D;AAE9D,MA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,4EAYC;AAED;;GAEG;AACH,SAAgB,mBAAmB,CACjC,IAAa,EACb,UAAmB;IAEnB,MAAM,YAAY,GAAG,UAAU,CAAC,SAAS,EAAE,CAAC;IAC5C,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,YAAY,EAAE;QACtC,OAAO,KAAK,CAAC;KACd;IAED,MAAM,gBAAgB,GAAG,CAAC,IAAI,CAAC,CAAC;IAChC,MAAM,aAAa,GAAG,IAAI,CAAC,YAAY,EAAE,CAAC;IAE1C,IAAI,aAAa,EAAE;QACjB,gBAAgB,CAAC,IAAI,CAAC,GAAG,aAAa,CAAC,CAAC;KACzC;IAED,KAAK,MAAM,QAAQ,IAAI,gBAAgB,EAAE;QACvC,MAAM,UAAU,GAAG,QAAQ,CAAC,SAAS,EAAE,CAAC;QACxC,IAAI,UAAU,IAAI,UAAU,CAAC,IAAI,KAAK,YAAY,CAAC,IAAI,EAAE;YACvD,OAAO,IAAI,CAAC;SACb;KACF;IAED,OAAO,KAAK,CAAC;AACf,CAAC;AAxBD,kDAwBC;AAED,SAAgB,uBAAuB,CACrC,IAAa;IAEb,OAAO,IAAA,6BAAa,EAAC,IAAI,EAAE,EAAE,CAAC,SAAS,CAAC,aAAa,CAAC,CAAC;AACzD,CAAC;AAJD,0DAIC;AAED,SAAgB,yBAAyB,CACvC,IAAa;IAEb,OAAO,IAAA,6BAAa,EAAC,IAAI,EAAE,EAAE,CAAC,SAAS,CAAC,eAAe,CAAC,CAAC;AAC3D,CAAC;AAJD,8DAIC"}
|
package/dist/typeFlagUtils.d.ts
CHANGED
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
import * as ts from 'typescript';
|
|
2
2
|
/**
|
|
3
|
-
* Gets all of the type flags in a type, iterating through unions automatically
|
|
3
|
+
* Gets all of the type flags in a type, iterating through unions automatically.
|
|
4
4
|
*/
|
|
5
5
|
export declare function getTypeFlags(type: ts.Type): ts.TypeFlags;
|
|
6
6
|
/**
|
|
7
|
-
*
|
|
8
|
-
* @param isReceiver
|
|
7
|
+
* @param flagsToCheck The composition of one or more `ts.TypeFlags`.
|
|
8
|
+
* @param isReceiver Whether the type is a receiving type (e.g. the type of a
|
|
9
|
+
* called function's parameter).
|
|
10
|
+
* @remarks
|
|
11
|
+
* Note that if the type is a union, this function will decompose it into the
|
|
12
|
+
* parts and get the flags of every union constituent. If this is not desired,
|
|
13
|
+
* use the `isTypeFlag` function from tsutils.
|
|
9
14
|
*/
|
|
10
15
|
export declare function isTypeFlagSet(type: ts.Type, flagsToCheck: ts.TypeFlags, isReceiver?: boolean): boolean;
|
|
11
16
|
//# sourceMappingURL=typeFlagUtils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"typeFlagUtils.d.ts","sourceRoot":"","sources":["../src/typeFlagUtils.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"typeFlagUtils.d.ts","sourceRoot":"","sources":["../src/typeFlagUtils.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,YAAY,CAAC;AAIjC;;GAEG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,GAAG,EAAE,CAAC,SAAS,CAOxD;AAED;;;;;;;;GAQG;AACH,wBAAgB,aAAa,CAC3B,IAAI,EAAE,EAAE,CAAC,IAAI,EACb,YAAY,EAAE,EAAE,CAAC,SAAS,EAC1B,UAAU,CAAC,EAAE,OAAO,GACnB,OAAO,CAQT"}
|
package/dist/typeFlagUtils.js
CHANGED
|
@@ -26,8 +26,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
26
26
|
exports.isTypeFlagSet = exports.getTypeFlags = void 0;
|
|
27
27
|
const tsutils = __importStar(require("ts-api-utils"));
|
|
28
28
|
const ts = __importStar(require("typescript"));
|
|
29
|
+
const ANY_OR_UNKNOWN = ts.TypeFlags.Any | ts.TypeFlags.Unknown;
|
|
29
30
|
/**
|
|
30
|
-
* Gets all of the type flags in a type, iterating through unions automatically
|
|
31
|
+
* Gets all of the type flags in a type, iterating through unions automatically.
|
|
31
32
|
*/
|
|
32
33
|
function getTypeFlags(type) {
|
|
33
34
|
// @ts-expect-error Since typescript 5.0, this is invalid, but uses 0 as the default value of TypeFlags.
|
|
@@ -39,12 +40,17 @@ function getTypeFlags(type) {
|
|
|
39
40
|
}
|
|
40
41
|
exports.getTypeFlags = getTypeFlags;
|
|
41
42
|
/**
|
|
42
|
-
*
|
|
43
|
-
* @param isReceiver
|
|
43
|
+
* @param flagsToCheck The composition of one or more `ts.TypeFlags`.
|
|
44
|
+
* @param isReceiver Whether the type is a receiving type (e.g. the type of a
|
|
45
|
+
* called function's parameter).
|
|
46
|
+
* @remarks
|
|
47
|
+
* Note that if the type is a union, this function will decompose it into the
|
|
48
|
+
* parts and get the flags of every union constituent. If this is not desired,
|
|
49
|
+
* use the `isTypeFlag` function from tsutils.
|
|
44
50
|
*/
|
|
45
51
|
function isTypeFlagSet(type, flagsToCheck, isReceiver) {
|
|
46
52
|
const flags = getTypeFlags(type);
|
|
47
|
-
if (isReceiver && flags &
|
|
53
|
+
if (isReceiver && flags & ANY_OR_UNKNOWN) {
|
|
48
54
|
return true;
|
|
49
55
|
}
|
|
50
56
|
return (flags & flagsToCheck) !== 0;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"typeFlagUtils.js","sourceRoot":"","sources":["../src/typeFlagUtils.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,sDAAwC;AACxC,+CAAiC;AAEjC;;GAEG;AACH,SAAgB,YAAY,CAAC,IAAa;IACxC,wGAAwG;IACxG,IAAI,KAAK,GAAiB,CAAC,CAAC;IAC5B,KAAK,MAAM,CAAC,IAAI,OAAO,CAAC,cAAc,CAAC,IAAI,CAAC,EAAE;QAC5C,KAAK,IAAI,CAAC,CAAC,KAAK,CAAC;KAClB;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAPD,oCAOC;AAED
|
|
1
|
+
{"version":3,"file":"typeFlagUtils.js","sourceRoot":"","sources":["../src/typeFlagUtils.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,sDAAwC;AACxC,+CAAiC;AAEjC,MAAM,cAAc,GAAG,EAAE,CAAC,SAAS,CAAC,GAAG,GAAG,EAAE,CAAC,SAAS,CAAC,OAAO,CAAC;AAE/D;;GAEG;AACH,SAAgB,YAAY,CAAC,IAAa;IACxC,wGAAwG;IACxG,IAAI,KAAK,GAAiB,CAAC,CAAC;IAC5B,KAAK,MAAM,CAAC,IAAI,OAAO,CAAC,cAAc,CAAC,IAAI,CAAC,EAAE;QAC5C,KAAK,IAAI,CAAC,CAAC,KAAK,CAAC;KAClB;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAPD,oCAOC;AAED;;;;;;;;GAQG;AACH,SAAgB,aAAa,CAC3B,IAAa,EACb,YAA0B,EAC1B,UAAoB;IAEpB,MAAM,KAAK,GAAG,YAAY,CAAC,IAAI,CAAC,CAAC;IAEjC,IAAI,UAAU,IAAI,KAAK,GAAG,cAAc,EAAE;QACxC,OAAO,IAAI,CAAC;KACb;IAED,OAAO,CAAC,KAAK,GAAG,YAAY,CAAC,KAAK,CAAC,CAAC;AACtC,CAAC;AAZD,sCAYC"}
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@typescript-eslint/type-utils",
|
|
3
|
-
"version": "6.0.
|
|
3
|
+
"version": "6.0.1-alpha.0+6ae1fa74b",
|
|
4
4
|
"description": "Type utilities for working with TypeScript + ESLint together",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist",
|
|
7
|
-
"_ts4.
|
|
7
|
+
"_ts4.3",
|
|
8
8
|
"package.json",
|
|
9
9
|
"README.md",
|
|
10
10
|
"LICENSE"
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"./package.json": "./package.json"
|
|
19
19
|
},
|
|
20
20
|
"engines": {
|
|
21
|
-
"node": "^
|
|
21
|
+
"node": "^16.0.0 || >=18.0.0"
|
|
22
22
|
},
|
|
23
23
|
"repository": {
|
|
24
24
|
"type": "git",
|
|
@@ -36,22 +36,22 @@
|
|
|
36
36
|
],
|
|
37
37
|
"scripts": {
|
|
38
38
|
"build": "tsc -b tsconfig.build.json",
|
|
39
|
-
"postbuild": "downlevel-dts dist _ts4.
|
|
39
|
+
"postbuild": "downlevel-dts dist _ts4.3/dist --to=4.3",
|
|
40
40
|
"clean": "tsc -b tsconfig.build.json --clean",
|
|
41
|
-
"postclean": "rimraf dist && rimraf _ts3.4 && rimraf _ts4.
|
|
41
|
+
"postclean": "rimraf dist && rimraf _ts3.4 && rimraf _ts4.3 && rimraf coverage",
|
|
42
42
|
"format": "prettier --write \"./**/*.{ts,mts,cts,tsx,js,mjs,cjs,jsx,json,md,css}\" --ignore-path ../../.prettierignore",
|
|
43
43
|
"lint": "nx lint",
|
|
44
44
|
"test": "jest --coverage",
|
|
45
45
|
"typecheck": "tsc -p tsconfig.json --noEmit"
|
|
46
46
|
},
|
|
47
47
|
"dependencies": {
|
|
48
|
-
"@typescript-eslint/typescript-estree": "6.0.
|
|
49
|
-
"@typescript-eslint/utils": "6.0.
|
|
48
|
+
"@typescript-eslint/typescript-estree": "6.0.1-alpha.0+6ae1fa74b",
|
|
49
|
+
"@typescript-eslint/utils": "6.0.1-alpha.0+6ae1fa74b",
|
|
50
50
|
"debug": "^4.3.4",
|
|
51
|
-
"ts-api-utils": "^
|
|
51
|
+
"ts-api-utils": "^1.0.1"
|
|
52
52
|
},
|
|
53
53
|
"devDependencies": {
|
|
54
|
-
"@typescript-eslint/parser": "6.0.
|
|
54
|
+
"@typescript-eslint/parser": "6.0.1-alpha.0+6ae1fa74b",
|
|
55
55
|
"ajv": "^8.12.0",
|
|
56
56
|
"typescript": "*"
|
|
57
57
|
},
|
|
@@ -70,9 +70,9 @@
|
|
|
70
70
|
"typesVersions": {
|
|
71
71
|
"<4.7": {
|
|
72
72
|
"*": [
|
|
73
|
-
"_ts4.
|
|
73
|
+
"_ts4.3/*"
|
|
74
74
|
]
|
|
75
75
|
}
|
|
76
76
|
},
|
|
77
|
-
"gitHead": "
|
|
77
|
+
"gitHead": "6ae1fa74b18af8a2d4baa0d3d4b43997cf9a9781"
|
|
78
78
|
}
|
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
import type * as ts from 'typescript';
|
|
2
|
-
interface FileSpecifier {
|
|
3
|
-
from: 'file';
|
|
4
|
-
name: string | string[];
|
|
5
|
-
path?: string;
|
|
6
|
-
}
|
|
7
|
-
interface LibSpecifier {
|
|
8
|
-
from: 'lib';
|
|
9
|
-
name: string | string[];
|
|
10
|
-
}
|
|
11
|
-
interface PackageSpecifier {
|
|
12
|
-
from: 'package';
|
|
13
|
-
name: string | string[];
|
|
14
|
-
package: string;
|
|
15
|
-
}
|
|
16
|
-
export type TypeOrValueSpecifier = string | FileSpecifier | LibSpecifier | PackageSpecifier;
|
|
17
|
-
export declare const typeOrValueSpecifierSchema: {
|
|
18
|
-
oneOf: ({
|
|
19
|
-
type: string;
|
|
20
|
-
additionalProperties?: undefined;
|
|
21
|
-
properties?: undefined;
|
|
22
|
-
required?: undefined;
|
|
23
|
-
} | {
|
|
24
|
-
type: string;
|
|
25
|
-
additionalProperties: boolean;
|
|
26
|
-
properties: {
|
|
27
|
-
from: {
|
|
28
|
-
type: string;
|
|
29
|
-
const: string;
|
|
30
|
-
};
|
|
31
|
-
name: {
|
|
32
|
-
oneOf: ({
|
|
33
|
-
type: string;
|
|
34
|
-
minItems?: undefined;
|
|
35
|
-
uniqueItems?: undefined;
|
|
36
|
-
items?: undefined;
|
|
37
|
-
} | {
|
|
38
|
-
type: string;
|
|
39
|
-
minItems: number;
|
|
40
|
-
uniqueItems: boolean;
|
|
41
|
-
items: {
|
|
42
|
-
type: string;
|
|
43
|
-
};
|
|
44
|
-
})[];
|
|
45
|
-
};
|
|
46
|
-
path: {
|
|
47
|
-
type: string;
|
|
48
|
-
};
|
|
49
|
-
package?: undefined;
|
|
50
|
-
};
|
|
51
|
-
required: string[];
|
|
52
|
-
} | {
|
|
53
|
-
type: string;
|
|
54
|
-
additionalProperties: boolean;
|
|
55
|
-
properties: {
|
|
56
|
-
from: {
|
|
57
|
-
type: string;
|
|
58
|
-
const: string;
|
|
59
|
-
};
|
|
60
|
-
name: {
|
|
61
|
-
oneOf: ({
|
|
62
|
-
type: string;
|
|
63
|
-
minItems?: undefined;
|
|
64
|
-
uniqueItems?: undefined;
|
|
65
|
-
items?: undefined;
|
|
66
|
-
} | {
|
|
67
|
-
type: string;
|
|
68
|
-
minItems: number;
|
|
69
|
-
uniqueItems: boolean;
|
|
70
|
-
items: {
|
|
71
|
-
type: string;
|
|
72
|
-
};
|
|
73
|
-
})[];
|
|
74
|
-
};
|
|
75
|
-
path?: undefined;
|
|
76
|
-
package?: undefined;
|
|
77
|
-
};
|
|
78
|
-
required: string[];
|
|
79
|
-
} | {
|
|
80
|
-
type: string;
|
|
81
|
-
additionalProperties: boolean;
|
|
82
|
-
properties: {
|
|
83
|
-
from: {
|
|
84
|
-
type: string;
|
|
85
|
-
const: string;
|
|
86
|
-
};
|
|
87
|
-
name: {
|
|
88
|
-
oneOf: ({
|
|
89
|
-
type: string;
|
|
90
|
-
minItems?: undefined;
|
|
91
|
-
uniqueItems?: undefined;
|
|
92
|
-
items?: undefined;
|
|
93
|
-
} | {
|
|
94
|
-
type: string;
|
|
95
|
-
minItems: number;
|
|
96
|
-
uniqueItems: boolean;
|
|
97
|
-
items: {
|
|
98
|
-
type: string;
|
|
99
|
-
};
|
|
100
|
-
})[];
|
|
101
|
-
};
|
|
102
|
-
package: {
|
|
103
|
-
type: string;
|
|
104
|
-
};
|
|
105
|
-
path?: undefined;
|
|
106
|
-
};
|
|
107
|
-
required: string[];
|
|
108
|
-
})[];
|
|
109
|
-
};
|
|
110
|
-
export declare function typeMatchesSpecifier(type: ts.Type, specifier: TypeOrValueSpecifier, program: ts.Program): boolean;
|
|
111
|
-
export {};
|
|
112
|
-
//# sourceMappingURL=TypeOrValueSpecifier.d.ts.map
|
|
@@ -1,118 +0,0 @@
|
|
|
1
|
-
import * as ts from 'typescript';
|
|
2
|
-
import type { TypeOrValueSpecifier } from './TypeOrValueSpecifier';
|
|
3
|
-
export interface ReadonlynessOptions {
|
|
4
|
-
readonly treatMethodsAsReadonly?: boolean;
|
|
5
|
-
readonly allow?: TypeOrValueSpecifier[];
|
|
6
|
-
}
|
|
7
|
-
export declare const readonlynessOptionsSchema: {
|
|
8
|
-
type: string;
|
|
9
|
-
additionalProperties: boolean;
|
|
10
|
-
properties: {
|
|
11
|
-
treatMethodsAsReadonly: {
|
|
12
|
-
type: string;
|
|
13
|
-
};
|
|
14
|
-
allow: {
|
|
15
|
-
type: string;
|
|
16
|
-
items: {
|
|
17
|
-
oneOf: ({
|
|
18
|
-
type: string;
|
|
19
|
-
additionalProperties?: undefined;
|
|
20
|
-
properties?: undefined;
|
|
21
|
-
required?: undefined;
|
|
22
|
-
} | {
|
|
23
|
-
type: string;
|
|
24
|
-
additionalProperties: boolean;
|
|
25
|
-
properties: {
|
|
26
|
-
from: {
|
|
27
|
-
type: string;
|
|
28
|
-
const: string;
|
|
29
|
-
};
|
|
30
|
-
name: {
|
|
31
|
-
oneOf: ({
|
|
32
|
-
type: string;
|
|
33
|
-
minItems?: undefined;
|
|
34
|
-
uniqueItems?: undefined;
|
|
35
|
-
items?: undefined;
|
|
36
|
-
} | {
|
|
37
|
-
type: string;
|
|
38
|
-
minItems: number;
|
|
39
|
-
uniqueItems: boolean;
|
|
40
|
-
items: {
|
|
41
|
-
type: string;
|
|
42
|
-
};
|
|
43
|
-
})[];
|
|
44
|
-
};
|
|
45
|
-
path: {
|
|
46
|
-
type: string;
|
|
47
|
-
};
|
|
48
|
-
package?: undefined;
|
|
49
|
-
};
|
|
50
|
-
required: string[];
|
|
51
|
-
} | {
|
|
52
|
-
type: string;
|
|
53
|
-
additionalProperties: boolean;
|
|
54
|
-
properties: {
|
|
55
|
-
from: {
|
|
56
|
-
type: string;
|
|
57
|
-
const: string;
|
|
58
|
-
};
|
|
59
|
-
name: {
|
|
60
|
-
oneOf: ({
|
|
61
|
-
type: string;
|
|
62
|
-
minItems?: undefined;
|
|
63
|
-
uniqueItems?: undefined;
|
|
64
|
-
items?: undefined;
|
|
65
|
-
} | {
|
|
66
|
-
type: string;
|
|
67
|
-
minItems: number;
|
|
68
|
-
uniqueItems: boolean;
|
|
69
|
-
items: {
|
|
70
|
-
type: string;
|
|
71
|
-
};
|
|
72
|
-
})[];
|
|
73
|
-
};
|
|
74
|
-
path?: undefined;
|
|
75
|
-
package?: undefined;
|
|
76
|
-
};
|
|
77
|
-
required: string[];
|
|
78
|
-
} | {
|
|
79
|
-
type: string;
|
|
80
|
-
additionalProperties: boolean;
|
|
81
|
-
properties: {
|
|
82
|
-
from: {
|
|
83
|
-
type: string;
|
|
84
|
-
const: string;
|
|
85
|
-
};
|
|
86
|
-
name: {
|
|
87
|
-
oneOf: ({
|
|
88
|
-
type: string;
|
|
89
|
-
minItems?: undefined;
|
|
90
|
-
uniqueItems?: undefined;
|
|
91
|
-
items?: undefined;
|
|
92
|
-
} | {
|
|
93
|
-
type: string;
|
|
94
|
-
minItems: number;
|
|
95
|
-
uniqueItems: boolean;
|
|
96
|
-
items: {
|
|
97
|
-
type: string;
|
|
98
|
-
};
|
|
99
|
-
})[];
|
|
100
|
-
};
|
|
101
|
-
package: {
|
|
102
|
-
type: string;
|
|
103
|
-
};
|
|
104
|
-
path?: undefined;
|
|
105
|
-
};
|
|
106
|
-
required: string[];
|
|
107
|
-
})[];
|
|
108
|
-
};
|
|
109
|
-
};
|
|
110
|
-
};
|
|
111
|
-
};
|
|
112
|
-
export declare const readonlynessOptionsDefaults: ReadonlynessOptions;
|
|
113
|
-
/**
|
|
114
|
-
* Checks if the given type is readonly
|
|
115
|
-
*/
|
|
116
|
-
declare function isTypeReadonly(program: ts.Program, type: ts.Type, options?: ReadonlynessOptions): boolean;
|
|
117
|
-
export { isTypeReadonly };
|
|
118
|
-
//# sourceMappingURL=isTypeReadonly.d.ts.map
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import * as ts from 'typescript';
|
|
2
|
-
/**
|
|
3
|
-
* Gets all of the type flags in a type, iterating through unions automatically
|
|
4
|
-
*/
|
|
5
|
-
export declare function getTypeFlags(type: ts.Type): ts.TypeFlags;
|
|
6
|
-
/**
|
|
7
|
-
* Checks if the given type is (or accepts) the given flags
|
|
8
|
-
* @param isReceiver true if the type is a receiving type (i.e. the type of a called function's parameter)
|
|
9
|
-
*/
|
|
10
|
-
export declare function isTypeFlagSet(type: ts.Type, flagsToCheck: ts.TypeFlags, isReceiver?: boolean): boolean;
|
|
11
|
-
//# sourceMappingURL=typeFlagUtils.d.ts.map
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|