Skip to content

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

Merged
RyanCavanaugh merged 2 commits into
microsoft:masterfrom
brendankenny:noimplicitjsdoc
Aug 16, 2019
Merged

checkJs: require JSDoc type argument for Array, Object, and Promise in noImplicitAny#32829
RyanCavanaugh merged 2 commits into
microsoft:masterfrom
brendankenny:noimplicitjsdoc

Conversation

@brendankenny
Copy link
Copy Markdown
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
Copy Markdown

msftclas commented Aug 12, 2019

CLA assistant check
All CLA requirements met.

Comment thread src/compiler/checker.ts
}
checkNoTypeArguments(node);
return anyType;
return !noImplicitAny ? anyType : undefined;
Copy link
Copy Markdown
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
Copy Markdown
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
@microsoft microsoft locked as resolved and limited conversation to collaborators Oct 21, 2025
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.

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

4 participants