Skip to content

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

Merged
aphillips merged 3 commits intomainfrom
no-part-source
Mar 31, 2025
Merged

In test suite, drop source from non-fallback formatted parts#1061
aphillips merged 3 commits intomainfrom
no-part-source

Conversation

@eemeli
Copy link
Copy Markdown
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
Copy Markdown
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
}
},
{
"description": "Fallback part.",
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Collaborator

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

@eemeli
Copy link
Copy Markdown
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
XM5jDcsHTyGJtQqlCi added a commit to XM5jDcsHTyGJtQqlCi/messageformat that referenced this pull request Oct 12, 2025
…ormat-wg#1061)

The source adds no value, and is directly constructable from the `name` and `kind`.
XM5jDcsHTyGJtQqlCi added a commit to XM5jDcsHTyGJtQqlCi/messageformat that referenced this pull request Oct 12, 2025
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