From 16babd823f0d6ca007edbb88fc7787784ec3339f Mon Sep 17 00:00:00 2001 From: Chris Krycho Date: Wed, 20 Jul 2022 20:00:20 -0600 Subject: [PATCH] Publish types in `public-types` with `typesVersions` Publish types to a `public-types` directory, in parallel to the in-place Babel-powered emit for JS. In the future, we should probably go ahead and remove the Babel emit and get this the rest of the way into a v2 addon format with a single publish step. However, this minimizes the delta introduced in this particular PR, and thus keeps the risk lower. This does *not* correctly publish types for `ember-test-helpers`. However, there remains only one export from that package the `has-ember-version` module and helper, which is also available from `@ember/test-helpers`. Accordingly, we can simply ignore that (and plan to go ahead and eventually remove it). --- .gitignore | 1 + package.json | 12 +++++++++++- tsconfig.json | 5 +++++ 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 6978e3523..f6a13b6ea 100644 --- a/.gitignore +++ b/.gitignore @@ -28,3 +28,4 @@ # tyescript related output files addon-test-support/**/*.js addon-test-support/**/*.d.ts +public-types diff --git a/package.json b/package.json index f18f6aa24..e132d1586 100644 --- a/package.json +++ b/package.json @@ -23,7 +23,10 @@ "test": "tests" }, "scripts": { - "prepack": "yarn babel --extensions '.ts' --presets @babel/preset-typescript addon-test-support --out-dir addon-test-support/ --ignore '**/*.d.ts'", + "build:types": "tsc", + "build:js": "yarn babel --extensions '.ts' --presets @babel/preset-typescript addon-test-support --out-dir addon-test-support/ --ignore '**/*.d.ts'", + "build": "npm-run-all --parallel build:*", + "prepack": "yarn build", "postpack": "rimraf addon-test-support/**/*.js", "clean": "git clean -x -f", "docs": "documentation build --document-exported \"addon-test-support/@ember/test-helpers/index.js\" --config documentation.yml --markdown-toc-max-depth 3 -f md -o API.md", @@ -152,5 +155,12 @@ "volta": { "node": "12.22.4", "yarn": "1.22.4" + }, + "typesVersions": { + "*": { + "*": [ + "public-types/*" + ] + } } } diff --git a/tsconfig.json b/tsconfig.json index 4a68608c9..241317076 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,6 +1,11 @@ { "extends": "@tsconfig/ember/tsconfig.json", "compilerOptions": { + // Use TS to emit declarations + "noEmit": false, + "emitDeclarationOnly": true, + "outDir": "public-types", + "paths": { "dummy/tests/*": ["./tests/*"], "dummy/*": ["./tests/dummy/app/*", "./app/*"],