Effect CommunityEC
Effect Community2y ago
6 replies
whatplan

Error with 'Options.withSchema' argument type

const StringPairsFromStrings = S.array(S.string).pipe(
  S.filter((arr) => arr.every((s) => s.split(": ").length === 2)),
  S.transform(
    S.array(S.tuple(S.string, S.string)),
    (arr) =>
      arr.map((s) => s.split(": ") as unknown as readonly [string, string]),
    (arr) => arr.map((s) => s.join(": "))
  )
);

const headersOption = Options.text("header").pipe(
  Options.repeated,
  Options.withSchema(StringPairsFromStrings) // error here
);

Argument of type 'Schema<readonly (readonly [string, string])[], readonly string[], never>' is not assignable to parameter of type 'Schema<readonly (readonly [string, string])[], string[], FileSystem | Path | Terminal>'.
  The types returned by '[TypeId]._I(...)' are incompatible between these types.
    The type 'readonly string[]' is 'readonly' and cannot be assigned to the mutable type 'string[]'.


it is possible for Options.repeated to return Options<readonly A[]>?
Was this page helpful?