From 7502d2c2882372813191eac9f7bc42338192b543 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eduardo=20Sanz=20Garc=C3=ADa?= Date: Thu, 2 Sep 2021 16:53:02 +0200 Subject: [PATCH] Create types using `tsconfig.json` Problem: the `tsc` command that generate the type declaration didn't include all the options used for type checking the project. Solution: use `tsc --build` command for both, type checking, and the generation of the type declaration. --- package.json | 3 +-- src/tsconfig.json | 6 ++++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index 76089ffa0..a514f1604 100644 --- a/package.json +++ b/package.json @@ -59,8 +59,7 @@ }, "scripts": { "build-js": "babel src --out-dir lib --source-maps --ignore '**/test' --ignore '**/karma.config.js'", - "build-types": "tsc --allowJs --declaration --emitDeclarationOnly --outDir lib src/index.js", - "build": "yarn build-js && yarn build-types", + "build": "yarn build-js && tsc --build src/tsconfig.json", "typecheck": "tsc --build src/tsconfig.json", "lint": "eslint .", "checkformatting": "prettier --check '**/*.{js,scss,md}'", diff --git a/src/tsconfig.json b/src/tsconfig.json index 071da3802..770f1f0dc 100644 --- a/src/tsconfig.json +++ b/src/tsconfig.json @@ -6,7 +6,9 @@ "jsx": "react-jsx", "jsxImportSource": "preact", "module": "commonjs", - "noEmit": true, + "declaration": true, + "emitDeclarationOnly": true, + "declarationDir": "../lib", "strict": true, "noImplicitAny": false, "target": "ES2020" @@ -15,6 +17,6 @@ "exclude": [ // Tests are not checked. "**/test/**/*.js", - "karma.config.js", + "karma.config.js" ] }