Skip to content
This repository has been archived by the owner on Jan 4, 2022. It is now read-only.

Cannot find name 'ProxyHandler'. #24

Closed
jorawarsingh opened this issue Oct 21, 2016 · 10 comments
Closed

Cannot find name 'ProxyHandler'. #24

jorawarsingh opened this issue Oct 21, 2016 · 10 comments

Comments

@jorawarsingh
Copy link

Any guess what it can be? i am using webstorm and if i do ctrl+click on ProxyHandler i can go to the declaration in typescript/lib/lib.es2015.proxy.d.ts

@gund
Copy link
Owner

gund commented Oct 21, 2016

That's totally fine since class ProxyHandler is part of standard library and it's location in file like that can tell you about it.

@jorawarsingh
Copy link
Author

Yes but i am getting this as error and it interceptor is not working. i am getting this error as well in browser cannot find name proxyhandler. i am using webpack.

@gund
Copy link
Owner

gund commented Oct 22, 2016

Well that's interesting. Are you using it in project generated via angular-cli?
Maybe you can share your tsconfig.json?

@dondimon
Copy link

I'm getting same issue - using Angular 2.1.1... can't build either.. can't build with either tsc or visual studio TS compiler.

node_modules/ng2-http-interceptor/dist/http/interceptable-http-proxy.service.d.ts(3,63): error TS2304: Cannot find name 'ProxyHandler'.

@gund
Copy link
Owner

gund commented Oct 22, 2016

Well as far as I can see it seems that your TS compiler does not support ES6 typings.
You can try to upgrade it to version 2.0.1.
Or if that does not help you can go and get this typing file, put it in your project and reference in your entry point *.ts file.

@jorawarsingh
Copy link
Author

I'm targeting es5. I have tried to target es6 but it seems to be many issues with that so till they are resolved i have to stick to es5.
microsoft/TypeScript#3215
angular/angular#4882

@gund
Copy link
Owner

gund commented Oct 24, 2016

@jorawarsingh so if you target ES5 this issue gone?

@jorawarsingh
Copy link
Author

No, still remain.

@gund
Copy link
Owner

gund commented Nov 1, 2016

Can you please try to compile with next options in tsconfig.json:
compilerOptions -> lib: ["es6", "dom"]
compilerOptions -> module: "es6"

I'm also targeting ES5 but don't have this issue so probably those settings might resolve them.

@gund
Copy link
Owner

gund commented Dec 6, 2016

Today I made use of this library in different project and experienced same issue so was able to check by myself how to fix this.
And yes compilerOptions -> lib: ["es6"] is the key point here - it tells TS compiler to include es6 type definitions in the project.

However in my particular case there where some external libs which were not able to compile with this configuration so in this case I left config as is and added next line to my custom definitions file:

declare interface ProxyHandler<T> {}

That fixed issue as well.

@gund gund closed this as completed Dec 6, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants