Compare feature
Feature of #1497
Classes
Added "class" property to detect that object is class
Classes forbidden to compare because there is a lot of deep cases that might leads to bug with prototypes.
Extends MetadataCollection
Added find method of type for objects. I think it's good idea to have possibility to get ts.Type by any Metadata.
It requires in my case, because metadata doesn't cover this methods declarations:
type Foo {
bar(): void
}
I've noticed that it's hard to compare unions:
type Foo = { foo: number }
type Bar = { bar?: number }
type Union = Foo | Bar
const a = { foo: 1 }
const b = { foo: 2 }
console.assert(
a === b || (
a.foo === b.foo
) || (
a.bar === b.bar
)
)
This will be true, because after fail on foo prop, a.bar === b.bar because undefined === undefined
And this unions a lot of corner cases. I just forbidden it. Left only for primitive types.
Development & Test Environment
I've faced with problem that tests take too much time. I've added possibility to add flag that will filter tests by folder.
pnpm dev --folder=compare.equals
Also added watch mode for root:
pnpm dev