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

Attach generic type parameters to the declaring type #2619

Merged
merged 4 commits into from
Jun 19, 2024

Conversation

flobernd
Copy link
Member

@flobernd flobernd commented Jun 18, 2024

Attach generic type parameters to the declaring type instead of the parent namespace.

This more precisely reflects the actual declaration hierarchy and allows type parameters to be uniquely identified by their FQNs.

The following definition:

export class A<T> { }

caused a type parameter with the FQN some.namespace.T to get emitted.

The same type parameter is now emitted as some.namespace.A.T instead.

@flobernd flobernd requested a review from l-trotta June 18, 2024 08:34
@@ -74,5 +74,6 @@ export default function buildJsonSpec (): Map<string, JsonSpec> {
map.set(name, json[name])
}

return map
// Ensure deterministic ordering
return new Map([...map.entries()].sort())
Copy link
Member Author

Choose a reason for hiding this comment

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

Maps in JS are iterated in the order of insertion. This map is created by enumerating the filesystem which causes the entries to be inserted in a different order on Linux and Windows.

Copy link
Member

@swallez swallez left a comment

Choose a reason for hiding this comment

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

LGTM.

@Anaethelion @JoshMock @l-trotta make sure this doesn't break anything in your respective clients. It should not, as it only changes the namespace of generic parameters, not their names.

The rationale behind this change is that it ensures global uniqueness of generic parameter names, even if their scope is limited to the enclosing type definition, which can help when processing a global type graph.

@flobernd flobernd merged commit f3bf565 into main Jun 19, 2024
8 checks passed
@flobernd flobernd deleted the improve-generic-params branch June 19, 2024 06:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants