Skip to content

Commit

Permalink
fix: fix namespace types and typing placement
Browse files Browse the repository at this point in the history
  • Loading branch information
ala-n committed Aug 5, 2021
1 parent 3e74568 commit c2e2ab0
Show file tree
Hide file tree
Showing 42 changed files with 306 additions and 127 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
"@typescript-eslint/member-ordering": "off",
"@typescript-eslint/no-this-alias": "error",
"@typescript-eslint/no-empty-function": "off",
"@typescript-eslint/no-empty-interface": "warn",
"@typescript-eslint/no-empty-interface": "off",
"@typescript-eslint/prefer-as-const": "error",
"@typescript-eslint/no-extra-semi": "error",
"@typescript-eslint/no-explicit-any": "off",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"types": "modules/all.d.ts",
"sideEffects": [
"modules/lib.js",
"src/modules/namespace.ts",
"src/modules/lib.ts",
"modules/esl-media/providers/**/*.js",
"src/modules/esl-media/providers/**/*.ts",
"modules/draft/esl-carousel/core/view/*.js",
Expand Down
7 changes: 7 additions & 0 deletions pages/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"parserOptions": {
"project": "tsconfig.json",
"sourceType": "module"
},
"rules": {}
}
2 changes: 1 addition & 1 deletion pages/src/localdev.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import './common/test-media';
import './common/test-media-source';

// With Namespace
import '../../src/modules/namespace';
import '../../src/modules/lib';

import {
ESLImage,
Expand Down
6 changes: 6 additions & 0 deletions src/modules/draft/esl-carousel/core/esl-carousel-slide.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,9 @@ export class ESLCarouselSlide extends ESLBaseElement {
this.toggleAttribute('first', first);
}
}

declare global {
export interface HTMLElementTagNameMap {
'esl-carousel-slide': ESLCarouselSlide;
}
}
11 changes: 11 additions & 0 deletions src/modules/draft/esl-carousel/core/esl-carousel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -289,3 +289,14 @@ export class ESLCarousel extends ESLBaseElement {
customElements.whenDefined(ESLCarouselSlide.is).then(() => super.register.call(this, tagName));
}
}

declare global {
export interface ESLCarouselPlugins {}
export interface ESLLibrary {
Carousel: typeof ESLCarousel;
CarouselPlugin: typeof ESLCarouselPlugin;
}
export interface HTMLElementTagNameMap {
'esl-carousel': ESLCarousel;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -90,3 +90,12 @@ export class ESLCarouselAutoplayPlugin extends ESLCarouselPlugin {
}
}
}

declare global {
export interface ESLCarouselPlugins {
Autoplay: typeof ESLCarouselAutoplayPlugin;
}
export interface HTMLElementTagNameMap {
'esl-carousel-autoplay-plugin': ESLCarouselAutoplayPlugin;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,12 @@ export class ESLCarouselDotsPlugin extends ESLCarouselPlugin {
return `<button role="button" class="carousel-dot ${isActive ? 'active-dot' : ''}" data-slide-target="g${index + 1}"></button>`;
}
}

declare global {
export interface ESLCarouselPlugins {
Dots: typeof ESLCarouselDotsPlugin;
}
export interface HTMLElementTagNameMap {
'esl-carousel-dots': ESLCarouselDotsPlugin;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,12 @@ export class ESLCarouselLinkPlugin extends ESLCarouselPlugin {
this._target = target;
}
}

declare global {
export interface ESLCarouselPlugins {
Link: typeof ESLCarouselLinkPlugin;
}
export interface HTMLElementTagNameMap {
'esl-carousel-link-plugin': ESLCarouselLinkPlugin;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -74,3 +74,12 @@ export class ESLCarouselTouchPlugin extends ESLCarouselPlugin {
event.stopPropagation();
};
}

declare global {
export interface ESLCarouselPlugins {
Touch: typeof ESLCarouselTouchPlugin;
}
export interface HTMLElementTagNameMap {
'esl-carousel-touch-plugin': ESLCarouselTouchPlugin;
}
}
9 changes: 9 additions & 0 deletions src/modules/esl-a11y-group/core/esl-a11y-group.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,3 +93,12 @@ export class ESLA11yGroup extends ESLBaseElement {
return this.$targets.includes($active) ? $active : null;
}
}

declare global {
export interface ESLLibrary {
A11yGroup: typeof ESLA11yGroup;
}
export interface HTMLElementTagNameMap {
'esl-a11y-group': ESLA11yGroup;
}
}
9 changes: 9 additions & 0 deletions src/modules/esl-alert/core/esl-alert.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,3 +150,12 @@ export class ESLAlert extends ESLToggleable {
e.stopPropagation();
}
}

declare global {
export interface ESLLibrary {
Alert: typeof ESLAlert;
}
export interface HTMLElementTagNameMap {
'esl-alert': ESLAlert;
}
}
9 changes: 9 additions & 0 deletions src/modules/esl-footnotes/core/esl-footnotes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,3 +109,12 @@ export class ESLFootnotes extends ESLBaseElement {
EventUtils.dispatch(this, `${ESLFootnotes.eventNs}:request`);
}
}

