0

I have an angular 2 beta 8 project with gulp working.

The problem is when gulp-typescript can't check the types. The gulp task is the following:

gulp.task('ts', function() {
  gulp.src('app/**/*.ts')
  .pipe(ts({
    target: 'ES6',
    emitDecoratorMetadata: true,
    experimentalDecorators: true
  }))
  .pipe(rename({ extname: '' }))
  .pipe(traceur({
      modules: 'instantiate',
      moduleName: true,
      annotations: true,
      types: true,
      memberVariables: true
  }))
  .pipe(rename({ extname: '' }))
  .pipe(gulp.dest('build'))
})

I'm compiling first to ES6, and using traceur after cause typescript show less errors. I show the shell log:

[19:23:37] Using gulpfile ~/front/gulpfile.js
[19:23:37] Starting 'dependencies'...
[19:23:37] Finished 'dependencies' after 15 ms
[19:23:37] Starting 'ts'...
[19:23:37] Finished 'ts' after 5.96 ms
[19:23:37] Starting 'html'...
[19:23:37] Finished 'html' after 1.15 ms
[19:23:37] Starting 'default'...
[19:23:37] Finished 'default' after 3.13 μs
app/app.ts(1,28): error TS2307: Cannot find module 'angular2/platform/browser'.
app/components/component.ts(1,25): error TS2307: Cannot find module 'angular2/core'.
[19:23:39] TypeScript: 2 semantic errors
[19:23:39] TypeScript: emit succeeded (with errors)

I'm wondering how can I include typescript definition files. I've tried to add this files into gulp.src like:

gulp.src(['app/**/*.ts', 'node_modules/angular2/**/*.d.ts)

But shows:Duplicated definition files errors.

I've even tried to add typing options to package.json like:

"typings": 'node_modules/angular2/platform/browser.d.ts'

But this file has imports that's not detected recursively.

So...Any advise?

The lasts versions of angular include angular2.d.ts but not this. I don't underestand why I should use typescript definition files whether angular is written in typescript.

Is it possible to import angular typescript from node_modules and compile it by typescript compiler?

1 Answer 1

1

You need to use moduleResoultion: "node" in the ts function in your gulp file. This will tell the TypeScript compiler to look for definitions in node_modules/angular2/...

Sign up to request clarification or add additional context in comments.

Comments

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.