@roots/bud-typescript
TypeScript icon, indicating that this package has built-in type declarations

6.21.0 • Public • Published

bud.js

MIT License npm Follow Roots

@roots/bud-typescript

Adds Typescript support to Bud


Installation

Install @roots/bud-typescript to your project.

Yarn:

yarn add @roots/bud-typescript --dev

npm:

npm install @roots/bud-typescript --save-dev

Configuration

General ts configuration is handled using a standard tsconfig.json in your project root. See the TypeScript docs on tsconfig.json for more information.

There is a base tsconfig available for you to extend:

{
  "extends": "@roots/bud-typescript/tsconfig/tsconfig.json"
}

If you are authoring your config file in TypeScript you must use the ts-bud command instead of bud.

Typechecking

By default TypeScript files will only be compiled to JS during builds. If you also want typechecking, you can enable it in your bud configuration:

bud.typescript.typecheck.enable();

You may wish to configure typechecking only in production so that your development experience stays snappy:

bud.isProduction && bud.typescript.typecheck.enable();

Babel

By default, @roots/bud-typescript will pass code to @roots/bud-babel for further transforms.

To disable babel and only use tsc:

bud.typescript.useBabel(false);

If you aren't using babel make sure your tsconfig.json is set up appropriately.

In particular, React users likely want to set jsx to react.

react-refresh

React refresh should work out of the box with zero configuration required.

  • If you are using @roots/bud-react the react-refresh-typescript transformer will automatically be used.
  • If you are using @roots/bud-babel the babel transformer will be used instead of the react-refresh-typescript.

Contributing

Contributions are welcome from everyone.

We have contribution guidelines to help you get started.

License

@roots/bud-typescript is licensed under MIT.

Community

Keep track of development and community news.

Sponsors

Bud is an open source project and completely free to use.

However, the amount of effort needed to maintain and develop new features and projects within the Roots ecosystem is not sustainable without proper financial backing. If you have the capability, please consider sponsoring Roots.

KM Digital Carrot WordPress.com Worksite Safety Copia Digital Freave

Readme

Keywords

Package Sidebar

Install

npm i @roots/bud-typescript

Weekly Downloads

442

Version

6.21.0

License

MIT

Unpacked Size

36.2 kB

Total Files

30

Last publish

Collaborators

  • qwp6t
  • swalkinshaw
  • retlehs
  • log1x
  • kellymears