declare global {
export interface ESLLibrary {
Footnotes: typeof ESLFootnotes;
}
export interface HTMLElementTagNameMap {
'esl-footnotes': ESLFootnotes;
}
}
9 changes: 9 additions & 0 deletions src/modules/esl-footnotes/core/esl-note.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,3 +166,12 @@ export class ESLNote extends ESLBaseElement {
EventUtils.dispatch(this, `${ESLFootnotes.eventNs}:response`);
}
}

declare global {
export interface ESLLibrary {
Note: typeof ESLNote;
}
export interface HTMLElementTagNameMap {
'esl-note': ESLNote;
}
}
9 changes: 9 additions & 0 deletions src/modules/esl-forms/esl-select-list/core/esl-select-item.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,12 @@ export class ESLSelectItem extends ESLBaseElement {
return item;
}
}

declare global {
export interface ESLLibrary {
SelectItem: typeof ESLSelectItem;
}
export interface HTMLElementTagNameMap {
'esl-select-item': ESLSelectItem;
}
}
9 changes: 9 additions & 0 deletions src/modules/esl-forms/esl-select-list/core/esl-select-list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,3 +179,12 @@ export class ESLSelectList extends ESLSelectWrapper {
}
}
}

declare global {
export interface ESLLibrary {
SelectList: typeof ESLSelectList;
}
export interface HTMLElementTagNameMap {
'esl-select-list': ESLSelectList;
}
}
6 changes: 6 additions & 0 deletions src/modules/esl-forms/esl-select/core/esl-select-dropdown.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,3 +106,9 @@ export class ESLSelectDropdown extends ESLToggleable {
this.style.width = `${rect.width}px`;
}
}

declare global {
export interface HTMLElementTagNameMap {
'esl-select-dropdown': ESLSelectDropdown;
}
}
6 changes: 6 additions & 0 deletions src/modules/esl-forms/esl-select/core/esl-select-renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,3 +120,9 @@ export class ESLSelectRenderer extends ESLBaseElement {
e.preventDefault();
}
}

declare global {
export interface HTMLElementTagNameMap {
'esl-select-renderer': ESLSelectRenderer;
}
}
9 changes: 9 additions & 0 deletions src/modules/esl-forms/esl-select/core/esl-select.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,3 +168,12 @@ export class ESLSelect extends ESLSelectWrapper {
this._onUpdate();
}
}

declare global {
export interface ESLLibrary {
Select: typeof ESLSelect;
}
export interface HTMLElementTagNameMap {
'esl-select': ESLSelect;
}
}
9 changes: 9 additions & 0 deletions src/modules/esl-image/core/esl-image.ts
Original file line number Diff line number Diff line change
Expand Up @@ -309,3 +309,12 @@ export class ESLImage extends ESLBaseElement {
return src === ESLImage.EMPTY_IMAGE;
}
}

declare global {
export interface ESLLibrary {
Image: typeof ESLImage;
}
export interface HTMLElementTagNameMap {
'esl-image': ESLImage;
}
}
6 changes: 6 additions & 0 deletions src/modules/esl-media-query/core/common/env-shortcuts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,9 @@ ESLEnvShortcuts.add('gecko', DeviceDetector.isGecko);
ESLEnvShortcuts.add('blink', DeviceDetector.isBlink);
ESLEnvShortcuts.add('safari', DeviceDetector.isSafari);
ESLEnvShortcuts.add('safari-ios', DeviceDetector.isMobileSafari);

