Angular2 and TypeScript: error TS2322: Type 'Response' is not assignable to type 'UserStatus' : <p>I'm playing with Angular2 and TypeScript and it's not going well (this would be so easy in AngularJS). I'm writing a little experiment app to get to grips with it all and I have the following component as my main / top level component...</p>

<pre><code>import {Component, OnInit} from 'angular2/core';
import {RouteConfig, ROUTER_DIRECTIVES} from 'angular2/router';
import {UserData} from './services/user-data/UserData';
import {Home} from './components/home/home';
import {UserStatus} from './types/types.ts';
import {Http, Headers, Response} from 'angular2/http';

@Component({
    selector: 'app', // &lt;app&gt;&lt;/app&gt;
    providers: [...FORM_PROVIDERS],
    directives: [...ROUTER_DIRECTIVES],
    template: require('./app.html')
})
@RouteConfig([
    {path: '/', component: Home, name: 'Home'},
    // more routes here....
])

export class App {

    userStatus: UserStatus;

    constructor(public http: Http) {
    }

    ngOnInit() {

        // I want to obtain a user Profile as soon as the code is initialised
        var headers = new Headers();
        headers.append('Content-Type', 'application/json');
        this.http.get('/restservice/userstatus', {headers: headers})
            .subscribe(
            (data: Response) =&gt; {
                data = JSON.parse(data['_body']);
                this.userStatus = data;
            },
            err =&gt; console.log(err), // error
            () =&gt; console.log('getUserStatus Complete') // complete
        );
    }    
}
</code></pre>

<p>Now when the top level component is bootstrapped / initialised I want to make a call to a phoney REST service (/restservice/userstatus) I set up that returns an object that I have made into a type like so (this is from <code>import {UserStatus} from './types/types.ts'</code>):</p>

<pre><code>export class UserStatus {

    constructor (
        public appOS?: any , // can be null
        public firstName: string,
        public formerName?: any, // can be null
        public fullPersId: number,
        public goldUser: boolean,
        public hasProfileImage: boolean,
        public hideMoblieNavigationAndFooter: boolean,
        public persId: string,
        public profileName: string,
        public profilePicture: string,
        public showAds: boolean,
        public siteId:  number,
        public url: string,
        public verified: boolean
    ) {

    }
}
</code></pre>

<p>Now the <code>appOS</code> and <code>formerName</code> properties could potentially be <code>null</code> and when serving up the response in my REST service they are, the JSON object looks like so:</p>

<pre><code>{
    appOS: null,
    firstName: "Max",
    formerName: null,
    fullPersId: 123456789,
    goldUser: true,
    hasProfileImage: true,
    hideMoblieNavigationAndFooter: false,
    persId: "4RUDIETMD",
    profileName: "Max Dietmountaindew",
    profilePicture: "http://myurl.com/images/maxdietmountaindew.jpg",
    showAds: true,
    siteId: 1,
    url: "/profile/maxdietmountaindew",
    verified: true
}
</code></pre>

<p>So the data structure sent from my phoney service and the Type Object match however when I try to assign the data from the Rest Service to component in the class <code>'this.userStatus = data;'</code> I get the following error.... </p>

<pre><code>"error TS2322: Type 'Response' is not assignable to type 'UserStatus'.
  Property 'appOS' is missing in type 'Response'."
</code></pre>

<p>I assume in my Type class I am doing something wrong with the definition where nulls are concerned can anyone see what I am doing wrong or explain why I am getting the error. Thanks in advance.</p>
