@react-analyzer/core 0.0.3-next.3 → 0.0.3-next.4

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.
Files changed (3) hide show
  1. package/dist/index.d.ts +96 -91
  2. package/dist/index.js +108 -114
  3. package/package.json +6 -6
package/dist/index.d.ts CHANGED
@@ -1,61 +1,64 @@
1
- import { AST, Context } from 'tsl';
2
- import { unit } from '@react-analyzer/eff';
3
- import ts from 'typescript';
4
- export { isFalseLiteralType, isTrueLiteralType } from 'ts-api-utils';
1
+ import { isFalseLiteralType, isTrueLiteralType } from "ts-api-utils";
2
+ import ts from "typescript";
3
+ import { unit } from "@react-analyzer/eff";
4
+ import { AST, Context } from "tsl";
5
5
 
6
+ //#region src/semantic/semantic-entry.d.ts
6
7
  interface SemanticEntry {
7
- node: AST.AnyNode;
8
+ node: AST.AnyNode;
8
9
  }
9
-
10
+ //#endregion
11
+ //#region src/semantic/semantic-node.d.ts
10
12
  interface SemanticNode {
11
- id: unit | AST.Identifier | AST.Identifier[];
12
- key: string;
13
- kind: string;
14
- name: unit | string;
15
- node: AST.AnyNode;
16
- flag: bigint;
17
- hint: bigint;
13
+ id: unit | AST.Identifier | AST.Identifier[];
14
+ key: string;
15
+ kind: string;
16
+ name: unit | string;
17
+ node: AST.AnyNode;
18
+ flag: bigint;
19
+ hint: bigint;
18
20
  }
19
-
21
+ //#endregion
22
+ //#region src/type/type-is.d.ts
20
23
  declare const isAnyType: (type: ts.Type) => boolean;
21
24
  declare const isBigIntType: (type: ts.Type) => boolean;
22
25
  declare const isBooleanType: (type: ts.Type) => boolean;
23
26
  declare const isEnumType: (type: ts.Type) => boolean;
24
27
  declare const isFalsyBigIntType: (type: ts.Type) => type is ts.LiteralType & {
25
- freshType: ts.FreshableType;
26
- regularType: ts.FreshableType;
27
- flags: ts.TypeFlags;
28
- symbol: ts.Symbol;
29
- pattern?: ts.DestructuringPattern;
30
- aliasSymbol?: ts.Symbol;
31
- aliasTypeArguments?: readonly ts.Type[];
32
- getFlags: () => ts.TypeFlags;
33
- getSymbol: () => ts.Symbol | undefined;
34
- getProperties: () => ts.Symbol[];
35
- getProperty: (propertyName: string) => ts.Symbol | undefined;
36
- getApparentProperties: () => ts.Symbol[];
37
- getCallSignatures: () => readonly ts.Signature[];
38
- getConstructSignatures: () => readonly ts.Signature[];
39
- getStringIndexType: () => ts.Type | undefined;
40
- getNumberIndexType: () => ts.Type | undefined;
41
- getBaseTypes: () => ts.BaseType[] | undefined;
42
- getNonNullableType: () => ts.Type;
43
- getConstraint: () => ts.Type | undefined;
44
- getDefault: () => ts.Type | undefined;
45
- isUnion: () => this is ts.UnionType;
46
- isIntersection: () => this is ts.IntersectionType;
47
- isUnionOrIntersection: () => this is ts.UnionOrIntersectionType;
48
- isLiteral: () => this is ts.LiteralType;
49
- isStringLiteral: () => this is ts.StringLiteralType;
50
- isNumberLiteral: () => this is ts.NumberLiteralType;
51
- isTypeParameter: () => this is ts.TypeParameter;
52
- isClassOrInterface: () => this is ts.InterfaceType;
53
- isClass: () => this is ts.InterfaceType;
54
- isIndexType: () => this is ts.IndexType;
55
- value: {
56
- negative: boolean;
57
- base10Value: "0";
58
- };
28
+ freshType: ts.FreshableType;
29
+ regularType: ts.FreshableType;
30
+ flags: ts.TypeFlags;
31
+ symbol: ts.Symbol;
32
+ pattern?: ts.DestructuringPattern;
33
+ aliasSymbol?: ts.Symbol;
34
+ aliasTypeArguments?: readonly ts.Type[];
35
+ getFlags: () => ts.TypeFlags;
36
+ getSymbol: () => ts.Symbol | undefined;
37
+ getProperties: () => ts.Symbol[];
38
+ getProperty: (propertyName: string) => ts.Symbol | undefined;
39
+ getApparentProperties: () => ts.Symbol[];
40
+ getCallSignatures: () => readonly ts.Signature[];
41
+ getConstructSignatures: () => readonly ts.Signature[];
42
+ getStringIndexType: () => ts.Type | undefined;
43
+ getNumberIndexType: () => ts.Type | undefined;
44
+ getBaseTypes: () => ts.BaseType[] | undefined;
45
+ getNonNullableType: () => ts.Type;
46
+ getConstraint: () => ts.Type | undefined;
47
+ getDefault: () => ts.Type | undefined;
48
+ isUnion: () => this is ts.UnionType;
49
+ isIntersection: () => this is ts.IntersectionType;
50
+ isUnionOrIntersection: () => this is ts.UnionOrIntersectionType;
51
+ isLiteral: () => this is ts.LiteralType;
52
+ isStringLiteral: () => this is ts.StringLiteralType;
53
+ isNumberLiteral: () => this is ts.NumberLiteralType;
54
+ isTypeParameter: () => this is ts.TypeParameter;
55
+ isClassOrInterface: () => this is ts.InterfaceType;
56
+ isClass: () => this is ts.InterfaceType;
57
+ isIndexType: () => this is ts.IndexType;
58
+ value: {
59
+ negative: boolean;
60
+ base10Value: "0";
61
+ };
59
62
  };
