Skip to content
This repository has been archived by the owner on Aug 24, 2022. It is now read-only.

JsAPI: Adapters and TypeScript #930

Open
iskiselev opened this issue Dec 9, 2015 · 2 comments
Open

JsAPI: Adapters and TypeScript #930

iskiselev opened this issue Dec 9, 2015 · 2 comments

Comments

@iskiselev
Copy link
Member

Let's start discussion of this discussion in parallel to #532.

I believe that we need some convenient way to interact between translated C# code and JavaScript.
Main problem here is dynamic nature of JavaScript. On other hand, we now, that TypeScript lives with it, and even provide statically typed mapping files for many existing pure-JavaScript libraries.

We can begin with such *.d.ts files. If we will be able to map them to some C# interfaces (it should be roundtrip, so that we should be able map produced C# interfaces back), we'll be able to pass our C# objects implementing them as input parameters to C# methods - and treat method results as C# objects.

Really, here we have second problem - we can't use raw JS object as .Net interface implementer (and vice versa). So we need an adapters layer - 2 of them, for wrapping .Net object and export it to JavaScript and wrapping JavaScrpt object and exporting it to .Net.

We may need to view, how same interaction implemented in https://github.com/bridgedotnet/Bridge and probably discuss it with them - it would be only benefit for all of us if we'll have compatible interfaces mapping.
Looks like they have C# project, that is able to parse *.d.ts files - https://github.com/bridgedotnet/Retyped (other option would be write C# interface generators in TypeScript and use TypeScript compiler for extracting type information).

So, first step should be mapping of TypeScript interface to C#. Let's discuss it.

@iskiselev iskiselev changed the title JsAPI: Adapters JsAPI: Adapters and TypeScript Dec 9, 2015
@iskiselev
Copy link
Member Author

Looks like Wire formats (dotnet/roslyn#3910), that are in working list for C#7 (dotnet/roslyn#2136) with (Strong interest) mark could also help us solve JS-interop problem.

@kg
Copy link
Member

kg commented Dec 11, 2015

Oh, nice! F# type providers are a great tool, so it's good to see they're thinking about things like that.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants