TypeScript bindings for Swell Apps.
npm install @swell/app-types -D
-- Or
yarn add @swell/app-types -DFunctions using req.appSecrets or req.oauth require @swell/app-types 1.4.0 or later.
If your app already has this dependency, update it there too. swell schema function --format=dts
uses the app's installed version first.
The following is a minimal tsconfig.json for use alongside this package:
tsconfig.json
{
"compilerOptions": {
"target": "esnext",
"module": "esnext",
"lib": ["esnext", "webworker"],
"types": ["@swell/app-types"]
}
}It's not always possible (or desirable) to modify the tsconfig.json settings for a project to include all the Swell app types. For use cases like that, this package provides importable versions of its types, which are usable with no additional tsconfig.json setup. For example:
import type { SwellRequest } from "@swell/app-types/index.js"
export default async function (request: SwellRequest) {
return { success: true }
}index.d.ts is the source of the types. index.ts, the importable form, is generated from it by npm run build, which also runs when the package is packed or published. npm run check fails when index.ts differs from what the build writes.