Skip to content

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

Closed

Description

@HoboCannibaL

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, 
     ]
...
})

Activity

  1. dushkostanoeski commented on Feb 23, 2018

    @dushkostanoeski

    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.

  2. added and removed
    freq1: lowOnly reported by a handful of users who observe it rarely
    on Jul 19, 2018
  3. angular-automatic-lock-bot commented on Sep 8, 2019

    @angular-automatic-lock-bot

    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.

  4. locked and limited conversation to collaborators on Sep 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions