Skip to content

Commit

Permalink
fix(useExternal): avoid wrong option (#2011)
Browse files Browse the repository at this point in the history
* fix: type narrowing

* chore: update ts type

* chore: update

* chore: adjust type

---------

Co-authored-by: miracles1919 <516571350@qq.com>
  • Loading branch information
vaakian and miracles1919 authored Feb 16, 2023
1 parent 17e2f07 commit 4d82a07
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions packages/hooks/src/useExternal/index.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,22 @@
import { useEffect, useRef, useState } from 'react';

export interface Options {
type?: 'js' | 'css';
type JsOptions = {
type: 'js';
js?: Partial<HTMLScriptElement>;
};

type CssOptions = {
type: 'css';
css?: Partial<HTMLStyleElement>;
}
};

type DefaultOptions = {
type?: never;
js?: Partial<HTMLScriptElement>;
css?: Partial<HTMLStyleElement>;
};

export type Options = JsOptions | CssOptions | DefaultOptions;

// {[path]: count}
// remove external when no used
Expand Down

0 comments on commit 4d82a07

Please sign in to comment.