60
63
  declare const isFalsyNumberType: (type: ts.Type) => boolean;
61
64
  declare const isFalsyStringType: (type: ts.Type) => boolean;
@@ -65,42 +68,43 @@ declare const isNumberType: (type: ts.Type) => boolean;
65
68
  declare const isObjectType: (type: ts.Type) => boolean;
66
69
  declare const isStringType: (type: ts.Type) => boolean;
67
70
  declare const isTruthyBigIntType: (type: ts.Type) => type is ts.LiteralType & {
68
- freshType: ts.FreshableType;
69
- regularType: ts.FreshableType;
70
- flags: ts.TypeFlags;
71
- symbol: ts.Symbol;
72
- pattern?: ts.DestructuringPattern;
73
- aliasSymbol?: ts.Symbol;
74
- aliasTypeArguments?: readonly ts.Type[];
75
- getFlags: () => ts.TypeFlags;
76
- getSymbol: () => ts.Symbol | undefined;
77
- getProperties: () => ts.Symbol[];
78
- getProperty: (propertyName: string) => ts.Symbol | undefined;
79
- getApparentProperties: () => ts.Symbol[];
80
- getCallSignatures: () => readonly ts.Signature[];
81
- getConstructSignatures: () => readonly ts.Signature[];
82
- getStringIndexType: () => ts.Type | undefined;
83
- getNumberIndexType: () => ts.Type | undefined;
84
- getBaseTypes: () => ts.BaseType[] | undefined;
85
- getNonNullableType: () => ts.Type;
86
- getConstraint: () => ts.Type | undefined;
87
- getDefault: () => ts.Type | undefined;
88
- isUnion: () => this is ts.UnionType;
89
- isIntersection: () => this is ts.IntersectionType;
90
- isUnionOrIntersection: () => this is ts.UnionOrIntersectionType;
91
- isLiteral: () => this is ts.LiteralType;
92
- isStringLiteral: () => this is ts.StringLiteralType;
93
- isNumberLiteral: () => this is ts.NumberLiteralType;
94
- isTypeParameter: () => this is ts.TypeParameter;
95
- isClassOrInterface: () => this is ts.InterfaceType;
96
- isClass: () => this is ts.InterfaceType;
97
- isIndexType: () => this is ts.IndexType;
98
- value: ts.PseudoBigInt;
71
+ freshType: ts.FreshableType;
72
+ regularType: ts.FreshableType;
73
+ flags: ts.TypeFlags;
74
+ symbol: ts.Symbol;
75
+ pattern?: ts.DestructuringPattern;
76
+ aliasSymbol?: ts.Symbol;
77
+ aliasTypeArguments?: readonly ts.Type[];
78
+ getFlags: () => ts.TypeFlags;
79
+ getSymbol: () => ts.Symbol | undefined;
80
+ getProperties: () => ts.Symbol[];
81
+ getProperty: (propertyName: string) => ts.Symbol | undefined;
82
+ getApparentProperties: () => ts.Symbol[];
83
+ getCallSignatures: () => readonly ts.Signature[];
84
+ getConstructSignatures: () => readonly ts.Signature[];
85
+ getStringIndexType: () => ts.Type | undefined;
86
+ getNumberIndexType: () => ts.Type | undefined;
87
+ getBaseTypes: () => ts.BaseType[] | undefined;
88
+ getNonNullableType: () => ts.Type;
89
+ getConstraint: () => ts.Type | undefined;
90
+ getDefault: () => ts.Type | undefined;
91
+ isUnion: () => this is ts.UnionType;
92
+ isIntersection: () => this is ts.IntersectionType;
93
+ isUnionOrIntersection: () => this is ts.UnionOrIntersectionType;
94
+ isLiteral: () => this is ts.LiteralType;
95
+ isStringLiteral: () => this is ts.StringLiteralType;
96
+ isNumberLiteral: () => this is ts.NumberLiteralType;
97
+ isTypeParameter: () => this is ts.TypeParameter;
98
+ isClassOrInterface: () => this is ts.InterfaceType;
99
+ isClass: () => this is ts.InterfaceType;
100
+ isIndexType: () => this is ts.IndexType;
101
+ value: ts.PseudoBigInt;
99
102
  };
