title: Why does TS do not get React state assertion from Interface?
body: <p>So, I have this component:</p>
  
  <pre><code>type TypeofArray&lt;
      ArrayTypeInstance
  &gt; = ArrayTypeInstance extends (infer ElementType)[] ? ElementType : never;
  
  type Property = {
      dataId: number;
      address: string;
      price?: number;
      transactionType: string;
      bedrooms?: number;
      coverImageUrl?: string;
      modifiedWhen: string;
      currentStage?: string;
  };
  
  type PropertiesState = {
      searchType: TypeofArray&lt;typeof SEARCH_TYPES&gt;;
      properties: Property[];
      [key: number]: boolean;
  };
  
  export class Properties extends Component&lt;{}, PropertiesState&gt; {
      readonly state = {
          searchType: 'buy',
          properties: []
      };
  ...
  </code></pre>
  
  <p>And here I am trying access this piece of state <code>[key: number]: boolean;</code>:</p>
  
  <pre><code> &lt;PropertyCard
                      isFavorite={this.state[property.dataId]}
                  /&gt;
  </code></pre>
  
  <p>But I get this error:</p>
  
  <p><strong>Error:(98, 33) TS7017: Element implicitly has an 'any' type because type '{ searchType: string; properties: never[]; }' has no index signature.</strong></p>
  
  <p>If I explicitly annotate state like this:</p>
  
  <pre><code>readonly state: PropertiesState = {
      searchType: 'buy',
      properties: []
  };
  </code></pre>
  
  <p>error disappears. </p>
  
  <p>Why? What is better way to fix this error?</p>
  
  <p>Thanks! </p>