v1.3.1

TypeScript

bongo ships ambient JSX types for its custom elements and attributes, and exports types for the config and the build.

JSX types

Extend the bundled config in your tsconfig.json:

tsconfig.jsonjson
{
	"extends": "bongo/tsconfig",
	"compilerOptions": {
		// your own settings
	}
}

The augmentation adds:

  • the <bongo:asset>, <bongo:client>, <bongo:image>, <bongo:script>, and <bongo:style> intrinsic elements,
  • transition:name and transition:animate on every HTML element,
  • transition:disable and prefetch:disable on anchors.

Or reference the types directly:

TypeScript
/// <reference types="bongo/jsx" />

See Special elements, View transitions, and Opt out.

Which tsconfig.json

Rolldown reads a tsconfig.json when it compiles the config, data modules, partials, and scripts. For each file, it reads the nearest one, but only in the project folder, which holds the config, or in a folder below it. A tsconfig.json in a folder above the project is never read, since it can belong to another project. When the project folder has no tsconfig.json, Rolldown uses none.

Exported types

Import types from bongo:

Type Use
Config The config. Write export default {…} satisfies Config. See Config.
Loader A loader in $loaders. See Loaders.
Build.Transform A $hooks.transform function. See Hooks.
Build.Context The ctx of a hook.
Build.Data What the default export of a data module gets when it is a function. See Data modules.
Images.Options The $images config field. See Image config.
Template.Site The $site config field. Add your own fields to it. See Define custom $site fields.
content/search.json.tsts
import type { Build } from 'bongo';

export default ({ $pages }: Build.Data) => $pages.map(page => ({ title: page.title, path: page.path }));

For import.meta.env.DEV and import.meta.env.PROD in scripts, add bongo/env to the types of your tsconfig.json. See Script values.

Import the client runtime types from bongo/client: ClientOptions, BongoEvent, and BongoEventDetails. See Client runtime.

Edit this page on GitHub MIT license · bongo v1.3.1

    Type to search page titles and sections.