title: typescript extending types vs interfaces
body: <p>This might a be relatively noob question,
  I have an interface</p>
  <pre><code>interface Employee {
     name: string
  }
  </code></pre>
  <p>and I would like to have an extended version of this after it being saved into the DB:</p>
  <pre><code>interface EmployeeDb {
     id: string,
     name: string
  }
  </code></pre>
  <p>I would like to differentiate it when handling checks so after saving data in my storage, the type checker won't complain about not having id value. Meaning I want to avoid using this:</p>
  <pre><code>interface Employee {
     id?: string,
     name: string
  }
  </code></pre>
  <p>so I don't have to check for id everywhere.</p>
  <p>So I am trying to do it this way:</p>
  <pre><code>type Employee = {
     name: string
  }
  
  type IDatabaseObject&lt;T&gt; = {
    id: IDatabaseObjectId;
    [P in keyof T]: T[P];
  };
  
  type EmployeeDb = IDatabaseObject&lt;Employee&gt;
  </code></pre>
  <p>which the IDE gives an error with the top syntax</p>
  <blockquote>
  <p>A computed property name must be of type 'string', 'number', 'symbol',
  or 'any'.ts(2464)</p>
  </blockquote>
  <p>so I tried to use interface and extend it</p>
  <pre><code>interface IDatabaseObject { 
     id: string
  }
  
  interface EmployeeDb extends Employee, IDatabaseObject {}
  </code></pre>
  <p>but in the backend code when I try to use this setup I get an error from vscode eslint again. I have a small code here that adds the data to localstorage, generates a id and returns the data. see code:</p>
  <pre><code>class DbAsyncStorageTemplate&lt;
      InputDataType,
      OutputDataType extends IDatabaseObject
  &gt; {
  
      async addEntry(object: InputDataType): Promise&lt;OutputDataType&gt; {
  
          const id: string = generateUuid()
          const dbObject = { id, ...object }
          dbObject.id = id
  
          // add the item to AsyncStorage directly
          await AsyncStorage.setItem(id, JSON.stringify(object))
  
          // ERROR HERE: return the new object
          return dbObject as OutputDataType
      } 
      }
  }
  </code></pre>
  <p>but I get an error from the IDE (eslint) for the last line</p>
  <blockquote>
  <p>Conversion of type '{ id: string; } &amp; InputDataType' to type
  'OutputDataType' may be a mistake because neither type sufficiently
  overlaps with the other. If this was intentional, convert the
  expression to 'unknown' first.   '{ id: string; } &amp; InputDataType' is
  assignable to the constraint of type 'OutputDataType', but
  'OutputDataType' could be instantiated with a different subtype of
  constraint 'any'.</p>
  </blockquote>
  <p>any recommendation on how to do this properly?</p>