diff --git a/package.json b/package.json index a03e20f4..fb312368 100644 --- a/package.json +++ b/package.json @@ -8,10 +8,11 @@ }, "main": "dist/neko.umd.js", "module": "dist/neko.common.js", + "typings": "dist/types/main.d.ts", "scripts": { "serve": "vue-cli-service serve --mode development", "lint": "vue-cli-service lint", - "build": "vue-cli-service build --target lib --name neko ./src/index.ts", + "build": "vue-cli-service build --target lib --name neko ./src/lib.ts && ./types-build.sh", "build:page": "vue-cli-service build" }, "dependencies": { diff --git a/src/component/utils/file-upload.ts b/src/component/utils/file-upload.ts index 014cf2a3..042ec875 100644 --- a/src/component/utils/file-upload.ts +++ b/src/component/utils/file-upload.ts @@ -19,6 +19,8 @@ export async function getFilesFromDataTansfer(dataTransfer: DataTransfer): Promi } const promises: Array> = [] + // Type 'DataTransferItemList' is not an array type or a string type. Use compiler option '--downlevelIteration' to allow iterating of iterators. + // @ts-ignore for (const item of dataTransfer.items) { if ('webkitGetAsEntry' in item) { promises.push(traverse(item.webkitGetAsEntry())) @@ -29,6 +31,8 @@ export async function getFilesFromDataTansfer(dataTransfer: DataTransfer): Promi } if (promises.length === 0) { + // Type 'FileList' is not an array type or a string type. Use compiler option '--downlevelIteration' to allow iterating of iterators. + // @ts-ignore return [...dataTransfer.files] } diff --git a/src/index.ts b/src/lib.ts similarity index 90% rename from src/index.ts rename to src/lib.ts index 0617b21f..24d7208f 100644 --- a/src/index.ts +++ b/src/lib.ts @@ -18,5 +18,4 @@ if (typeof window !== 'undefined' && window.Vue) { window.Vue.use(NekoElements, {}) } -export { Neko } -export default NekoElements +export default Neko diff --git a/types-build.sh b/types-build.sh new file mode 100755 index 00000000..9ab79853 --- /dev/null +++ b/types-build.sh @@ -0,0 +1,50 @@ +#!/bin/bash + +rm -rf dist/types + +# Find all vue files, and convert them to .ts files +find src/component -name "*.vue" -type f -print0 | while IFS= read -r -d '' file; do + # Get the file name + filename=$(basename -- "$file") + # Get the file name without extension + filename="${filename%.*}" + # Get the directory name + directory=$(dirname -- "$file") + # Get the directory name without the first dot + directory="${directory}" + + if [ "$directory" = "" ]; then + directory="." + fi + + echo "Creating: $file --> $directory/$filename.ts" + + # Get contant of the file, that is between + content=$(sed -n '/