Skip to content

Commit

Permalink
style: 兜底类型约束补充
Browse files Browse the repository at this point in the history
  • Loading branch information
bailicangdu committed Oct 24, 2021
1 parent d8c4935 commit 96e5f86
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 8 deletions.
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ module.exports = {
'@typescript-eslint/camelcase': 0,
'@typescript-eslint/no-namespace': 0,
'@typescript-eslint/ban-ts-comment': 0,
'@typescript-eslint/ban-types': 0,
'standard/no-callback-literal': 0,
'no-console': ['error', { allow: ['warn', 'error'] }],
'prefer-spread': 0,
Expand Down
2 changes: 1 addition & 1 deletion src/interact/event_center.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export default class EventCenter {
const eventInfo = this.eventList.get(name)
if (eventInfo) {
if (isFunction(f)) {
eventInfo.callbacks.delete(f)
eventInfo.callbacks.delete(f!)
} else {
eventInfo.callbacks.clear()
}
Expand Down
4 changes: 2 additions & 2 deletions src/prefetch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ export default function preFetch (apps: prefetchParamList): void {
return logError('preFetch is only supported in browser environment')
}
requestIdleCallback(() => {
if (isFunction(apps)) apps = apps()
if (isFunction(apps)) apps = (apps as Function)()

filterPreFetchTarget(apps).forEach((item) => {
filterPreFetchTarget(apps as prefetchParam[]).forEach((item) => {
const app = new CreateApp({
name: item.name,
url: item.url,
Expand Down
2 changes: 1 addition & 1 deletion src/sandbox/effect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ function overwriteDocumentOnClick (): void {

function onClickHandler (e: MouseEvent) {
documentClickListMap.forEach((f) => {
isFunction(f) && f.call(document, e)
isFunction(f) && (f as Function).call(document, e)
})
}

Expand Down
4 changes: 2 additions & 2 deletions src/source/load_event.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export function dispatchOnLoadEvent (element: HTMLLinkElement | HTMLScriptElemen
const event = new CustomEvent('load')
eventHandler(event, element)
if (isFunction(element.onload)) {
element.onload(event)
element.onload!(event)
} else {
element.dispatchEvent(event)
}
Expand All @@ -34,7 +34,7 @@ export function dispatchOnErrorEvent (element: HTMLLinkElement | HTMLScriptEleme
const event = new CustomEvent('error')
eventHandler(event, element)
if (isFunction(element.onerror)) {
element.onerror(event)
element.onerror!(event)
} else {
element.dispatchEvent(event)
}
Expand Down
4 changes: 2 additions & 2 deletions src/source/scripts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -365,15 +365,15 @@ function usePlugins (url: string, code: string, appName: string, plugins: plugin
if (isArray(plugins.global)) {
for (const plugin of plugins.global) {
if (isPlainObject(plugin) && isFunction(plugin.loader)) {
code = plugin.loader(code, url, plugin.options)
code = plugin.loader!(code, url, plugin.options)
}
}
}

if (isArray(plugins.modules?.[appName])) {
for (const plugin of plugins.modules![appName]) {
if (isPlainObject(plugin) && isFunction(plugin.loader)) {
code = plugin.loader(code, url, plugin.options)
code = plugin.loader!(code, url, plugin.options)
}
}
}
Expand Down

0 comments on commit 96e5f86

Please sign in to comment.