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

Ability to 'import' Typescript libraries #23423

Closed
DartBot opened this issue May 11, 2015 · 10 comments
Closed

Ability to 'import' Typescript libraries #23423

DartBot opened this issue May 11, 2015 · 10 comments
Labels
area-web Use area-web for Dart web related issues, including the DDC and dart2js compilers and JS interop. closed-not-planned Closed as we don't intend to take action on the reported issue type-enhancement A request for a change that isn't a bug

Comments

@DartBot
Copy link

DartBot commented May 11, 2015

This issue was originally filed by jdav...@pcprogramming.com


What steps will clearly show the issue / need for enhancement?

  1. using the 'import' statement, try to import a Typescript library
    2.
    3.

What is the current output?
nothing

What would you like to see instead?
I would like to be able to use Typescript libraries with the 'import' statement.

What version of the product are you using? On what operating system?
latest, 1.11

Please provide any additional information below.
win 8.1

@anders-sandholm
Copy link
Contributor

I suggest potentially looking at the DEP process on https://github.com/dart-lang/dart_enhancement_proposals to get more traction on this kind of request.


Added Area-LanguageFeature, Triaged labels.

@kevmoo
Copy link
Member

kevmoo commented May 23, 2015

Work related to this is in-progress. Stay tuned...


cc @jacob314.

@mit-mit mit-mit added area-language Dart language related items (some items might be better tracked at github.com/dart-lang/language). and removed Area-LanguageFeature labels Sep 1, 2015
@kevmoo kevmoo added type-enhancement A request for a change that isn't a bug and removed triaged labels Mar 1, 2016
@denisoby
Copy link

denisoby commented May 21, 2016

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

@unicomp21
Copy link

Hmmmm ... this is dead?

@eyalkutz
Copy link

@kevmoo is this still being worked on?

@lrhn
Copy link
Member

lrhn commented Jan 29, 2021

I don't believe anyone is currently working on this issue.
It would only make sense when compiling for the web, and our JavaScript integration story does not extend to directly importing typescript libraries (Dart is not a typescript compiler).
A more likely approach is to generate Dart code with JS annotations to interface with the JS code. (I don't personally know of any such project, but I'm also not doing much web development).

@lrhn lrhn added area-web Use area-web for Dart web related issues, including the DDC and dart2js compilers and JS interop. and removed area-language Dart language related items (some items might be better tracked at github.com/dart-lang/language). labels Jan 29, 2021
@unicomp21
Copy link

see babylon_dart for some good examples of how to handle this problem

also, i'm having very good luck w/ protobuf-ts and dart protocol buffers for marshaling between the two languages, within the browser.

@sigmundch sigmundch added the closed-not-planned Closed as we don't intend to take action on the reported issue label Feb 3, 2021
@sigmundch
Copy link
Member

indeed, as @lrhn, this seems to be closer to the area of JS-interop.

Since the time this issue was filed we have added support for interoperability between Dart and JavaScript via package:js. It requires JS code to be loaded separately, and Dart facades to be declared to expose JavaScript/TypeScript APIs to the Dart application.

We are still actively working on improving the JS-interop story, so the solution will continue to change. That being said, our plans involve improvements in making the JS-interop declarations more ergonomic and idiomatic in Dart, but we do not have any plans that will make JS constructs like a ES6 module import directly accessible from Dart. For that reason I will be closing this issue at this time.

Hope this answers some of your questions.

@unicomp21
Copy link

disappointing

@sigmundch
Copy link
Member

Just to be clear: we value interoperability a lot and we are working heavily in this area to provide good building blocks and foundations to make interoperability with JS/TS easy and flexible.

Since Dart is a multi-platform language, there are constraints to balance when we think about how to bridge Dart and other languages. As a result, we can't simply make Dart tools accept and understand imports to other languages like TS without some additional hints and binding logic. We do believe, however, that one can make it easier to create those bindings with code generation tools that create JS-interop definitions from .d.ts files (like https://github.com/dart-lang/js_facade_gen, and babylon_dart_gen that you pointed out above).

@unicomp21 - using protobuf to marshal between the two languages it's pretty clever! One caveat is that there is a cost in marshalling data. It may not be a cost that is visible in your application, but if it becomes noticeable I'd recommend to check out the package:js alternative. With package:js you should be able access and interact with TS in the browser without the cost of coping/serialization. Today there may be a layer of indirection in our JS-interop communication, but we expect some of that indirection to be removed in the future with the improvements we are making.

Cheers!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-web Use area-web for Dart web related issues, including the DDC and dart2js compilers and JS interop. closed-not-planned Closed as we don't intend to take action on the reported issue type-enhancement A request for a change that isn't a bug
Projects
None yet
Development

No branches or pull requests

9 participants