100
103
  declare const isTruthyNumberType: (type: ts.Type) => boolean;
101
104
  declare const isTruthyStringType: (type: ts.Type) => boolean;
102
105
  declare const isUnknownType: (type: ts.Type) => boolean;
103
-
106
+ //#endregion
107
+ //#region src/type/type-variant.d.ts
104
108
  type TypeVariant = "any" | "bigint" | "boolean" | "enum" | "never" | "nullish" | "number" | "object" | "string" | "unknown" | "falsy bigint" | "falsy boolean" | "falsy number" | "falsy string" | "truthy bigint" | "truthy boolean" | "truthy number" | "truthy string";
105
109
  /**
106
110
  * Ported from https://github.com/typescript-eslint/typescript-eslint/blob/eb736bbfc22554694400e6a4f97051d845d32e0b/packages/eslint-plugin/src/rules/strict-boolean-expressions.ts#L826 with some enhancements
@@ -109,19 +113,20 @@ type TypeVariant = "any" | "bigint" | "boolean" | "enum" | "never" | "nullish" |
109
113
  * @returns The variants of the types
110
114
  */
111
115
  declare function getVariantsOfTypes(types: ts.Type[]): Set<TypeVariant>;
112
-
116
+ //#endregion
117
+ //#region src/utils/is-react-api.d.ts
113
118
  declare namespace isReactAPI {
114
- type ReturnType = {
115
- (context: Context, node: unit | null | AST.AnyNode): node is AST.MemberExpression;
116
- (context: Context): (node: unit | null | AST.AnyNode) => node is AST.MemberExpression;
117
- };
119
+ type ReturnType = {
120
+ (context: Context, node: unit | null | AST.AnyNode): node is AST.MemberExpression;
121
+ (context: Context): (node: unit | null | AST.AnyNode) => node is AST.MemberExpression;
122
+ };
118
123
  }
119
124
  declare function isReactAPI(api: string): isReactAPI.ReturnType;
120
125
  declare namespace isReactAPICall {
121
- type ReturnType = {
122
- (context: Context, node: unit | null | AST.AnyNode): node is AST.CallExpression;
123
- (context: Context): (node: unit | null | AST.AnyNode) => node is AST.CallExpression;
124
- };
126
+ type ReturnType = {
127
+ (context: Context, node: unit | null | AST.AnyNode): node is AST.CallExpression;
128
+ (context: Context): (node: unit | null | AST.AnyNode) => node is AST.CallExpression;
129
+ };
125
130
  }
126
131
  declare function isReactAPICall(api: string): isReactAPICall.ReturnType;
