Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Publish .d.ts TypeScript declaration files for plugins #1892

Closed
cpcallen opened this issue Sep 4, 2023 · 3 comments
Closed

Publish .d.ts TypeScript declaration files for plugins #1892

cpcallen opened this issue Sep 4, 2023 · 3 comments
Labels
ghc-osd Reserved for open source day: https://anitab-org.github.io/open-source-day/ type: feature request New feature or request

Comments

@cpcallen
Copy link
Contributor

cpcallen commented Sep 4, 2023

Category

  • Plugins

Component

All—at least all that are written in TypeScript—most probably via modifications to dev-scripts.

Is your feature request related to a problem? Please describe.

Users in the forum report issues with their editors and/or builds complaining about missing type declarations.

Describe the solution you'd like

For the plugins that are built from TypeScript source, we should generate a dist/index.d.ts file and ensure it is included in the published NPM package.

Describe alternatives you've considered

  • We could… just not. But it seems like it should be easy to do and be helpful to developers using plugins from TypeScript.
  • On the other hand we could autogenerate .d.ts files for TS-sourced plugins and hand roll .d.ts files or try to use tsickle to translate Closure type declarations for those that are still written in JS—but that seems like a lot of work that might better be spent on porting those plugins to TypeScript.

Additional context

It's not immediately obvious whether this can be done merely by modifying plugins/dev-scripts/config/webpack.config.js or whether we will additionally have to update all of the plugins/*/tsconfig.json files (plus dev-create/templates/typescript-*/template/tsconfig.json).

@cpcallen cpcallen added type: feature request New feature or request triage labels Sep 4, 2023
@laurensvalk
Copy link
Contributor

This would be very useful.

I wonder if it is sufficient to set "declaration": true for the tsconfig.json files of the ts-based plugins. With the following patch, running build will produce the d.ts files in the src output.

diff --git a/plugins/block-shareable-procedures/package.json b/plugins/block-shareable-procedures/package.json
index 06f56f7d..02e6f13e 100644
--- a/plugins/block-shareable-procedures/package.json
+++ b/plugins/block-shareable-procedures/package.json
@@ -15,6 +15,7 @@
   "main": "./dist/index.js",
   "module": "./src/index.js",
   "unpkg": "./dist/index.js",
+  "types": "./src/index.d.ts",
   "author": "Blockly Team",
   "keywords": [
     "blockly",
diff --git a/plugins/block-shareable-procedures/tsconfig.json b/plugins/block-shareable-procedures/tsconfig.json
index 6e26e186..42844cb6 100644
--- a/plugins/block-shareable-procedures/tsconfig.json
+++ b/plugins/block-shareable-procedures/tsconfig.json
@@ -5,7 +5,8 @@
     "allowJs": true,
     "sourceMap": true,
     "lib": ["es6", "dom"],
-    "moduleResolution": "node"
+    "moduleResolution": "node",
+    "declaration": true,
   },
   "include": [
     "src", "test"
cd plugins/block-shareable-procedures
npm run build

@BeksOmega BeksOmega added ghc-osd Reserved for open source day: https://anitab-org.github.io/open-source-day/ and removed triage labels Sep 5, 2023
@BeksOmega
Copy link
Contributor

I discussed this briefly with Maribeth last Thursday after seeing the forum post. We decided to split this into individual issues for osd, but I didn't follow up with it because I was doing docs Friday.

So I'm going to close this issue and split it up by plugin.

@BeksOmega
Copy link
Contributor

Added a comment to #1871 for tracking dev-create updates.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ghc-osd Reserved for open source day: https://anitab-org.github.io/open-source-day/ type: feature request New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants