@mutates/core 0.2.0 → 0.3.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mutates/core",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
4
  "keywords": [
5
5
  "typescript",
6
6
  "ast",
@@ -1,4 +1,6 @@
1
1
  export * from './add-imports';
2
2
  export * from './edit-imports';
3
+ export * from './get-import-refs';
3
4
  export * from './get-imports';
5
+ export * from './get-named-imports';
4
6
  export * from './remove-imports';
@@ -3,6 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
4
  tslib_1.__exportStar(require("./add-imports"), exports);
5
5
  tslib_1.__exportStar(require("./edit-imports"), exports);
6
+ tslib_1.__exportStar(require("./get-import-refs"), exports);
6
7
  tslib_1.__exportStar(require("./get-imports"), exports);
8
+ tslib_1.__exportStar(require("./get-named-imports"), exports);
7
9
  tslib_1.__exportStar(require("./remove-imports"), exports);
8
10
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../packages/core/src/lib/imports/index.ts"],"names":[],"mappings":";;;AAAA,wDAA8B;AAC9B,yDAA+B;AAC/B,wDAA8B;AAC9B,2DAAiC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../packages/core/src/lib/imports/index.ts"],"names":[],"mappings":";;;AAAA,wDAA8B;AAC9B,yDAA+B;AAC/B,4DAAkC;AAClC,wDAA8B;AAC9B,8DAAoC;AACpC,2DAAiC"}
@@ -6,11 +6,13 @@ const utils_1 = require("../../utils");
6
6
  function getDeclarationEditor() {
7
7
  return function editDeclarations(declarations, editor) {
8
8
  (0, utils_1.coerceArray)(declarations).forEach((declaration) => {
9
- const newStructure = Object.assign({}, declaration.getStructure(),
10
- // TODO: refactor it to support new typings
11
9
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
12
10
  // @ts-ignore
13
- editor(declaration.getStructure(), declaration));
11
+ const result = editor(declaration.getStructure(), declaration);
12
+ if (!result) {
13
+ return;
14
+ }
15
+ const newStructure = Object.assign({}, declaration.getStructure(), result);
14
16
  // todo: see https://github.com/dsherret/ts-morph/issues/882
15
17
  // if the issue is resolved code will be remove
16
18
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
@@ -1 +1 @@
1
- {"version":3,"file":"get-declaration-editor.js","sourceRoot":"","sources":["../../../../../../../packages/core/src/lib/utils/helpers/get-declaration-editor.ts"],"names":[],"mappings":";;;AAAA,uCAA2C;AAG3C,uCAA0C;AAK1C,SAAgB,oBAAoB;IAIlC,OAAO,SAAS,gBAAgB,CAC9B,YAAyC,EACzC,MAA8D;QAE9D,IAAA,mBAAW,EAAC,YAAY,CAAC,CAAC,OAAO,CAAC,CAAC,WAAW,EAAE,EAAE;YAChD,MAAM,YAAY,GAAG,MAAM,CAAC,MAAM,CAChC,EAAE,EACF,WAAW,CAAC,YAAY,EAAE;YAC1B,2CAA2C;YAC3C,6DAA6D;YAC7D,aAAa;YACb,MAAM,CAAC,WAAW,CAAC,YAAY,EAAE,EAAE,WAAW,CAAC,CAClC,CAAC;YAEhB,4DAA4D;YAC5D,+CAA+C;YAC/C,6DAA6D;YAC7D,mBAAmB;YACnB,IAAI,oBAAS,CAAC,OAAO,CAAC,YAAY,CAAC,IAAI,eAAI,CAAC,YAAY,CAAC,WAAW,CAAC,EAAE,CAAC;gBACtE,WAAW,CAAC,MAAM,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;gBACtC,6DAA6D;gBAC7D,kBAAkB;gBAClB,OAAO,YAAY,CAAC,IAAI,CAAC;YAC3B,CAAC;YAED,WAAW,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;QAChC,CAAC,CAAC,CAAC;IACL,CAAC,CAAC;AACJ,CAAC;AAhCD,oDAgCC"}
1
+ {"version":3,"file":"get-declaration-editor.js","sourceRoot":"","sources":["../../../../../../../packages/core/src/lib/utils/helpers/get-declaration-editor.ts"],"names":[],"mappings":";;;AAAA,uCAA2C;AAG3C,uCAA0C;AAK1C,SAAgB,oBAAoB;IAIlC,OAAO,SAAS,gBAAgB,CAC9B,YAAyC,EACzC,MAA8D;QAE9D,IAAA,mBAAW,EAAC,YAAY,CAAC,CAAC,OAAO,CAAC,CAAC,WAAW,EAAE,EAAE;YAChD,6DAA6D;YAC7D,aAAa;YACb,MAAM,MAAM,GAAG,MAAM,CAAC,WAAW,CAAC,YAAY,EAAE,EAAE,WAAW,CAAC,CAAC;YAE/D,IAAI,CAAC,MAAM,EAAE,CAAC;gBACZ,OAAO;YACT,CAAC;YAED,MAAM,YAAY,GAAG,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,WAAW,CAAC,YAAY,EAAE,EAAE,MAAM,CAAe,CAAC;YAEzF,4DAA4D;YAC5D,+CAA+C;YAC/C,6DAA6D;YAC7D,mBAAmB;YACnB,IAAI,oBAAS,CAAC,OAAO,CAAC,YAAY,CAAC,IAAI,eAAI,CAAC,YAAY,CAAC,WAAW,CAAC,EAAE,CAAC;gBACtE,WAAW,CAAC,MAAM,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;gBACtC,6DAA6D;gBAC7D,kBAAkB;gBAClB,OAAO,YAAY,CAAC,IAAI,CAAC;YAC3B,CAAC;YAED,WAAW,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;QAChC,CAAC,CAAC,CAAC;IACL,CAAC,CAAC;AACJ,CAAC;AAjCD,oDAiCC"}
@@ -2,4 +2,4 @@ import type { FilterPrimitive } from '../types/filter-primitive';
2
2
  import type { StructureType } from '../types/structure-type';
3
3
  import type { StructuredStatement } from '../types/structured-statement';
4
4
  import { OptionalKind } from './optional-kind';
5
- export type StructureEditor<Declaration extends StructuredStatement<Declaration>, Structure extends OptionalKind<StructureType<Declaration>> = OptionalKind<StructureType<Declaration>>, UpdatableData extends FilterPrimitive<Structure> = FilterPrimitive<Structure>> = (structure: Structure, declaration: Declaration) => Partial<UpdatableData>;
5
+ export type StructureEditor<Declaration extends StructuredStatement<Declaration>, Structure extends OptionalKind<StructureType<Declaration>> = OptionalKind<StructureType<Declaration>>, UpdatableData extends FilterPrimitive<Structure> = FilterPrimitive<Structure>> = (structure: Structure, declaration: Declaration) => Partial<UpdatableData> | void;