Skip to content

Commit

Permalink
Fixed types
Browse files Browse the repository at this point in the history
  • Loading branch information
mateussouzaweb committed Mar 22, 2022
1 parent b0b33cc commit 1d1068c
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
10 changes: 5 additions & 5 deletions src/core/component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ declare type State = any
declare type Callback = (component: Component) => void | Promise<void>

declare type Component = {
element: Element,
element: HTMLElement,
state: State,
template: Template,
render: (state?: State) => void | Promise<void>
Expand All @@ -28,7 +28,7 @@ declare type Definition = {
onDestroy: Callback
}

declare interface WithComponents extends Element {
declare interface WithComponents extends HTMLElement {
__components?: Record<string, Component>
}

Expand Down Expand Up @@ -164,7 +164,7 @@ async function render(component: Component, callback: Callback) {
* Mount components on given target element
* @param target
*/
async function mount(target: Element) {
async function mount(target: HTMLElement) {

for (const definition of _definitions) {

Expand Down Expand Up @@ -228,7 +228,7 @@ async function mount(target: Element) {
* Destroy components on given target element
* @param target
*/
async function destroy(target: Element) {
async function destroy(target: HTMLElement) {

for (const definition of _definitions) {

Expand Down Expand Up @@ -259,5 +259,5 @@ async function destroy(target: Element) {

}

export type { Selector, Template, State, Callback }
export type { Selector, Template, State, Component, Callback }
export { register, unregister, render, mount, destroy }
8 changes: 4 additions & 4 deletions src/core/selector.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
declare type Selectable = HTMLElement | Element | Document
declare type Selectable = HTMLElement | Document
declare type Context = string | Selectable

/**
* Retrieve the resolved valid context
* @param context
* @returns
*/
function getContext(context?: Context): Selectable {
function getContext(context?: Context) {
context = (typeof context === 'string') ? $(context) : context
context = (context instanceof Node) ? context : document
return context
return context as Selectable
}

/**
Expand All @@ -19,7 +19,7 @@ function getContext(context?: Context): Selectable {
* @returns
*/
function $(selector: string, context?: Context) {
return getContext(context).querySelector(selector)
return getContext(context).querySelector(selector) as Selectable
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/extra/http.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ function interceptAfter(callback: HTTPCallback) {
* @param headers
* @returns
*/
async function request(method: string, url: string, data?: BodyInit, headers?: HeadersInit) {
async function request(method: string, url: string, data?: BodyInit, headers?: HeadersInit): Promise<any> {

const request: HTTPRequest = {
method: method,
Expand Down
2 changes: 1 addition & 1 deletion src/extra/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { fire, watch } from "../core/observers"

declare interface RoutePath {
path: string
regex: RegExp
regex?: RegExp
location?: string,
[key: string]: any
}
Expand Down

0 comments on commit 1d1068c

Please sign in to comment.