Skip to content

Unexpected type inference when creating ref in function call #257

@jsmith

Description

@jsmith

I'm getting unexpected type inference when creating a ref in a function call. The ref('') is interpreted as ref<number> which could definitely cause bugs (this actually happened to me as I was writing a unit test). The simple example below should provide all of the details but please let me know if there is anything else you need!

const foo = (bar: Ref<number>) => {
  return bar;
};

// there are no TS errors in any of this code
// ref('') -> ref<unknown, string, number>(raw: string): Ref<number>
const result = foo(ref('')); // result -> Ref<number>

Thanks for your help!

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinghas PR

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions