question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Angular 2 compilation works with tsc and ngc but not tsickle

See original GitHub issue

I’m new to build tools in general, so I’m probably making a silly error. Ask for more info and I’ll provide.

I have an Angular 2 application written in typsecript 2. I can use tsc to compile it without problem. I’m now trying to optimize:

Typescript >> Ahead-of-Time compiler (ngc) >> tsickle >> google-closure-compiler-js

My dev/main.ts (bootstrap file for my Angular 2 app):

1| //import dependencies (core-js, zone.js, reflect-metadata)
2| import 'core-js';
3| import 'reflect-metadata';
4| import 'zone.js';
5| // AHEAD-OF-TIME COMPILATION
6| import {platformBrowser} from '@angular/platform-browser';
7| import {AppModuleNgFactory} from '../aot/dev/app/app.module.ngfactory' //generated code
8| platformBrowser().bootstrapModuleFactory(AppModuleNgFactory);

After I’ve run ngc (successfully), I’m not sure how to properly use tsickle. I’ve tried:

"node_modules/.bin/tsickle" -- -p ./

Error at /dev/main.ts:6:9: Import declaration conflicts with local declaration of ‘platformBrowser’ Error at /dev/main.ts:7:24: Cannot find name ‘NeverTypeCheckMe’. Error at /dev/main.ts:7:43: Block-scoped variable ‘platformBrowser’ used before its declaration. Error at /dev/main.ts:8:9: Import declaration conflicts with local declaration of ‘AppModuleNgFactory’ Error at /dev/main.ts:9:27: Cannot find name ‘NeverTypeCheckMe’. Error at /dev/main.ts:9:46: Block-scoped variable ‘AppModuleNgFactory’ used before its declaration.

What’s causing these errors? There is no local declaration, so how can it conflict with imports?

tsconfig.json

{
  "compilerOptions": {
    "target": "es5",
    "module": "es2015",
    "moduleResolution": "node",
    "sourceMap": true,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "removeComments": false,
    "noImplicitAny": false,
    "outDir": "./dist",
    "baseUrl": "."
  },
  "compileOnSave": false,
  "files": ["./dev/main.ts","./dev/app/custom.typings.d.ts"]
}

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
RoxKillycommented, Oct 11, 2016

I was able to get the contents of build/ and node_modules/ directories by:

  1. Cloning this repository
  2. Running npm install
  3. Running gulp task compile

I then copied the two directories and replaced the matching dirs in my project:

  • node_modules/tsickle/build
  • node_modules/tsickle/node_modules

Once I succeeded, The compilation completed without raising any error.

0reactions
DustinWehrcommented, Oct 28, 2016

@RoxKilly I would’ve given up had I not read your comments. Still haven’t succeeded though.

update: Ah, I wasn’t using the local project version of tsickle.

Read more comments on GitHub >

github_iconTop Results From Across the Web

ngc fails when used with recent tsickle versions · Issue #43220
The tsickle failure appears to be a compatibility issue with how compiler-cli invokes tsickle, where the provided host is not up-to-date with ...
Read more >
Angular compiler options
The ngc command is just a wrapper around TypeScript's tsc compiler command and is primarily configured via the tsconfig. json configuration options documented ......
Read more >
Angular: ngc or tsc? - typescript - Stack Overflow
tsc is a TypeScript compiler, and you need it to generate JavaScript if your app is written in TypeScript. ngc is an Angular-specific...
Read more >
@bazel/typescript - npm
tsc is the TypeScript compiler published by the team at Microsoft. You can call it without any custom Bazel rules. To use this...
Read more >
bazel/typescript rules - Jaya Dewata
We will silently fallback to non-worker mode on Windows regardless of the value of this attribute. tsc = "@npm//@angular/compiler-cli/bin:ngc" It also ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found