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 🏠 label Jun 22, 2022
@babel-bot
Copy link
Collaborator

babel-bot commented Jun 22, 2022

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
Contributor

@liuxingbaoyu liuxingbaoyu Jun 22, 2022

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

@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.

@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
Contributor

@liuxingbaoyu liuxingbaoyu Jun 22, 2022

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
35 checks passed
@JLHwung JLHwung deleted the strictBindCallApply branch Jun 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PR: Internal 🏠
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants