Skip to content

Improve discoverability of JS object literal constructors in interop docs - #7556

Merged
conooi merged 1 commit into
dart-lang:mainfrom
conooi:js-object-literal-constructors
Oct 7, 2026
Merged

conooi merged 1 commit into
dart-lang:mainfrom
conooi:js-object-literal-constructors

Conversation

@conooi

@conooi conooi commented Oct 6, 2026

Copy link
Copy Markdown
Contributor

Fixes #7523.

Summary

  • Get started guide (start.md):
    • Added a dedicated Create a JavaScript object literal section showing how to declare a named-parameter external constructor on an extension type and pass it directly to JS APIs (fetch()), with a cross-link to the usage reference.
    • Updated the page title (Get started with JavaScript interop) and corresponding links in index.md and tutorials.md to use imperative mood per Google developer documentation style guidelines.
  • Usage reference (usage.md):
    • Promoted member categories under Interop members (Constructors, Object literal constructors, Static members, Instance members, and Operators) to h3 headings so each appears in the right-hand "On this page" navigation with a direct URL anchor (#object-literal-constructors).
    • Clarified in Object literal constructors that constructors can be declared with or without factory, and that @anonymous / @JS() annotations aren't required (replacing the obsolete pre-Dart 3.3.1 compiler note).
    • Reorganized @js() to lead with when @JS() is required versus optional, followed by Rename interop members and types and Namespace a library subheadings.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request updates the Dart JS interop documentation by renaming sections for consistency, adding a new guide on creating JavaScript object literals, and restructuring the usage guide with clearer subheadings and updated explanations of the @JS() annotation. The review feedback correctly identifies several Dart code examples where optional parameters are declared as non-nullable, which violates sound null safety. It is recommended to apply the suggested changes to make these parameters nullable (e.g., String?, bool?, int?, and RequestOptions?) to prevent static analysis errors.

Comment thread src/content/interop/js-interop/start.md Resolved
Comment thread src/content/interop/js-interop/start.md Resolved
Comment thread src/content/interop/js-interop/usage.md Resolved
@dart-github-bot

Copy link
Copy Markdown
Collaborator

@sfshaza2 sfshaza2 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

lgtm

@conooi
conooi merged commit a997da6 into dart-lang:main Oct 7, 2026
17 checks passed
@conooi
conooi deleted the js-object-literal-constructors branch October 7, 2026 16:34
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.

[Proposal] raise visiblity for object literal constructors in the JS interop docs

3 participants