typechecking carousel: remove shame files#37213
Conversation
|
|
||
| const doc = element.ownerDocument; | ||
| const cells = realChildElements(element); | ||
| const cells = /** @type {HTMLDivElement[]}*/ (realChildElements(element)); |
There was a problem hiding this comment.
Is this guaranteed to be DIVs?
There was a problem hiding this comment.
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.
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.
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.
Could you still extend the base here, but override the noImplicitAny?
There was a problem hiding this comment.
I'll test it out. The thing I'm more concerned about is #paths.
There was a problem hiding this comment.
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.
If we add .d.ts files for the utils dependency it would make future typechecking progressively easier
| // TODO(samouri): Move the types below to better locations. | ||
| declare type AmpElement = HTMLElement; | ||
|
|
||
| declare type Layout = |
There was a problem hiding this comment.
I think LayoutSize and LayoutRect can be imported from #core/dom/layout
There was a problem hiding this comment.
Ok that didn't work. Cannot import a module from an ambient context :(
There was a problem hiding this comment.
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
…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.1to Core types s.t. we no longer need most of the shame file.Unfortunately I could not simply extend the
tsconfig.base.jsonyet, as there are a couple hundred errors thatstrictNullCheckandnoImplicitAnycause. Will need to address those separately.