[wp-trac] [WordPress Trac] #58671: "error TS2315: Type 'Server' is not generic" when building Gutenberg from WP checkout

WordPress Trac noreply at wordpress.org
Thu Jun 29 14:53:48 UTC 2023


#58671: "error TS2315: Type 'Server' is not generic" when building Gutenberg from
WP checkout
----------------------------+--------------------
 Reporter:  SergeyBiryukov  |      Owner:  (none)
     Type:  defect (bug)    |     Status:  new
 Priority:  normal          |  Milestone:  6.3
Component:  Bundled Theme   |    Version:  trunk
 Severity:  normal          |   Keywords:
  Focuses:                  |
----------------------------+--------------------
 Discovered in a coding session with @afercia and @aristath.

 Steps to reproduce:
 1. Have a Gutenberg repo checkout in the plugins directory of a WordPress
 core checkout:
 {{{
 wordpress-develop/build/wp-content/plugins/gutenberg/
 }}}
 2. Attempt to build Gutenberg from that directory:
 {{{
 npm run build
 }}}
 3. At some point the process fails with a few errors:
 {{{
 > gutenberg at 16.0.0 build:packages .../wordpress-develop/build/wp-
 content/plugins/gutenberg
 > npm run build:package-types && node ./bin/packages/build.js


 > gutenberg at 16.0.0 build:package-types .../wordpress-develop/build/wp-
 content/plugins/gutenberg
 > node ./bin/packages/validate-typescript-version.js && tsc --build &&
 node ./bin/packages/check-build-type-declaration-files.js

 Incorrect published types for .../wordpress-develop/build/wp-
 content/plugins/gutenberg/packages/core-data/build-types/index.d.ts:
 .../wordpress-develop/node_modules/@types/ws/index.d.ts(328,18): error
 TS2315: Type 'Server' is not generic.
 .../wordpress-develop/node_modules/@types/ws/index.d.ts(328,34): error
 TS2315: Type 'Server' is not generic.

 Incorrect published types for .../wordpress-develop/build/wp-
 content/plugins/gutenberg/packages/data/build-types/index.d.ts:
 .../wordpress-develop/node_modules/@types/ws/index.d.ts(328,18): error
 TS2315: Type 'Server' is not generic.
 .../wordpress-develop/node_modules/@types/ws/index.d.ts(328,34): error
 TS2315: Type 'Server' is not generic.

 Incorrect published types for .../wordpress-develop/build/wp-
 content/plugins/gutenberg/packages/e2e-test-utils-playwright/build-
 types/index.d.ts:
 .../wordpress-develop/node_modules/@types/ws/index.d.ts(328,18): error
 TS2315: Type 'Server' is not generic.
 .../wordpress-develop/node_modules/@types/ws/index.d.ts(328,34): error
 TS2315: Type 'Server' is not generic.

 Incorrect published types for .../wordpress-develop/build/wp-
 content/plugins/gutenberg/packages/notices/build-types/index.d.ts:
 .../wordpress-develop/node_modules/@types/ws/index.d.ts(328,18): error
 TS2315: Type 'Server' is not generic.
 .../wordpress-develop/node_modules/@types/ws/index.d.ts(328,34): error
 TS2315: Type 'Server' is not generic.

 Incorrect published types for .../wordpress-develop/build/wp-
 content/plugins/gutenberg/packages/rich-text/build-types/index.d.ts:
 .../wordpress-develop/node_modules/@types/ws/index.d.ts(328,18): error
 TS2315: Type 'Server' is not generic.
 .../wordpress-develop/node_modules/@types/ws/index.d.ts(328,34): error
 TS2315: Type 'Server' is not generic.
 }}}

 Note that `@types/ws/index.d.ts` is used not from the Gutenberg directory,
 but from the WordPress core checkout.

 This appears to be introduced in [56065], where the `@types/ws` package
 was updated from version 8.5.4 to 8.5.5. Though the package is not used
 directly by core or Gutenberg, it is used as a dependency of some other
 packages.

 A recent [https://stackoverflow.com/questions/76436147/types-ws-type-
 server-is-not-generic Stack Overflow thread with a similar error] suggests
 reverting `@types/ws` to 8.5.4 as a workaround:
 {{{
 npm i @types/ws at 8.5.4
 }}}
 That indeed allows the build to complete successfully.

 There appears to be a
 [https://github.com/DefinitelyTyped/DefinitelyTyped/pull/65849 related PR
 with the fix upstream], however it is not merged yet.

 This ticket is mostly for tracking purposes. In case anyone else
 encounters the issue, it might be worth locking `@types/ws` to version
 8.5.4 in core for now.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/58671>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list