127
132
  declare const isCaptureOwnerStack: isReactAPI.ReturnType;
@@ -150,5 +155,5 @@ declare const isCreateRefCall: isReactAPICall.ReturnType;
150
155
  declare const isForwardRefCall: isReactAPICall.ReturnType;
151
156
  declare const isMemoCall: isReactAPICall.ReturnType;
152
157
  declare const isLazyCall: isReactAPICall.ReturnType;
153
-
154
- export { type SemanticEntry, type SemanticNode, type TypeVariant, getVariantsOfTypes, isAnyType, isBigIntType, isBooleanType, isCaptureOwnerStack, isCaptureOwnerStackCall, isChildrenCount, isChildrenCountCall, isChildrenForEach, isChildrenForEachCall, isChildrenMap, isChildrenMapCall, isChildrenOnly, isChildrenOnlyCall, isChildrenToArray, isChildrenToArrayCall, isCloneElement, isCloneElementCall, isCreateContext, isCreateContextCall, isCreateElement, isCreateElementCall, isCreateRef, isCreateRefCall, isEnumType, isFalsyBigIntType, isFalsyNumberType, isFalsyStringType, isForwardRef, isForwardRefCall, isLazy, isLazyCall, isMemo, isMemoCall, isNeverType, isNullishType, isNumberType, isObjectType, isReactAPI, isReactAPICall, isStringType, isTruthyBigIntType, isTruthyNumberType, isTruthyStringType, isUnknownType };
158
+ //#endregion
159
+ export { SemanticEntry, SemanticNode, TypeVariant, getVariantsOfTypes, isAnyType, isBigIntType, isBooleanType, isCaptureOwnerStack, isCaptureOwnerStackCall, isChildrenCount, isChildrenCountCall, isChildrenForEach, isChildrenForEachCall, isChildrenMap, isChildrenMapCall, isChildrenOnly, isChildrenOnlyCall, isChildrenToArray, isChildrenToArrayCall, isCloneElement, isCloneElementCall, isCreateContext, isCreateContextCall, isCreateElement, isCreateElementCall, isCreateRef, isCreateRefCall, isEnumType, isFalseLiteralType, isFalsyBigIntType, isFalsyNumberType, isFalsyStringType, isForwardRef, isForwardRefCall, isLazy, isLazyCall, isMemo, isMemoCall, isNeverType, isNullishType, isNumberType, isObjectType, isReactAPI, isReactAPICall, isStringType, isTrueLiteralType, isTruthyBigIntType, isTruthyNumberType, isTruthyStringType, isUnknownType };
package/dist/index.js CHANGED
@@ -1,122 +1,116 @@
1
- import { isTypeFlagSet, isFalseLiteralType, isTrueLiteralType } from 'ts-api-utils';
2
- export { isFalseLiteralType, isTrueLiteralType } from 'ts-api-utils';
3
- import { isMatching, P, match } from 'ts-pattern';
4
- import ts, { SyntaxKind } from 'typescript';
5
- import { dual } from '@react-analyzer/eff';
6
- import { toStringFormat } from '@react-analyzer/ast';
1
+ import { isFalseLiteralType, isTrueLiteralType, isTypeFlagSet } from "ts-api-utils";
2
+ import { P, isMatching, match } from "ts-pattern";
3
+ import ts, { SyntaxKind } from "typescript";
4
+ import { dual, unit } from "@react-analyzer/eff";
5
+ import { toStringFormat } from "@react-analyzer/ast";
7
6
 
8
- // src/type/type-is.ts
9
- var isAnyType = (type) => isTypeFlagSet(type, ts.TypeFlags.TypeParameter | ts.TypeFlags.Any);
10
- var isBigIntType = (type) => isTypeFlagSet(type, ts.TypeFlags.BigIntLike);
11
- var isBooleanType = (type) => isTypeFlagSet(type, ts.TypeFlags.BooleanLike);
12
- var isEnumType = (type) => isTypeFlagSet(type, ts.TypeFlags.EnumLike);
13
- var isFalsyBigIntType = (type) => type.isLiteral() && isMatching({ value: { base10Value: "0" } }, type);
14
- var isFalsyNumberType = (type) => type.isNumberLiteral() && type.value === 0;
15
- var isFalsyStringType = (type) => type.isStringLiteral() && type.value === "";
16
- var isNeverType = (type) => isTypeFlagSet(type, ts.TypeFlags.Never);
17
- var isNullishType = (type) => isTypeFlagSet(type, ts.TypeFlags.Null | ts.TypeFlags.Undefined | ts.TypeFlags.VoidLike);
18
- var isNumberType = (type) => isTypeFlagSet(type, ts.TypeFlags.NumberLike);
19
- var isObjectType = (type) => !isTypeFlagSet(
20
- type,
21
- ts.TypeFlags.Null | ts.TypeFlags.Undefined | ts.TypeFlags.VoidLike | ts.TypeFlags.BooleanLike | ts.TypeFlags.StringLike | ts.TypeFlags.NumberLike | ts.TypeFlags.BigIntLike | ts.TypeFlags.TypeParameter | ts.TypeFlags.Any | ts.TypeFlags.Unknown | ts.TypeFlags.Never
22
- );
23
- var isStringType = (type) => isTypeFlagSet(type, ts.TypeFlags.StringLike);
24
- var isTruthyBigIntType = (type) => type.isLiteral() && isMatching({ value: { base10Value: P.not("0") } }, type);
25
- var isTruthyNumberType = (type) => type.isNumberLiteral() && type.value !== 0;
26
- var isTruthyStringType = (type) => type.isStringLiteral() && type.value !== "";
27
- var isUnknownType = (type) => isTypeFlagSet(type, ts.TypeFlags.Unknown);
7
+ //#region src/type/type-is.ts
8
+ const isAnyType = (type) => isTypeFlagSet(type, ts.TypeFlags.TypeParameter | ts.TypeFlags.Any);
9
+ const isBigIntType = (type) => isTypeFlagSet(type, ts.TypeFlags.BigIntLike);
10
+ const isBooleanType = (type) => isTypeFlagSet(type, ts.TypeFlags.BooleanLike);
11
+ const isEnumType = (type) => isTypeFlagSet(type, ts.TypeFlags.EnumLike);
12
+ const isFalsyBigIntType = (type) => type.isLiteral() && isMatching({ value: { base10Value: "0" } }, type);
13
+ const isFalsyNumberType = (type) => type.isNumberLiteral() && type.value === 0;
14
+ const isFalsyStringType = (type) => type.isStringLiteral() && type.value === "";
15
+ const isNeverType = (type) => isTypeFlagSet(type, ts.TypeFlags.Never);
16
+ const isNullishType = (type) => isTypeFlagSet(type, ts.TypeFlags.Null | ts.TypeFlags.Undefined | ts.TypeFlags.VoidLike);
17
+ const isNumberType = (type) => isTypeFlagSet(type, ts.TypeFlags.NumberLike);
18
+ const isObjectType = (type) => !isTypeFlagSet(type, ts.TypeFlags.Null | ts.TypeFlags.Undefined | ts.TypeFlags.VoidLike | ts.TypeFlags.BooleanLike | ts.TypeFlags.StringLike | ts.TypeFlags.NumberLike | ts.TypeFlags.BigIntLike | ts.TypeFlags.TypeParameter | ts.TypeFlags.Any | ts.TypeFlags.Unknown | ts.TypeFlags.Never);
19
+ const isStringType = (type) => isTypeFlagSet(type, ts.TypeFlags.StringLike);
20
+ const isTruthyBigIntType = (type) => type.isLiteral() && isMatching({ value: { base10Value: P.not("0") } }, type);
21
+ const isTruthyNumberType = (type) => type.isNumberLiteral() && type.value !== 0;
22
+ const isTruthyStringType = (type) => type.isStringLiteral() && type.value !== "";
23
+ const isUnknownType = (type) => isTypeFlagSet(type, ts.TypeFlags.Unknown);
24
+
25
+ //#endregion
26
+ //#region src/type/type-variant.ts
27
+ /**
28
+ * Ported from https://github.com/typescript-eslint/typescript-eslint/blob/eb736bbfc22554694400e6a4f97051d845d32e0b/packages/eslint-plugin/src/rules/strict-boolean-expressions.ts#L826 with some enhancements
29
+ * Get the variants of an array of types.
30
+ * @param types The types to get the variants of
31
+ * @returns The variants of the types
32
+ */
28
33
  function getVariantsOfTypes(types) {
29
- const variants = /* @__PURE__ */ new Set();
30
- if (types.some(isUnknownType)) {
31
- variants.add("unknown");
32
- return variants;
33
- }
34
- if (types.some(isNullishType)) {
35
- variants.add("nullish");
36
- }
37
- const booleans = types.filter(isBooleanType);
38
- const boolean0 = booleans[0];
39
- if (booleans.length === 1 && boolean0 != null) {
40
- if (isFalseLiteralType(boolean0)) {
41
- variants.add("falsy boolean");
42
- } else if (isTrueLiteralType(boolean0)) {
43
- variants.add("truthy boolean");
44
- }
45
- } else if (booleans.length === 2) {
46
- variants.add("boolean");
47
- }
48
- const strings = types.filter(isStringType);
49
- if (strings.length > 0) {
50
- const evaluated = match(strings).when((types2) => types2.every(isTruthyStringType), () => "truthy string").when((types2) => types2.every(isFalsyStringType), () => "falsy string").otherwise(() => "string");
51
- variants.add(evaluated);
52
- }
53
- const bigints = types.filter(isBigIntType);
54
- if (bigints.length > 0) {
55
- const evaluated = match(bigints).when((types2) => types2.every(isTruthyBigIntType), () => "truthy bigint").when((types2) => types2.every(isFalsyBigIntType), () => "falsy bigint").otherwise(() => "bigint");
56
- variants.add(evaluated);
57
- }
58
- const numbers = types.filter(isNumberType);
59
- if (numbers.length > 0) {
60
- const evaluated = match(numbers).when((types2) => types2.every(isTruthyNumberType), () => "truthy number").when((types2) => types2.every(isFalsyNumberType), () => "falsy number").otherwise(() => "number");
61
- variants.add(evaluated);
62
- }
63
- if (types.some(isEnumType)) {
64
- variants.add("enum");
65
- }
66
- if (types.some(isObjectType)) {
67
- variants.add("object");
68
- }
69
- if (types.some(isAnyType)) {
70
- variants.add("any");
71
- }
72
- if (types.some(isNeverType)) {
73
- variants.add("never");
74
- }
75
- return variants;
34
+ const variants = /* @__PURE__ */ new Set();
35
+ if (types.some(isUnknownType)) {
36
+ variants.add("unknown");
37
+ return variants;
38
+ }
39
+ if (types.some(isNullishType)) variants.add("nullish");
40
+ const booleans = types.filter(isBooleanType);
41
+ const boolean0 = booleans[0];
42
+ if (booleans.length === 1 && boolean0 != null) {
43
+ if (isFalseLiteralType(boolean0)) variants.add("falsy boolean");
44
+ else if (isTrueLiteralType(boolean0)) variants.add("truthy boolean");
45
+ } else if (booleans.length === 2) variants.add("boolean");
46
+ const strings = types.filter(isStringType);
47
+ if (strings.length > 0) {
48
+ const evaluated = match(strings).when((types$1) => types$1.every(isTruthyStringType), () => "truthy string").when((types$1) => types$1.every(isFalsyStringType), () => "falsy string").otherwise(() => "string");
49
+ variants.add(evaluated);
50
+ }
51
+ const bigints = types.filter(isBigIntType);
52
+ if (bigints.length > 0) {
53
+ const evaluated = match(bigints).when((types$1) => types$1.every(isTruthyBigIntType), () => "truthy bigint").when((types$1) => types$1.every(isFalsyBigIntType), () => "falsy bigint").otherwise(() => "bigint");
54
+ variants.add(evaluated);
55
+ }
56
+ const numbers = types.filter(isNumberType);
57
+ if (numbers.length > 0) {
58
+ const evaluated = match(numbers).when((types$1) => types$1.every(isTruthyNumberType), () => "truthy number").when((types$1) => types$1.every(isFalsyNumberType), () => "falsy number").otherwise(() => "number");
59
+ variants.add(evaluated);
60
+ }
61
+ if (types.some(isEnumType)) variants.add("enum");
62
+ if (types.some(isObjectType)) variants.add("object");
63
+ if (types.some(isAnyType)) variants.add("any");
64
+ if (types.some(isNeverType)) variants.add("never");
65
+ return variants;
76
66
  }
