Skip to content

Commit

Permalink
fix types
Browse files Browse the repository at this point in the history
  • Loading branch information
saqqdy committed Dec 13, 2022
1 parent 79f1cdd commit 39ac1fd
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
5 changes: 5 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ export type { AnyObject, AnyFunction, ArrayOneMore } from '../typings/common'
export type { WindowSizeObj } from './getWindowSize'
export type { SearchKeySet } from './searchTreeObject'
export type { DirParamType } from './getDirParam'
export type { SourceFileType, SourceOptions } from './loadSource'
export type { CssOptions, LinkAttributes } from './mountCss'
export type { ImgOptions, ImageAttributes } from './mountImg'
export type { JsOptions, ScriptAttributes } from './mountJs'
export type { StyleOptions, StyleAttributes } from './mountStyle'

// 全局参数
import client from './client' // client方法返回一个浏览器判断结果对象
Expand Down
6 changes: 3 additions & 3 deletions src/loadSource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import mountJs, { type JsOptions, type ScriptAttributes } from './mountJs'
import mountStyle, { type StyleAttributes, type StyleOptions } from './mountStyle'

export type SourceFileType = 'js' | 'img' | 'css' | 'style' | string
export interface Options {
export interface SourceOptions {
type: SourceFileType
attrs?: LinkAttributes | StyleAttributes | ScriptAttributes | ImageAttributes
props?: LinkAttributes | StyleAttributes | ScriptAttributes | ImageAttributes
Expand All @@ -20,10 +20,10 @@ export interface Options {
*/
async function loadSource(
url: string,
option: SourceFileType | Options
option: SourceFileType | SourceOptions
): Promise<boolean | string> {
if (!url) throw new Error('url不能为空')
if (!option) option = {} as Options
if (!option) option = {} as SourceOptions
if (typeof option === 'string') {
option = { type: option }
} else if (!option.type) {
Expand Down

0 comments on commit 39ac1fd

Please sign in to comment.