declare global {
export interface ESLLibrary {
EnvShortcuts: typeof ESLEnvShortcuts;
}
}
8 changes: 7 additions & 1 deletion src/modules/esl-media-query/core/common/screen-breakpoint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const registry = new Map<string, ESLScreenBreakpoint>();
*
* Screen Breakpoint registry is used to provide custom breakpoints for {@link ESLMediaQuery}
*/
@ExportNs('ScreenBreakpoint')
@ExportNs('ScreenBreakpoints')
export abstract class ESLScreenBreakpoints {
protected static readonly BP_REGEXP = /^([+-]?)([a-z]+)/i;
protected static readonly BP_NAME_REGEXP = /^[a-z]+/i;
Expand Down Expand Up @@ -88,3 +88,9 @@ ESLScreenBreakpoints.add('sm', 768, 991);
ESLScreenBreakpoints.add('md', 992, 1199);
ESLScreenBreakpoints.add('lg', 1200, 1599);
ESLScreenBreakpoints.add('xl', 1600, 999999);

declare global {
export interface ESLLibrary {
ScreenBreakpoints: typeof ESLScreenBreakpoints;
}
}
6 changes: 6 additions & 0 deletions src/modules/esl-media-query/core/common/screen-dpr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,9 @@ export class ESLScreenDPR {
return `(min-resolution: ${ESLScreenDPR.toDPI(dpr)}dpi)`;
}
}

declare global {
export interface ESLLibrary {
ScreenDPR: typeof ESLScreenDPR;
}
}
6 changes: 6 additions & 0 deletions src/modules/esl-media-query/core/esl-media-query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,3 +103,9 @@ export abstract class ESLMediaQuery implements IMediaQueryCondition {
ESLMediaQuery.use(ESLScreenDPR);
ESLMediaQuery.use(ESLScreenBreakpoints);
ESLMediaQuery.use(ESLEnvShortcuts);

declare global {
export interface ESLLibrary {
MediaQuery: typeof ESLMediaQuery;
}
}
6 changes: 6 additions & 0 deletions src/modules/esl-media-query/core/esl-media-rule-list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,3 +129,9 @@ export class ESLMediaRuleList<T = any> extends Observable<RuleChangedCallback<T>
this.fire(this._active = rule, this);
}
}

declare global {
export interface ESLLibrary {
MediaRuleList: typeof ESLMediaRuleList;
}
}
9 changes: 9 additions & 0 deletions src/modules/esl-media/core/esl-media.ts
Original file line number Diff line number Diff line change
Expand Up @@ -400,3 +400,12 @@ export class ESLMedia extends ESLBaseElement {
return EventUtils.dispatch(this, ns + eventName, eventInit);
}
}

declare global {
export interface ESLLibrary {
Media: typeof ESLMedia;
}
export interface HTMLElementTagNameMap {
'esl-media': ESLMedia;
}
}
9 changes: 9 additions & 0 deletions src/modules/esl-panel/core/esl-panel-group.ts
Original file line number Diff line number Diff line change
Expand Up @@ -232,3 +232,12 @@ export class ESLPanelGroup extends ESLBaseElement {
});
}
}

declare global {
export interface ESLLibrary {
PanelGroup: typeof ESLPanelGroup;
}
export interface HTMLElementTagNameMap {
'esl-panel-group': ESLPanelGroup;
}
}
9 changes: 9 additions & 0 deletions src/modules/esl-panel/core/esl-panel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,3 +145,12 @@ export class ESLPanel extends ESLToggleable {
return Object.assign({}, stackConfig, this.defaultParams, params || {});
}
}

declare global {
export interface ESLLibrary {
Panel: typeof ESLPanel;
}
export interface HTMLElementTagNameMap {
'esl-panel': ESLPanel;
}
}
9 changes: 9 additions & 0 deletions src/modules/esl-popup/core/esl-popup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -206,3 +206,12 @@ export class ESLPopup extends ESLToggleable {
}
}
}

declare global {
export interface ESLLibrary {
Popup: typeof ESLPopup;
}
export interface HTMLElementTagNameMap {
'esl-popup': ESLPopup;
}
}
9 changes: 9 additions & 0 deletions src/modules/esl-scrollbar/core/esl-scrollbar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -308,3 +308,12 @@ export class ESLScrollbar extends ESLBaseElement {
this.deferredRefresh();
}
}

declare global {
export interface ESLLibrary {
Scrollbar: typeof ESLScrollbar;
}
export interface HTMLElementTagNameMap {
'esl-scrollbar': ESLScrollbar;
}
}
9 changes: 9 additions & 0 deletions src/modules/esl-tab/core/esl-tab.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,12 @@ export class ESLTab extends ESLTrigger {
}
}
}

declare global {
export interface ESLLibrary {
Tab: typeof ESLTab;
}
export interface HTMLElementTagNameMap {
'esl-tab': ESLTab;
}
}
9 changes: 9 additions & 0 deletions src/modules/esl-tab/core/esl-tabs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -244,3 +244,12 @@ export class ESLTabs extends ESLBaseElement {
}
}
}

declare global {
export interface ESLLibrary {
Tabs: typeof ESLTabs;
}
export interface HTMLElementTagNameMap {
'esl-tabs': ESLTabs;
}
}
Loading

0 comments on commit c2e2ab0

Please sign in to comment.