67
+
68
+ //#endregion
69
+ //#region src/utils/is-react-api.ts
77
70
  function isReactAPI(api) {
78
- const func = (context, node) => {
79
- if (node == null) return false;
80
- const name = toStringFormat(node);
81
- if (name === api) return true;
82
- if (name.substring(name.indexOf(".") + 1) === api) return true;
83
- return false;
84
- };
85
- return dual(2, func);
71
+ const func = (context, node) => {
72
+ if (node == null) return false;
73
+ const name = toStringFormat(node);
74
+ if (name === api) return true;
75
+ if (name.substring(name.indexOf(".") + 1) === api) return true;
76
+ return false;
77
+ };
78
+ return dual(2, func);
86
79
  }
87
80
  function isReactAPICall(api) {
88
- const func = (context, node) => {
89
- if (node == null) return false;
90
- if (node.kind !== SyntaxKind.CallExpression) return false;
91
- return isReactAPI(api)(context, node.expression);
92
- };
93
- return dual(2, func);
81
+ const func = (context, node) => {
82
+ if (node == null) return false;
83
+ if (node.kind !== SyntaxKind.CallExpression) return false;
84
+ return isReactAPI(api)(context, node.expression);
85
+ };
86
+ return dual(2, func);
94
87
  }
95
- var isCaptureOwnerStack = isReactAPI("captureOwnerStack");
96
- var isChildrenCount = isReactAPI("Children.count");
97
- var isChildrenForEach = isReactAPI("Children.forEach");
98
- var isChildrenMap = isReactAPI("Children.map");
99
- var isChildrenOnly = isReactAPI("Children.only");
100
- var isChildrenToArray = isReactAPI("Children.toArray");
101
- var isCloneElement = isReactAPI("cloneElement");
102
- var isCreateContext = isReactAPI("createContext");
103
- var isCreateElement = isReactAPI("createElement");
104
- var isCreateRef = isReactAPI("createRef");
105
- var isForwardRef = isReactAPI("forwardRef");
106
- var isMemo = isReactAPI("memo");
107
- var isLazy = isReactAPI("lazy");
108
- var isCaptureOwnerStackCall = isReactAPICall("captureOwnerStack");
109
- var isChildrenCountCall = isReactAPICall("Children.count");
110
- var isChildrenForEachCall = isReactAPICall("Children.forEach");
111
- var isChildrenMapCall = isReactAPICall("Children.map");
112
- var isChildrenOnlyCall = isReactAPICall("Children.only");
113
- var isChildrenToArrayCall = isReactAPICall("Children.toArray");
114
- var isCloneElementCall = isReactAPICall("cloneElement");
115
- var isCreateContextCall = isReactAPICall("createContext");
116
- var isCreateElementCall = isReactAPICall("createElement");
117
- var isCreateRefCall = isReactAPICall("createRef");
118
- var isForwardRefCall = isReactAPICall("forwardRef");
119
- var isMemoCall = isReactAPICall("memo");
120
- var isLazyCall = isReactAPICall("lazy");
88
+ const isCaptureOwnerStack = isReactAPI("captureOwnerStack");
89
+ const isChildrenCount = isReactAPI("Children.count");
90
+ const isChildrenForEach = isReactAPI("Children.forEach");
91
+ const isChildrenMap = isReactAPI("Children.map");
92
+ const isChildrenOnly = isReactAPI("Children.only");
93
+ const isChildrenToArray = isReactAPI("Children.toArray");
94
+ const isCloneElement = isReactAPI("cloneElement");
95
+ const isCreateContext = isReactAPI("createContext");
96
+ const isCreateElement = isReactAPI("createElement");
97
+ const isCreateRef = isReactAPI("createRef");
98
+ const isForwardRef = isReactAPI("forwardRef");
99
+ const isMemo = isReactAPI("memo");
100
+ const isLazy = isReactAPI("lazy");
101
+ const isCaptureOwnerStackCall = isReactAPICall("captureOwnerStack");
102
+ const isChildrenCountCall = isReactAPICall("Children.count");
103
+ const isChildrenForEachCall = isReactAPICall("Children.forEach");
104
+ const isChildrenMapCall = isReactAPICall("Children.map");
105
+ const isChildrenOnlyCall = isReactAPICall("Children.only");
106
+ const isChildrenToArrayCall = isReactAPICall("Children.toArray");
107
+ const isCloneElementCall = isReactAPICall("cloneElement");
108
+ const isCreateContextCall = isReactAPICall("createContext");
109
+ const isCreateElementCall = isReactAPICall("createElement");
110
+ const isCreateRefCall = isReactAPICall("createRef");
111
+ const isForwardRefCall = isReactAPICall("forwardRef");
112
+ const isMemoCall = isReactAPICall("memo");
113
+ const isLazyCall = isReactAPICall("lazy");
121
114
 
