Skip to content
This repository was archived by the owner on Jun 13, 2024. It is now read-only.
This repository was archived by the owner on Jun 13, 2024. It is now read-only.

Type check before callable ignore in callable #2

@Arcoz0308

Description

@Arcoz0308

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());
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions