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

enable TS compiler option: strictBindCallApply #14685

Merged
merged 1 commit into from Jun 22, 2022

Conversation

JLHwung
Copy link
Contributor

@JLHwung JLHwung commented Jun 22, 2022

Q                       A
License MIT

Enabled the TS compiler option strictBindCallApply and fixed such typing errors.

@JLHwung JLHwung added the PR: Internal 🏠 A type of pull request used for our changelog categories label Jun 22, 2022
@babel-bot
Copy link
Collaborator

Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/52325/

@@ -81,6 +81,7 @@ export function ExportAllDeclaration(
this.word("from");
this.space();
this.print(node.source, node);
// @ts-expect-error Fixme: assertions is not defined in DeclareExportAllDeclaration
Copy link
Contributor Author

@JLHwung JLHwung Jun 22, 2022

Choose a reason for hiding this comment

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

Currently the flow parser plugin accepts

declare export * from "./module.json" assert { type: "json" }
declare export * as ns from "./module.json" assert { type: "json" }
declare export { default } from "./module.json" assert { type: "json" }

None of them are supported by Flow as of Jun 2022.

However only

declare export * from "./module.json" assert { type: "json" }

works on generator because the DeclareExportAllDeclaration reuses the ExportAllDeclaration printer.

There are two solutions:

  1. Add the missing assertions type definition to DeclareExportDeclaration and add the generator support
  2. Throw an error (i.e. JSON modules are not yet supported in Flow) when DeclareExport*Declaration have assertions and remove the generator support mentioned above

While I personally think Flow should eventually support declared JSON modules imports. I am good with either supporting it prior to the Flow project or disabling it.

Note that

declare export default from "./module.json" assert { type: "json" }

is not supported when Flow and exportDefaultFrom are both enabled, though the error message "Missing semicolon. (1:27)" after from is not very helpful.

Copy link
Member

Choose a reason for hiding this comment

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

While I personally think Flow should eventually support declared JSON modules imports. I am good with either supporting it prior to the Flow project or disabling it.

I tend to do that too.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@liuxingbaoyu I am not sure I can follow. Do you tend to agree that we should support import assertions in Flow declare exports or disallow it (like Flow current does)?

Copy link
Member

Choose a reason for hiding this comment

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

Yes, I prefer to disable them before they actually work.

@JLHwung JLHwung merged commit 3636faa into babel:main Jun 22, 2022
@JLHwung JLHwung deleted the strictBindCallApply branch June 22, 2022 16:43
@github-actions github-actions bot added the outdated A closed issue/PR that is archived due to age. Recommended to make a new issue label Sep 22, 2022
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 22, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
outdated A closed issue/PR that is archived due to age. Recommended to make a new issue PR: Internal 🏠 A type of pull request used for our changelog categories
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants