# TypeScript

Typed ports, the StillMade and input globals and the module entry, generated from your manifest.

`stillmade-block types <folder>` writes `stillmade-env.d.ts` beside the
manifest (`create` writes it too, with a `jsconfig.json`, and running `types`
again replaces it after you change ports). It is self-contained and declares:

- `BlockInputs` and `BlockOutputs`, one property per port, typed by port type:
  `text`, `url`, `date` and `color` are strings, `number` and `integer` are
  numbers, media ports are saved references, `file`, `document`, `table` and
  `transcript` have their value shapes, a `json` or `object` port with a compact
  schema (`{"points": "number[]"}`) gets that shape, and lists are arrays.
  Optional inputs (`required: false` or a default) are optional properties.
- The global `StillMade` in your interface, typed from the
  [view bridge reference](/docs/reference/view-bridge):
  `StillMade.run(values: BlockInputs): Promise<BlockOutputs>`,
  `StillMade.onInput(callback)` and the rest.
- The global `input` in `src/run.js` (JavaScript Blocks).
- `StillMadeModule` and `BlockRun` for a module entry:

```ts
import type {BlockRun} from '../stillmade-env';
const run: BlockRun = async (input, stillmade) => {
  stillmade.progress(0.5, 'Working');
  return {summary: input.text.toUpperCase()};
};
export default run;
```

Bundle TypeScript with your bundler as usual (esbuild handles `.ts` and
`.tsx`); StillMade runs the bundled JavaScript. The SDK's own declarations are
in `packages/block-sdk/*.d.ts`; `blockTypeDeclarations(manifest)`,
`portValueType(port)`, `schemaType(schema)` and `PORT_VALUE_TYPES` generate the
file, and `VIEW_BRIDGE` (with `VIEW_BRIDGE_MEMBERS` and
`viewBridgeReference()`) is the list of interface bridge members it types.
