ts-codemod-lib 3.3.0 → 3.3.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 +22 -0
- package/dist/entry-point.mjs +2 -24
- package/dist/entry-point.mjs.map +1 -1
- package/dist/functions/ast-transformers/append-as-const.mjs +330 -292
- package/dist/functions/ast-transformers/append-as-const.mjs.map +1 -1
- package/dist/functions/ast-transformers/convert-interface-to-type.mjs +85 -70
- package/dist/functions/ast-transformers/convert-interface-to-type.mjs.map +1 -1
- package/dist/functions/ast-transformers/convert-to-readonly.d.mts.map +1 -1
- package/dist/functions/ast-transformers/convert-to-readonly.mjs +971 -838
- package/dist/functions/ast-transformers/convert-to-readonly.mjs.map +1 -1
- package/dist/functions/ast-transformers/enable-no-unchecked-indexed-access.d.mts +32 -9
- package/dist/functions/ast-transformers/enable-no-unchecked-indexed-access.d.mts.map +1 -1
- package/dist/functions/ast-transformers/enable-no-unchecked-indexed-access.mjs +299 -134
- package/dist/functions/ast-transformers/enable-no-unchecked-indexed-access.mjs.map +1 -1
- package/dist/functions/ast-transformers/index.mjs +10 -12
- package/dist/functions/ast-transformers/index.mjs.map +1 -1
- package/dist/functions/ast-transformers/readonly-transformer-helpers/compare-union-types.mjs +14 -7
- package/dist/functions/ast-transformers/readonly-transformer-helpers/compare-union-types.mjs.map +1 -1
- package/dist/functions/ast-transformers/readonly-transformer-helpers/constants.mjs +12 -15
- package/dist/functions/ast-transformers/readonly-transformer-helpers/constants.mjs.map +1 -1
- package/dist/functions/ast-transformers/readonly-transformer-helpers/group-union-types.d.mts.map +1 -1
- package/dist/functions/ast-transformers/readonly-transformer-helpers/group-union-types.mjs +70 -59
- package/dist/functions/ast-transformers/readonly-transformer-helpers/group-union-types.mjs.map +1 -1
- package/dist/functions/ast-transformers/readonly-transformer-helpers/index.mjs +5 -5
- package/dist/functions/ast-transformers/readonly-transformer-helpers/index.mjs.map +1 -1
- package/dist/functions/ast-transformers/readonly-transformer-helpers/readonly-context.mjs +15 -20
- package/dist/functions/ast-transformers/readonly-transformer-helpers/readonly-context.mjs.map +1 -1
- package/dist/functions/ast-transformers/replace-any-with-unknown.mjs +30 -34
- package/dist/functions/ast-transformers/replace-any-with-unknown.mjs.map +1 -1
- package/dist/functions/ast-transformers/replace-record-with-unknown-record.mjs +197 -156
- package/dist/functions/ast-transformers/replace-record-with-unknown-record.mjs.map +1 -1
- package/dist/functions/ast-transformers/transform-source-code.mjs +74 -75
- package/dist/functions/ast-transformers/transform-source-code.mjs.map +1 -1
- package/dist/functions/ast-transformers/types.mjs +2 -2
- package/dist/functions/ast-transformers/types.mjs.map +1 -1
- package/dist/functions/constants/ignore-comment-text.mjs +11 -13
- package/dist/functions/constants/ignore-comment-text.mjs.map +1 -1
- package/dist/functions/constants/index.mjs +2 -2
- package/dist/functions/constants/index.mjs.map +1 -1
- package/dist/functions/functions/has-call-or-construct-signature.d.mts +18 -0
- package/dist/functions/functions/has-call-or-construct-signature.d.mts.map +1 -0
- package/dist/functions/functions/has-call-or-construct-signature.mjs +87 -0
- package/dist/functions/functions/has-call-or-construct-signature.mjs.map +1 -0
- package/dist/functions/functions/has-disable-next-line-comment.mjs +67 -38
- package/dist/functions/functions/has-disable-next-line-comment.mjs.map +1 -1
- package/dist/functions/functions/index.d.mts +1 -0
- package/dist/functions/functions/index.d.mts.map +1 -1
- package/dist/functions/functions/index.mjs +12 -11
- package/dist/functions/functions/index.mjs.map +1 -1
- package/dist/functions/functions/is-as-const-node.mjs +25 -20
- package/dist/functions/functions/is-as-const-node.mjs.map +1 -1
- package/dist/functions/functions/is-atomic-type-node.mjs +245 -25
- package/dist/functions/functions/is-atomic-type-node.mjs.map +1 -1
- package/dist/functions/functions/is-conditional-type-distribution-guard.mjs +34 -13
- package/dist/functions/functions/is-conditional-type-distribution-guard.mjs.map +1 -1
- package/dist/functions/functions/is-readonly-node.mjs +120 -14
- package/dist/functions/functions/is-readonly-node.mjs.map +1 -1
- package/dist/functions/functions/is-spread-parameter-node.mjs +5 -6
- package/dist/functions/functions/is-spread-parameter-node.mjs.map +1 -1
- package/dist/functions/functions/remove-parentheses.mjs +4 -4
- package/dist/functions/functions/remove-parentheses.mjs.map +1 -1
- package/dist/functions/functions/should-avoid-parentheses-for-readonly.mjs +23 -9
- package/dist/functions/functions/should-avoid-parentheses-for-readonly.mjs.map +1 -1
- package/dist/functions/functions/unwrap-readonly.mjs +3 -4
- package/dist/functions/functions/unwrap-readonly.mjs.map +1 -1
- package/dist/functions/functions/wrap-with-parentheses.d.mts +14 -5
- package/dist/functions/functions/wrap-with-parentheses.d.mts.map +1 -1
- package/dist/functions/functions/wrap-with-parentheses.mjs +67 -30
- package/dist/functions/functions/wrap-with-parentheses.mjs.map +1 -1
- package/dist/functions/index.mjs +5 -24
- package/dist/functions/index.mjs.map +1 -1
- package/dist/functions/utils/index.mjs +2 -2
- package/dist/functions/utils/index.mjs.map +1 -1
- package/dist/functions/utils/replace-with-debug.mjs +4 -6
- package/dist/functions/utils/replace-with-debug.mjs.map +1 -1
- package/dist/index.mjs +2 -24
- package/dist/index.mjs.map +1 -1
- package/package.json +18 -18
- package/src/functions/ast-transformers/convert-to-readonly.mts +19 -13
- package/src/functions/ast-transformers/convert-to-readonly.test.mts +129 -1
- package/src/functions/ast-transformers/enable-no-unchecked-indexed-access.mts +32 -9
- package/src/functions/ast-transformers/enable-no-unchecked-indexed-access.test.mts +76 -22
- package/src/functions/ast-transformers/readonly-transformer-helpers/group-union-types.mts +8 -1
- package/src/functions/functions/has-call-or-construct-signature.mts +120 -0
- package/src/functions/functions/index.mts +1 -0
- package/src/functions/functions/wrap-with-parentheses.mts +32 -17
|
@@ -1,15 +1,13 @@
|
|
|
1
|
-
const IGNORE_LINE_COMMENT_PREFIXES = [
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
export const IGNORE_LINE_COMMENT_PREFIXES = [
|
|
2
|
+
'transformer-ignore-next-line',
|
|
3
|
+
'ts-codemod-ignore-next-line',
|
|
4
|
+
'codemod-ignore-next-line',
|
|
5
|
+
'transform-ignore-next-line',
|
|
6
6
|
];
|
|
7
|
-
const IGNORE_FILE_COMMENT_PREFIXES = [
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
7
|
+
export const IGNORE_FILE_COMMENT_PREFIXES = [
|
|
8
|
+
'transformer-ignore',
|
|
9
|
+
'ts-codemod-ignore',
|
|
10
|
+
'codemod-ignore',
|
|
11
|
+
'transform-ignore',
|
|
12
12
|
];
|
|
13
|
-
|
|
14
|
-
export { IGNORE_FILE_COMMENT_PREFIXES, IGNORE_LINE_COMMENT_PREFIXES };
|
|
15
|
-
//# sourceMappingURL=ignore-comment-text.mjs.map
|
|
13
|
+
//# sourceMappingURL=ignore-comment-text.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ignore-comment-text.mjs","sources":["../../../src/functions/constants/ignore-comment-text.mts"],"
|
|
1
|
+
{"version":3,"file":"ignore-comment-text.mjs","sourceRoot":"","sources":["../../../src/functions/constants/ignore-comment-text.mts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,4BAA4B,GAAG;IAC1C,8BAA8B;IAC9B,6BAA6B;IAC7B,0BAA0B;IAC1B,4BAA4B;CACpB,CAAC;AAEX,MAAM,CAAC,MAAM,4BAA4B,GAAG;IAC1C,oBAAoB;IACpB,mBAAmB;IACnB,gBAAgB;IAChB,kBAAkB;CACV,CAAC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export
|
|
2
|
-
//# sourceMappingURL=index.mjs.map
|
|
1
|
+
export * from './ignore-comment-text.mjs';
|
|
2
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","
|
|
1
|
+
{"version":3,"file":"index.mjs","sourceRoot":"","sources":["../../../src/functions/constants/index.mts"],"names":[],"mappings":"AAAA,cAAc,2BAA2B,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import * as tsm from 'ts-morph';
|
|
2
|
+
/**
|
|
3
|
+
* Determines whether a node is a type literal or an interface that declares a
|
|
4
|
+
* call or construct signature.
|
|
5
|
+
*
|
|
6
|
+
* `Readonly<T>` is a mapped type over `keyof T`, and neither signature kind is a
|
|
7
|
+
* property, so neither survives the mapping: wrapping `{ (x: string): void }`
|
|
8
|
+
* with `Readonly` produces a type that is no longer callable. A type mixing
|
|
9
|
+
* properties with a call signature is worse still — the properties come through
|
|
10
|
+
* and only the signature disappears. So a type literal carrying one must not be
|
|
11
|
+
* wrapped; its members are marked `readonly` in place instead.
|
|
12
|
+
*
|
|
13
|
+
* @param node - The node to check
|
|
14
|
+
* @returns true if the node declares at least one call or construct signature,
|
|
15
|
+
* false for any other node kind
|
|
16
|
+
*/
|
|
17
|
+
export declare const hasCallOrConstructSignature: (node: tsm.Node) => boolean;
|
|
18
|
+
//# sourceMappingURL=has-call-or-construct-signature.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"has-call-or-construct-signature.d.mts","sourceRoot":"","sources":["../../../src/functions/functions/has-call-or-construct-signature.mts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,UAAU,CAAC;AAEhC;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,2BAA2B,SAAU,GAAG,CAAC,IAAI,KAAG,OASxD,CAAC"}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import * as tsm from 'ts-morph';
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
export const hasCallOrConstructSignature = (node) => (node.isKind(tsm.SyntaxKind.TypeLiteral) ||
|
|
18
|
+
node.isKind(tsm.SyntaxKind.InterfaceDeclaration)) &&
|
|
19
|
+
node
|
|
20
|
+
.getMembers()
|
|
21
|
+
.some((member) => member.isKind(tsm.SyntaxKind.CallSignature) ||
|
|
22
|
+
member.isKind(tsm.SyntaxKind.ConstructSignature));
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
//# sourceMappingURL=has-call-or-construct-signature.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"has-call-or-construct-signature.mjs","sourceRoot":"","sources":["../../../src/functions/functions/has-call-or-construct-signature.mts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,UAAU,CAAC;AAEhC;;;;;;;;;;;;;;GAcG;AACH,MAAM,CAAC,MAAM,2BAA2B,GAAG,CAAC,IAAc,EAAW,EAAE,C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E,IAAI,EAAE,oBAAoB;gBAC1B,IAAI,EAAE,gCAAgC;gBACtC,IAAI,EAAE,GAAG,CAAC,UAAU,CAAC,eAAe;aACrC;YACD;gBACE,IAAI,EAAE,qBAAqB;gBAC3B,IAAI,EAAE,uCAAuC;gBAC7C,IAAI,EAAE,GAAG,CAAC,UAAU,CAAC,gBAAgB;aACtC;SACF,CAAC,CAAC,oBAAoB,EAAE,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE,EAAE;YAC1C,MAAM,CAAC,OAAO,CACZ,2BAA2B,CAAC,kBAAkB,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAC5D,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -1,43 +1,72 @@
|
|
|
1
1
|
import * as tsm from 'ts-morph';
|
|
2
|
-
import { IGNORE_LINE_COMMENT_PREFIXES } from '../constants/
|
|
2
|
+
import { IGNORE_LINE_COMMENT_PREFIXES } from '../constants/index.mjs';
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
if (transformerName === void 0) {
|
|
23
|
-
return true;
|
|
24
|
-
}
|
|
25
|
-
const afterPrefix = commentText.slice(commentText.indexOf(matchedPrefix)).replace(matchedPrefix, "").trim();
|
|
26
|
-
if (afterPrefix === "") {
|
|
27
|
-
return true;
|
|
28
|
-
}
|
|
29
|
-
const targetTransformers = afterPrefix.split(",").map((name) => name.trim());
|
|
30
|
-
return targetTransformers.includes(transformerName);
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
return false;
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
export const hasDisableNextLineComment = (node, transformerName) => {
|
|
18
|
+
const nodeStartLine = node.getStartLineNumber();
|
|
19
|
+
|
|
20
|
+
if (nodeStartLine <= 1) {
|
|
21
|
+
return false;
|
|
34
22
|
}
|
|
35
|
-
|
|
36
|
-
|
|
23
|
+
const sourceFile = node.getSourceFile();
|
|
24
|
+
const leadingCommentRanges = node.getLeadingCommentRanges();
|
|
25
|
+
|
|
26
|
+
for (let mut_i = leadingCommentRanges.length - 1; mut_i >= 0; mut_i--) {
|
|
27
|
+
|
|
28
|
+
const commentRange = leadingCommentRanges[mut_i];
|
|
29
|
+
|
|
30
|
+
const commentEndPos = commentRange.getEnd();
|
|
31
|
+
const commentEndLine = sourceFile.getLineAndColumnAtPos(commentEndPos).line;
|
|
32
|
+
|
|
33
|
+
if (nodeStartLine === commentEndLine + 1) {
|
|
34
|
+
|
|
35
|
+
if (commentRange.getKind() === tsm.SyntaxKind.SingleLineCommentTrivia) {
|
|
36
|
+
const commentText = commentRange.getText().trim();
|
|
37
|
+
|
|
38
|
+
const matchedPrefix = IGNORE_LINE_COMMENT_PREFIXES.find((prefix) => commentText.includes(prefix));
|
|
39
|
+
if (matchedPrefix !== undefined) {
|
|
40
|
+
|
|
41
|
+
if (transformerName === undefined) {
|
|
42
|
+
return true;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const afterPrefix = commentText
|
|
46
|
+
.slice(commentText.indexOf(matchedPrefix))
|
|
47
|
+
.replace(matchedPrefix, '')
|
|
48
|
+
.trim();
|
|
49
|
+
|
|
50
|
+
if (afterPrefix === '') {
|
|
51
|
+
return true;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const targetTransformers = afterPrefix
|
|
55
|
+
.split(',')
|
|
56
|
+
.map((name) => name.trim());
|
|
57
|
+
return targetTransformers.includes(transformerName);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
return false;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
if (commentEndLine < nodeStartLine - 1) {
|
|
67
|
+
break;
|
|
68
|
+
}
|
|
37
69
|
}
|
|
38
|
-
|
|
39
|
-
return false;
|
|
70
|
+
return false;
|
|
40
71
|
};
|
|
41
|
-
|
|
42
|
-
export { hasDisableNextLineComment };
|
|
43
|
-
//# sourceMappingURL=has-disable-next-line-comment.mjs.map
|
|
72
|
+
//# sourceMappingURL=has-disable-next-line-comment.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"has-disable-next-line-comment.mjs","sources":["../../../src/functions/functions/has-disable-next-line-comment.mts"],"
|
|
1
|
+
{"version":3,"file":"has-disable-next-line-comment.mjs","sourceRoot":"","sources":["../../../src/functions/functions/has-disable-next-line-comment.mts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,UAAU,CAAC;AAChC,OAAO,EAAE,4BAA4B,EAAE,MAAM,wBAAwB,CAAC;AAEtE;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,MAAM,yBAAyB,GAAG,CACvC,IAAc,EACd,eAAwB,EACf,EAAE;IACX,MAAM,aAAa,GAAG,IAAI,CAAC,kBAAkB,EAAE,CAAC;IAEhD,8CAA8C;IAC9C,IAAI,aAAa,IAAI,CAAC,EAAE,CAAC;QACvB,OAAO,KAAK,CAAC;IACf,CAAC;IAED,MAAM,UAAU,GAAG,IAAI,CAAC,aAAa,EAAE,CAAC,CAAC,qBAAqB;IAE9D,MAAM,oBAAoB,GAAG,IAAI,CAAC,uBAAuB,EAAE,CAAC;IAE5D,yEAAyE;IACzE,KAAK,IAAI,KAAK,GAAG,oBAAoB,CAAC,MAAM,GAAG,CAAC,EAAE,KAAK,IAAI,CAAC,EAAE,KAAK,EAAE,EAAE,CAAC;QACtE,oEAAoE;QACpE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AC;gBACtD,CAAC;YACH,CAAC;YAED,iEAAiE;YACjE,8DAA8D;YAC9D,6EAA6E;YAC7E,OAAO,KAAK,CAAC;QACf,CAAC;QAED,6EAA6E;QAC7E,IAAI,cAAc,GAAG,aAAa,GAAG,CAAC,EAAE,CAAC;YACvC,MAAM;QACR,CAAC;IACH,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../../../src/functions/functions/index.mts"],"names":[],"mappings":"AAAA,cAAc,qCAAqC,CAAC;AACpD,cAAc,wBAAwB,CAAC;AACvC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,8CAA8C,CAAC;AAC7D,cAAc,wBAAwB,CAAC;AACvC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,0BAA0B,CAAC;AACzC,cAAc,6CAA6C,CAAC;AAC5D,cAAc,uBAAuB,CAAC;AACtC,cAAc,6BAA6B,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../../../src/functions/functions/index.mts"],"names":[],"mappings":"AAAA,cAAc,uCAAuC,CAAC;AACtD,cAAc,qCAAqC,CAAC;AACpD,cAAc,wBAAwB,CAAC;AACvC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,8CAA8C,CAAC;AAC7D,cAAc,wBAAwB,CAAC;AACvC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,0BAA0B,CAAC;AACzC,cAAc,6CAA6C,CAAC;AAC5D,cAAc,uBAAuB,CAAC;AACtC,cAAc,6BAA6B,CAAC"}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
3
|
-
export
|
|
4
|
-
export
|
|
5
|
-
export
|
|
6
|
-
export
|
|
7
|
-
export
|
|
8
|
-
export
|
|
9
|
-
export
|
|
10
|
-
export
|
|
11
|
-
|
|
1
|
+
export * from './has-call-or-construct-signature.mjs';
|
|
2
|
+
export * from './has-disable-next-line-comment.mjs';
|
|
3
|
+
export * from './is-as-const-node.mjs';
|
|
4
|
+
export * from './is-atomic-type-node.mjs';
|
|
5
|
+
export * from './is-conditional-type-distribution-guard.mjs';
|
|
6
|
+
export * from './is-readonly-node.mjs';
|
|
7
|
+
export * from './is-spread-parameter-node.mjs';
|
|
8
|
+
export * from './remove-parentheses.mjs';
|
|
9
|
+
export * from './should-avoid-parentheses-for-readonly.mjs';
|
|
10
|
+
export * from './unwrap-readonly.mjs';
|
|
11
|
+
export * from './wrap-with-parentheses.mjs';
|
|
12
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","
|
|
1
|
+
{"version":3,"file":"index.mjs","sourceRoot":"","sources":["../../../src/functions/functions/index.mts"],"names":[],"mappings":"AAAA,cAAc,uCAAuC,CAAC;AACtD,cAAc,qCAAqC,CAAC;AACpD,cAAc,wBAAwB,CAAC;AACvC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,8CAA8C,CAAC;AAC7D,cAAc,wBAAwB,CAAC;AACvC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,0BAA0B,CAAC;AACzC,cAAc,6CAA6C,CAAC;AAC5D,cAAc,uBAAuB,CAAC;AACtC,cAAc,6BAA6B,CAAC"}
|
|
@@ -1,23 +1,28 @@
|
|
|
1
1
|
import { Arr } from 'ts-data-forge';
|
|
2
|
-
import * as
|
|
2
|
+
import * as ts from 'ts-morph';
|
|
3
|
+
export const isAsConstNode = (node) => {
|
|
4
|
+
if (!node.isKind(ts.SyntaxKind.AsExpression)) {
|
|
5
|
+
return false;
|
|
6
|
+
}
|
|
3
7
|
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
if (!typeNameNode.isKind(tsm.SyntaxKind.Identifier)) {
|
|
17
|
-
return false;
|
|
18
|
-
}
|
|
19
|
-
return typeNameNode.getText() === "const" && Arr.isEmpty(typeNode.getTypeArguments());
|
|
20
|
-
};
|
|
8
|
+
const typeNode = node.getTypeNode();
|
|
9
|
+
if (typeNode === undefined) {
|
|
10
|
+
return false;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
if (!typeNode.isKind(ts.SyntaxKind.TypeReference)) {
|
|
14
|
+
return false;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const typeNameNode = typeNode.getTypeName();
|
|
18
|
+
|
|
19
|
+
if (!typeNameNode.isKind(ts.SyntaxKind.Identifier)) {
|
|
21
20
|
|
|
22
|
-
|
|
23
|
-
|
|
21
|
+
return false;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
return (typeNameNode.getText() === 'const' &&
|
|
26
|
+
Arr.isEmpty(typeNode.getTypeArguments()));
|
|
27
|
+
};
|
|
28
|
+
//# sourceMappingURL=is-as-const-node.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"is-as-const-node.mjs","sources":["../../../src/functions/functions/is-as-const-node.mts"],"
|
|
1
|
+
{"version":3,"file":"is-as-const-node.mjs","sourceRoot":"","sources":["../../../src/functions/functions/is-as-const-node.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AACpC,OAAO,KAAK,EAAE,MAAM,UAAU,CAAC;AAE/B,MAAM,CAAC,MAAM,aAAa,GAAG,CAC3B,IAAa,EAWV,EAAE;IACL,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,UAAU,CAAC,YAAY,CAAC,EAAE,CAAC;QAC7C,OAAO,KAAK,CAAC;IACf,CAAC;IAED,+CAA+C;IAC/C,MAAM,QAAQ,GAAG,IAAI,CAAC,WAAW,EAAE,CAAC;IAEpC,IAAI,QAAQ,KAAK,SAAS,EAAE,CAAC;QAC3B,OAAO,KAAK,CAAC,CAAC,yCAAyC;IACzD,CAAC;IAED,iDAAiD;IACjD,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC,UAAU,CAAC,aAAa,CAAC,EAAE,CAAC;QAClD,OAAO,KAAK,CAAC;IACf,CAAC;IAED,+CAA+C;IAC/C,MAAM,YAAY,GAAG,QAAQ,CAAC,WAAW,EAAE,CAAC;IAE5C,8CAA8C;IAC9C,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,EAAE,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,CAAC;QACnD,mEAAmE;QACnE,OAAO,KAAK,CAAC;IACf,CAAC;IAED,+CAA+C;IAC/C,uEAAuE;IACvE,OAAO,CACL,YAAY,CAAC,OAAO,EAAE,KAAK,OAAO;QAClC,GAAG,CAAC,OAAO,CAAC,QAAQ,CAAC,gBAAgB,EAAE,CAAC,CACzC,CAAC;AACJ,CAAC,CAAC"}
|