title: Why does the argument for Array.prototype.includes(searchElement) need the same type as array elements?
body: <p>I honestly don't know if something is wrong with my settings or of if this is a typescript feature. In the following example:</p>
  
  <pre class="lang-js prettyprint-override"><code>type AllowedChars = 'x' | 'y' | 'z';
  const exampleArr: AllowedChars[] = ['x', 'y', 'z'];
  
  function checkKey(e: KeyboardEvent) { 
      if (exampleArr.includes(e.key)) { // &lt;-- here
          // ...
      } 
  }
  </code></pre>
  
  <p>The typescript compiler complains that <code>Argument of type 'string' is not assignable to parameter of type 'AllowedChars'.</code> But where am I assigning? <code>Array.prototype.includes</code> returns a boolean (which I am not storing). I could silence the error by a type assertion, like this:</p>
  
  <pre><code>if (exampleArr.includes(e.key as AllowedChars)) {}
  </code></pre>
  
  <p>But how is that correct, I am expecing user input which could be anything. I don't understand why a function (<code>Array.prototype.includes()</code>) made to check <em>if</em> an element is found in an array, should have knowledge about the type of input to expect. </p>
  
  <p>My <code>tsconfig.json</code> (typescript v3.1.3):</p>
  
  <pre><code> {
      "compilerOptions": {
        "target": "esnext",
        "moduleResolution": "node",
        "allowJs": true,
        "noEmit": true,
        "strict": true,
        "isolatedModules": true,
        "esModuleInterop": true,
        "jsx": "preserve",
      },
      "include": [
        "src"
      ],
      "exclude": [
        "node_modules",
        "**/__tests__/**"
      ]
    }
  </code></pre>
  
  <p>Any help would be appreciated!</p>