-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
Conversation
@@ -150,7 +150,7 @@ function buildScrollableCarousel(element) { | |||
} | |||
|
|||
const doc = element.ownerDocument; | |||
const cells = realChildElements(element); | |||
const cells = /** @type {HTMLDivElement[]}*/ (realChildElements(element)); |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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"] |
There was a problem hiding this comment.
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
?
There was a problem hiding this comment.
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
.
There was a problem hiding this comment.
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!
There was a problem hiding this comment.
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 = |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 :(
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Owners
…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) ...
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 thatstrictNullCheck
andnoImplicitAny
cause. Will need to address those separately.