Skip to content

Commit

Permalink
fix: Prevent removing decorator imports used as paramters
Browse files Browse the repository at this point in the history
fixes #20 fixes #34
  • Loading branch information
kcmr committed Jun 26, 2024
1 parent 3eb3d96 commit e91a09c
Show file tree
Hide file tree
Showing 6 changed files with 363 additions and 291 deletions.
18 changes: 18 additions & 0 deletions __tests__/__snapshots__/transform.spec.js.snap
Original file line number Diff line number Diff line change
@@ -1,5 +1,23 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`does not remove parameter decorators 1`] = `
"
import { Component, Inject } from '@angular/core';
import { MAT_DIALOG_DATA } from '@angular/material/dialog';
@Component({
template: '',
styles: ['']
})
export class SomeComponent {
constructor(
@Inject(MAT_DIALOG_DATA)
public dialogData
) { }
}
"
`;

exports[`removes unused import specifiers and import declarations 1`] = `
"
import 'side-effects';
Expand Down
21 changes: 21 additions & 0 deletions __tests__/transform.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,27 @@ it('supports decorators', () => {
expect(transform(code)).toMatchSnapshot();
});

it('does not remove parameter decorators', () => {
const code = `
import { Component, Inject } from '@angular/core';
import { MAT_DIALOG_DATA } from '@angular/material/dialog';
@Component({
template: '',
styles: ['']
})
export class SomeComponent {
constructor(
@Inject(MAT_DIALOG_DATA)
public dialogData
) { }
}
`;

expect(() => transform(code)).not.toThrow();
expect(transform(code)).toMatchSnapshot();
});

it('supports "satisfies" TS keyword', () => {
const code = `
type Test = {
Expand Down
Loading

0 comments on commit e91a09c

Please sign in to comment.