x)
- [ ] new
- [x] build
- [x] serve
- [ ] test
- [ ] e2e
- [ ] generate
- [ ] add
- [ ] update
- [ ] lint
- [ ] xi18n
- [ ] run
- [ ] config
- [ ] help
- [ ] version
- [ ] doc
Not sure about this. This seems to be a reappearance of #9571.
For a const enum of type number, like const enum TestEnum { DESC = 2, }, usage of this kind TestEnum.DESC.toString(10) breaks on ng serve/build --prod.
My global environments:
node --version // v11.10.1
npm --version // 6.9.0
npm list -g --depth=0 | grep angular // @angular/[email protected]
ng new prod-build-test-proj;cd prod-build-test-proj/;src/app/app.component.ts:const enum TestBuildProd {
OPT1 = 1,
OPT2 = 2,
}
console.log(TestBuildProd.OPT1.toString(10));
npx ng build, success;npx ng build --prod, fail;
ERROR in ./src/app/app.component.ts 8:25
Module parse failed: Unexpected token (8:25)
You may need an appropriate loader to handle this file type.
| }());
| export { AppComponent };
> console.log(1 /* OPT1 */..toString(10));
|
Angular CLI: 7.3.5
Node: 11.10.1
OS: darwin x64
Angular:
...
Package Version
------------------------------------------------------
@angular-devkit/architect 0.13.5
@angular-devkit/core 7.3.5
@angular-devkit/schematics 7.3.5
@schematics/angular 7.3.5
@schematics/update 0.13.5
rxjs 6.3.3
typescript 3.2.4
Anything else relevant?
If the code was appended to main.ts then everything works normally, this error only occurs when it was appended to *.service.ts or *.component.ts;
Hi, I am sorry but this is not caused by Angular CLI, the issue here is a bug in TypeScript.
Build Optimizer use TypeScript to transform source files, and unfortunately when TypeScript encounters 1 /* OPT1 */.toString(10); it will add an addition dot.
This issue should be resolved with TypeScript 3.3.X.
Related TypeScript issue https://github.com/Microsoft/TypeScript/issues/28868
Thanks for your quick reply, I just used template string as a workaround until TS 3.3 is supported.
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._