generator-gulp-angular icon indicating copy to clipboard operation
generator-gulp-angular copied to clipboard

Standard TS file reference doesn't seam to work

Open TomaszScisloGS opened this issue 10 years ago • 9 comments

When generator-gulp-angular moved to ES6 modules does such reference at the begging of TS is still valid:

reference path="some other ts file"

I cannot make the application to work when I use my references... Is internal module TS concept (http://www.typescriptlang.org/Handbook#modules-splitting-across-files) still supported with current configuration with ES6 modules?

TomaszScisloGS avatar Nov 24 '15 12:11 TomaszScisloGS

+1

tscislo avatar Nov 24 '15 21:11 tscislo

When I made the move, I didn't succeed importing the typings with an ES6 import. The TS reference notations worked in the other hand. Does it stopped working out of the box? It could be possible if a TS version upgrade deprecates the reference notation...

Swiip avatar Nov 26 '15 08:11 Swiip

OK so there are two issues

  1. References stopped working out of the box. I do not suppose that TypeScript 1.6.2 which is now in the project deprecates them. According to TS documentation they are fully backward compatible with this. For sure this worked for generator prior to version 1.0.0.
  2. That's true that after adding ES6 import typings work in a very strange manner. For example they work fine when I import modules into index.module.ts.

This in index.module.ts works perfectly: import { RouterConfig as GsRouterConfig } from './modules/gs/routing';

./modules/gs/routing.ts has standard dependencies:

export function RouterConfig($stateProvider:ng.ui.IStateProvider, $urlRouterProvider:ng.ui.IUrlRouterProvider) {

But on the other hand when in index.module.ts I import some other module like this:

import trades from './modules/trades/trades';

And in ./modules/trades/trades.ts I import exactly the same /modules/gs/routing like this import { RouterConfig as GsRouterConfig } from './routing';

It gives me the following error when I launch the application: Uncaught Error: [$injector:modulerr] Failed to instantiate module gsWebDetailsPanel due to: Error: [$injector:modulerr] Failed to instantiate module trades due to: Error: [$injector:unpr] Unknown provider: $stateProvider

TS compiles fine though... any ideas?

TomaszScisloGS avatar Nov 26 '15 09:11 TomaszScisloGS

That doesn't look like a TS error. It looks like a Angular's dependency injection error. It fails to find a $state service. Did you load ui router (script and module) well?

Swiip avatar Nov 26 '15 11:11 Swiip

I know it's Angular dep injection error, but please read all the above. There is one case in which dependency works and one in which it doesn't. I described in details above.

Thanks!

TomaszScisloGS avatar Nov 26 '15 11:11 TomaszScisloGS

Ok sorry, don't you want a relative path in this import ? import { RouterConfig as GsRouterConfig } from 'routing'; -> import { RouterConfig as GsRouterConfig } from './routing';

As it is, it will search for a lib routing.

Swiip avatar Nov 26 '15 11:11 Swiip

There was a typo above, I'm using: import { RouterConfig as GsRouterConfig } from './routing';

TomaszScisloGS avatar Nov 26 '15 11:11 TomaszScisloGS

arf ^^

With the failing version, there is any error in the console during the TS compilation?

Swiip avatar Nov 26 '15 12:11 Swiip

Unfortunately there isn't. It's so problematic because TS compilation ends with success and the application fails to start with the above error in console.

TomaszScisloGS avatar Nov 26 '15 13:11 TomaszScisloGS