Skip to content

Commit a282a01

Browse files
authored
Merge pull request #24 from dartess/ts
add typescript declaration file
2 parents 09f6c10 + 21ccbb8 commit a282a01

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

index.d.ts

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
type Callback = (errorOrNull: Error | null, script: HTMLScriptElement) => void;
2+
3+
type AllowedAttributes = 'type' | 'charset' | 'async' | 'text';
4+
5+
type Options = Partial<Pick<HTMLScriptElement, AllowedAttributes>> & {
6+
attrs?: Record<string, string>;
7+
}
8+
9+
declare function load (src: HTMLScriptElement['src'], opts: Callback): void;
10+
declare function load (src: HTMLScriptElement['src'], opts: Options, cb: Callback): void;
11+
12+
export default load;

package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
{
22
"name": "load-script",
33
"description": "Dynamic script loading for browser",
4-
"version": "1.0.0",
4+
"version": "2.0.0",
5+
"types": "./index.d.ts",
56
"keywords": [
67
"browser",
78
"script",

0 commit comments

Comments
 (0)