From 39ac1fd8046b91299f8b7be1528115d32ae451b4 Mon Sep 17 00:00:00 2001 From: saqqdy Date: Tue, 13 Dec 2022 20:39:15 +0800 Subject: [PATCH] fix types --- src/index.ts | 5 +++++ src/loadSource.ts | 6 +++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/index.ts b/src/index.ts index b8f73486..2ada6e88 100644 --- a/src/index.ts +++ b/src/index.ts @@ -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方法返回一个浏览器判断结果对象 diff --git a/src/loadSource.ts b/src/loadSource.ts index 5b806333..7a68a988 100644 --- a/src/loadSource.ts +++ b/src/loadSource.ts @@ -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 @@ -20,10 +20,10 @@ export interface Options { */ async function loadSource( url: string, - option: SourceFileType | Options + option: SourceFileType | SourceOptions ): Promise { 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) {