question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Don't typealias Month (and others)

See original GitHub issue

I suggest to not typealias anything in a multiplatform date/time library.

  • It mixes platform-provided API into the library’s API which causes confusion and is platform-dependent.
  • It doesn’t allow for adding a companion and thus “static” functionality - not even through extensions.

For example: I had code in the back-end that used Month.of(someInt). The code was relatively simple and there were no JVM-specific imports. So I’ve moved it to a shared multiplatform dependency and was surprised that Month.of() was no longer available. Month.<autocomplete> didn’t provide me with any useful alternative.

After Cmd-clicking on Month I’ve learned that it is merely a typealias on JVM. It took a while to figure out that there’s an additional Month(Int) function in kotlinx-datetime that I should’ve used instead. Scenarios like that can easily lead to confusion and inconsistency.

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:3
  • Comments:5

github_iconTop GitHub Comments

1reaction
JakeWhartoncommented, Mar 17, 2021

@september669 the whole library requires coreLibraryDesugaring to be enabled enabling the use of java.time on previous API levels.

0reactions
fluidsoniccommented, May 25, 2021

With Kotlin 1.5 it became super annoying and really needs to be changed.

image

Read more comments on GitHub >

github_iconTop Results From Across the Web

firebase - Problems with typealias swift - Stack Overflow
Hey i have a code that uses a typealias so that it will be able to send an error code to the user...
Read more >
Mailman 3 Explicit Type Aliases - Typing-sig - python.org
Proposal (with explicit aliases): ``` from typing import List, TypeAlias ... At this point we don't know whether T is a type or...
Read more >
PEP 604 unions don't work with generic type aliases #12211
Anyway, to the concrete suggestion of having to explicitly list the type vars generic type aliases are generic over — I think it's...
Read more >
How to use Typealias in Swift | Continued Learning #19
In this quick video, we will learn a simple implementation of Typealias. This lesser known declaration is used to create an alias (...
Read more >
Swift - How to use typealias | Swift 5.2, Xcode 11 - YouTube
Head to https://squarespace.com/seanallen to save 10% off your first purchase of a website or domain using code SEANALLEN.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found