Title: Enhanced TypeScript support in WordPress 6.1
Author: Adam Zieliński
Published: October 11, 2022

---

 [  ](https://profiles.wordpress.org/zieladam/) [Adam Zieliński](https://profiles.wordpress.org/zieladam/)
12:48 pm _on_ October 11, 2022     
Tags: [6.1 ( 94 )](https://make.wordpress.org/core/tag/6-1/),
[dev-notes ( 661 )](https://make.wordpress.org/core/tag/dev-notes/), [dev-notes-6.1 ( 37 )](https://make.wordpress.org/core/tag/dev-notes-6-1/)

# Enhanced TypeScript support in WordPress 6.1

WordPress 6.1 enhances the TypeScript support for the frontend data stores. The 
types it ships for the `@wordpress/data` and `@wordpress/core-data` npm packages
enable auto-completion and improvements in static type checks.

As a recap, `@wordpress/data` is the foundational package powering all the data 
stores in the WordPress editor. WordPress 6.1 provides the TypeScript signatures
for its central utilities: `createReduxStore`, and `useSelect`, ensuring the selector
types are correctly reflected in the code that uses them:

    ```notranslate
    import {
    	createReduxStore,
    	useSelect,
    	useDispatch
    } from '@wordpress/data';

    const config = {
    	reducer: () => null,
    	selectors: {
    		/**
    		 * @param {Object} state
    		 * @param {string} unit
    		 * @return {number}
    		 */
    		getTemperature: ( state, unit = 'C' ) => {
    			/* action implementation */
    		}
    	}
    };

    const store = createReduxStore( 'STORE_NAME', config );

    // Correct call:
    useSelect( store, [] ).getTemperature( 'F' ); 

    // TypeScript error
    useSelect( store, [] ).getTemperature( {} );
    ```

TypeScript developers can now build strongly typed data stores with autocompletion
and static checks:

Video shows the interaction of an IDEIDE Integrated Development Environment. A software
package that provides a full suite of functionality to software developers/programmers.
Normally an IDE includes a source code editor, code-build tools and debugging functionality.
for auto-completion and static checks.

The `@wordpress/core-data` store is the first to take advantage of the enhanced 
TypeScript support. Enhanced autocompletion and static checks are also available
when working with the `@wordpress/core-data` selectors, including `getEntityRecord`
and `getEntityRecords`:

[[

 * Documentation: 
   [@wordpress/data package](https://developer.wordpress.org/block-editor/reference-guides/packages/packages-data/)
 * [@wordpress/core-data package](https://developer.wordpress.org/block-editor/reference-guides/packages/packages-core-data/)

_Props to [@bph](https://profiles.wordpress.org/bph/), [@gziolo](https://profiles.wordpress.org/gziolo/),
and [@webcommsat](https://profiles.wordpress.org/webcommsat/) for review_.

[#6-1](https://make.wordpress.org/core/tag/6-1/), [#dev-notes](https://make.wordpress.org/core/tag/dev-notes/),
[#dev-notes-6-1](https://make.wordpress.org/core/tag/dev-notes-6-1/)

### Share this:

 * [  Threads ](https://make.wordpress.org/core/2022/10/11/enhanced-typescript-support-in-wordpress-6-1/?share=threads)
 * [  Mastodon ](https://make.wordpress.org/core/2022/10/11/enhanced-typescript-support-in-wordpress-6-1/?share=mastodon)
 * [  Bluesky ](https://make.wordpress.org/core/2022/10/11/enhanced-typescript-support-in-wordpress-6-1/?share=bluesky)
 * [  X ](https://make.wordpress.org/core/2022/10/11/enhanced-typescript-support-in-wordpress-6-1/?share=x)
 * [  Facebook ](https://make.wordpress.org/core/2022/10/11/enhanced-typescript-support-in-wordpress-6-1/?share=facebook)
 * [  LinkedIn ](https://make.wordpress.org/core/2022/10/11/enhanced-typescript-support-in-wordpress-6-1/?share=linkedin)

# Post navigation

[← Roster of design tools per block](https://make.wordpress.org/core/2022/10/11/roster-of-design-tools-per-block/)

[Performance Field Guide for WordPress 6.1 →](https://make.wordpress.org/core/2022/10/11/performance-field-guide-for-wordpress-6-1/)