Argument of type 'Http' is not assignable to parameter of type 'Http'
See original GitHub issueI’m submitting a … (check one with “x”)
[x] bug report => search github for a similar issue or PR before submitting
[ ] feature request
[ ] support request => Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question
Current behavior
class RESTClient {
constructor(@Inject(Http) protected http: Http){
}
//Some code
}
@Injectable()
@BaseUrl("https://api.github.com/")
export class ReposService extends RESTClient{
apiUrl: string = "https://api.github.com/";
constructor(private _http: Http){
super(_http)
}
@GET("orgs/angular/repos")
list(){
return null;
}
}
Above code is throwing following error:
error TS2345: Argument of type 'Http' is not assignable to parameter of type 'Http'.
Property '_backend' is protected but type 'Http' is not a class derived from 'Http'.
Expected behavior
Reproduction of the problem
What is the motivation / use case for changing the behavior?
Please tell us about your environment:
macOS Sierra, atom, npm
-
Angular version: 2.0.0
-
Browser: [all | Chrome XX | Firefox XX | IE XX | Safari XX | Mobile Chrome XX | Android X.X Web Browser | iOS XX Safari | iOS XX UIWebView | iOS XX WKWebView ]
-
Language: TypeScript 1.8.10
-
Node (for AoT issues):
node --version
= 6.3.0
Issue Analytics
- State:
- Created 7 years ago
- Comments:8 (1 by maintainers)
Top Results From Across the Web
Argument of type 'Http' is not assignable to parameter of type ...
Try using HttpClient import {HttpClientModule, HttpClient} from '@angular/common/http'; import {TranslateModule ...
Read more >Argument of type 'Http' is not assignable to ... - Ionic Forum
Argument of type 'HttpClient' is not assignable to parameter of type 'Http'. Property '_backend' is missing in type 'HttpClient'.
Read more >Argument of type 'Http' is not assignable to ... - iTecNote
I'm developing an Ionic 2 mobile app and want to use ngx-translate features. Following the tutorial, I'm importing necessary files in app module...
Read more >Angular | null' is not assignable to parameter of type 'string'
The TypeScript interface for the JSON.parse() function defines a string parameter as the first argument, whereas the interface for localStorage.
Read more >Type 'Observable<Product[]>' is not assignable to type ...
Btw I want to use HttpClient, not Http, and the mapping should be done automatically by using the get<type>("api/route"); syntax, right?
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@vicb This is still an issue. As you wrote above Http is imported from a different location:
Is there no workaround for this? I have created this for reproduction.
Edit: Sorry i used a different account back then - I am also st3h3n.
Indeed, when using npm link your dependency tree looks like this:
A solution would be to add @angular/http as peerDependency in myModule. But then when developing myModule IntelliSense would complain about not finding @angular/http.