Skip to content

TypeScript

Troy Gunawardene edited this page Jul 30, 2025 · 2 revisions

This project uses TypeScript as opposed to plain JavaScript to improve clarity of data types and the availability of IDE auto-complete features.

Faust.js / WPGraphQL

First, run npm install in the nefac-website directory if you haven't already. Then, use the following command to generate TypeScript types based on the GraphQL schema:

npm run generate:types

This will generate types using graphql-codegen. These are deliberately gitignored.

This command is not to be confused with npm run generate, which serves a different purpose. See documentation about Faust.js for more details.

Further Documentation

Please reference the following Faust.js documentation pages for detailed information and examples related to using TypeScript in Faust.js.

WordPress Libraries

Our project uses a few libraries maintained by WordPress for functionality and components related to custom blocks. For example, @wordpress/block-editor. These libraries are not typed for use in TypeScript out of the box. Fortunately, separate libraries containing type definitions for WordPress libraries are available, thanks to DefinitelyTyped. These are already installed in our project, and no local configuration or setup is needed. If another @wordpress library needs to be added, and it is not typed, check NPM to see if there is a type definition library for it.

Clone this wiki locally