Skip to content

Commit

Permalink
feat: add typescript definition
Browse files Browse the repository at this point in the history
  • Loading branch information
Joxit committed Jul 22, 2021
1 parent 09d849c commit d19c7bd
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 1 deletion.
10 changes: 10 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { JawgPlaces } from '@jawg/types';

interface Options {
accessToken: string;
}

export default class JawgJSLoader {
constructor(options: Options);
loadJawgPlaces(version?: string): Promise<typeof JawgPlaces>;
}
6 changes: 6 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"version": "0.0.0",
"description": "A library to load jawg js libraries",
"main": "./dist/jawg-js-loader.js",
"types": "./index.d.ts",
"scripts": {
"build": "rollup -c",
"watch": "rollup -c -w",
Expand All @@ -14,6 +15,8 @@
"src/index.js",
"dist/jawg-js-loader.js",
"README.md",
"tsconfig.json",
"index.d.ts",
"packages.json"
],
"devDependencies": {
Expand All @@ -30,5 +33,8 @@
"rollup-plugin-app-utils": "^1.0.6",
"rollup-plugin-serve": "^1.1.0",
"rollup-plugin-terser": "^7.0.2"
},
"dependencies": {
"@jawg/types": "^1.0.0"
}
}
2 changes: 1 addition & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const load = ({ lib, version, accessToken } = {}) => {
script.async = true;
script.onload = () => {
CALLBACK_CACHE[lib].forEach(({ resolve }) => {
resolve(window.JawgPlaces);
resolve(window[lib]);
});
};

Expand Down
23 changes: 23 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6",
"dom"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": false,
"strictFunctionTypes": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": ["@jawg/types"],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts"
]
}

0 comments on commit d19c7bd

Please sign in to comment.