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

typechecking carousel: remove shame files #37213

Merged
merged 3 commits into from
Jan 6, 2022
Merged

Conversation

samouri
Copy link
Member

@samouri samouri commented Dec 14, 2021

summary
Hooks up amp-carousel-0.1 to Core types s.t. we no longer need most of the shame file.
Unfortunately I could not simply extend the tsconfig.base.json yet, as there are a couple hundred errors that strictNullCheck and noImplicitAny cause. Will need to address those separately.

@samouri samouri changed the title typechecking carousel/compiler: Remove shame files typechecking carousel: remove shame files Jan 6, 2022
@samouri samouri marked this pull request as ready for review January 6, 2022 16:45
@samouri samouri requested review from rcebulko and removed request for alanorozco January 6, 2022 16:45
@samouri samouri self-assigned this Jan 6, 2022
@samouri samouri enabled auto-merge (squash) January 6, 2022 16:45
@samouri samouri disabled auto-merge January 6, 2022 16:45
@@ -150,7 +150,7 @@ function buildScrollableCarousel(element) {
}

const doc = element.ownerDocument;
const cells = realChildElements(element);
const cells = /** @type {HTMLDivElement[]}*/ (realChildElements(element));
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this guaranteed to be DIVs?

Copy link
Member Author

Choose a reason for hiding this comment

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

Good point. Technically we aren't even guaranteed they will be HTMLElements..but we currently have code that assumes they are.

I'll cast to HTMLElement for now.

Copy link
Contributor

Choose a reason for hiding this comment

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

realChildElements returns an array of the same type as element, so if element is properly typed to HTMLElement, an additional cast shouldn't be necessary

Copy link
Member Author

@samouri samouri Jan 7, 2022

Choose a reason for hiding this comment

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

Didn't know that! Very cool. Is it correct though? I think realChildElements can legitimately return Element (i.e. SVG or HTML)

"include": ["*.js", "**/*.d.ts", "../../../src/*.d.ts"],
"exclude": []
"include": ["*.js", "**/*.d.ts", "../../../src/**/*.d.ts"],
"exclude": ["../../../src/purifier/index.d.ts"]
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you still extend the base here, but override the noImplicitAny?

Copy link
Member Author

Choose a reason for hiding this comment

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

I'll test it out. The thing I'm more concerned about is #paths.

Copy link
Member Author

@samouri samouri Jan 6, 2022

Choose a reason for hiding this comment

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

Good idea! We cannot fully do this yet bc of paths.
Not all of #utils is typed yet and carousel utilizes utils.

The rest works!

Copy link
Contributor

Choose a reason for hiding this comment

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

If we add .d.ts files for the utils dependency it would make future typechecking progressively easier

@@ -107,9 +107,6 @@ declare namespace AMP {
) => void;
}

// TODO(samouri): Move the types below to better locations.
declare type AmpElement = HTMLElement;

declare type Layout =
Copy link
Contributor

Choose a reason for hiding this comment

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

I think LayoutSize and LayoutRect can be imported from #core/dom/layout

Copy link
Member Author

Choose a reason for hiding this comment

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

Sick. I'll do that.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ok that didn't work. Cannot import a module from an ambient context :(

Copy link
Contributor

Choose a reason for hiding this comment

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

You should be able to import it from within the namespace, though, which is where the types are used (or just import inline on lines 27/28

Copy link
Contributor

@jridgewell jridgewell left a comment

Choose a reason for hiding this comment

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

Owners

@samouri samouri merged commit 3b1371f into ampproject:main Jan 6, 2022
@samouri samouri deleted the tsconfig branch January 6, 2022 20:53
westonruter added a commit that referenced this pull request Jan 10, 2022
…nce-attr-to-hero-img

* 'main' of github.com:ampproject/amphtml: (525 commits)
  mathml storybook: supply missing component definition. (#37326)
  storybook: Iframe --> BentoIframe (#37327)
  🖍  [Story system layer] New ad badge (#37311)
  🐛 [amp story] Replay/next page button bug fix (#37316)
  🚀  [Story performance] Remove affiliate links (#37280)
  Compiler: Add amp-carousel-0.1 to the builder map (#37308)
  ⏪  [Story system layer] Audio icon disappears when story has background audio (#37314)
  🚀  [Story performance] Remove story access (#37281)
  Fix remapping esbuild output on Windows (#37312)
  🐛 adds in correct weight for amp-story-product-tag text (#37188)
  typechecking carousel: remove shame files (#37213)
  Use remapping to remap minified sourcemap into source code (#37238)
  SwG Release 0.1.22.199 (#37310)
  🐛 Adds microsoft-edge protocol (#34168)
  Sync for validator cpp engine and cpp htmlparser (#37292)
  ✨ amp-story-shopping Updated currency with product price and correct Localized currency (#37249)
  ✨[Smartadserver ad extension] Implement support for Fast Fetch (#36991)
  Remove client-side-experiments-config.json from this repo (#37304)
  🚮  Remove closure compiler logic from build-system. (#37296)
  🌐 Added RTL ordering i18n for amp story shopping tag (#37252)
  ...
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