These are chat archives for ramda/ramda

29th
Jan 2019
Lewis
@6ewis
Jan 29 02:57
i don't remember those type signatures from clojure
Aaron Rice
@adrice727
Jan 29 18:42

I have some code that I can't seem to get TypeScript to not complain about:

type ErrorAttrs = {
  errorId: number;
  code: string;
  featureKey: string;
  featureValue: number;
};

const flatMapIndexed = R.addIndex(R.chain);

function getRows(code, rows, attrs, errorIds): ErrorAttrs[] {
  const attrRows: ErrorAttrs[] = flatMapIndexed((id: {}, idx: number): ErrorAttrs[] => {
    const row = rows[idx];
    return R.map(
      (featureKey): ErrorAttrs => ({
        errorId: id as number,
        code,
        featureKey,
        featureValue: row[featureKey],
      }),
      attrs
    );
  }, errorIds);
  return attrRows;
}

I'm getting the following error: Type 'ReadonlyArray<{}>[]' is not assignable to type 'ErrorAttrs[]'. Type 'ReadonlyArray<{}>' is missing the following properties from type 'ErrorAttrs': errorId, code, featureKey, featureValue [2322]