122
- export { getVariantsOfTypes, isAnyType, isBigIntType, isBooleanType, isCaptureOwnerStack, isCaptureOwnerStackCall, isChildrenCount, isChildrenCountCall, isChildrenForEach, isChildrenForEachCall, isChildrenMap, isChildrenMapCall, isChildrenOnly, isChildrenOnlyCall, isChildrenToArray, isChildrenToArrayCall, isCloneElement, isCloneElementCall, isCreateContext, isCreateContextCall, isCreateElement, isCreateElementCall, isCreateRef, isCreateRefCall, isEnumType, isFalsyBigIntType, isFalsyNumberType, isFalsyStringType, isForwardRef, isForwardRefCall, isLazy, isLazyCall, isMemo, isMemoCall, isNeverType, isNullishType, isNumberType, isObjectType, isReactAPI, isReactAPICall, isStringType, isTruthyBigIntType, isTruthyNumberType, isTruthyStringType, isUnknownType };
115
+ //#endregion
116
+ export { getVariantsOfTypes, isAnyType, isBigIntType, isBooleanType, isCaptureOwnerStack, isCaptureOwnerStackCall, isChildrenCount, isChildrenCountCall, isChildrenForEach, isChildrenForEachCall, isChildrenMap, isChildrenMapCall, isChildrenOnly, isChildrenOnlyCall, isChildrenToArray, isChildrenToArrayCall, isCloneElement, isCloneElementCall, isCreateContext, isCreateContextCall, isCreateElement, isCreateElementCall, isCreateRef, isCreateRefCall, isEnumType, isFalseLiteralType, isFalsyBigIntType, isFalsyNumberType, isFalsyStringType, isForwardRef, isForwardRefCall, isLazy, isLazyCall, isMemo, isMemoCall, isNeverType, isNullishType, isNumberType, isObjectType, isReactAPI, isReactAPICall, isStringType, isTrueLiteralType, isTruthyBigIntType, isTruthyNumberType, isTruthyStringType, isUnknownType };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-analyzer/core",
3
- "version": "0.0.3-next.3",
3
+ "version": "0.0.3-next.4",
4
4
  "description": "React Analyzer utility module for static analysis of React core APIs and patterns.",
5
5
  "homepage": "https://github.com/Rel1cx/react-analyzer",
6
6
  "bugs": {
@@ -28,14 +28,14 @@
28
28
  ],
29
29
  "dependencies": {
30
30
  "ts-pattern": "^5.8.0",
31
- "@react-analyzer/ast": "0.0.3-next.3",
32
- "@react-analyzer/eff": "0.0.3-next.3",
33
- "@react-analyzer/kit": "0.0.3-next.3"
31
+ "@react-analyzer/ast": "0.0.3-next.4",
32
+ "@react-analyzer/kit": "0.0.3-next.4",
33
+ "@react-analyzer/eff": "0.0.3-next.4"
34
34
  },
35
35
  "devDependencies": {
36
36
  "@tsconfig/node22": "^22.0.2",
37
37
  "@types/node": "^24.3.0",
38
- "tsup": "^8.5.0",
38
+ "tsdown": "^0.14.1",
39
39
  "type-fest": "^4.41.0",
40
40
  "@local/configs": "0.0.0"
41
41
  },
@@ -49,7 +49,7 @@
49
49
  "node": ">=22.17.0"
50
50
  },
51
51
  "scripts": {
52
- "build": "tsup --dts-resolve",
52
+ "build": "tsdown --dts-resolve",
53
53
  "build:docs": "typedoc",
54
54
  "lint:publish": "publint",
55
55
  "lint:ts": "tsl"