Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dart should support interoperability with TypeScript & CoffeeScript libraries #20215

Closed
DartBot opened this issue Jul 26, 2014 · 8 comments
Closed
Assignees
Labels
area-core-library SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries. area-web Use area-web for Dart web related issues, including the DDC and dart2js compilers and JS interop. closed-obsolete Closed as the reported issue is no longer relevant library-js type-enhancement A request for a change that isn't a bug

Comments

@DartBot
Copy link

DartBot commented Jul 26, 2014

This issue was originally filed by @Emasoft


I post this as a separate proposal. The issue arised first in response to 20189 ( https://code.google.com/p/dart/issues/detail?id=20189 ).

PROBLEM: Interoperating with large JS libraries from Dart is challenging and painful. Many js libraries use scripts like TypeScript or CoffeScript to help improve type checking and usability. Dart is not able to understand those scripts files, making very difficult to migrate projects to Dart and making the transition without wasting to much time.

SOLUTION: Dart should support TypeScript for interoperability. This would allow an easier migration from the .Net ecosystem to Dart. It would allow the users to immediatly include and reuse their TypeScript libraries in Dart projects without wasting years of work. Supporting CoffeScript should also be very important, many very important libraries are written in CoffeScript todays.

To do a proper support of Typescript the following requisites have to be meet:

  1. User should just "drag&drop" a Typescript library in the DartEditor and it should automatically recognize it and make it works as a interop package. No configuration necessary.

  2. Typescript types and classes should be recognized when called from Dart code and included in the static type checking analysis at compile time. The errors should be marked on the Typescript source, not on the derived javascript code.

  3. Autocompletition of the Dart Analyzer should support Typescript autocompletitions when editing Typescript files.

  4. Interop syntax should be completely automated and hidden to the user. API access from Dart to Typescript and from Typescript to Dart should not require to write or regenerate additional code. Typescript sources should be modified at any time without being forced to modify/update the Dart code that import them.

  5. Typescript source files should be debugged, imported and exported to pub packages with yaml files the same way the Dart source files are.

  6. When called from Dart sources, all autocompletition, function declarations and auto-discovery informations of TypeScript analyzer should be still available and integrated with the Dart Analyzer. It should be possible to choose from an autocompletition list and call any class, variable or function availables in the imported Typescript library.

  7. Static type checking should be applied to ensure that the correct types are passed as arguments to (or from) the TypeScript libraries.

The same requisites should be meet in adding CoffeeScript support.

Dart should not only be able to "eat" the javascript world, it should also be able to absorb the huge CoffeeScript and TypeScript ecosystem, because almost all modern web projects are made with a mix of these.

@sethladd
Copy link
Contributor

I wonder if this is an issue for https://github.com/dart-lang/js-interop ?


cc @justinfagnani.
Added Library-JS, Area-Library, Triaged labels.

@DartBot
Copy link
Author

DartBot commented May 10, 2015

This comment was originally written by jdav...@pcprogramming.com


Please escalate, this is a big deal.

@jacob314
Copy link
Member

Set owner to @jacob314.
Added Accepted label.

@DartBot DartBot added Type-Enhancement library-js area-core-library SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries. labels May 11, 2015
@DavidSouther
Copy link

Is the opposite story going to be supported? EG if someone has an Angular2 component library written in Dart, should I just be able to take their output and link against it in my TS project?

@zoechi
Copy link
Contributor

zoechi commented Sep 21, 2015

I think the https://github.com/dart-lang/dev_compiler project is supposed to support your scenario.

@jacob314
Copy link
Member

The dev compiler is the best option for your scenario.

@kevmoo kevmoo added type-enhancement A request for a change that isn't a bug and removed accepted labels Feb 29, 2016
@denisoby
Copy link

I've tried to make my implementation of .d.ts -> dart2js annotations converter. Please, see https://github.com/denis-aes/DefinitelyTyped.dart

@vsmenon vsmenon added the area-web Use area-web for Dart web related issues, including the DDC and dart2js compilers and JS interop. label Jul 20, 2019
@sigmundch sigmundch added the closed-obsolete Closed as the reported issue is no longer relevant label Nov 8, 2021
@sigmundch
Copy link
Member

I'm about to close this issue as obsolete. Just want to provide some context:

There has been many efforts in this area since this bug was filed. We have improved the declarative @JS interop (aka package:js) and teams have been successful using tools like js_facade_gen to automatically generate Dart interop stubs from .d.ts declarations as well.

We don't have plans to make our compilers and tools to automatically recognize .d.ts or coffeescript, but instead we are investing in improving the building blocks that will make it very easy to create and maintain such language integrations outside our tools.

Next steps on our JS-interop journey is to support zero-cost static wrappers. Being static, these abstractions will add extra flexibility we need to adapt APIs when bridging between Dart and JS, but at the same time they are analyzable by our compilers and allows for a very low-cost interop at runtime.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-core-library SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries. area-web Use area-web for Dart web related issues, including the DDC and dart2js compilers and JS interop. closed-obsolete Closed as the reported issue is no longer relevant library-js type-enhancement A request for a change that isn't a bug
Projects
None yet
Development

No branches or pull requests

9 participants