Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • 10:57
    saschanaz synchronize #35518
  • 06:20
    sviat9440 closed #35553
  • 06:14
    sviat9440 edited #35553
  • 04:30
    typescript-bot opened #35564
  • 04:26
    agrozyme edited #35563
  • 04:20
    agrozyme opened #35563
  • 02:25
    alshdavid edited #35537
  • 02:24
    alshdavid edited #35537
  • 01:34
    amcasey closed #19533
  • 01:29
    minestarks edited #35559
  • 01:28
    minestarks edited #35559
  • 01:21
    weswigham edited #35561
  • 01:21
    weswigham edited #35561
  • 01:21
    weswigham edited #35561
  • 00:25
    loilo opened #35562
  • 00:25
    andrewbranch labeled #35019
  • 00:25
    andrewbranch labeled #35019
  • 00:23
    amcasey closed #21485
  • 00:22
    weswigham opened #35561
  • 00:21
    amcasey closed #35175
AnyhowStep
@AnyhowStep
It's type guards all the way down!
Bruce Pascoe
@fatcerberus
@AnyhowStep I like that yours is basically a type guard factory
for some reason I didn’t think you could curry them but when I think about it... there’s no reason why it shouldn’t work
AnyhowStep
@AnyhowStep
You'll notice I hecked up the factory, though
The keys should go into the factory function
Instead, the keys are being passed when invoked
And I could be caching it and reusing it but I'm not
Derek Wickern
@dwickern
is there a type for something which can be imported?
import 'foo' // good
import 'bar' // error

const x: Importable = 'foo' // good
const y: Importable = 'bar' // error
Orta
@orta
That change to add a link to Gitter just got deployed to prod
AnyhowStep
@AnyhowStep
<3
@fatcerberus remember how we were discussing the following?
Where ? denotes the existential type, ? extends ? is true
But ? = ? (assignment) is not allowed
@jack-williams just gave another example of that behavior but it's an actual current behaviour
Not exactly the same
But similar enough that it made me think of that
AnyhowStep
@AnyhowStep
In that issue, (arg : never) => T is assignable to (...args : any) => any but not really. It behaves differently depending on whether it's used to constrain a type parameter, or used in a conditional type
Tõnis Ostrat
@tonisostrat
@VulcanRav, it doesn't, yes, but that technically wasn't your requirement either. if you actually need to access a then use any
AnyhowStep
@AnyhowStep
@orta Gitter really needs a better looking logo
Orta
@orta
Yeah, not much I can do there - gitter got bought now, so it’s kinda on the way out I bet
AnyhowStep
@AnyhowStep
I literally had trouble locating it even though there are only 6 icons!
I had to go Ctrl+F > "Gitter"
Orta
@orta
Hah, yep, them memorable 4 lines
webstrand
@webstrand
Did Gitter get sold again? Or does GitLab still own it?
Orta
@orta
nah, still gitlab
Bruce Pascoe
@fatcerberus
@AnyhowStep I always wondered whether (...args: any) => any was checked structurally or not. Good to have some confirmation one way or the other
Although shouldn’t it be ...args: any[] since the rest param always has to be an array
AnyhowStep
@AnyhowStep
Should be ...args : never >;(
Probably something to do with any being assignable to any[] and the other way around. So it doesn't matter
Less concise than any[], though
Bruce Pascoe
@fatcerberus
...args: never - were you trying to make a top type for functions?
AnyhowStep
@AnyhowStep
Yeap
I added that as a comment at the very bottom
ReturnType<> should be accepting a top type for functions, anyway
Bruce Pascoe
@fatcerberus
I had that issue a while ago. ...args: never[] is no good since you can still call it with no args
Never found a good solution :(
Bruce Pascoe
@fatcerberus
If it’s generic though, what about F extends Function?
AnyhowStep
@AnyhowStep
No good, can't use the infer R syntax if you're using extends Function
Also, my concrete F will still end up having never in the param and will break ReturnType<> =x
Even if I'm using Function as the top type for functions
Keith Layne
@keithlayne
IIRC all function has is a name member.
raghanag
@raghanag
hi all, if the typescript class constructor has too many lines, are we going to stub all of it when we are writing unit tests
AnyhowStep
@AnyhowStep
What does that question even mean
Bruce Pascoe
@fatcerberus
@keithlayne Function doesn’t guarantee that it’s callable?
Because that’s kind of sucky if it doesn’t
Keith Layne
@keithlayne
I must have seen an augmentation instead of the actual definition, my bad
Gareth Jones
@G-Rath
ok want to see something interesting?
interface Mx {
  v: string;
}

const promiseTuple = async <T1, T2>(t1: T1, t2: Promise<T2>): Promise<[T1, T2]> =>
  [t1, await t2];

const doThings = async (): Promise<Array<[string, Mx[]]>> => Promise.all([
  promiseTuple('hello', Promise.resolve([{ v: 'sunshine' }])),
  promiseTuple('world', await [{ v: 'peace' }])
]);

doThings().then(r => r.forEach(console.log));
pretty sure that's a bug :grimacing:
AnyhowStep
@AnyhowStep
I'm pretty sure it's not