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

Core Typechecking: enable noImplicitAny #37201

Merged
merged 10 commits into from
Dec 13, 2021
Merged

Conversation

samouri
Copy link
Member

@samouri samouri commented Dec 13, 2021

summary
Enables the noImplicitAny option for core tsconfig. There were a few changes necessary, and I am happy to bikeshed any of them:

  1. Typedefs needed to be defined in their jsdoc instead of as variables for TS to not label them any. This required I then remove all the explicit import statement of those types, since they are not JS values.
  2. @const and @private shorthand cannot be used for declaring types, and I switched them to using @type.
  3. HTMLElement and Window cannot be indexed via string, where we do this I added globals. Happy to 🚲 shed on where the global modifiers should live.
  4. Anything indexing Object or CSSStyleDeclarations via a string needed casting to any. Some I was able to fix via restructure, others seemed like too deep a well to solve (i.e.deepMerge). The logic for leaving as-is in this PR as that this doesn't make things perfect, but better than they were before (explicit any > implicit any).

@samouri samouri changed the title Core Typechecking: Add noImplicitAny Core Typechecking: enable noImplicitAny Dec 13, 2021
@samouri samouri self-assigned this Dec 13, 2021
@@ -128,8 +128,7 @@ export function isAmpMessage(message) {
);
}

/** @typedef {{creativeId: string, message: string}} */
export let IframeTransportEventDef;
/** @typedef {{creativeId: string, message: string}} IframeTransportEventDef */
Copy link
Contributor

Choose a reason for hiding this comment

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

Def as a suffix existed so we could lint-allow unused variables. For TS typing we can/should drop it

Copy link
Member Author

Choose a reason for hiding this comment

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

🚲 time! I agree overall, but I view that as incredibly low priority. Low enough that I'd rather not make the change in this PR, and likely won't in followup PRs either. AFAIK there is no downside to keeping the Def in there.

src/core/data-structures/priority-queue.js Show resolved Hide resolved
src/core/document/visibility.js Outdated Show resolved Hide resolved
src/core/assert/base.js Outdated Show resolved Hide resolved
src/core/context/node.js Outdated Show resolved Hide resolved
src/core/types/object/index.js Outdated Show resolved Hide resolved
src/core/types/object/index.js Outdated Show resolved Hide resolved
src/core/types/object/index.js Outdated Show resolved Hide resolved
src/core/types/object/json.js Outdated Show resolved Hide resolved
src/core/window/interface.js Outdated Show resolved Hide resolved
extensions/amp-video-docking/0.1/viewport-rect.js Outdated Show resolved Hide resolved
src/core/dom/layout/intersection.js Outdated Show resolved Hide resolved
src/core/dom/parse-date-attributes.js Outdated Show resolved Hide resolved
src/core/window/window.d.ts Outdated Show resolved Hide resolved
src/polyfills/get-bounding-client-rect.js Outdated Show resolved Hide resolved
@samouri samouri marked this pull request as ready for review December 13, 2021 21:50
@amp-owners-bot
Copy link

amp-owners-bot bot commented Dec 13, 2021

Hey @jridgewell! These files were changed:

src/core/3p-frame-messaging.js
src/core/assert/base.js
src/core/constants/action-constants.js
src/core/constants/loading-instructions.js
src/core/context/node.js
src/core/context/subscriber.js
src/core/context/types.d.ts
src/core/context/values.js
src/core/data-structures/curve.js
src/core/data-structures/priority-queue.js
src/core/data-structures/promise.js
src/core/data-structures/signals.js
+36 more

src/core/context/node.js Outdated Show resolved Hide resolved
src/core/dom/jsx.js Outdated Show resolved Hide resolved
src/core/context/values.js Show resolved Hide resolved
src/core/dom/layout/size-observer.js Outdated Show resolved Hide resolved
src/core/types/object/index.js Outdated Show resolved Hide resolved
src/core/types/object/index.js Outdated Show resolved Hide resolved
src/core/types/object/index.js Outdated Show resolved Hide resolved
@samouri samouri enabled auto-merge (squash) December 13, 2021 23:17
@samouri samouri merged commit 1f332cf into ampproject:main Dec 13, 2021
@samouri samouri deleted the noImplicitAny branch December 13, 2021 23:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants