Skip to content

Fix React.Component type errors in amp-date-picker and remove suppressions #23429

@rsimha

Description

@rsimha

The latest version of closure compiler returns these type errors in amp-date-picker.

The moment errors were fixed by renaming the local variable to Moment. The React.Component errors were a tougher nut to crack, so I had to suppress them in 53b4fc1.

/cc @jridgewell

Type checking failed:
extensions/amp-date-picker/0.1/date-picker-common.js:39: ERROR - [JSC_UNRECOGNIZED_TYPE_ERROR] Bad type annotation. Unknown type moment
It's possible that a local variable called 'moment' is shadowing the intended global namespace.
   * @param {?moment} max
              ^

extensions/amp-date-picker/0.1/date-picker-common.js:40: ERROR - [JSC_UNRECOGNIZED_TYPE_ERROR] Bad type annotation. Unknown type moment
It's possible that a local variable called 'moment' is shadowing the intended global namespace.
   * @return {?moment}
               ^

extensions/amp-date-picker/0.1/date-picker-common.js:53: ERROR - [JSC_UNRECOGNIZED_TYPE_ERROR] Bad type annotation. Unknown type moment
It's possible that a local variable called 'moment' is shadowing the intended global namespace.
   * @param {!moment} date
              ^

extensions/amp-date-picker/0.1/date-picker-common.js:54: ERROR - [JSC_UNRECOGNIZED_TYPE_ERROR] Bad type annotation. Unknown type moment
It's possible that a local variable called 'moment' is shadowing the intended global namespace.
   * @param {!moment} min
              ^

extensions/amp-date-picker/0.1/date-picker-common.js:55: ERROR - [JSC_UNRECOGNIZED_TYPE_ERROR] Bad type annotation. Unknown type moment
It's possible that a local variable called 'moment' is shadowing the intended global namespace.
   * @param {!moment} max
              ^

extensions/amp-date-picker/0.1/date-picker-common.js:67: ERROR - [JSC_UNRECOGNIZED_TYPE_ERROR] Bad type annotation. Unknown type moment
It's possible that a local variable called 'moment' is shadowing the intended global namespace.
   * @param {!moment} date
              ^

extensions/amp-date-picker/0.1/date-picker-common.js:86: ERROR - [JSC_UNRECOGNIZED_TYPE_ERROR] Bad type annotation. Unknown type moment
It's possible that a local variable called 'moment' is shadowing the intended global namespace.
   * @param {!moment} day
              ^

extensions/amp-date-picker/0.1/date-picker-common.js:110: ERROR - [JSC_UNRECOGNIZED_TYPE_ERROR] Bad type annotation. Unknown type moment
It's possible that a local variable called 'moment' is shadowing the intended global namespace.
   * @param {?moment} startDate
              ^

extensions/amp-date-picker/0.1/date-picker-common.js:111: ERROR - [JSC_UNRECOGNIZED_TYPE_ERROR] Bad type annotation. Unknown type moment
It's possible that a local variable called 'moment' is shadowing the intended global namespace.
   * @param {?moment} endDate
              ^

extensions/amp-date-picker/0.1/date-picker-common.js:113: ERROR - [JSC_UNRECOGNIZED_TYPE_ERROR] Bad type annotation. Unknown type moment
It's possible that a local variable called 'moment' is shadowing the intended global namespace.
   * @param {!moment} day
              ^

extensions/amp-date-picker/0.1/date-picker-common.js:128: ERROR - [JSC_UNRECOGNIZED_TYPE_ERROR] Bad type annotation. Unknown type React.Component
It's possible that a local variable called 'React' is shadowing the intended global namespace.
  class Component extends React.Component {
                          ^

extensions/amp-date-picker/0.1/react-utils.js:28: ERROR - [JSC_UNRECOGNIZED_TYPE_ERROR] Bad type annotation. Unknown type React.Component
It's possible that a local variable called 'React' is shadowing the intended global namespace.
  class DeferredType extends React.Component {
                             ^

extensions/amp-date-picker/0.1/react-utils.js:34: ERROR - [JSC_CONFORMANCE_POSSIBLE_VIOLATION] Possible violation: History.p.state is broken in IE11. Please use the helper methods provided in src/history.js
The type information available for this expression is too loose to ensure conformance.
      this.state = {value: this.props.initial};
      ^^^^^^^^^^

extensions/amp-date-picker/0.1/react-utils.js:48: ERROR - [JSC_CONFORMANCE_POSSIBLE_VIOLATION] Possible violation: History.p.state is broken in IE11. Please use the helper methods provided in src/history.js
The type information available for this expression is too loose to ensure conformance.
        shallowDiffers(this.props, props) || shallowDiffers(this.state, state)
                                                            ^^^^^^^^^^

extensions/amp-date-picker/0.1/react-utils.js:59: ERROR - [JSC_CONFORMANCE_POSSIBLE_VIOLATION] Possible violation: History.p.state is broken in IE11. Please use the helper methods provided in src/history.js
The type information available for this expression is too loose to ensure conformance.
      return this.props.then(this.state.value);
                             ^^^^^^^^^^

extensions/amp-date-picker/0.1/single-date-picker.js:105: ERROR - [JSC_UNRECOGNIZED_TYPE_ERROR] Bad type annotation. Unknown type React.Component
It's possible that a local variable called 'React' is shadowing the intended global namespace.
  class FocusedTrueHack extends React.Component {
                                ^

extensions/amp-date-picker/0.1/wrappers/maximum-nights.js:34: ERROR - [JSC_UNRECOGNIZED_TYPE_ERROR] Bad type annotation. Unknown type React.Component
It's possible that a local variable called 'React' is shadowing the intended global namespace.
  class MaximumNights extends React.Component {
                              ^

17 error(s), 0 warning(s), 92.6% typed

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions