Make WordPress Core

Opened 13 months ago

Closed 9 months ago

Last modified 9 months ago

#58671 closed defect (bug) (worksforme)

"error TS2315: Type 'Server' is not generic" when building Gutenberg from WP checkout

Reported by: sergeybiryukov's profile SergeyBiryukov Owned by:
Milestone: Priority: normal
Severity: normal Version: 6.3
Component: Build/Test Tools Keywords:
Focuses: Cc:

Description

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@16.0.0 build:packages .../wordpress-develop/build/wp-content/plugins/gutenberg
    > npm run build:package-types && node ./bin/packages/build.js
    
    
    > gutenberg@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 Stack Overflow thread with a similar error suggests reverting @types/ws to 8.5.4 as a workaround:

npm i @types/ws@8.5.4

That indeed allows the build to complete successfully.

There appears to be a 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.

Change History (5)

#1 @SergeyBiryukov
13 months ago

  • Component changed from Bundled Theme to Build/Test Tools

#2 @audrasjb
12 months ago

  • Milestone changed from 6.3 to 6.4

Moving to milestone 6.4 as WP 6.3 RC3 has been released.

#3 follow-up: @desrosj
10 months ago

  • Keywords close reporter-feedback added

I've spent a good chunk of time working on #59632 today. This was in an effort to avoid reintroduction of #59634. But I also tested for this issue in the process.

I was unable to reproduce this one both locally and within the workflow with the changes being proposed in the PR attached to #59632. I'm wondering if this was fixed, either by the upstream change linked in the ticket (though the specific PR was closed in favor of the author creating a new one) or in Gutenberg itself.

@SergeyBiryukov @aristath, @afercia could you confirm whether this problem is still occurring for you? And if it is, could you take a look at the steps being performed within the PR to try and identify which test case is missing?

Marking as close candidate since it works-for-me, but can leave open to explore further if there's something I'm missing.

#4 in reply to: ↑ 3 @SergeyBiryukov
9 months ago

  • Keywords close reporter-feedback removed
  • Milestone 6.4 deleted
  • Resolution set to worksforme
  • Status changed from new to closed

Replying to desrosj:

could you confirm whether this problem is still occurring for you?

Thanks for the ping! This appears to be resolved in our testing.

#5 @desrosj
9 months ago

In 56976:

Build/Test Tools: Test the Gutenberg plugin build process.

A very common contributor setup is having a copy of the gutenberg development repository within a checkout of the wordpress-develop repository. On occasion, there are some strange incompatibilities that come up when using this setup. A few examples can be seen in #58671 and #59634.

This changeset helps ensure that these edge cases are not introduced by testing the Gutenberg plugin’s build process within WordPress configured to run from both the src and build directories.

This also renames the “Test npm” workflow to a more general “Test Build Processes”, which more accurately describes what is actually being tested within it and allows these new test jobs to be grouped in.

And finally, the logic within the workflow has been split out into two callable workflows. This helps avoid code duplication within the workflow, and allows for better grouping on the workflow run screen.

Props swissspidy, aferica, SergeyBiryukov, antonvlasenko, desrosj.
Fixes #59632. See #58671, #59634.

Note: See TracTickets for help on using tickets.