Skip to content

Commit

Permalink
typechecking carousel: remove shame files (#37213)
Browse files Browse the repository at this point in the history
* typechecking carousel/compiler: Remove shame files

* cleanup, remove accidental shame

* rcebulko comments
  • Loading branch information
samouri authored Jan 6, 2022
1 parent 5f9e38d commit 3b1371f
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 93 deletions.
22 changes: 10 additions & 12 deletions extensions/amp-carousel/0.1/build-dom.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ export function queryCarouselControls(element) {
* @param {Element} element
* @return {{
* container: HTMLDivElement
* cells: HTMLDivElement[]
* cells: HTMLElement[]
* }}
*/
function buildScrollableCarousel(element) {
Expand All @@ -150,7 +150,7 @@ function buildScrollableCarousel(element) {
}

const doc = element.ownerDocument;
const cells = realChildElements(element);
const cells = /** @type {HTMLElement[]} */ (realChildElements(element));
const container = doc.createElement('div');

container.classList.add(ClassNames.SCROLLABLE_CONTAINER);
Expand All @@ -170,7 +170,7 @@ function buildScrollableCarousel(element) {
* @param {Element} element
* @return {{
* container: HTMLDivElement
* cells: HTMLDivElement[]
* cells: HTMLElement[]
* }}
*/
function queryScrollableCarousel(element) {
Expand All @@ -179,7 +179,7 @@ function queryScrollableCarousel(element) {
`.${escapeCssSelectorIdent(ClassNames.SCROLLABLE_CONTAINER)}`
)
);
const cells = /** @type {HTMLDivElement[]} */ (
const cells = /** @type {HTMLElement[]} */ (
Array.from(
element.querySelectorAll(`.${escapeCssSelectorIdent(ClassNames.SLIDE)}`)
)
Expand All @@ -192,7 +192,7 @@ function queryScrollableCarousel(element) {
* Builds the DOM necessary for slidescroll carousel.
* @param {Element} element
* @return {{
* slides: HTMLDivElement[]
* slides: Element[]
* slidesContainer: HTMLDivElement
* slideWrappers: HTMLDivElement[]
* }}
Expand Down Expand Up @@ -236,7 +236,7 @@ function buildSlideScrollCarousel(element) {
* Queries for ivars for slidescroll.
* @param {Element} element
* @return {{
* slides: HTMLDivElement[]
* slides: Element[]
* slidesContainer: HTMLDivElement
* slideWrappers: HTMLDivElement[]
* }}
Expand All @@ -254,10 +254,8 @@ function querySlideScrollCarousel(element) {
)
)
);
const slides = /** @type {HTMLDivElement[]} */ (
Array.from(
element.querySelectorAll(`.${escapeCssSelectorIdent(ClassNames.SLIDE)}`)
)
const slides = Array.from(
element.querySelectorAll(`.${escapeCssSelectorIdent(ClassNames.SLIDE)}`)
);
assertDomQueryResults(slidesContainer, slideWrappers, slides);
return {slides, slidesContainer, slideWrappers};
Expand All @@ -270,8 +268,8 @@ function querySlideScrollCarousel(element) {
* prevButton: HTMLDivElement,
* nextButton: HTMLDivElement
* container?: HTMLDivElement
* cells?: HTMLDivElement[]
* slides?: HTMLDivElement[]
* cells?: HTMLElement[]
* slides?: Element[]
* slidesContainer?: HTMLDivElement
* slideWrappers?: HTMLDivElement[]
* }}
Expand Down
68 changes: 0 additions & 68 deletions extensions/amp-carousel/0.1/shame.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,71 +24,3 @@ declare module '#service' {
declare module '#utils/analytics' {
export var triggerAnalyticsEvent: any;
}

declare module '#core/dom/css-selectors' {
export var escapeCssSelectorIdent: (s: string) => string;
}

// TODO: everything below are core stubs, which we can remove once Core has been
// converted to TS.
declare module '#core/constants/key-codes' {
export var Keys_Enum: any;
}

declare module '#core/document/format' {
export var isAmp4Email: any;
}

declare module '#core/dom/layout/viewport-observer' {
export var observeIntersections: any;
}

declare module '#core/dom' {
export var toggleAttribute: any;
export var dispatchCustomEvent: any;
export var isServerRendered: (el: Element) => boolean;
}

declare module '#core/window' {
export var getWin: (element: Element) => Window;
}

declare module '#core/dom/query' {
export var realChildElements: any;
export var closestAncestorElementBySelector: any;
}

declare module '#core/constants/action-constants' {
export var ActionTrust_Enum: any;
}

declare module '#core/dom/layout' {
export var isLayoutSizeFixed: any;
export var isLayoutSizeDefined: any;
}

declare module '#core/dom/layout/size-observer' {
export var observeContentSize: any;
export var unobserveContentSize: any;
}

declare module '#core/types' {
export var isFiniteNumber: any;
}

declare module '#core/types/object' {
export var dict: any;
}

declare module '#core/dom/transition' {
export var numeric: any;
}

declare module '#core/dom/style' {
export var getStyle: any;
export var setStyle: any;
}

declare module '#core/data-structures/curve' {
export var bezierCurve: any;
}
2 changes: 1 addition & 1 deletion extensions/amp-carousel/0.1/slidescroll.js
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ export class AmpSlideScroll extends AMP.BaseElement {
}

/**
* @param {!LayoutSize} size
* @param {import('#core/dom/layout/rect').LayoutSizeDef} size
* @private
*/
onResized_(size) {
Expand Down
18 changes: 12 additions & 6 deletions extensions/amp-carousel/0.1/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
{
"extends": "../../../tsconfig.base.json",
"compilerOptions": {
"allowJs": true,
"checkJs": true,
"noEmit": true,
"paths": {}
"noImplicitAny": false,
"strictNullChecks": false,
"paths": {
"#compiler": ["../../../src/compiler"],
"#compiler/*": ["../../../src/compiler/*"],
"#core": ["../../../src/core"],
"#core/*": ["../../../src/core/*"],
"#third_party/*": ["../../../third_party/*"]
}
},
"include": ["*.js", "**/*.d.ts", "../../../src/*.d.ts"],
"exclude": []
"include": ["*.js", "**/*.d.ts", "../../../src/**/*.d.ts"],
"exclude": ["../../../src/purifier/index.d.ts"]
}
6 changes: 0 additions & 6 deletions src/base-element.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,6 @@ declare namespace AMP {
) => void;
}

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

declare type Layout =
| 'nodisplay'
| 'fixed'
Expand All @@ -136,6 +133,3 @@ declare type LayoutRect = {
type Mutations = {
[key: string]: null | boolean | string | number | Array<any> | Object;
};

// TODO:(samouri): correctly type this within src/core/types/object/json
declare type JsonObject = any;

0 comments on commit 3b1371f

Please sign in to comment.