Bluzzi / rustic-error

Robust and type-safe error management 🦀
https://www.npmjs.com/package/rustic-error
MIT License
6 stars 0 forks source link

Type check before callable ignore in callable #2

Open Arcoz0308 opened 1 year ago

Arcoz0308 commented 1 year ago

image

test.ts :

import {resultify} from "rustic-error";

type a = {
    bar(): string;
}
type b = {
    foo: a|null
}

const bFoo: b = {
    foo: {
        bar(): string {
            return 'Joe doe'
        }
    }
}
if (bFoo.foo !== null) {
    const bar1 = bFoo.foo.bar();
    const bar2 = resultify(() => bFoo.foo.bar());
}

tsconfig.json :

{
  "compilerOptions": {
    "target": "es2022",
    "module": "commonjs",
    "strict": true,
  }
}

solution that can remove error, but not pratical :

if (bFoo.foo !== null) {
    const bar1 = bFoo.foo.bar();
    const foo = bFoo.foo
    const bar2 = resultify(() => foo.bar());
}
Arcoz0308 commented 6 months ago

update ?

Bluzzi commented 6 months ago

We are currently testing this package on a large-scale project in order to understand its strengths and weaknesses. We also want to concentrate on the new version of our ESLint config before getting back to developing the organisation's other projects.

After these two things, we're going to actively resume the development of this package and resolve the open issues.