Skip to content

BREAKING: rename isInstanceOf(x,y) to cast(x).to(y)#13

Open
knocte wants to merge 5 commits into
mainfrom
wip/reworkCasting
Open

BREAKING: rename isInstanceOf(x,y) to cast(x).to(y)#13
knocte wants to merge 5 commits into
mainfrom
wip/reworkCasting

Conversation

@knocte
Copy link
Copy Markdown
Contributor

@knocte knocte commented May 25, 2026

It is way more readable, because this way you don't have to check which param is the type.

knocte added 3 commits May 25, 2026 15:47
It is way more readable, because this way you don't have to
check which param is the type.
Most of the time when you're checking if a var is of type T,
you want to cast afterwards if the result is true, so let's
reuse Option types here. If you don't want to cast, you simply
use isSome() or isNone() later.
@knocte knocte force-pushed the wip/reworkCasting branch from 6abc2d0 to 04fa4b1 Compare May 25, 2026 08:39
knocte added 2 commits May 25, 2026 16:47
Sounds better and shorter.
One of the last commits left this shit:

```
   expect(Dyn.cast(foo).to<Foo>().isSome()).toBe(true);
   expect(Dyn.cast(bar).to<Bar>().isSome()).toBe(true);
   expect(Dyn.cast(foo).to<Bar>().isSome()).toBe(true);
   expect(Dyn.cast(bar).to<Foo>().isSome()).toBe(true);
```
@knocte
Copy link
Copy Markdown
Contributor Author

knocte commented May 25, 2026

TODO:

  • move Dyn.cast().to() to Check.if().is() and just accept to only be true or false.
  • move TypeHelpers.isNullOrUndefined() to Check.if().isNullish()
  • move TypeHelpers.stringIsNullishOrEmpty() to Check.ifString().isNullishOrEmpty()
  • move TypeHelpers.stringIsNullishOrWhiteSpace() to Check.ifString().IsNullishOrWhiteSpace()
  • verify TypeHelpers.ts doesn't exist
  • rename OptionHelpers to Opt (for ofObj and Nothing)
  • improve warning msg for new None to include ns of Nothing

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