mobily / ts-belt

šŸ”§ Fast, modern, and practical utility library for FP in TypeScript.
https://mobily.github.io/ts-belt
MIT License
1.11k stars 31 forks source link

VSCODE pipe -> O.map -> O.getWithDefault Function -> ts2345 error is displayed. #50

Closed araera111 closed 1 year ago

araera111 commented 1 year ago

I use VSCode.

in my environment, after using the map function of type option, use the getWithDefault function of type option. Then the ts(2345) error is displayed.

const result = pipe(
  O.fromNullable(null),
  O.map((value) => `${value} world!`), //ā† ts2345 error is displayed.
  O.getWithDefault("error")
);

but

const temp = pipe(
  O.fromNullable(null),
  O.map((value) => `${value} world!`)
);

const result = O.getWithDefault(temp, "test"); //ā† ts2345 error is NOT displayed.

and

const temp = pipe(
  O.fromNullable(null),
  O.map((value) => `${value} world!`),
  O.getWithDefault("test" as string) //ā† ts2345 error is NOT displayed.
);

mytsconfig

{
  "compilerOptions": {
    "strictNullChecks": true,
    "noUncheckedIndexedAccess": false,
    "target": "ESNext",
    "module": "commonjs",
    "esModuleInterop": true,
    "forceConsistentCasingInFileNames": true,
    "strict": true,
    "skipLibCheck": true
  }
}

typescript: 4.8.4 node: 16.18.0

use tsc command -> ts2345 error is NOT displayed.

mobily commented 1 year ago

@araera111 please install @mobily/ts-belt@next and let me know if that solves your issue :)

araera111 commented 1 year ago

Solved! Very very very thank you .