Writing config in Typescript
Introduction
- Besides YAML, you can write your configuration in Javascript and Typescript.
- This is useful, if have a lot of dynamic behavior in your configuration.
- Please note that you can also add dynamic behavior to your templates using directives.
Usage
Writing your configuration in javascript or typescript is straightforward.
Copy
export default {// your configuration};
When using the CLI, Stacktape will automatically pick up the configuration, if you name it stacktape.js
. Stacktape
picks up the configuration files in the following order:
- YAML
- JSON
- Typescript
- Javascript
Using Stacktape Typescript types
To improve your development experience, you can use typescript types provided by the @stacktape/sdk
package. To
install it, run
Copy
npm install @stacktape/sdk
or
Copy
yarn add @stacktape/sdk
For javascript files, you can use it in the following way:
Copy
/** @type {import('@stacktape/sdk').StacktapeConfig} */const config = {// your config};export default config;
For typescript files:
Copy
import { StacktapeConfig } from '@stacktape/sdk';const config: StacktapeConfig = {// your config};export default config;