🎉 Calling all TypeScript developers 🎉TypeScript components are in beta, and we’re looking for feedback. Please see our list of known issues, start writing TypeScript components, and give us feedback in our community.During the beta, the
@pipedream/types package and other TypeScript configuration in the pipedream repo is subject to change.Why TypeScript?
Most Pipedream components in the registry are written in Node.js. Writing components in TypeScript can reduce bugs and speed up development, with very few changes to your code. If you haven’t written TypeScript, start with this tutorial.Quickstart
If you’ve never developed Pipedream components before, start here.
Developing TypeScript components in the PipedreamHQ/pipedream registry
- Fork and clone the repo.
-
Run
pnpm installto install dependencies. -
See the RSS sources and actions for example
tsconfig.jsonconfiguration and TypeScript components. If the app you’re working with doesn’t yet have atsconfig.jsonfile, copy the file from the RSS component directory and modify accordingly. -
In the RSS examples, you’ll see how we use the
defineApp,defineAction, anddefineSourcemethods from the@pipedream/typespackage. This lets us strictly-typethisin apps and components. See the TypeScript docs onThisTypefor more detail on this pattern. - Before you publish components to Pipedream, you’ll need to compile your TypeScript to JavaScript. Run:
/dist directory.
For example, if you compile a TypeScript file at pipedream/components/rss/sources/new-item-in-feed/new-item-in-feed.ts, the corresponding JS file will be produced at pipedream/components/rss/dist/sources/new-item-in-feed/new-item-in-feed.js.
- Use the Pipedream CLI to
pd publishorpd devthe JavaScript components emitted by step 5 by the full path to the file.
Don’t forget to use the dist directoryIf you attempt to deploy the TypeScript component directly, you’ll receive a 500 error from the publish endpoint. Instead deploy the JavaScript file produced within the
/dist directory as described in step 5.- If it doesn’t exist in the app directory, add a
.gitignorefile that ignores the following files. Commit onlytsfiles to Git, not compiled*jsfiles.
Developing TypeScript components in your own application
First, install the@pipedream/types package:
- The
tsconfig.jsonin the root of the repo contains references to component app directories. For example, the root config provides a reference to thecomponents/rssdirectory, which contains its owntsconfig.jsonfile. npm run buildcompiles the TypeScript in all directories inreferences.- The
tsconfig.jsonin each component app directory contains the app-specific TypeScript configuration. - The GitHub actions in
.github/workflowscompile and publish our components.
Known issues
We welcome PRs in thePipedreamHQ/pipedream repo, where we store all sources and actions, the @pipedream/types package, these docs, and other Pipedream code. Here are a few known issues durin the beta:
thisis strictly-typed withinmethods,run,hooks, and everywhere you have access tothisin the component API. But this typing can be improved. For example, we don’t yet map props to their appropriate TypeScript type (everything is typed withany).- The compile -> publish lifecycle hasn’t been fully-automated when you’re developing in the
pipedreamrepo. Currently, you have to runnpm run buildfrom the repo root, then use thepdCLI to publish components after compilation. It would be nice to runtsc-watchand have that compile and publish the new version of the component using the--onSuccessflag, publishing any sources or actions accordingly. - We should add a linter (like
dtslint) to all TypeScript components). Currently,dtslintis configured only for the@pipedream/typespackage.
@pipedream/types
See the types directory of the PipedreamHQ/pipedream repo for Pipedream types. We welcome PRs!