Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • 17:23
    typescript-bot synchronize #36322
  • 16:57
    dphochman edited #36260
  • 16:56
    orta synchronize #15575
  • 16:55
    orta synchronize #28460
  • 16:55
    orta synchronize #31641
  • 16:54

    orta on master

    Remove the compiler diag 1360 a… (compare)

  • 16:54
    orta closed #36332
  • 16:02
    orta assigned #36332
  • 16:02
    orta opened #36332
  • 15:35
    realh closed #36331
  • 14:21
    antongolub review_requested #36328
  • 14:11
    a-tarasyuk review_requested #36187
  • 13:40
    a-tarasyuk synchronize #36187
  • 13:29
    realh opened #36331
  • 13:10
    a-tarasyuk synchronize #36187
  • 13:08
    a-tarasyuk reopened #36187
  • 12:53
    OliverJAsh edited #36330
  • 12:46
    OliverJAsh edited #36330
  • 12:46
    OliverJAsh edited #36330
  • 12:46
    OliverJAsh edited #36330
Robert Plummer
@robertleeplummerjr
I’m fully aware of the dag-on disconnect! I wrote like 90% of GPU.js.
:P
Bruce Pascoe
@fatcerberus
Okay, just making sure
Robert Plummer
@robertleeplummerjr
(Meant in a funny jokey reply, not angry)
Bruce Pascoe
@fatcerberus
I like the two-level generic you have going there :smile:
Robert Plummer
@robertleeplummerjr
I just want it to give proper feedback for developers.
Bruce Pascoe
@fatcerberus
Sorry it took so long to get to the root of the issue
Robert Plummer
@robertleeplummerjr
Nope, no problem.
ty for your very generous help!
Bruce Pascoe
@fatcerberus
n/p, always happy to help
Robert Plummer
@robertleeplummerjr
Can a method inherit a type?
Bruce Pascoe
@fatcerberus
Not sure what you mean
Robert Plummer
@robertleeplummerjr
Like can I just say: “Use the type from the class in this method."
Because when I remove the <> from the method, it all breaks.
Bruce Pascoe
@fatcerberus
If I understand correctly:
class Foo {
    fooey(x: this): void;
}

new Foo().fooey(new Foo());
Also works if the class is generic
Robert Plummer
@robertleeplummerjr
This doesn’t work:
class GPU<ArgT extends ThreadKernelVariable = ThreadKernelVariable> {
    createKernel(kernel: KernelFunction<ArgT[]>): void { 

    }
}
This works:
class GPU<ArgT extends ThreadKernelVariable = ThreadKernelVariable> {
    createKernel<ArgTThatIHaveToRepeat extends ArgT>(kernel: KernelFunction<ArgTThatIHaveToRepeat[]>): void { 

    }
}
Bruce Pascoe
@fatcerberus
Yeah, you need the latter because the type can vary on two axes (when the class is constructed, then again depending on the function the user passed)
In the former, ArgT is fixed at class construction
HOWEVER, you could do this with the former version:
const gpu = new GPU<number[]>();
const kernel = gpu.createKernel(function (electricFieldX: number[]) {});
Your problem there was that new GPU() has no inference source for ArgT, but you can provide it explicitly
Robert Plummer
@robertleeplummerjr
"Overly complex, it is” - Yoda
cphoover
@cphoover

@keithlayne what's the deal with runtypes error reporting. I have a deeply nested object and it just says:

errors.js:19 Uncaught (in promise) Error: Expected string, but was undefined

No field level messages?

for Record types?
Bruce Pascoe
@fatcerberus
@robertleeplummerjr new GPU() - with no type parameter gives you a GPU instance which is expected to handle any kind of ThreadKernelVariable. So your options are either:
  1. Specialize it further in createKernel using another level of generic
  2. Provide the correct type parameter at construction
GIven how you've described your system, I'd go with 2
Robert Plummer
@robertleeplummerjr
@fatcerberus ty!
Bruce Pascoe
@fatcerberus
btw shameless plug tangentially related to your GPU.js: https://github.com/fatcerberus/oozaru
Demo: https://fatcerberus.github.io/specs
oh, oops
My bad, the demo will only work in Chrome with import maps enabled in about:flags
cphoover
@cphoover
anyone have experience with runtypes?
Keith Layne
@keithlayne
@cphoover The info is in the error, it's just not in the message
cphoover
@cphoover
@keithlayne hmmm it's not pointing to the bad line in the stack trace is it?
I don't think so.
could be wrong
Nope stack trace not useful
Keith Layne
@keithlayne
there's at least a key field
I meant the error object
cphoover
@cphoover
ooo lemme try that...
thanks @keithlayne
Keith Layne
@keithlayne
umm, wait a sec
I get it from the validate method, gotta look at the types
cphoover
@cphoover
What's the difference between the check and validate methods?
Keith Layne
@keithlayne
check throws
cphoover
@cphoover
interesting...
Keith Layne
@keithlayne
export declare class ValidationError extends Error {
    message: string;
    key?: string | undefined;
    name: string;
    constructor(message: string, key?: string | undefined);
}
cphoover
@cphoover
awesome
thank you
Keith Layne
@keithlayne
:thumbsup: