Skip to content

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

Closed
@HoboCannibaL

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

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