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

fix: better detection of references, handle namespace dependencies #89

Merged
merged 4 commits into from
Aug 23, 2024

Conversation

dummdidumm
Copy link
Collaborator

@dummdidumm dummdidumm commented Aug 22, 2024

  • fixes dts-buddy 0.5.1 generating error_1 instead of error #86: tweak the "is this a reference logic" to not care about method signatures, and not care about the sub parts of qualified names (i.e. we only care about X in a X.Y.Z type reference, because we don't traverse into namespaces, and this can only be a namespace reference)
  • fixes namespaces are not traversed #88: add the dependencies of namespaces to the namespace declaration, or else treeshaking would wrongfully remove imports that are only dependencies of the declarations inside the namespace
  • also fixes import * as X namespace imports, they were not handled correctly before (a bit unrelated to this PR, but I came across it while investigating the whole namespace thing)

@dummdidumm dummdidumm marked this pull request as ready for review August 23, 2024 12:19
if (!ts.isIdentifier(node)) return false;

if (node.parent) {
if (is_declaration(node.parent)) {
if (ts.isVariableStatement(node.parent)) {
return node === node.parent.declarationList.declarations[0].name;
return false;
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I changed this because the previous statement didn't make sense - the node could never be equal to the right hand side, because the node itself can only ever be VariableDeclarationList

@dummdidumm
Copy link
Collaborator Author

dummdidumm commented Aug 23, 2024

(side note: I recommend changing the default from Merge pull request to Squash and merge in the project settings)

@Rich-Harris Rich-Harris merged commit fc14a42 into main Aug 23, 2024
16 checks passed
@Rich-Harris Rich-Harris deleted the namespace-and-id-conflicts branch August 23, 2024 14:58
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.

namespaces are not traversed dts-buddy 0.5.1 generating error_1 instead of error
2 participants