Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • 06:42
    liudonghua123 opened #35604
  • 04:30
    typescript-bot synchronize #35599
  • 04:26
    abidingotter edited #35603
  • 04:26
    abidingotter opened #35603
  • 04:24
    mjbvz edited #35602
  • 04:24
    mjbvz opened #35602
  • 04:08
    mjbvz unassigned #35601
  • 04:08
    Arlen22 opened #35601
  • 04:06
    dolphinlin edited #35600
  • 04:05
    dolphinlin opened #35600
  • 01:33
    proteriax closed #29044
  • 01:32
    typescript-bot synchronize #35599
  • 01:31
    proteriax edited #29044
  • 01:17

    sandersn on protected-jsdoc

    Fix @declaration draft abstraction + one usage (compare)

  • 01:04
    weswigham synchronize #35561
  • 01:04

    sandersn on protected-jsdoc

    Add @private/@protected/@public… (compare)

  • 01:01
    typescript-bot opened #35599
  • 00:50
    weswigham synchronize #15575
  • 00:50
    weswigham synchronize #28460
  • 00:49
    sccolbert opened #35598
garyking
@garyking
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.
Bruce Pascoe
@fatcerberus
The compiler sees a syntax error in reality but it always tries to recover and emit valid code so that makes sense
Keith Layne
@keithlayne
whoosh
Bruce Pascoe
@fatcerberus
Huh?
Anthony Lukach
@alukach
@fatcerberus :thumbsup: Oops, I spaced the error about Property 'entries' does not exist on type 'ObjectConstructor'.
Thanzex
@Thanzex

I'm trying to create a package to export some constants and interfaces that we need for a project. The interfaces work just fine, but trying to import and use one of the exported constants gives an error in compilation with webpack.
WARNING in ./src/app/app.component.ts 6:17-20 "export 'CONSTANT' was not found in 'package'
My package is made of:
constants.ts

export const TEST="test";

index.js

import { TEST } from './constants'

module.exports = { TEST }

index.d.ts

export { TEST} from './constants'

After searching for a while i found webpack/webpack#7378 that seems to dive into the problem but i haven't found a soultion yet.
Any ideas?

Keith Layne
@keithlayne
you need to export { TEST } from './constants'
Thanzex
@Thanzex
yup sorry, i re-wrote everything for the message, there are no typos
Keith Layne
@keithlayne
and in the types. Not sure what your mixed case meant. Okay.