Skip to content

ng xi18n doesn't report typescript errors #8065

Closed
@ocombe

Description

@ocombe

Bug Report or Feature Request (mark with an x)

- [x] bug report

Versions.

Angular CLI: 1.5.0-rc.0 (e)
Node: 6.9.5
OS: win32 x64
Angular: 5.0.0-rc.2
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router

@angular/cli: 1.5.0-rc.0
@angular-devkit/build-optimizer: 0.0.27
@angular-devkit/core: 0.0.20
@angular-devkit/schematics: 0.0.33
@ngtools/json-schema: 1.1.0
@ngtools/webpack: 1.8.0-rc.0
@schematics/angular: 0.0.45
typescript: 2.3.3
webpack-concat-plugin: 1.4.0
webpack-dev-server: 2.7.1
webpack: 3.7.1

Repro steps.

Create a new app with the cli 1.5.0-rc.0 but skip install. Update Angular dependencies to 5.0.0-rc.2, but don't update typescript (keep ~2.3.3).
Update your component to add a i18n attribute on some text. For example: <h1 i18n>Welcome to {{title}}!</h1>.
Add the following command to your package.json file: "extract": "ng xi18n -f xlf -l en --of messages.xlf -op src/i18n" and start it with npm run extract.
The app is compiled and... nothing happens. The translations are not extracted.

The log given by the failure.

There is no log and that is the problem. The actual error is:

Error: The Angular Compiler requires TypeScript >= 2.4.\n    at new AngularCompilerProgram (C:\\www\\i18n-no-cli\\node_modules\\@angular\\compiler-cli\\src\\transformers\\program.js:61:19)\n    at Object.exports.createProgram (C:\\www\\i18n-no-cli\\node_modules\\@angular\\compiler-cli\\src\\transformers\\program.js:650:12)\n    at Object.createProgram (C:\\www\\i18n-no-cli\\node_modules\\@angular\\compiler-cli\\src\\ngtools_api2.js:27:22)\n    at AngularCompilerPlugin._createOrUpdateProgram (C:\\www\\i18n-no-cli\\node_modules\\@ngtools\\webpack\\src\\angular_compiler_plugin.js:234:43)\n    at _donePromise.Promise.resolve.then.then (C:\\www\\i18n-no-cli\\node_modules\\@ngtools\\webpack\\src\\angular_compiler_plugin.js:459:29)

But it is not reported. If you go to this line:

const callback: webpack.compiler.CompilerCallback = (err, stats) => {
then you can see that err is null, but if you log the stats object you will see the errors.
Also the .catch method line 53 is called but err is undefined so nothing happens (I'm not sure if it is related).

Desired functionality.

It should log the error to the console and fail the extraction instead of looking like everything worked.

Metadata

Metadata

Assignees

Labels

P1Impacts a large percentage of users; if a workaround exists it is partial or overly painfultype: bug/fix

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions