Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • Mar 19 2021 08:31
    Himujjal commented #34
  • Mar 19 2021 08:30
    Himujjal commented #34
  • May 07 2019 13:57
    ThomasdenH edited #37
  • May 07 2019 13:56
    ThomasdenH closed #36
  • May 06 2019 20:05
    ThomasdenH edited #37
  • May 06 2019 20:00
    ThomasdenH synchronize #37
  • May 04 2019 16:52
    yever synchronize #23
  • May 04 2019 16:52

    yever on forEachTrailingCommentRange

    Last chance for iterator; other… Implement iterateCommentRanges … Compiles but tests are failing and 1 more (compare)

  • May 03 2019 19:29
    yever closed #29
  • May 03 2019 19:29
    yever commented #29
  • May 02 2019 15:03
    ThomasdenH opened #37
  • May 02 2019 07:02
    ThomasdenH opened #36
  • May 01 2019 10:51
    yever assigned #35
  • May 01 2019 10:51
    yever opened #35
  • May 01 2019 10:13
    yever commented #34
  • May 01 2019 10:09
    goodmind commented #34
  • May 01 2019 10:08
    goodmind commented #34
  • May 01 2019 10:06
    goodmind reopened #34
  • May 01 2019 09:49
    yever commented #33
  • May 01 2019 09:24
    goodmind reopened #33
andretshurotshka
@goodmind
It wouldn't work if you just replaced js toString with Rust equivalent because they don't work the same. I just don't see how would you rewrite typechecker
Ya'ar Hever
@yever
The compiler parses and analyzes the TypeScript code in terms of tokens and abstract syntax tree. The type check analysis doesn't need the JS runtime.
The goal of this project is to rewrite the TypeScript compiler. The compiler is written in TypeScript and compiles to JS and runs on nodejs. But this is a somewhat arbitrary choice. It could have been written in C just as well.
andretshurotshka
@goodmind
It does, because it uses toString for number literals, I can't find the code because checker.ts is 2mb file
And I'm on phone
Ya'ar Hever
@yever
You mean for parsing a numeric literal as string?
andretshurotshka
@goodmind
I mean it stores it internally as string
type S = 0xdeadbeef
Type hint wouldn't display hex number
Ya'ar Hever
@yever
Yeah, so parsing numeric literals like 56e-13214126 or 0xdeadbeef etc. would probably need to be reimplemented in Rust
Maybe there is already some crate that does that... But yeah, it's needed
Well, in the context of Rust => WebAssembly, wasm-bindgen allows bindings in both directions. So we can "import" a JS function and use it from Rust.
But this would couple our implementation to wasm-bindgen and the JS runtime... I'm not sure whether we want it or not.
Thomas den Hollander
@ThomasdenH
It would be nice to have different targets ultimately.
But for single functions it shouldn't be too hard to be spec compliant and use something like proptest to test they're equivalent.
Thomas den Hollander
@ThomasdenH
@yever You have forEachLeadingCommentRange in both the todo column and the in progress column.
How should SourceFileLike be provided? An equivalent struct?
Thomas den Hollander
@ThomasdenH
I have added get_position_of_line_and_character, but I can't figure out how to cache the lineMap in SourceFileLike.
It isn't required to provide the correct interface, but I think it matters performance-wise.
Ya'ar Hever
@yever
I think the best way is to create structs/enums to represent TypeScript types
I started with a types.rs file for that, maybe this should be reorganized somehow
Nice work, @ThomasdenH ! ThomasdenH/rusty-typescript@a9e9f12
You can make a pull request so we can discuss the code in review comments
I'm starting a new job tomorrow, so I might be a bit less responsive until the weekend.
Thomas den Hollander
@ThomasdenH
I have created the PR. #36
Thomas den Hollander
@ThomasdenH
However, it is not possible to then create an object that satisfies the interface as far as I could see.
Ya'ar Hever
@yever
Thanks for the PRs. I'll be able to read them and understand the issues more thoroughly during the weekend.
But I'm thinking that there isn't much point in satisfying JS interfaces, except for the endpoints that we expose. So, if TypeScript has func1() calling func2() calling func3() and all three are exported, then each one has to do the wasteful thing of serializing/deserializing, but if you call func1, it can use from the Rust side the Rust func2 and func3, so no serialization/deserialization is needed.
Ya'ar Hever
@yever
One stupid solution for creating JS objects is to use Object.fromEntries(), which is expose as js_sys::Object::from_entries() -- https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/fromEntries
You'll need to create an array of key-value pairs, like [['key1', 'value1'], ['key2', 'value2']]
As a JsValue
Ok, that's all the time I have for now. More in two days :)
Thomas den Hollander
@ThomasdenH
I now have a Javascript interface with the simplest possible conversion to a Rust equivalent.
That way it's usable without issues in Rust, but a simple into() should do.
I think that's faster than deriving Serialize, but I'm not certain.
Ya'ar Hever
@yever
How do you implement this into()?
Tochukwu Nkemdilim
@TNkemdilim
I was looking into implementing the getLeadingCommentRanges(...). Should I implement it, or is someone else working on it?
Thomas den Hollander
@ThomasdenH
I think it's free.
I was tinkering with with the TextSpan functions myself.
Into is automatically implemented via From<T>.
You can even accept impl Into<SomeRustType>, because any type implements a zero-cost into for themselves
But I'm not sure whether wasm_bindgen can deal with it.
Tochukwu Nkemdilim
@TNkemdilim
@ThomasdenH Then I'll work on it.
Ya'ar Hever
@yever
Thanks for continuing to work. I've been having a couple of quite hectic days.
Thomas den Hollander
@ThomasdenH
I have added some more methods to one of my PR's.
It's failing because of EOL delimiters, not sure how to fix it.
andretshurotshka
@goodmind
Is this
Madhava Jay
@madhavajay
Hi, I am wondering does anyone know is it possible to pass functions / callbacks to Rust from TypeScript which Rust can then invoke back after doing some work?
Himujjal Upadhyaya
@Himujjal
Is this project still active? I would like to contribute.