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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unrelated JSDoc annotation causes class to not be assignable to itself or iterable #53967
Comments
My initial guess is that the implicit export Edit: The fact that the error can go away when rebuilding the checker implies that there may be a missing call to |
Slightly simplified repro (this version only has one call to make debugging easier): // @lib: es2017
// @allowJs: true
// @checkJs: true
// @noEmit: true
// from #53967, based on webpack/webpack#16957
// @filename: index.js
const LazySet = require("./LazySet");
/** @type {LazySet} */
const stringSet = undefined;
stringSet.addAll(stringSet);
// @filename: LazySet.js
// Comment out this JSDoc, and note that the errors index.js go away.
/**
* @typedef {Object} SomeObject
*/
class LazySet {
/**
* @param {LazySet} iterable
*/
addAll(iterable) {}
[Symbol.iterator]() {}
}
module.exports = LazySet; |
Fixes microsoft#53967 The problem is that the weird, ad-hoc CJS merge needs to happen at two different times. The first is its existing location in getCommonJsExportEquals. The second is getResolvedMembersOrExportsOfSymbol, which combines normal, early-bound symbols with late-bound symbols. The CJS merge happens before the addition of late-bound symbols, so a merge will result in the loss of [Symbol.iterable] from the bug. But manually merging the resolvedExports/Members during the CJS merge also doesn't work, because it prevents the module's resolvedExports/Members from being filled in later. Instead, this PR delays part of the CJS merge to getResolvedMembersOrExportsOfSymbol. Unfortunately, this requires retrieving the original, unmerged symbols--since their resolvedExports/Members are already cached. I do this by looking at the symbols for each of the merged symbol's declarations, which feels wrong. Please suggest alternate ways to do this. I don't think I understand the late-binding machinery well enough, so it's likely there's a cleaner way.
Maybe I have a similar problem? The type from a JavaScript import is incompatible with a JSDoc import. Files
To reproduce
Actual behavior
Edit: #55608 |
It could be related because of the |
Bug Report
馃攷 Search Terms
jsdoc annotation iterable self assignable
馃晽 Version & Regression Information
馃捇 Code
Here's a compiler repro that reliably works.
馃檨 Actual behavior
webpack/webpack#16957 (comment)
Note that
LazySet
is not assignable toLazySet
, which is weird. Changing the signature ofaddAll
to just beIterable<T>
is equivalent.Also, if you actually construct this example in the editor, editing
index.js
will make the error go away temporarily, until tsserver is restarted, orLazySet.js
is edited. Very odd.馃檪 Expected behavior
No errors.
@alexander-akait @TheLarkInn
The text was updated successfully, but these errors were encountered: