This repository has been archived by the owner on Feb 18, 2022. It is now read-only.
Fix detection of export syntax in declaration file #24
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When we inspect a declaration file, we try to decide if it uses
export =
syntax or named/default ("normal") exports. To do this, we were looking for export constructs in the AST. If we fail to find any export construct, then we stop (with aninferenceError
) and don't proceed to infer the type of the module and so we don't perform any further checks.However, if there's no explicit export keyword or statement, every declaration is considered as exported. So in cases where there's no explicit export, we don't check for instance if the properties exported from the JS match the d.ts.
This PR changes the code to always consider that we're dealing with "normal" exports if we don't find an
export =
, so we're able to perform further checks for more packages.The observable result should be that we're able to perform the "JsPropertyNotInDts" check for more packages, which only changes the suggestions provided and doesn't interfere with linting, but it would be nice to test this and future PRs using dtslint-runner before merging and publishing.