title: How can I cast custom type to primitive type?
body: <p>I have a type</p>
  
  <pre><code>type Rating = 0 | 1 | 2 | 3 | 4 | 5 | number
  </code></pre>
  
  <p>Now I want to do something like this.</p>
  
  <pre><code>let myRating:Rating = 4
  let rate:number = myRating as number
  </code></pre>
  
  <p>How can I cast my <code>myRating</code> into <code>number</code> primitive type?</p>
  
  <p>It is giving me error as: </p>
  
  <blockquote>
    <p>Conversion of type 'Rating' to type 'number' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first.ts(2352)</p>
  </blockquote>
  
  <p>I have been through <a href="https://stackoverflow.com/questions/37978528/typescript-type-string-is-not-assignable-to-type">this</a>, but what I want is its reverse</p>
  
  <p>Edit:</p>
  
  <blockquote>
    <p>tsconfig.json</p>
  </blockquote>
  
  <pre><code>{
    "compilerOptions": {
      "noImplicitAny": false,
      "target": "es6",
      "allowJs": true,
      "skipLibCheck": false,
      "esModuleInterop": true,
      "allowSyntheticDefaultImports": true,
      "forceConsistentCasingInFileNames": true,
      "module": "esnext",
      "moduleResolution": "node",
      "resolveJsonModule": true,
      "isolatedModules": true,
      "noEmit": true,
      "jsx": "preserve",
      "strict": true
    },
    "include": [
      "src"
    ]
  }
  </code></pre>
  
  <p>tsc version: 3.2.1</p>