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

checkJs: require JSDoc type argument for Array, Object, and Promise in noImplicitAny #32829

Merged
merged 2 commits into from
Aug 16, 2019

Conversation

brendankenny
Copy link
Contributor

Fixes #32766

As discussed in that issue, when noImplicitAny is set in checkJs, this change makes it an error to not specify a type argument in the jsdoc annotations for /** @type {Array} */, /** @type {Object} */, and /** @type {Promise} */ the same way it is for all other jsdoc parameterized types.

If not noImplicitAny, nothing changes and the type argument(s) will continue to default to any for these three special cases.

Also as discussed in #32766 (comment), dropping the Object -> any mapping will be a bigger change than the other two types, though

  • it's arguably what the author wants if they've set noImplicitAny and
  • it's unclear how many strict checkJs projects are out there that will break with this change

@msftclas
Copy link

msftclas commented Aug 12, 2019

CLA assistant check
All CLA requirements met.

@@ -9348,7 +9348,7 @@ namespace ts {
return anyType;
}
checkNoTypeArguments(node);
return anyType;
return !noImplicitAny ? anyType : undefined;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

these were the minimal change, but they could be negated or split up if that seems clearer

@RyanCavanaugh RyanCavanaugh merged commit f45add0 into microsoft:master Aug 16, 2019
@sandersn
Copy link
Member

I think changing Object to Object is what people want when writing fresh jsdoc for Typescript's consumption. And there don't seem to be many people to break anyway.

@brendankenny brendankenny deleted the noimplicitjsdoc branch August 19, 2019 18:20
timsuchanek pushed a commit to timsuchanek/TypeScript that referenced this pull request Sep 11, 2019
…n noImplicitAny (microsoft#32829)

* Require type argument for JSDoc Array, Object, and Promise in noImplicitAny

* add jsdoc Array/Object/Promise noImplicitAny tests
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.

JSDoc: make it a noImplicitAny error to leave out Array or Promise type argument
4 participants