Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • 01:25
    weswigham review_requested #35095
  • 01:25
    weswigham review_requested #35095
  • 01:25
    weswigham opened #35095
  • 01:24
    weswigham milestoned #35093
  • 01:24
    weswigham assigned #35093
  • 01:23
    weswigham labeled #35093
  • 01:18
    orta synchronize #15575
  • 01:17
    orta synchronize #28460
  • 01:17
    orta synchronize #31641
  • 01:17

    orta on master

    Adds 'did you mean' to the CLI … (compare)

  • 01:16
    orta closed #35063
  • 01:16
    DanielRosenwasser assigned #35094
  • 01:16
    DanielRosenwasser assigned #35094
  • 01:16
    DanielRosenwasser labeled #35094
  • 01:16
    DanielRosenwasser labeled #35094
  • 01:16
    DanielRosenwasser labeled #35094
  • 01:01
    mjbvz edited #35094
  • 01:00
    mjbvz edited #35094
  • 01:00
    mjbvz opened #35094
  • 00:52
    weswigham opened #35093
Shanon Jackson
@ShanonJackson
no problem
Bruce Pascoe
@fatcerberus
I’m very confused by this comment, it seems like a non sequitur https://github.com/microsoft/TypeScript/issues/34534#issuecomment-543408917
I’m not your mom, right?
What.
Keith Layne
@keithlayne
Bob's your uncle.
Bruce Pascoe
@fatcerberus
But that guy sucks
garyking
@garyking
Does anyone know how to generate a .d.ts file for a JS project that uses JSDoc, automatically? Rather than need to write it by hand, for a module.
garyking
@garyking
I'm assuming you can really only generate one by hand, which is what I've been doing so far. I'm checking this out but I've already encountered so many bugs.
Bugs which seem to mostly do with JSDoc itself.
Gerrit Birkeland
@Gerrit0
Can't you use tsc with --emitDeclarationOnly?
Keith Layne
@keithlayne
yeah allowJs and declarations are supposed to no longer be incompatible.
AnyhowStep
@AnyhowStep
Is there even a point in banning him
He'd just create another account and throw another hissy fit
Edoardo Luppi
@lppedd

Quick style question. To convert a any value to a boolean, do you prefer

Boolean(value) \\ or
!!value

Just curious. I prefer the explicit Boolean(...) alternative.

Tõnis Ostrat
@tonisostrat
depends on the context
AnyhowStep
@AnyhowStep
I prefer if (typeof value != "boolean") { throw new Error(); }
Orta
@orta
@keithlayne - re: TS in web app - yeah the default TS support with monaco only supports editing one file
You’d need to make the virtual host support more files etc
is a pretty good example of it
Keith Layne
@keithlayne
thanks
Orta
@orta
Wow, I didn’t really know how bad android support in monaco is
you really can’t even delete
AnyhowStep
@AnyhowStep
¯_(ツ)_/¯
Why do you think I keep bugging you all for better mobile support =P
Keith Layne
@keithlayne
your dude is missing an arm
Bruce Pascoe
@fatcerberus
@orta It’s not too nice on iOS either, there’s literally no way to pull up the copy/paste UI because the custom context menu overrides it
Orta
@orta
I’m fighting the desire to go fix some of the worst offenders in monaco itself
Bruce Pascoe
@fatcerberus
@AnyhowStep ban who? I don’t know see what that was in response to
Keith Layne
@keithlayne
to the your mom dude on github
Bruce Pascoe
@fatcerberus
Oh
anthalon
@anthalon

I have an object that accepts a string parameter in it's constructor, and it's toString() formats that string in a specific way.

for instance:

export class Currency
{
    constructor(private amt: string) {}
    ...
    toString() { /* return formatted string here, comma separated etc */ }
}

amd if I use an object of this class directly, it returns the formatted string.

But when I try to parse from json, the Currency object is treated as string, and doesn't format with it's toString() method.

How can I initialize this object from json so that it's treated as a Currency object?
Keith Layne
@keithlayne
you probably know this, but that has nothing to do with TS. You're going to have to write some kind of deserialization function.
anthalon
@anthalon
the Currency class is part of a model, and it's being given a string value when the json is JSON.parsed. Instead of doing this manually, I was wondering if typescript offers some functionality to initialize these objects, maybe in a way where the string is not assigned to the object, but instead passed in as a constructor parameter?
Bruce Pascoe
@fatcerberus
All the functionality typescript adds is compile-time only, it doesn’t help you at runtime
What I think you want is a “reviver”, google “json reviver”
anthalon
@anthalon
yup, that's what I'm after. Thanks
Thanzex
@Thanzex
What are the best practices to export constants from a package?
Anthony Lukach
@alukach

Does TS not allow typing a function without directly calling it?

e.g.

[{x: 1}].map(Object.entries<number>) // 'number' only refers to a type, but is being used as a value here.
Bruce Pascoe
@fatcerberus
Yeah, you can’t instantiate the generic without calling the function, we were discussing that here recently
Keith Layne
@keithlayne
if you could....
Bruce Pascoe
@fatcerberus
It actually seems like it’s interpreting the angle brackets as comparison operators there, which is odd
Anthony Lukach
@alukach
Is it clear what I'm trying to do? This would be helpful for composing "point free" functions (I'm using ramda). WIthout adding a type to Object.entries, TS thinkings the 1 index of the tuple is any rather than number... Is there a way to achieve my goal?
Keith Layne
@keithlayne
yeah, we all understand what you want
Anthony Lukach
@alukach
Keith Layne
@keithlayne
write a lambda where you specify the type
Anthony Lukach
@alukach
well that's not much fun, but if that's the way it has to be...
Keith Layne
@keithlayne
for your own functions you can sort of work around by writing a generic interface with a call signature.