Skip to content

[BUG] Union properties are broken #83

@AntonC9018

Description

@AntonC9018

Consider the following code:

import {getType,Type} from "tst-reflect";
class A
{
    s?: string | undefined;
} 
console.log(getType<number|string>().isUnion());
console.log(getType<A>().getProperties().find(p => p.name == "s")!.type.isUnion());

The first check works fine and returns true.
In the second check, the type of s is clearly a union, but it returns false.
The same thing happens if I try to extract the types — the first statement correctly returns the two types, while the second one sometimes returns an empty array and sometimes return undefined.
I'm using Vite with HMR (btw the hot reloading doesn't trigger when the transformed input changes, it may or may not be a problem on your side of things).

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingenhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions