Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • 11:40
    weakish closed #35235
  • 10:51
    devdoomari3 edited #35264
  • 10:50
    devdoomari3 opened #35264
  • 09:49
    michalburger1 closed #35231
  • 09:47
    deser opened #35263
  • 09:32
    huangjihua opened #35262
  • 07:46
    hubluesky opened #35261
  • 07:05
    oluwasayo opened #35260
  • 06:43
    Daniel15 opened #35259
  • 06:39
    sapphiredev opened #35258
  • 06:28
    UselessPickles opened #35257
  • 05:51
    alshdavid edited #35030
  • 04:28
    typescript-bot synchronize #35255
  • 03:45
    Jack-Works ready_for_review #35219
  • 02:43
    zengwe opened #35256
  • 00:35
    DanielRosenwasser synchronize #35254
  • 00:35

    DanielRosenwasser on removeScareQuotes

    Typescript -> TypeScript Accepted baselines. (compare)

  • 00:22
    typescript-bot opened #35255
  • 00:15
    DanielRosenwasser assigned #35254
  • 00:15
    DanielRosenwasser assigned #35254
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
Gareth Jones
@G-Rath
whys that?
they have the same output
AnyhowStep
@AnyhowStep
(await x) does not give you an expression of type Promise<typeof x>, I'm sure
It's just syntactic sugar
Gareth Jones
@G-Rath
Yeah, that's what I'm questioning
why doesn't it give you an expression of that type? b/c as you say, it's syntactic sugar, so it does give that expression in Node (iirc)
AnyhowStep
@AnyhowStep
If it did return a promise, this would work,
function returnPromise () : Promise<number> {
  return (await 1);
}
Gareth Jones
@G-Rath
which it does
once you add the missing async keyword
AnyhowStep
@AnyhowStep
image.png
Exactly. The async part is the problem here
Gareth Jones
@G-Rath
oh ffs
no wait what
async is in my code
for a second I thought it was I'd just missed async, but nope: async is there
so your example doesn't really relate to mine, as far as I can tell
AnyhowStep
@AnyhowStep

function takesNumberOnly (x : number) {
  console.log(x+1);
}
async function returnPromise ()  {
  const x = await 1;
  takesNumberOnly(x);
  takesNumberOnly(await 1);
}
If (await 1) is an expression of type Promise<number>