Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compare feature #1511

Draft
wants to merge 13 commits into
base: master
Choose a base branch
from
Draft

Compare feature #1511

wants to merge 13 commits into from

Conversation

snatvb
Copy link

@snatvb snatvb commented Feb 24, 2025

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant