-
Notifications
You must be signed in to change notification settings - Fork 1.7k
[breaking change] Change parameter type of importModule
from String
to JSAny
#55508
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
Labels
area-web
Use area-web for Dart web related issues, including the DDC and dart2js compilers and JS interop.
breaking-change-approved
breaking-change-request
This tracks requests for feedback on breaking changes
web-js-interop
Issues that impact all js interop
Comments
@itsjustkevin FYI - I just sent out an email to announce@dartlang.org for both this and #55267. |
Looks good to me! |
lgtm as well |
LGTM |
no objection |
@vsmenon ping |
lgtm |
This breaking change has been approved |
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.
breaking-change-approved
breaking-change-request
This tracks requests for feedback on breaking changes
web-js-interop
Issues that impact all js interop
Change Intent
dart:js_interop
'simportModule
should accept aJSAny
instead of aString
.Original issue here: #55429
Justification
JavaScript's
dynamic import
function can accept more than justString
s. See https://tc39.es/proposal-dynamic-import/#sec-import-call-runtime-semantics-evaluation and https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/import#importing_modules_with_a_non-literal_specifier. One key usage is the ability to pass aTrustedScriptURL
, allowing a sanitized specifier to be imported.Impact
Minimal. There's only one usage in GitHub, and no usages in the SDK, google3, or Flutter.
Mitigation
The fix is to convert the
String
to aJSString
usingtoJS
e.g.importModule('module')
->importModule('module'.toJS)
I don't believe mitigation is possible due to it being a parameter and not a return type. There's no way to "test" that a function takes in a specific type. One possibility that may work if it only needs to be mitigated for DDC and dart2js is to use
dynamic
to pass the value toimportModule
e.g.Since
JSString
is a DartString
when compiling to JS, this will avoid the breakage. This won't work for mitigating the issue for dart2wasm.Change Timeline
This is a simple change and should go in Dart 3.5. No specific beta is planned yet.
Associated CLs
WIP CL here: https://dart-review.googlesource.com/c/sdk/+/363504
The text was updated successfully, but these errors were encountered: