Open jianzhou520 opened 3 weeks ago
Hi @jianzhou520
Which version of the extension do you have?
I'm not able to reproduce the issue you describe. forwardRef
is not removed, but Injectable
is.
I'm getting a SyntaxError Leading decorators must be attached to a class declaration
Hi @kcmr Our team are now using v1.2.4, there is more complete code:
import { forwardRef, Inject, Injectable } from '@nestjs/common'
@Injectable()
export class AutoSaveTestService {
constructor(
@Inject(forwardRef(() => TestRemoveService))
){}
}
Hi @jianzhou520
I couldn't get the code you provided to work, but I have a similar use case in these tests: https://github.com/kcmr/vsce-remove-unused-imports/blob/master/__tests__/transform.spec.js#L101-L104.
I'm not familiar with Angular code and can't confirm its correctness, but could the following refactor potentially solve your issue? This way, the import won't be removed:
import { forwardRef, Inject, Injectable } from '@nestjs/common'
const testRemoveService = forwardRef(() => TestRemoveService);
@Injectable()
export class AutoSaveTestService {
constructor(
@Inject(testRemoveService) public readonly testRemoveService: TestRemoveService
){}
}
I'm using this plugin in our NestJS projects, in many tims it works well, but misunderstand the following code
after save