Skip to content

"ng destroy component" doesn't remove the "import" statement from "app.module.ts", nor does it remove the component from the declarations array #1788

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
NgxDev opened this issue Aug 21, 2016 · 10 comments

Comments

@NgxDev
Copy link

NgxDev commented Aug 21, 2016

When generating a component, the CLI makes necessary changes to "app.module.ts".
I would expect that destroying a component should accomplish the opposite (remove files, remove that import statement and also remove that component from the declarations array on the @NgModule decorator).

angular-cli: 1.0.0-beta.11-webpack.2
node: 6.4.0
os: win32 x64
@NgxDev NgxDev changed the title "ng destroy component" doesn't remove the "import" statement from "app.module.ts" "ng destroy component" doesn't remove the "import" statement from "app.module.ts", nor does it remove the component from the declarations array Aug 21, 2016
@filipesilva
Copy link
Contributor

We don't really support destroying generated stuff, it's a remnant from ember-cli functionality. We'll try to remove it from ng help in #1807.

@timondavis
Copy link

It seems to me that if the automated inclusion routine edits a given file, the automation removal routine should remove the edits on that same file. Either that, or the deletion routine should be scrapped. Inconsistent behavior will likely lead to confusion and not convenience.

@elvisbegovic
Copy link
Contributor

@filipesilva why not add support ng destroy ? it's realy helpfull and it works just import from *.module.ts doesn't removed, will be nice to get a look here

@filipesilva
Copy link
Contributor

It's more than just removing imports. There's usually more code than that added, and users might have modified it further after the generator did it's job. So we can't determine well what should be removed.

@elvisbegovic
Copy link
Contributor

ok then you can destroy only if you create by error without and modification, as me 5min ago. I just created and directly ng destroy c header ... by this way only import doesn't work ! but anyway this is "nice to have feature" better perform angular-cli command because it's a little slow right now,

thanks for reply

@inigopascall
Copy link

I agree, it's a pain in the ass when you create the component with an error in the name and just want to immediately delete...

@tomeastmanjr
Copy link

tomeastmanjr commented Feb 1, 2017

100% agree. I just created a test component for testing using
$ ng g component chartJS-charts
I did not pay attention to when it saved as chart-js-charts. I then immediately created a new component using
$ ng g component chartJS-charts/bar-charts
This created a new fileless component actually titled chartJS-charts with a child/sub component titled bar-charts.

All I want to do is go remove one of the duplicates in an automated way so that I can keep clean organization going forward.

@judasane
Copy link

100% agree too. It would be really helpful to have a command to destroy components, so we can delete them keeping the code clean

@navidRashik
Copy link

navidRashik commented Oct 20, 2018

I would like to see this feature in future !!!

@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 8, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants