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

error gulp serving with typescript build

Open phamdt opened this issue 8 years ago • 10 comments

i installed angular 1.5 with typescript. this occurs on serve:

ERROR in ./src/app/main/main.controller.ts
(11,26): error TS2503: Cannot find namespace 'angular'.

ERROR in ./src/app/main/main.controller.ts
(21,22): error TS2503: Cannot find namespace 'angular'.

ERROR in /Users/phamdt/Documents/ui/src/app/main/main.controller.spec.ts
(4,1): error TS2304: Cannot find name 'describe'.

ERROR in /Users/phamdt/Documents/ui/src/app/main/main.controller.spec.ts
(7,3): error TS2304: Cannot find name 'beforeEach'.

ERROR in /Users/phamdt/Documents/ui/src/app/main/main.controller.spec.ts
(7,14): error TS2304: Cannot find name 'angular'.

phamdt avatar May 13 '16 02:05 phamdt

I was able to fix this issue on my project by using:

typings install angular --ambient --save

Where typings can be installed via npm.

lucasangelon avatar May 13 '16 08:05 lucasangelon

have same issue, typings install angular --ambient --save did not helped

dinuchiriac avatar May 16 '16 14:05 dinuchiriac

same issue

devakone avatar May 17 '16 16:05 devakone

Same here. Will it be fixed in some upcomming version?

UPDATE: Okay, I think, that issue is with changed DefinitelyTyped angularjs directory structure. If you search typings search angularjs, then you will see, that it doesn't provide angularjs typings, that are placed in typings.json file. That is why after generator finished app is missing required typings.

As far as I can tell, it means, that if one does select angularjs version 1.5 (stable), then he can't use TypeScript. Sadly, but so. Will try with 1.2.

jeserkin avatar Jun 03 '16 08:06 jeserkin

I was able to quick win this issue by downgrading global typing package to 0.7.9 version

michalstolinski avatar Jun 03 '16 12:06 michalstolinski

Workarounds are not suitable in this case as a permanent solution.

jeserkin avatar Jun 03 '16 13:06 jeserkin

Maybe it will be enought to update typings.json? I was able to update all typings. Since recently one needs to specify the source other than npm manually, e.g. typings install dt~angular --save --global, where [dt - typings from DefinitelyTyped (usually --global)] is. Full example of my typings.json

{
  "name": "gulpAngular",
  "version": false,
  "ambientDependencies": {
    "angular-cookies": "github:DefinitelyTyped/DefinitelyTyped/angularjs/angular-cookies.d.ts#bb051830df88f5a55dcf06b7fe85bf6b62cc97f2",
    "angular-sanitize": "github:DefinitelyTyped/DefinitelyTyped/angularjs/angular-sanitize.d.ts#bb051830df88f5a55dcf06b7fe85bf6b62cc97f2",
    "jquery": "github:DefinitelyTyped/DefinitelyTyped/jquery/jquery.d.ts#bb051830df88f5a55dcf06b7fe85bf6b62cc97f2",
    "angular-resource": "github:DefinitelyTyped/DefinitelyTyped/angularjs/angular-resource.d.ts#bb051830df88f5a55dcf06b7fe85bf6b62cc97f2",
    "angular-ui-router": "github:DefinitelyTyped/DefinitelyTyped/angular-ui-router/angular-ui-router.d.ts#bb051830df88f5a55dcf06b7fe85bf6b62cc97f2",
    "ui-bootstrap": "github:DefinitelyTyped/DefinitelyTyped/angular-ui-bootstrap/angular-ui-bootstrap.d.ts#bb051830df88f5a55dcf06b7fe85bf6b62cc97f2",
    "angular-mocks": "github:DefinitelyTyped/DefinitelyTyped/angularjs/angular-mocks.d.ts#bb051830df88f5a55dcf06b7fe85bf6b62cc97f2",
    "angular": "github:DefinitelyTyped/DefinitelyTyped/angularjs/angular.d.ts#bb051830df88f5a55dcf06b7fe85bf6b62cc97f2",
    "jasmine": "github:DefinitelyTyped/DefinitelyTyped/jasmine/jasmine.d.ts#bb051830df88f5a55dcf06b7fe85bf6b62cc97f2",
    "karma-jasmine": "github:DefinitelyTyped/DefinitelyTyped/karma-jasmine/karma-jasmine.d.ts#bb051830df88f5a55dcf06b7fe85bf6b62cc97f2",
    "moment-node": "github:DefinitelyTyped/DefinitelyTyped/moment/moment-node.d.ts#bb051830df88f5a55dcf06b7fe85bf6b62cc97f2",
    "moment": "github:DefinitelyTyped/DefinitelyTyped/moment/moment.d.ts#bb051830df88f5a55dcf06b7fe85bf6b62cc97f2"
  },
  "globalDependencies": {
    "angular": "registry:dt/angular#1.5.0+20160602160139",
    "angular-cookies": "registry:dt/angular-cookies#1.4.0+20160317120654",
    "angular-mocks": "registry:dt/angular-mocks#1.3.0+20160425155016",
    "angular-resource": "registry:dt/angular-resource#1.5.0+20160602125522",
    "angular-sanitize": "registry:dt/angular-sanitize#1.3.0+20160317120654",
    "angular-ui-bootstrap": "registry:dt/angular-ui-bootstrap#0.13.3+20160602140119",
    "angular-ui-router": "registry:dt/angular-ui-router#1.1.5+20160521151413",
    "jasmine": "registry:dt/jasmine#2.2.0+20160505161446",
    "jquery": "registry:dt/jquery#1.10.0+20160417213236",
    "karma-jasmine": "registry:dt/karma-jasmine#0.0.0+20160316155526",
    "moment": "registry:dt/moment#2.8.0+20160316155526",
    "moment-node": "registry:dt/moment-node#2.11.1+20160511043338"
  }
}

jeserkin avatar Jun 05 '16 23:06 jeserkin

@jeserkin is right on this, but he left the last part out for my setup to work. From the beginning, I went through each of the ambientDependencies and installed each one with typings install angular --global --save where angular was replaced each time. This got my typings.json to match @jeserkin's with my own components.

The important part is to make sure you do a typings i after going through your list.

To save time on the typings install process, you can string all your typings together like below: typings install --global --save angular angular-cookies angular-mocks angular-resource angular-sanitize and so on.

BAByrne avatar Jun 24 '16 13:06 BAByrne

@lucasangelon

typings ERR! deprecated The "ambient" flag is deprecated. Please use "global" instead

BTW using global flag doesn't fix the problem. Logs persist.

screen shot 2016-08-01 at 11 27 59

UPDATE

@BAByrne

To save time on the typings install process, you can string all your typings together like below: typings install --global --save angular angular-cookies angular-mocks angular-resource angular-sanitize and so on.

It seems like there's no "--ignore" flag and when one typing crashes it stops all the flow. Like @jeserkin said, I had to specify the source ( registry mirror ) for every packet. Example:

typings install dt~angular --save --global

not

typings install angular --save --global
RE-UPDATE

IT WORKED FOR ME

I don't know why but after installing all typings if you go into src/app/index.module.ts

You'll find

/// <reference path="../../typings/main.d.ts" />

Which is pointing to a file that doesn't exist ( for me ) I renamed into

/// <reference path="../../typings/index.d.ts" />

and it worked, all logs are gone 🎉

Alligatore3 avatar Aug 01 '16 09:08 Alligatore3

@Alligatore3 Your comment works for me , thanks a lot.

histfuture avatar Feb 21 '17 03:02 histfuture