@travetto/transformer 3.0.0-rc.0 → 3.0.0-rc.1

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,7 +1,7 @@
1
1
  {
2
2
  "name": "@travetto/transformer",
3
3
  "displayName": "Transformation",
4
- "version": "3.0.0-rc.0",
4
+ "version": "3.0.0-rc.1",
5
5
  "description": "Functionality for AST transformations, with transformer registration, and general utils",
6
6
  "keywords": [
7
7
  "typescript",
package/src/state.ts CHANGED
@@ -164,9 +164,9 @@ export class TransformerState implements State {
164
164
  * Get list of all #decorators for a node
165
165
  */
166
166
  getDecoratorList(node: ts.Node): DecoratorMeta[] {
167
- return (node.decorators ?? [])
167
+ return ts.canHaveDecorators(node) ? (ts.getDecorators(node) ?? [])
168
168
  .map(dec => this.getDecoratorMeta(dec))
169
- .filter(x => !!x.ident);
169
+ .filter(x => !!x.ident) : [];
170
170
  }
171
171
 
172
172
  /**
@@ -24,11 +24,14 @@ export class DecoratorUtil {
24
24
  /**
25
25
  * Replace or add a decorator to a list of decorators
26
26
  */
27
- static spliceDecorators(node: ts.Node, target: ts.Decorator | undefined, replacements: ts.Decorator[], idx = -1): ts.Decorator[] {
27
+ static spliceDecorators(node: ts.Node, target: ts.Decorator | undefined, replacements: ts.Decorator[], idx = -1): ts.ModifierLike[] {
28
+ if (!ts.canHaveDecorators(node)) {
29
+ return [];
30
+ }
28
31
  if (idx < 0 && target) {
29
- idx = node.decorators?.indexOf(target) ?? -1;
32
+ idx = node.modifiers?.indexOf(target) ?? -1;
30
33
  }
31
- const out = (node.decorators ?? []).filter(x => x !== target);
34
+ const out = (node.modifiers ?? []).filter(x => x !== target);
32
35
  if (idx < 0) {
33
36
  out.push(...replacements);
34
37
  } else {