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

fix: warn about import assertions when using typescript #25135

Merged

Conversation

dsherret
Copy link
Member

  1. On emit, checks for the prescence of import assertions.
  2. Warns and doesn't store the parsed source in the emit cache in this case.

Comment on lines +330 to +334
for item in &module.body {
match item {
deno_ast::swc::ast::ModuleItem::ModuleDecl(decl) => match decl {
deno_ast::swc::ast::ModuleDecl::Import(n) => {
if n.with.is_some()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you also handle import("./data.json", { assert: { type: "json" }})?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, that's annoying. I'll update it.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't need to do it for that because v8 will warn about it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay 👍

@dsherret dsherret enabled auto-merge (squash) August 21, 2024 16:35
Copy link
Member

@littledivy littledivy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm, cool fix. I guess swc should have an option to preserve import attr syntax?

@dsherret dsherret merged commit 1d41692 into denoland:main Aug 21, 2024
17 checks passed
@dsherret dsherret deleted the fix_warn_import_assertions_typescript branch August 21, 2024 18:20
@dsherret
Copy link
Member Author

I guess swc should have an option to preserve import attr syntax?

It's probably not worth the trouble.

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

Successfully merging this pull request may close these issues.

3 participants