title: Angular 4 typescript parsing enum interface attribute in response object
body: <p>I have a response from API which is returning a enum value. value returned from API is represented as a string in request.
  This value is a <code>enum</code> attribute of typescript interface. </p>
  
  <p><strong>Problem:</strong> 
  when receiving a response, TS interface store that value as a string (probably thats the issue) so i can't use it directly as <code>enum</code>.</p>
  
  <p><strong>obj model:</strong></p>
  
  <pre><code>export interface Condo {
  
    id:number
    title:string
    latitude:number
    longitude:number
  
    city:string
    country:string
    district:string
    address:string
    locationType: LocationType
  }
  
  export enum LocationType {
    CONDO,
    MALL,
    STATION
  }
  </code></pre>
  
  <p><strong>request:</strong></p>
  
  <pre><code>getCondoAllByCountry(country_code){
      return this.http.get(this.config.apiEndpoint +this.subApiUrl+'/all')
        .map(res =&gt; &lt;Condo[]&gt;res.json())
        .catch((err:Response) =&gt; {
          return Observable.throw(err.json());
        });
      }
  </code></pre>
  
  <p><strong>usage sample:</strong></p>
  
  <pre><code>    this.condoService.getCondoAllByCountry(this.userData.country_code).subscribe(data=&gt;{
            someFunc(data)
          })
  
  ............
      someFunc(condo_list: Condo[]){
      //here is need to know the `locationType` for each object
        console.log(typeof condo_list[i].locationType);
        console.log(typeof LocationType.CONDO)
        switch (condo_list[i].locationType){
          case LocationType.CONDO:
            console.log('Case - condo')
            break;
          case LocationType.MALL:
            console.log('Case - mall')
            break;
          case LocationType.STATION:
            console.log('Case - station')
            break;
        }
      }
  </code></pre>
  
  <p>So, the <code>switch.. case</code>is not working for this attribute. in <code>console.log()</code> i'm getting:</p>
  
  <p><code>console.log(typeof condo_list[i].locationType);</code> - <code>string</code></p>
  
  <p><code>console.log(typeof LocationType.CONDO)</code> - <code>number</code></p>
  
  <p>So, that means that there were a parsing prob and <code>condo_list[i].locationType</code> is not a <code>enum</code> (considering it should show <code>number</code> for enum)?</p>
  
  <p>How should i fix it?</p>