Skip to content

The CLI adds the imports and declarations 3 characters too early #9712

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
dushkostanoeski opened this issue Feb 21, 2018 · 4 comments
Closed
Labels
area: @angular-devkit/schematics freq1: low Only reported by a handful of users who observe it rarely severity3: broken type: bug/fix

Comments

@dushkostanoeski
Copy link

dushkostanoeski commented Feb 21, 2018

Versions

Angular CLI: 1.7.0
Node: 9.5.0
OS: win32 x64
Angular: 5.2.5
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, platform-server, router

angular/cdk: 5.2.2
angular/cli: 1.7.0
angular/material: 5.2.2
angular-devkit/build-optimizer: 0.3.1
angular-devkit/core: 0.3.1
angular-devkit/schematics: 0.3.1
ngtools/json-schema: 1.2.0
ngtools/webpack: 1.10.0
schematics/angular: 0.3.1
schematics/package-update: 0.3.1
typescript: 2.6.2
webpack: 3.11.0

Repro steps

I am writing an app in a Cyrillic language, and the encoding of the files that the CLI generates don't support the Cyrillic characters (I am getting ��� �� ������ in the browser) so I found this powershell script:

$files = Get-ChildItem 'PATH_TO_APP_FOLDER' -Recurse | ? {Test-Path $_.FullName -PathType Leaf}
                           foreach($file in $files)
{
    $content = Get-Content $file.FullName
    $content | Out-File $file.FullName -Encoding utf8
}

that converts all the files to UTF 8 and that way I can get Cyrillic in the browser. To reproduce the issue simply create a new project, run the script (make sure that the path points to the app folder) and then add a new component to the project. Imports in the module would look something like this:

import { ChangePasswordComponent } from './dialogs/change-password/change-password.componen;
import { TestComponent } from './test/test.component't';

and the same happens with the declarations:

    ChangePasswordCompone,
    TestComponentnt

I don't know if this is connected to #2077, but never the less, changing the encoding of the module file shouldn't break the functionality of the CLI.

Desired behavior

The module shouldn't have any errors after a component is generated.

Mention any other details that might be useful (optional)

I thought it had something to do with the script, so I used Notepad++ to convert the module file to UTF8 and again I got the same result.

EDIT:
I just noticed that the import is added 3 characters too early, but the declaration only 2.

@stiofand
Copy link

stiofand commented Feb 22, 2018

I can confirm this also happens without any alternate non utf text:

ng g c new-component

result in app.module.ts:

import { NewComponentComponent } from './new-component/new-component.component'';

...

declarations: [
    AppComponen,
    NewComponentComponentt
]

Happens on OSX with two different MPS

Node: 8.9.4
OS: darwin x64
Angular: 5.2.6
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router

@angular/cli: 1.7.1
@angular-devkit/build-optimizer: 0.3.2
@angular-devkit/core: 0.3.2
@angular-devkit/schematics: 0.3.2
@ngtools/json-schema: 1.2.0
@ngtools/webpack: 1.10.1
@schematics/angular: 0.3.2
@schematics/package-update: 0.3.2
typescript: 2.5.3
webpack: 3.11.0

@dushkostanoeski
Copy link
Author

dushkostanoeski commented May 16, 2018

I got used to using the --skip-import flag and this was the first time I forgot to use it after v6 is out. The issue seems to be fixed :D

@clydin
Copy link
Member

clydin commented Jul 19, 2018

Duplicate of #9560

@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
area: @angular-devkit/schematics freq1: low Only reported by a handful of users who observe it rarely severity3: broken type: bug/fix
Projects
None yet
Development

No branches or pull requests

4 participants