From 4904e85bd22237b51e0c678339506bf68b9d2dd9 Mon Sep 17 00:00:00 2001 From: Nolan Lawson Date: Sat, 6 Jun 2020 18:08:05 -0700 Subject: [PATCH] feat: add typescript types --- .gitignore | 6 +++++- index.d.ts | 7 +++++++ package.json | 10 +++++++--- src/types/{Database.ts => database.ts} | 0 src/types/{Picker.ts => picker.ts} | 3 +++ 5 files changed, 22 insertions(+), 4 deletions(-) create mode 100644 index.d.ts rename src/types/{Database.ts => database.ts} (100%) rename src/types/{Picker.ts => picker.ts} (92%) diff --git a/.gitignore b/.gitignore index 6bf7b46..4132386 100644 --- a/.gitignore +++ b/.gitignore @@ -119,5 +119,9 @@ dist /database.js.map /picker.js /picker.js.map +/picker.d.ts +/database.d.ts +/shared.d.ts -/docs-tmp \ No newline at end of file +/docs-tmp +/ts-tmp \ No newline at end of file diff --git a/index.d.ts b/index.d.ts new file mode 100644 index 0000000..978bd98 --- /dev/null +++ b/index.d.ts @@ -0,0 +1,7 @@ +import Picker from './picker' +import Database from './database' + +export { + Picker, + Database +} diff --git a/package.json b/package.json index e6a68d2..2791941 100644 --- a/package.json +++ b/package.json @@ -4,18 +4,22 @@ "description": "A lightweight emoji picker, distributed as a custom element", "main": "index.js", "module": "index.js", + "types": "index.d.ts", "type": "module", "files": [ "database.js*", "index.js*", - "picker.js*" + "picker.js*", + "*.d.ts" ], "scripts": { - "build": "run-s build:rollup build:css-docs build:i18n-docs", + "prepare": "run-s build", + "build": "run-s build:rollup build:css-docs build:i18n-docs build:types build:typedoc", "build:rollup": "NODE_ENV=production rollup -c", "build:css-docs": "node ./bin/generateCssDocs", "build:i18n-docs": "node ./bin/generateI18nDocs", - "build:typedoc": "rm -fr docs-tmp && typedoc --out docs-tmp --theme markdown --excludePrivate --excludeNotExported --hideSources --hideBreadcrumbs ./src/types && node ./bin/generateTypeDocs && rm -fr docs-tmp", + "build:typedoc": "typedoc --out docs-tmp --theme markdown --excludePrivate --excludeNotExported --hideSources --hideBreadcrumbs ./src/types && node ./bin/generateTypeDocs && rm -fr docs-tmp", + "build:types": "tsc -d --outDir ./ts-tmp ./src/types/*.ts && mv ./ts-tmp/*.d.ts ./ && rm -fr ts-tmp", "dev": "NODE_ENV=development rollup -c -w", "lint": "standard && stylelint '**/*.scss'", "lint:fix": "standard --fix && stylelint --fix '**/*.scss'", diff --git a/src/types/Database.ts b/src/types/database.ts similarity index 100% rename from src/types/Database.ts rename to src/types/database.ts diff --git a/src/types/Picker.ts b/src/types/picker.ts similarity index 92% rename from src/types/Picker.ts rename to src/types/picker.ts index 0e61c64..2c3a4bc 100644 --- a/src/types/Picker.ts +++ b/src/types/picker.ts @@ -1,6 +1,9 @@ import {PickerConstructorOptions} from "./shared"; export default class Picker extends HTMLElement { + dataSource: string; + locale: string; + i18n: object; /** *