Skip to content

Commit

Permalink
Merge pull request #24 from dartess/ts
Browse files Browse the repository at this point in the history
add typescript declaration file
  • Loading branch information
eldargab authored Aug 15, 2021
2 parents 09f6c10 + 21ccbb8 commit a282a01
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
12 changes: 12 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
type Callback = (errorOrNull: Error | null, script: HTMLScriptElement) => void;

type AllowedAttributes = 'type' | 'charset' | 'async' | 'text';

type Options = Partial<Pick<HTMLScriptElement, AllowedAttributes>> & {
attrs?: Record<string, string>;
}

declare function load (src: HTMLScriptElement['src'], opts: Callback): void;
declare function load (src: HTMLScriptElement['src'], opts: Options, cb: Callback): void;

export default load;
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"name": "load-script",
"description": "Dynamic script loading for browser",
"version": "1.0.0",
"version": "2.0.0",
"types": "./index.d.ts",
"keywords": [
"browser",
"script",
Expand Down

0 comments on commit a282a01

Please sign in to comment.