Skip to content

Add __brand to make empty interfaces nominal #2075

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

saschanaz
Copy link
Contributor

@saschanaz saschanaz commented Jul 19, 2025

Because who have thought that there are so many existing empty interfaces which are also used as parameter types. And thus this follows the pattern in https://www.typescriptlang.org/play/?#example/nominal-typing.

Preparing for #2074.

Because who have thought that there are so many existing interfaces which are also used as parameter types.
Copy link
Contributor

Thanks for the PR!

This section of the codebase is owned by @saschanaz - if they write a comment saying "LGTM" then it will be merged.

@saschanaz
Copy link
Contributor Author

https://github.com/microsoft/TypeScript-DOM-lib-generator/pull/1246/files#r881972594 suggested emitting a class with a private member. While I'm all for emitting classes (yes please) but a private member would only raise the possibility to clash with other libraries. Introducing a public member would allow other libraries to match the brand.

Copy link
Contributor

@Bashamega Bashamega left a comment

Choose a reason for hiding this comment

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

Mostly looks good.

Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe combine all the if statements into one if statement?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

IMO complex expressions are better as a separate statement.

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.

2 participants