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

Produce an error for an augmentation of an untyped module even if moduleNotFoundError is not defined #12852

Merged
1 commit merged into from
Dec 12, 2016

Conversation

ghost
Copy link

@ghost ghost commented Dec 12, 2016

Fixes #12827

The fix in #11962 asserted that moduleNotFoundError would be defined for any module augmentations.
However, if the augmentation is in a declaration file, this is undefined, because we don't validate names of augmentations that are defined in ambient context. See #8200. The reason @vladima mentioned was (#8113 (comment)):

it is quite possible that some 3rd party module A that was imported in application also defines an augmentation for some another module B but application itself does not use B and as a consequence does not have dependency on it so resolution for B always will fail and user will always see some errors that he cannot get rid of.

However, if we have an untyped import, that means that we are using the library, but don't have typings for it. The problem is that you can't augment typings that don't exist.
We could elide the error, but the augmentation would then have no effect -- you would still get any when trying to use functions defined by the augmentation.

const diag = Diagnostics.Invalid_module_name_in_augmentation_Module_0_resolves_to_an_untyped_module_at_1_which_cannot_be_augmented;
error(errorNode, diag, moduleName, resolvedModule.resolvedFileName);
error(errorNode, diag, moduleReference, resolvedModule.resolvedFileName);
Copy link
Author

@ghost ghost Dec 12, 2016

Choose a reason for hiding this comment

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

This has no effect on tests, but seemed more correct, as moduleName is escaped, and the below error also uses moduleReference.

@mhegazy
Copy link
Contributor

mhegazy commented Dec 12, 2016

@andy-ms, please port this change to release-2.1 as well.

@ghost ghost merged commit a33e653 into master Dec 12, 2016
@ghost ghost deleted the untyped_augmentation_2 branch December 12, 2016 20:33
@mhegazy mhegazy mentioned this pull request Dec 12, 2016
@microsoft microsoft locked and limited conversation to collaborators Jun 19, 2018
This pull request was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Debug.assert for missing module name augmentation
3 participants