voliva / angular2-interceptors

79 stars 20 forks source link

Problem importing intercepted-request.ts and intercepted-response.ts #2

Closed esneivro closed 7 years ago

esneivro commented 7 years ago

I'm having a problem building my app because it seems that import InterceptedRequest and InterceptedResponse from interceptor are not working. intercepted-request.ts and intercepted-response.ts doesn't exists.

Maybe it'll be better import InterceptedRequest and InterceptedResponse using (no use sufix .ts):

import { InterceptedRequest } from "./intercepted-request"; import { InterceptedResponse } from "./intercepted-response";

I'm not sure if it's a problem with my building system...

esneivro commented 7 years ago

Seems to be that provideInterceptorService is not exported too. I've manually modified index.js to include a reference to interceptor-provider (provideInterceptorService)

voliva commented 7 years ago

Right, sorry... For some reason it works in my environment but seems broken to everyone else. @nsmgr8 made a fork here that should fix the issue: https://github.com/nsmgr8/angular2-interceptors. I'll pull, test & update it as soon as I can.

voliva commented 7 years ago

@esneivro Should be fixed with latest commit https://github.com/voliva/angular2-interceptors/commit/9e6a4107841a8dff0189fd701da990cf13b9e4f8. It's published in npm as version 1.1.1, can you try it out?

RomanFrom710 commented 7 years ago

@voliva I have the same issue too, even after your fix.

telran commented 7 years ago

Please remove .ts from your imports. Thanks :)

.../node_modules/ng2-interceptors/lib/interceptor.d.ts(1,36): error TS2691: An import path cannot end with a '.ts' extension. Consider importing './intercepted-request' instead. .../node_modules/ng2-interceptors/lib/interceptor.d.ts(2,37): error TS2691: An import path cannot end with a '.ts' extension. Consider importing './intercepted-response' instead. [10:00:00] TypeScript: 2 semantic errors [10:00:00] TypeScript: emit succeeded (with errors)

voliva commented 7 years ago

@telran Done :) TS2.0 thing. Released in version 1.1.2 @RomanFrom710 I tried in many environments but I can't reproduce your issue, have you tried installing it by NPM?

npm install ng2-interceptors --save

Then you should be able to import everything as

import { provideInterceptorService, Interceptor, InterceptedRequest } from 'ng2-interceptors'; // etc

At least, it should work if you have a proper tsconfig.json... I use the one that Angular2 CLI generates.

RomanFrom710 commented 7 years ago

@voliva it has started working after your last commit. Thanks for such a useful lib! :)