mattpocock / ts-error-translator

VSCode extension to turn TypeScript errors into plain English
https://ts-error-translator.vercel.app
2.36k stars 90 forks source link

Translation request for 18031 #253

Open travishaby opened 8 months ago

travishaby commented 8 months ago

Error Text

The intersection 'DBPersonRecord & DBPersonTechnologyRecord' was reduced to 'never' because property 'type' has conflicting types in some constituents.

Supporting Information

Please provide other information which led to this error, and any specific questions you have about it:

Here's the setup that led to this type error and missing translation:


export interface DBRecord {
  PK: string;
  SK: string;
  type: string;
  [key: string]: string;
}

export interface DBPersonRecord extends DBRecord {
  name: string;
  id: string;
  type: "PERSON";
  GSI1PK: string;
  GSI1SK: string;
}

export interface DBPersonTechnologyRecord extends DBRecord {
  tech_person_rating: string;
  type: "TECH_PERSON";
  GSI1PK: string;
  GSI1SK: string;
}

type DBPersonRecordTypes = DBPersonRecord | DBPersonTechnologyRecord
type DBRecordGroups = {
  PERSON: DBPersonRecord[]
  TECH_PERSON: DBPersonTechnologyRecord[]
}

interface QueryPersonResponseContext extends PersonContext {
  result: {
    items: DBPersonRecordTypes[];
  };
}

export function response(context: QueryPersonResponseContext) {
  const { result } = context;

  const itemGroups = result.items.reduce((acc, item) => {
    if (!acc[item.type]) {
      acc[item.type] = []
    }
    acc[item.type].push(item) // type error was here on `item`
    return acc
  }, {} as DBRecordGroups)
  // ...
}

Screenshot of translations with missing one: image