Inconsistent Return Type for splitPathAndFormat Function
why wouldn't this be return type:
it's showing as:
Effect.Effect<never, IncorrectFileFormat, {splitPath: string, format: ".webp" | ".png" | ".jpg"}> Effect.Effect<never, IncorrectFileFormat, {splitPath: string, format: ".webp" | ".png" | ".jpg"}>it's showing as:
const splitPathAndFormat: (path: string) => Effect.Effect<never, never, {
splitPath: string;
format: ".webp" | ".png" | ".jpg";
}> | Effect.Effect<never, IncorrectFileFormat, never>const splitPathAndFormat: (path: string) => Effect.Effect<never, never, {
splitPath: string;
format: ".webp" | ".png" | ".jpg";
}> | Effect.Effect<never, IncorrectFileFormat, never>class IncorrectFileFormat extends Data.TaggedClass("IncorrectFileFormat")<{
readonly custom: string;
}> {}
export const supportableFormats = [".webp" as const, ".png" as const, ".jpg" as const];
export const splitPathAndFormat = (path: string) => {
const splitPathArray = path.split(".");
const splitPath = splitPathArray.slice(0, -1).join(".");
const format = `.${splitPathArray[splitPathArray.length - 1]}` as (typeof supportableFormats)[number];
return supportableFormats.includes(format)
? Effect.succeed({
splitPath: splitPath,
format: format,
})
: Effect.fail(
new IncorrectFileFormat({
custom: `There was not an acceptable format per the supportableFormats: ${supportableFormats}`,
})
);
};class IncorrectFileFormat extends Data.TaggedClass("IncorrectFileFormat")<{
readonly custom: string;
}> {}
export const supportableFormats = [".webp" as const, ".png" as const, ".jpg" as const];
export const splitPathAndFormat = (path: string) => {
const splitPathArray = path.split(".");
const splitPath = splitPathArray.slice(0, -1).join(".");
const format = `.${splitPathArray[splitPathArray.length - 1]}` as (typeof supportableFormats)[number];
return supportableFormats.includes(format)
? Effect.succeed({
splitPath: splitPath,
format: format,
})
: Effect.fail(
new IncorrectFileFormat({
custom: `There was not an acceptable format per the supportableFormats: ${supportableFormats}`,
})
);
};