Skip to content

In test suite, drop source from non-fallback formatted parts #1061

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

Merged
merged 3 commits into from
Mar 31, 2025

Conversation

eemeli
Copy link
Collaborator

@eemeli eemeli commented Mar 25, 2025

While reviewing the messageformat.dev documentation, I started to re-think the source value that's currently included in formatted parts.

I think we should drop it, as it makes a part of what ought to be considered implementation details into a public API (such as the name of a message variable or function). If a user does have a need to identify a specific part in the output, that ought to be explicit, and it's what we have u:id for.

For markup in particular it adds no value, as the source value is constructable from the name and the kind.

CC @ryzokuken

@eemeli eemeli added the test-suite Issue pertains to tests label Mar 25, 2025
@eemeli
Copy link
Collaborator Author

eemeli commented Mar 25, 2025

Needed to fix up the JSON schema a bit to make this work. The relative $schema reference should also make edits easier, esp. as the formatted expression part type is now an enum.

eemeli added a commit to messageformat/messageformat that referenced this pull request Mar 26, 2025
…ormat-wg#1061)

The source adds no value, and is directly constructable from the `name` and `kind`.
eemeli added a commit to messageformat/messageformat that referenced this pull request Mar 26, 2025
@@ -347,6 +342,23 @@
},
"value": {}
}
},
{
"description": "Fallback part.",
Copy link
Member

Choose a reason for hiding this comment

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

Can we be more verbose with the descriptions? They're here as documentation, after all...

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is literally a fallback part, i.e. the result of formatting a value that experienes fallback. I don't really know what else to say about it?

"id": "foo",
"value": "world"
},
{ "type": "string", "dir": "ltr", "id": "foo", "value": "world" },
Copy link
Member

Choose a reason for hiding this comment

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

any reason to lose the formatting?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Do you mean that this is on a single line, rather than the multiple lines it had previously? It's because with the change, it's now short enough to easily fit on a single line.

@catamorphism
Copy link
Collaborator

I'm not sure of the reasoning behind still including the source in fallback parts.

@eemeli
Copy link
Collaborator Author

eemeli commented Mar 27, 2025

I'm not sure of the reasoning behind still including the source in fallback parts.

It's needed to hold the representation that's also used in the string output, i.e. source: '$x' when the part would be formatted to a string as {$x}.

@aphillips aphillips merged commit 9652481 into main Mar 31, 2025
2 checks passed
@aphillips aphillips deleted the no-part-source branch March 31, 2025 16:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
test-suite Issue pertains to tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants