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.
Files changed (86) hide show
  1. package/README.md +22 -0
  2. package/dist/entry-point.mjs +2 -24
  3. package/dist/entry-point.mjs.map +1 -1
  4. package/dist/functions/ast-transformers/append-as-const.mjs +330 -292
  5. package/dist/functions/ast-transformers/append-as-const.mjs.map +1 -1
  6. package/dist/functions/ast-transformers/convert-interface-to-type.mjs +85 -70
  7. package/dist/functions/ast-transformers/convert-interface-to-type.mjs.map +1 -1
  8. package/dist/functions/ast-transformers/convert-to-readonly.d.mts.map +1 -1
  9. package/dist/functions/ast-transformers/convert-to-readonly.mjs +971 -838
  10. package/dist/functions/ast-transformers/convert-to-readonly.mjs.map +1 -1
  11. package/dist/functions/ast-transformers/enable-no-unchecked-indexed-access.d.mts +32 -9
  12. package/dist/functions/ast-transformers/enable-no-unchecked-indexed-access.d.mts.map +1 -1
  13. package/dist/functions/ast-transformers/enable-no-unchecked-indexed-access.mjs +299 -134
  14. package/dist/functions/ast-transformers/enable-no-unchecked-indexed-access.mjs.map +1 -1
  15. package/dist/functions/ast-transformers/index.mjs +10 -12
  16. package/dist/functions/ast-transformers/index.mjs.map +1 -1
  17. package/dist/functions/ast-transformers/readonly-transformer-helpers/compare-union-types.mjs +14 -7
  18. package/dist/functions/ast-transformers/readonly-transformer-helpers/compare-union-types.mjs.map +1 -1
  19. package/dist/functions/ast-transformers/readonly-transformer-helpers/constants.mjs +12 -15
  20. package/dist/functions/ast-transformers/readonly-transformer-helpers/constants.mjs.map +1 -1
  21. package/dist/functions/ast-transformers/readonly-transformer-helpers/group-union-types.d.mts.map +1 -1
  22. package/dist/functions/ast-transformers/readonly-transformer-helpers/group-union-types.mjs +70 -59
  23. package/dist/functions/ast-transformers/readonly-transformer-helpers/group-union-types.mjs.map +1 -1
  24. package/dist/functions/ast-transformers/readonly-transformer-helpers/index.mjs +5 -5
  25. package/dist/functions/ast-transformers/readonly-transformer-helpers/index.mjs.map +1 -1
  26. package/dist/functions/ast-transformers/readonly-transformer-helpers/readonly-context.mjs +15 -20
  27. package/dist/functions/ast-transformers/readonly-transformer-helpers/readonly-context.mjs.map +1 -1
  28. package/dist/functions/ast-transformers/replace-any-with-unknown.mjs +30 -34
  29. package/dist/functions/ast-transformers/replace-any-with-unknown.mjs.map +1 -1
  30. package/dist/functions/ast-transformers/replace-record-with-unknown-record.mjs +197 -156
  31. package/dist/functions/ast-transformers/replace-record-with-unknown-record.mjs.map +1 -1
  32. package/dist/functions/ast-transformers/transform-source-code.mjs +74 -75
  33. package/dist/functions/ast-transformers/transform-source-code.mjs.map +1 -1
  34. package/dist/functions/ast-transformers/types.mjs +2 -2
  35. package/dist/functions/ast-transformers/types.mjs.map +1 -1
  36. package/dist/functions/constants/ignore-comment-text.mjs +11 -13
  37. package/dist/functions/constants/ignore-comment-text.mjs.map +1 -1
  38. package/dist/functions/constants/index.mjs +2 -2
  39. package/dist/functions/constants/index.mjs.map +1 -1
  40. package/dist/functions/functions/has-call-or-construct-signature.d.mts +18 -0
  41. package/dist/functions/functions/has-call-or-construct-signature.d.mts.map +1 -0
  42. package/dist/functions/functions/has-call-or-construct-signature.mjs +87 -0
  43. package/dist/functions/functions/has-call-or-construct-signature.mjs.map +1 -0
  44. package/dist/functions/functions/has-disable-next-line-comment.mjs +67 -38
  45. package/dist/functions/functions/has-disable-next-line-comment.mjs.map +1 -1
  46. package/dist/functions/functions/index.d.mts +1 -0
  47. package/dist/functions/functions/index.d.mts.map +1 -1
  48. package/dist/functions/functions/index.mjs +12 -11
  49. package/dist/functions/functions/index.mjs.map +1 -1
  50. package/dist/functions/functions/is-as-const-node.mjs +25 -20
  51. package/dist/functions/functions/is-as-const-node.mjs.map +1 -1
  52. package/dist/functions/functions/is-atomic-type-node.mjs +245 -25
  53. package/dist/functions/functions/is-atomic-type-node.mjs.map +1 -1
  54. package/dist/functions/functions/is-conditional-type-distribution-guard.mjs +34 -13
  55. package/dist/functions/functions/is-conditional-type-distribution-guard.mjs.map +1 -1
  56. package/dist/functions/functions/is-readonly-node.mjs +120 -14
  57. package/dist/functions/functions/is-readonly-node.mjs.map +1 -1
  58. package/dist/functions/functions/is-spread-parameter-node.mjs +5 -6
  59. package/dist/functions/functions/is-spread-parameter-node.mjs.map +1 -1
  60. package/dist/functions/functions/remove-parentheses.mjs +4 -4
  61. package/dist/functions/functions/remove-parentheses.mjs.map +1 -1
  62. package/dist/functions/functions/should-avoid-parentheses-for-readonly.mjs +23 -9
  63. package/dist/functions/functions/should-avoid-parentheses-for-readonly.mjs.map +1 -1
  64. package/dist/functions/functions/unwrap-readonly.mjs +3 -4
  65. package/dist/functions/functions/unwrap-readonly.mjs.map +1 -1
  66. package/dist/functions/functions/wrap-with-parentheses.d.mts +14 -5
  67. package/dist/functions/functions/wrap-with-parentheses.d.mts.map +1 -1
  68. package/dist/functions/functions/wrap-with-parentheses.mjs +67 -30
  69. package/dist/functions/functions/wrap-with-parentheses.mjs.map +1 -1
  70. package/dist/functions/index.mjs +5 -24
  71. package/dist/functions/index.mjs.map +1 -1
  72. package/dist/functions/utils/index.mjs +2 -2
  73. package/dist/functions/utils/index.mjs.map +1 -1
  74. package/dist/functions/utils/replace-with-debug.mjs +4 -6
  75. package/dist/functions/utils/replace-with-debug.mjs.map +1 -1
  76. package/dist/index.mjs +2 -24
  77. package/dist/index.mjs.map +1 -1
  78. package/package.json +18 -18
  79. package/src/functions/ast-transformers/convert-to-readonly.mts +19 -13
  80. package/src/functions/ast-transformers/convert-to-readonly.test.mts +129 -1
  81. package/src/functions/ast-transformers/enable-no-unchecked-indexed-access.mts +32 -9
  82. package/src/functions/ast-transformers/enable-no-unchecked-indexed-access.test.mts +76 -22
  83. package/src/functions/ast-transformers/readonly-transformer-helpers/group-union-types.mts +8 -1
  84. package/src/functions/functions/has-call-or-construct-signature.mts +120 -0
  85. package/src/functions/functions/index.mts +1 -0
  86. package/src/functions/functions/wrap-with-parentheses.mts +32 -17
package/README.md CHANGED
@@ -110,6 +110,28 @@ type User2 = Readonly<{
110
110
  friendIds: readonly number[];
111
111
  mut_items: string[]; // Not made readonly due to 'mut_' prefix
112
112
  }>;
113
+
114
+ // A type literal that declares a call or construct signature is marked
115
+ // `readonly` member by member rather than wrapped, because `Readonly<T>` is a
116
+ // mapped type over `keyof T` and neither signature kind survives it.
117
+
118
+ // Before
119
+ type Parse = {
120
+ (input: string): string[];
121
+
122
+ (input: string, strict: boolean): string[] | undefined;
123
+
124
+ separators: string[];
125
+ };
126
+
127
+ // After (still callable; only the members inside it changed)
128
+ type Parse2 = {
129
+ (input: string): readonly string[];
130
+
131
+ (input: string, strict: boolean): readonly string[] | undefined;
132
+
133
+ readonly separators: readonly string[];
134
+ };
113
135
  ```
114
136
 
115
137
  For more detailed transformation examples, see the [test file](https://github.com/noshiro-pf/mono/blob/main/libs/ts-codemod-lib/src/functions/ast-transformers/convert-to-readonly.test.mts) which covers various scenarios including complex types, nested structures, and DeepReadonly transformations.
@@ -1,24 +1,2 @@
1
- export { appendAsConstTransformer } from './functions/ast-transformers/append-as-const.mjs';
2
- export { convertInterfaceToTypeTransformer } from './functions/ast-transformers/convert-interface-to-type.mjs';
3
- export { convertToReadonlyTransformer } from './functions/ast-transformers/convert-to-readonly.mjs';
4
- export { enableNoUncheckedIndexedAccessTransformer } from './functions/ast-transformers/enable-no-unchecked-indexed-access.mjs';
5
- export { compareUnionIntersectionTypes } from './functions/ast-transformers/readonly-transformer-helpers/compare-union-types.mjs';
6
- export { invalidDeepReadonlyTypeName } from './functions/ast-transformers/readonly-transformer-helpers/constants.mjs';
7
- export { groupUnionIntersectionTypes } from './functions/ast-transformers/readonly-transformer-helpers/group-union-types.mjs';
8
- export { nextReadonlyContext } from './functions/ast-transformers/readonly-transformer-helpers/readonly-context.mjs';
9
- export { replaceAnyWithUnknownTransformer } from './functions/ast-transformers/replace-any-with-unknown.mjs';
10
- export { replaceRecordWithUnknownRecordTransformer } from './functions/ast-transformers/replace-record-with-unknown-record.mjs';
11
- export { transformSourceCode } from './functions/ast-transformers/transform-source-code.mjs';
12
- export { IGNORE_FILE_COMMENT_PREFIXES, IGNORE_LINE_COMMENT_PREFIXES } from './functions/constants/ignore-comment-text.mjs';
13
- export { hasDisableNextLineComment } from './functions/functions/has-disable-next-line-comment.mjs';
14
- export { isAsConstNode } from './functions/functions/is-as-const-node.mjs';
15
- export { isAtomicTypeNode } from './functions/functions/is-atomic-type-node.mjs';
16
- export { isConditionalTypeDistributionGuard } from './functions/functions/is-conditional-type-distribution-guard.mjs';
17
- export { isReadonlyArrayTypeNode, isReadonlyTupleOrArrayTypeNode, isReadonlyTupleTypeNode, isReadonlyTypeReferenceNode, isShallowReadonlyTypeNode } from './functions/functions/is-readonly-node.mjs';
18
- export { isSpreadNamedTupleMemberNode, isSpreadParameterNode } from './functions/functions/is-spread-parameter-node.mjs';
19
- export { removeParentheses } from './functions/functions/remove-parentheses.mjs';
20
- export { shouldAvoidParenthesesForReadonly } from './functions/functions/should-avoid-parentheses-for-readonly.mjs';
21
- export { unwrapReadonlyTypeArgText } from './functions/functions/unwrap-readonly.mjs';
22
- export { wrapWithParentheses } from './functions/functions/wrap-with-parentheses.mjs';
23
- export { replaceNodeWithDebugPrint } from './functions/utils/replace-with-debug.mjs';
24
- //# sourceMappingURL=entry-point.mjs.map
1
+ export * from './index.mjs';
2
+ //# sourceMappingURL=entry-point.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"entry-point.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"entry-point.mjs","sourceRoot":"","sources":["../src/entry-point.mts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC"}