Skip to content

Generating a component appends new code a few characters too early in module #9560

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
HoboCannibaL opened this issue Feb 8, 2018 · 2 comments · Fixed by #11978
Closed

Generating a component appends new code a few characters too early in module #9560

HoboCannibaL opened this issue Feb 8, 2018 · 2 comments · Fixed by #11978

Comments

@HoboCannibaL
Copy link

Versions

ng CLI version: 1.6.5
ng version: 5.2.1
node version: 8.9.4
npm version: 5.6.0
Windows 10 v.1703 build 15063.850

Repro steps

  • Step 1: Run Command: ng g c path/component-name
  • Step 2: Navigate to app.module.ts
  • Step 3: Observe new import statement path errors and NgModule declarations array errors

Observed behavior

import { ExistingComponent } from './path/existing.componen; <-- cut off the last two characters
import { NewComponent } from './path/subfolder/new/new.component't'; <--and added them here

@NgModule({
 ...
     declarations: [
          ...
          ExistingCompone, <-- cut off the last two characters
          NewComponentnt, <-- and again added them here
     ]
...
})


Desired behavior

Proper output:

import { ExistingComponent } from './path/existing.component'; 
import { NewComponent } from './path/subfolder/new/new.component';

@NgModule({
 ...
     declarations: [
          ...
          ExistingComponent, 
          NewComponent, 
     ]
...
})

@Brocco Brocco added area: @angular-devkit/schematics needs: more info Reporter must clarify the issue freq1: low Only reported by a handful of users who observe it rarely severity3: broken labels Feb 8, 2018
@dushkostanoeski
Copy link

This seems to be related to #9712, but I am getting this issue only if I change the encoding of the file where the module is defined. Keeping the original encoding (which Notepad++ can't detect) it works just fine.

@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.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants