From 6016704a8b9ed462f10af7ec1ee6087f7211e12e Mon Sep 17 00:00:00 2001 From: Geoff Rich <4992896+geoffrich@users.noreply.github.com> Date: Thu, 28 Apr 2022 12:16:15 -0700 Subject: [PATCH] feat: support TypeScript #121 --- package-lock.json | 11 +++++++++-- package.json | 8 +++++--- tsconfig.json | 18 ++++++++++++++++++ 3 files changed, 32 insertions(+), 5 deletions(-) create mode 100644 tsconfig.json diff --git a/package-lock.json b/package-lock.json index 0b685df..b1abcbb 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "@alaskaairux/icons", - "version": "4.10.1", + "version": "4.11.1", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -8646,7 +8646,8 @@ }, "hosted-git-info": { "version": "2.8.8", - "resolved": "", + "resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-2.8.8.tgz", + "integrity": "sha512-f/wzC2QaWBs7t9IYqB4T3sR1xviIViXJRJTWBlx2Gf3g0Xi5vI7Yy4koXQ1c9OYDGHN9sBy1DQ2AB8fqZBWhUg==", "dev": true }, "normalize-package-data": { @@ -11171,6 +11172,12 @@ "is-typedarray": "^1.0.0" } }, + "typescript": { + "version": "4.6.3", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.6.3.tgz", + "integrity": "sha512-yNIatDa5iaofVozS/uQJEl3JRWLKKGJKh6Yaiv0GLGSuhpFJe7P3SbHZ8/yjAHRQwKRoA6YZqlfjXWmVzoVSMw==", + "dev": true + }, "typical": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/typical/-/typical-4.0.0.tgz", diff --git a/package.json b/package.json index 4737dcc..1761f63 100644 --- a/package.json +++ b/package.json @@ -27,7 +27,8 @@ "nodemon": "^2.0.15", "npm-run-all": "^4.1.5", "semantic-release": "^17.4.7", - "svglint": "^2.1.0" + "svglint": "^2.1.0", + "typescript": "^4.6.3" }, "scripts": { "postinstall": "node packageScripts/postinstall.js", @@ -39,7 +40,7 @@ "copy:cssJs": "copyfiles -f ./src/tokens/*.js ./dist/tokens", "svglint": "svglint dist/icons/*.svg dist/icons/alert/*.svg dist/icons/in-flight/*.svg dist/icons/interface/*.svg dist/icons/shop/*.svg dist/icons/social/*.svg dist/icons/terminal/*.svg --ci", "generator": "node scripts/generate.js", - "generate": "npm-run-all sweep generator build:demo copy:dist", + "generate": "npm-run-all sweep generator build:demo copy:dist types", "test": "npm-run-all svgjest jsonlint svglint", "svgjest": "jest", "sweep": "rm -rf ./dist", @@ -47,7 +48,8 @@ "build": "npm-run-all sweep generate test copy:styles svgjest build:demo", "build:dev": "npm-run-all sweep generate build:demo test", "watch": "nodemon -e svg,js --watch src --exec npm-run-all generate test", - "serve": "web-dev-server --open demo/ --node-resolve --watch" + "serve": "web-dev-server --open demo/ --node-resolve --watch", + "types": "tsc" }, "husky": { "hooks": { diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000..8ea5fdf --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,18 @@ +{ + "include": ["dist/**/*.js"], // process the generated JS files from the SVGs + "exclude": [], + "compilerOptions": { + // Tells TypeScript to read JS files, as + // normally they are ignored as source files + "allowJs": true, + // Generate d.ts files + "declaration": true, + // This compiler run should + // only output d.ts files + "emitDeclarationOnly": true, + "outDir": "dist", + // go to js file when using IDE functions like + // "Go to Definition" in VSCode + "declarationMap": true + } +}