2

I'm working on upgrading to Angular2 RC1 and I've suddenly got the following errors on a pretty simple typescript server : enter image description here

I have installed the typings I though were required and I'm building it using gulp: typings.json:

{
  "ambientDependencies": {
  "es6-collections": "registry:dt/es6-collections#0.5.1+20160316155526",
  "es6-promise": "registry:dt/es6-promise#0.0.0+20160423074304",
  "es6-shim": "registry:dt/es6-shim#0.31.2+20160317120654",
  "express": "registry:dt/express#4.0.0+20160317120654",
  "express-serve-static-core": "registry:dt/express-serve-static-core#0.0.0+20160322035842",
  "node": "registry:dt/node#4.0.0+20160505172921",
  "require": "registry:dt/require#2.1.20+20160316155526",
  "serve-static": "registry:dt/serve-static#0.0.0+20160501131543"
  }
}

gulp task for proxy building:

gulp.task('build:proxy', function () {
    var tsProject = ts.createProject('tsconfig.json');
    var tsResult = gulp.src(['proxy/**/*.ts','!proxy/typings/**/*.*'])
        .pipe(sourcemaps.init())
        .pipe(ts(tsProject))
    return tsResult.js
        .pipe(concat('proxy.js'))
        .pipe(sourcemaps.write())
        .pipe(gulp.dest('dist'))
});

and tsconfig.json:

{
  "compilerOptions": {
    "target": "es6",
    "module": "commonjs",
    "moduleResolution": "node",
    "sourceMap": true,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "removeComments": false,
    "noImplicitAny": false
  },
  "exclude": [
    "node_modules",
    "proxy/typings/main",
    "proxy/typings/main.d.ts"
  ],
  "buildOnSave": false,
  "disableCompileOnSave": true,
  "compileOnSave" : false
}    

Since everything seems to look like before I've kept my imports the same, for example import express = require('express'). I can't seem to figure out what I have to do to get those modules in.

4
  • Have you checked typings/main.d.ts? Commented May 10, 2016 at 13:35
  • does your source ts files reside inside proxy\<another folder>\ts files? Commented May 10, 2016 at 16:20
  • @Zen Yes, it looks good! Commented May 10, 2016 at 16:23
  • @MadhuRanjan Only have one ts file called proxy.ts inside the proxy folder. I've also tried moving everything to the root folder but same problems. Commented May 10, 2016 at 16:23

2 Answers 2

1

Put a new main.d.ts inside proxy folder with below content

 /// <reference path="./typings/main.d.ts" />
Sign up to request clarification or add additional context in comments.

1 Comment

Tried it, with that I'm getting duplicate identifier ( also tried excluding the main.d.ts in typings from tsconfig and still getting the duplicate error).
1

I answered on the GitHub issue (https://github.com/typings/typings/issues/491). In summary, you need to correct the gulp.src() call to not ignore all typings and only ignore either main or browser typings. E.g. gulp.src(['proxy/**/*.ts', '!proxy/typings/main/**', '!proxy/typings/main.d.ts'].

1 Comment

I have question about an npm package that you published. Are you willing to help resolve it? Here is the link: stackoverflow.com/questions/38162115/…

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.