oxlint-plugin-effect 0.8.0 → 0.8.2
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 +4 -0
- package/dist/plugin.d.ts +1 -1
- package/dist/presets/recommended.d.ts +6 -2
- package/dist/presets/recommended.js +7 -3
- package/dist/rules/_anti-slop-dictionary-types.js +1 -6
- package/dist/rules/index.d.ts +1 -1
- package/dist/rules/index.js +1 -1
- package/dist/rules/prefer-effect-fn.js +41 -13
- package/dist/vendor/effect-oxlint/AST.d.ts +1 -1
- package/dist/vendor/effect-oxlint/AST.js +1 -1
- package/dist/vendor/effect-oxlint/Comment.d.ts +1 -1
- package/dist/vendor/effect-oxlint/Comment.js +1 -1
- package/dist/vendor/effect-oxlint/Diagnostic.d.ts +1 -1
- package/dist/vendor/effect-oxlint/Diagnostic.js +1 -1
- package/dist/vendor/effect-oxlint/Plugin.d.ts +1 -1
- package/dist/vendor/effect-oxlint/Plugin.js +1 -1
- package/dist/vendor/effect-oxlint/Rule.d.ts +1 -1
- package/dist/vendor/effect-oxlint/Rule.js +1 -1
- package/dist/vendor/effect-oxlint/RuleContext.d.ts +1 -7
- package/dist/vendor/effect-oxlint/Scope.d.ts +1 -1
- package/dist/vendor/effect-oxlint/Scope.js +1 -1
- package/dist/vendor/effect-oxlint/SourceCode.d.ts +1 -1
- package/dist/vendor/effect-oxlint/SourceCode.js +1 -1
- package/dist/vendor/effect-oxlint/Testing.d.ts +1 -1
- package/dist/vendor/effect-oxlint/Testing.js +1 -1
- package/dist/vendor/effect-oxlint/Token.d.ts +1 -1
- package/dist/vendor/effect-oxlint/Token.js +1 -1
- package/dist/vendor/effect-oxlint/Visitor.d.ts +1 -1
- package/dist/vendor/effect-oxlint/Visitor.js +1 -1
- package/package.json +3 -2
- package/dist/rules/_anti-slop-dictionary-types.d.ts +0 -24
package/README.md
CHANGED
|
@@ -149,8 +149,12 @@ export const noThing = Rule.define({
|
|
|
149
149
|
bun install
|
|
150
150
|
bun run gate
|
|
151
151
|
bun run codegen
|
|
152
|
+
bun run add-rule -- no-example --dry-run
|
|
152
153
|
```
|
|
153
154
|
|
|
155
|
+
`bun run codegen` owns both the rule export barrel and the recommended preset.
|
|
156
|
+
`bun run gate` fails when either generated file is stale.
|
|
157
|
+
|
|
154
158
|
## License
|
|
155
159
|
|
|
156
160
|
MIT
|
package/dist/plugin.d.ts
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
//#region src/presets/recommended.d.ts
|
|
2
|
-
/**
|
|
2
|
+
/**
|
|
3
|
+
* Strict, non-type-aware policy for Effect-native application code.
|
|
4
|
+
*
|
|
5
|
+
* AUTO-GENERATED by scripts/codegen.ts — do not edit manually.
|
|
6
|
+
*/
|
|
3
7
|
declare const recommended: {
|
|
4
8
|
readonly "effect/noAs": "error";
|
|
5
9
|
readonly "effect/noAsyncFunction": "error";
|
|
@@ -17,7 +21,6 @@ declare const recommended: {
|
|
|
17
21
|
readonly "effect/noObjectParameters": "error";
|
|
18
22
|
readonly "effect/noRuntimeTypeof": "error";
|
|
19
23
|
readonly "effect/noShapeInSymbolNames": "error";
|
|
20
|
-
readonly "effect/preferEffectFn": "error";
|
|
21
24
|
readonly "effect/noTernary": "error";
|
|
22
25
|
readonly "effect/noTestLifecycleHooks": "error";
|
|
23
26
|
readonly "effect/noThrowStatement": "error";
|
|
@@ -26,6 +29,7 @@ declare const recommended: {
|
|
|
26
29
|
readonly "effect/noUnknownTypeAliases": "error";
|
|
27
30
|
readonly "effect/noUnsafeDictionaryType": "error";
|
|
28
31
|
readonly "effect/noWidenThenAssert": "error";
|
|
32
|
+
readonly "effect/preferEffectFn": "error";
|
|
29
33
|
};
|
|
30
34
|
//#endregion
|
|
31
35
|
export { recommended };
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
//#region src/presets/recommended.ts
|
|
2
|
-
/**
|
|
2
|
+
/**
|
|
3
|
+
* Strict, non-type-aware policy for Effect-native application code.
|
|
4
|
+
*
|
|
5
|
+
* AUTO-GENERATED by scripts/codegen.ts — do not edit manually.
|
|
6
|
+
*/
|
|
3
7
|
const recommended = {
|
|
4
8
|
"effect/noAs": "error",
|
|
5
9
|
"effect/noAsyncFunction": "error",
|
|
@@ -17,7 +21,6 @@ const recommended = {
|
|
|
17
21
|
"effect/noObjectParameters": "error",
|
|
18
22
|
"effect/noRuntimeTypeof": "error",
|
|
19
23
|
"effect/noShapeInSymbolNames": "error",
|
|
20
|
-
"effect/preferEffectFn": "error",
|
|
21
24
|
"effect/noTernary": "error",
|
|
22
25
|
"effect/noTestLifecycleHooks": "error",
|
|
23
26
|
"effect/noThrowStatement": "error",
|
|
@@ -25,7 +28,8 @@ const recommended = {
|
|
|
25
28
|
"effect/noUnknownParameters": "error",
|
|
26
29
|
"effect/noUnknownTypeAliases": "error",
|
|
27
30
|
"effect/noUnsafeDictionaryType": "error",
|
|
28
|
-
"effect/noWidenThenAssert": "error"
|
|
31
|
+
"effect/noWidenThenAssert": "error",
|
|
32
|
+
"effect/preferEffectFn": "error"
|
|
29
33
|
};
|
|
30
34
|
//#endregion
|
|
31
35
|
export { recommended };
|
|
@@ -233,11 +233,6 @@ function classifyAliasBroadTarget(type, environment, substitutions, resolvingAli
|
|
|
233
233
|
nextResolving.add(name);
|
|
234
234
|
return classifyAliasBroadTarget(alias.typeAnnotation, environment, nextSubstitutions, nextResolving);
|
|
235
235
|
}
|
|
236
|
-
function isPopulatedObjectExpression(expression) {
|
|
237
|
-
let current = expression;
|
|
238
|
-
while (current.type === "ParenthesizedExpression" || current.type === "TSAsExpression" || current.type === "TSTypeAssertion" || current.type === "TSNonNullExpression") current = current.expression;
|
|
239
|
-
return current.type === "ObjectExpression" && current.properties.length > 0;
|
|
240
|
-
}
|
|
241
236
|
function isKnownEvidenceExpression(expression) {
|
|
242
237
|
let current = expression;
|
|
243
238
|
while (current.type === "ParenthesizedExpression" || current.type === "TSAsExpression" || current.type === "TSTypeAssertion" || current.type === "TSNonNullExpression" || current.type === "TSSatisfiesExpression") current = current.expression;
|
|
@@ -245,4 +240,4 @@ function isKnownEvidenceExpression(expression) {
|
|
|
245
240
|
return current.type === "ArrayExpression" || current.type === "ArrowFunctionExpression" || current.type === "ClassExpression" || current.type === "FunctionExpression" || current.type === "NewExpression" || current.type === "Literal" || current.type === "TemplateLiteral" || current.type === "UnaryExpression";
|
|
246
241
|
}
|
|
247
242
|
//#endregion
|
|
248
|
-
export { classifyUnsafeDictionary, classifyUnsafeDictionaryValue, classifyWideningTarget, createTypeEnvironment, isKnownEvidenceExpression
|
|
243
|
+
export { classifyUnsafeDictionary, classifyUnsafeDictionaryValue, classifyWideningTarget, createTypeEnvironment, isKnownEvidenceExpression };
|
package/dist/rules/index.d.ts
CHANGED
|
@@ -29,4 +29,4 @@ declare namespace index_d_exports {
|
|
|
29
29
|
export { noAs, noAsyncFunction, noChainedTypeAssertions, noConditionalEmptyObjectSpread, noDynamicImports, noEffectBind, noEffectDo, noGlobals, noKnownValueWidening, noNewError, noNewPromise, noNodeBuiltinImport, noNullish, noObjectParameters, noRuntimeTypeof, noShapeInSymbolNames, noTernary, noTestLifecycleHooks, noThrowStatement, noTryCatch, noUnknownParameters, noUnknownTypeAliases, noUnsafeDictionaryType, noWidenThenAssert, preferEffectFn };
|
|
30
30
|
}
|
|
31
31
|
//#endregion
|
|
32
|
-
export { index_d_exports
|
|
32
|
+
export { index_d_exports };
|
package/dist/rules/index.js
CHANGED
|
@@ -53,4 +53,4 @@ var rules_exports = /* @__PURE__ */ __exportAll({
|
|
|
53
53
|
preferEffectFn: () => preferEffectFn
|
|
54
54
|
});
|
|
55
55
|
//#endregion
|
|
56
|
-
export {
|
|
56
|
+
export { rules_exports };
|
|
@@ -1,14 +1,29 @@
|
|
|
1
1
|
import { make } from "../vendor/effect-oxlint/Diagnostic.js";
|
|
2
2
|
import { RuleContext } from "../vendor/effect-oxlint/RuleContext.js";
|
|
3
3
|
import { define, meta } from "../vendor/effect-oxlint/Rule.js";
|
|
4
|
+
import { findVariableUp } from "../vendor/effect-oxlint/Scope.js";
|
|
4
5
|
import "../vendor/effect-oxlint/index.js";
|
|
6
|
+
import * as Option from "effect/Option";
|
|
5
7
|
import * as Effect from "effect/Effect";
|
|
6
8
|
//#region src/rules/prefer-effect-fn.ts
|
|
7
|
-
const isStaticMember = (node,
|
|
8
|
-
const isEffectGenCall = (node) => node.type === "CallExpression" && node.callee.type !== "Super" && isStaticMember(node.callee,
|
|
9
|
-
const isEffectWithSpanCall = (node) => node.type === "CallExpression" && node.callee.type !== "Super" && isStaticMember(node.callee,
|
|
10
|
-
const spansEffectGenDirectly = (node) => node.callee.type !== "Super" && node.callee.type === "MemberExpression" && !node.callee.computed && node.callee.property.type === "Identifier" && node.callee.property.name === "withSpan" && isEffectGenCall(node.callee.object);
|
|
11
|
-
const
|
|
9
|
+
const isStaticMember = (node, objects, property) => node.type === "MemberExpression" && !node.computed && node.object.type === "Identifier" && objects.has(node.object.name) && node.property.type === "Identifier" && node.property.name === property;
|
|
10
|
+
const isEffectGenCall = (node, effectNamespaces) => node.type === "CallExpression" && node.callee.type !== "Super" && isStaticMember(node.callee, effectNamespaces, "gen");
|
|
11
|
+
const isEffectWithSpanCall = (node, effectNamespaces) => node.type === "CallExpression" && node.callee.type !== "Super" && isStaticMember(node.callee, effectNamespaces, "withSpan");
|
|
12
|
+
const spansEffectGenDirectly = (node, effectNamespaces) => node.callee.type !== "Super" && node.callee.type === "MemberExpression" && !node.callee.computed && node.callee.property.type === "Identifier" && node.callee.property.name === "withSpan" && isEffectGenCall(node.callee.object, effectNamespaces);
|
|
13
|
+
const pipesWithSpanFromEffectGen = (node, effectNamespaces) => node.callee.type !== "Super" && node.callee.type === "MemberExpression" && !node.callee.computed && node.callee.property.type === "Identifier" && node.callee.property.name === "pipe" && isEffectGenCall(node.callee.object, effectNamespaces) && node.arguments.some((argument) => isEffectWithSpanCall(argument, effectNamespaces));
|
|
14
|
+
const effectNamespaceFromImport = (node) => {
|
|
15
|
+
const source = node.source.value;
|
|
16
|
+
if (source !== "effect" && source !== "effect/Effect") return [];
|
|
17
|
+
const namespaces = [];
|
|
18
|
+
for (const specifier of node.specifiers) {
|
|
19
|
+
if (specifier.type === "ImportNamespaceSpecifier" && source === "effect/Effect") {
|
|
20
|
+
namespaces.push(specifier.local.name);
|
|
21
|
+
continue;
|
|
22
|
+
}
|
|
23
|
+
if (specifier.type === "ImportSpecifier" && source === "effect" && specifier.imported.type === "Identifier" && specifier.imported.name === "Effect") namespaces.push(specifier.local.name);
|
|
24
|
+
}
|
|
25
|
+
return namespaces;
|
|
26
|
+
};
|
|
12
27
|
const preferEffectFn = define({
|
|
13
28
|
name: "prefer-effect-fn",
|
|
14
29
|
meta: meta({
|
|
@@ -17,14 +32,27 @@ const preferEffectFn = define({
|
|
|
17
32
|
}),
|
|
18
33
|
create: function* () {
|
|
19
34
|
const ctx = yield* RuleContext;
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
35
|
+
const effectNamespaces = /* @__PURE__ */ new Set();
|
|
36
|
+
const visibleEffectNamespaces = (node) => new Set([...effectNamespaces].filter((namespace) => Option.match(findVariableUp(ctx.sourceCode.getScope(node), namespace), {
|
|
37
|
+
onNone: () => true,
|
|
38
|
+
onSome: (variable) => variable.defs.some((definition) => definition.type === "ImportBinding")
|
|
39
|
+
})));
|
|
40
|
+
return {
|
|
41
|
+
ImportDeclaration: (node) => {
|
|
42
|
+
if (node.type !== "ImportDeclaration") return Effect.void;
|
|
43
|
+
for (const namespace of effectNamespaceFromImport(node)) effectNamespaces.add(namespace);
|
|
44
|
+
return Effect.void;
|
|
45
|
+
},
|
|
46
|
+
CallExpression: (node) => {
|
|
47
|
+
if (node.type !== "CallExpression") return Effect.void;
|
|
48
|
+
const namespaces = visibleEffectNamespaces(node);
|
|
49
|
+
if (!spansEffectGenDirectly(node, namespaces) && !pipesWithSpanFromEffectGen(node, namespaces)) return Effect.void;
|
|
50
|
+
return ctx.report(make({
|
|
51
|
+
node,
|
|
52
|
+
message: "Avoid a span on Effect.gen. Define the named operation with Effect.fn."
|
|
53
|
+
}));
|
|
54
|
+
}
|
|
55
|
+
};
|
|
28
56
|
}
|
|
29
57
|
});
|
|
30
58
|
//#endregion
|
|
@@ -196,4 +196,4 @@ declare const hasAncestor: {
|
|
|
196
196
|
}, type: string): boolean;
|
|
197
197
|
};
|
|
198
198
|
//#endregion
|
|
199
|
-
export { AST_d_exports
|
|
199
|
+
export { AST_d_exports };
|
|
@@ -211,4 +211,4 @@ const findAncestor = dual(2, (node, type) => {
|
|
|
211
211
|
*/
|
|
212
212
|
const hasAncestor = dual(2, (node, type) => Option.isSome(findAncestor(node, type)));
|
|
213
213
|
//#endregion
|
|
214
|
-
export { AST_exports, calleeName,
|
|
214
|
+
export { AST_exports, calleeName, importSource, matchImport, matchMember, memberNames, narrow };
|
|
@@ -52,4 +52,4 @@ declare const isDisableDirective: (comment: Comment) => boolean;
|
|
|
52
52
|
*/
|
|
53
53
|
declare const isEnableDirective: (comment: Comment) => boolean;
|
|
54
54
|
//#endregion
|
|
55
|
-
export { Comment_d_exports
|
|
55
|
+
export { Comment_d_exports };
|
|
@@ -64,4 +64,4 @@ const isEnableDirective = (comment) => {
|
|
|
64
64
|
return Str.startsWith("eslint-enable")(trimmed) || Str.startsWith("oxlint-enable")(trimmed);
|
|
65
65
|
};
|
|
66
66
|
//#endregion
|
|
67
|
-
export { Comment_exports
|
|
67
|
+
export { Comment_exports };
|
|
@@ -83,4 +83,4 @@ declare const removeFix: (nodeOrToken: Ranged) => FixFn;
|
|
|
83
83
|
*/
|
|
84
84
|
declare const composeFixes: (...fixes: ReadonlyArray<FixFn>) => FixFn;
|
|
85
85
|
//#endregion
|
|
86
|
-
export {
|
|
86
|
+
export { Diagnostic_d_exports };
|
|
@@ -112,4 +112,4 @@ const extractFixes = (result) => {
|
|
|
112
112
|
*/
|
|
113
113
|
const composeFixes = (...fixes) => (fixer) => Arr.flatMap(fixes, (fn) => Array.from(extractFixes(fn(fixer))));
|
|
114
114
|
//#endregion
|
|
115
|
-
export { Diagnostic_exports,
|
|
115
|
+
export { Diagnostic_exports, fromId, make, replaceText, withFix };
|
|
@@ -215,4 +215,4 @@ declare const banMultiple: (config: {
|
|
|
215
215
|
readonly specs: ReadonlyArray<BanSpec>;
|
|
216
216
|
}) => CreateRule;
|
|
217
217
|
//#endregion
|
|
218
|
-
export {
|
|
218
|
+
export { Rule_d_exports };
|
|
@@ -22,12 +22,6 @@ declare const RuleContext_base: Context$1.ServiceClass<RuleContext, "oxlint-plug
|
|
|
22
22
|
* @since 0.1.0
|
|
23
23
|
*/
|
|
24
24
|
declare class RuleContext extends RuleContext_base {}
|
|
25
|
-
/**
|
|
26
|
-
* Build a `RuleContext` value from the raw oxlint `Context`.
|
|
27
|
-
*
|
|
28
|
-
* @internal
|
|
29
|
-
*/
|
|
30
|
-
declare const fromOxlintContext: (ctx: Context) => RuleContext["Service"];
|
|
31
25
|
/**
|
|
32
26
|
* Effectful access to the rule ID.
|
|
33
27
|
*
|
|
@@ -74,4 +68,4 @@ declare const ast: Effect.Effect<ESTree.Program, never, RuleContext>;
|
|
|
74
68
|
*/
|
|
75
69
|
declare const report: (diagnostic: Diagnostic) => Effect.Effect<void, never, RuleContext>;
|
|
76
70
|
//#endregion
|
|
77
|
-
export { RuleContext, ast, cwd, filename,
|
|
71
|
+
export { RuleContext, ast, cwd, filename, id, report, sourceCode, text };
|
|
@@ -97,4 +97,4 @@ declare const throughReferences: (scope: Scope) => ReadonlyArray<Reference>;
|
|
|
97
97
|
*/
|
|
98
98
|
declare const isStrict: (scope: Scope) => boolean;
|
|
99
99
|
//#endregion
|
|
100
|
-
export { Scope_d_exports
|
|
100
|
+
export { Scope_d_exports };
|
|
@@ -107,4 +107,4 @@ const throughReferences = (scope) => scope.through;
|
|
|
107
107
|
*/
|
|
108
108
|
const isStrict = (scope) => scope.isStrict;
|
|
109
109
|
//#endregion
|
|
110
|
-
export { Scope_exports,
|
|
110
|
+
export { Scope_exports, findVariableUp };
|
|
@@ -177,4 +177,4 @@ declare const isSpaceBetween: (first: ESTree.Node | Token | Comment, second: EST
|
|
|
177
177
|
*/
|
|
178
178
|
declare const getLines: () => Effect.Effect<ReadonlyArray<string>, never, RuleContext>;
|
|
179
179
|
//#endregion
|
|
180
|
-
export { SourceCode_d_exports
|
|
180
|
+
export { SourceCode_d_exports };
|
|
@@ -200,4 +200,4 @@ const isSpaceBetween = (first, second) => withSourceCode((sc) => sc.isSpaceBetwe
|
|
|
200
200
|
*/
|
|
201
201
|
const getLines = () => withSourceCode((sc) => sc.getLines());
|
|
202
202
|
//#endregion
|
|
203
|
-
export { SourceCode_exports,
|
|
203
|
+
export { SourceCode_exports, isGlobalReference };
|
|
@@ -507,4 +507,4 @@ declare const expectDiagnostics: (result: ReadonlyArray<ReportedDiagnostic>, exp
|
|
|
507
507
|
*/
|
|
508
508
|
declare const expectNoDiagnostics: (result: ReadonlyArray<ReportedDiagnostic>) => void;
|
|
509
509
|
//#endregion
|
|
510
|
-
export {
|
|
510
|
+
export { Testing_d_exports };
|
|
@@ -963,4 +963,4 @@ const expectNoDiagnostics = (result) => Arr.match(result, {
|
|
|
963
963
|
}
|
|
964
964
|
});
|
|
965
965
|
//#endregion
|
|
966
|
-
export { Testing_exports
|
|
966
|
+
export { Testing_exports };
|
|
@@ -95,4 +95,4 @@ declare const value: (token: Token) => string;
|
|
|
95
95
|
*/
|
|
96
96
|
declare const type: (token: Token) => string;
|
|
97
97
|
//#endregion
|
|
98
|
-
export { Token_d_exports
|
|
98
|
+
export { Token_d_exports };
|
|
@@ -100,4 +100,4 @@ const value = (token) => token.value;
|
|
|
100
100
|
*/
|
|
101
101
|
const type = (token) => token.type;
|
|
102
102
|
//#endregion
|
|
103
|
-
export { Token_exports
|
|
103
|
+
export { Token_exports };
|
|
@@ -163,4 +163,4 @@ declare const accumulate: <A>(nodeType: string, extract: (node: ESTree.Node) =>
|
|
|
163
163
|
*/
|
|
164
164
|
declare const toOxlintVisitor: (effectVisitor: EffectVisitor, runHandler: (effect: Effect.Effect<void, never, RuleContext>) => void) => Visitor;
|
|
165
165
|
//#endregion
|
|
166
|
-
export {
|
|
166
|
+
export { EffectVisitor, Visitor_d_exports };
|
|
@@ -135,4 +135,4 @@ const accumulate = (nodeType, extract, analyze) => Effect.gen(function* () {
|
|
|
135
135
|
*/
|
|
136
136
|
const toOxlintVisitor = (effectVisitor, runHandler) => R.map(effectVisitor, (handler) => (node) => runHandler(handler(node)));
|
|
137
137
|
//#endregion
|
|
138
|
-
export { Visitor_exports,
|
|
138
|
+
export { Visitor_exports, merge, toOxlintVisitor };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "oxlint-plugin-effect",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.2",
|
|
4
4
|
"description": "oxlint plugin with Effect-specific lint rules",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -49,8 +49,9 @@
|
|
|
49
49
|
"fmt": "oxfmt",
|
|
50
50
|
"fmt:check": "oxfmt --check",
|
|
51
51
|
"test": "bun run build && bun test",
|
|
52
|
-
"gate": "concurrently -n type,style,test -c blue,yellow,green \"bun run typecheck\" \"bun run lint\" \"bun run test\"",
|
|
52
|
+
"gate": "concurrently -n type,style,generated,test -c blue,yellow,magenta,green \"bun run typecheck\" \"bun run lint\" \"bun run codegen:check\" \"bun run test\"",
|
|
53
53
|
"codegen": "bun run scripts/codegen.ts",
|
|
54
|
+
"codegen:check": "bun run scripts/codegen.ts --check",
|
|
54
55
|
"add-rule": "bun run scripts/add-rule.ts",
|
|
55
56
|
"version": "changeset version",
|
|
56
57
|
"release": "bun run build && changeset publish",
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { ESTree } from "@oxlint/plugins";
|
|
2
|
-
|
|
3
|
-
//#region src/rules/_anti-slop-dictionary-types.d.ts
|
|
4
|
-
type UnsafeDictionary = {
|
|
5
|
-
readonly kind: "unsafe-dictionary";
|
|
6
|
-
readonly unsafeValue: "any" | "empty-object" | "object" | "union" | "unknown";
|
|
7
|
-
};
|
|
8
|
-
type WideningTargetKind = "anonymous object" | "generic container" | "object" | "open dictionary" | "unknown";
|
|
9
|
-
type WideningTarget = {
|
|
10
|
-
readonly kind: WideningTargetKind;
|
|
11
|
-
};
|
|
12
|
-
type TypeEnvironment = {
|
|
13
|
-
readonly aliases: ReadonlyMap<string, ESTree.TSTypeAliasDeclaration>;
|
|
14
|
-
readonly interfaces: ReadonlyMap<string, readonly ESTree.TSInterfaceDeclaration[]>;
|
|
15
|
-
readonly shadowedBuiltIns: ReadonlySet<string>;
|
|
16
|
-
};
|
|
17
|
-
declare function createTypeEnvironment(program: ESTree.Program): TypeEnvironment;
|
|
18
|
-
declare function classifyUnsafeDictionaryValue(valueType: ESTree.TSType, environment: TypeEnvironment): UnsafeDictionary | null;
|
|
19
|
-
declare function classifyUnsafeDictionary(type: ESTree.TSType, environment: TypeEnvironment): UnsafeDictionary | null;
|
|
20
|
-
declare function classifyWideningTarget(type: ESTree.TSType, environment: TypeEnvironment): WideningTarget | null;
|
|
21
|
-
declare function isPopulatedObjectExpression(expression: ESTree.Expression): boolean;
|
|
22
|
-
declare function isKnownEvidenceExpression(expression: ESTree.Expression): boolean;
|
|
23
|
-
//#endregion
|
|
24
|
-
export { TypeEnvironment, UnsafeDictionary, WideningTarget, WideningTargetKind, classifyUnsafeDictionary, classifyUnsafeDictionaryValue, classifyWideningTarget, createTypeEnvironment, isKnownEvidenceExpression, isPopulatedObjectExpression };
|