Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 27, 2025

Motivation for the change, related issues

Node.js type stripping (--experimental-strip-types) fails on TypeScript syntax with runtime semantics. This caused runtime errors like:

SyntaxError [ERR_UNSUPPORTED_TYPESCRIPT_SYNTAX]: TypeScript parameter property is not supported

Implementation details

Added the existing @typescript-eslint/parameter-properties ESLint rule to prevent TypeScript parameter properties that are unsupported by Node.js type stripping.

  • Parameter propertiesconstructor(private foo: string) → explicit property + assignment

Fixed existing violations:

  • blueprints-v1-handler.ts, blueprints-v2-handler.ts, website-page.ts, code-editor.tsx — converted parameter properties to explicit declarations

Testing Instructions (or ideally a Blueprint)

npm run lint

Verify the rule catches new violations:

// Should error
class Foo {
  constructor(private bar: string) {}
}
Original prompt

Start a new PR to add an eslint rule – only allow TypeScript syntax that's supported by Node.js type stripping (to prevent future errors such as this):

Version number df6471b7770cee7792040577 copied to clipboard
Use Ctrl+C to stop the server
node:internal/modules/run_main:123
triggerUncaughtException(
^

file:///Users/mho/Work/projects/xdebug/wordpress-playground/packages/playground/blueprints/src/lib/v1/compile.ts:47
export class InvalidBlueprintError extends Error {
constructor(message: string, public readonly validationErrors?: unknown) {
^^^^^^^^^^^^^^^^^^^^^^^^^^
super(message);

SyntaxError [ERR_UNSUPPORTED_TYPESCRIPT_SYNTAX]: TypeScript parameter property is n
40 references
Copilot said: Let me search for more specific ESLint
Let me search for more specific ESLint configuration files in the repository:Based on my research into the WordPress Playground repository, I can see that:

The repo already has a custom ESLint plugin at packages/meta/src/eslint-plugin-playground-dev/ with one existing rule (avoid-wordpress-builds-dependency)
The root .eslintrc.json already has some Node.js type stripping support with @typescript-eslint/consistent-type-imports rule enabled
The error you referenced is about TypeScript parameter properties (like public readonly validationErrors), which are not supported by Node.js type stripping. A new ESLint rule should be added to prevent this syntax.

I'll create a PR that adds an ESLint rule to disallow TypeScript syntax that's unsupported by Node.js type stripping, specifically:

Parameter properties (constructor(public foo: string))
Enums (which also aren't supported by type stripping)
Namespaces


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Add `no-unsupported-typescript-syntax` rule to the eslint-plugin-playground-dev
plugin. This rule prevents:
- Parameter properties (constructor(private foo: string))
- Enums (use const objects with `as const` instead)
- Namespaces with value statements (type-only namespaces are allowed)

Also fix existing violations:
- Convert parameter properties in 4 files to explicit property declarations
- Convert enum in typedoc-model.ts to const object with as const

Co-authored-by: adamziel <205419+adamziel@users.noreply.github.com>
Copilot AI changed the title [WIP] Add eslint rule for TypeScript syntax support Add ESLint rule for Node.js type stripping compatibility Nov 27, 2025
Copilot AI requested a review from adamziel November 27, 2025 13:55
Copilot finished work on behalf of adamziel November 27, 2025 13:55
@mho22
Copy link
Collaborator

mho22 commented Nov 27, 2025

There is an existing Typescript Eslint rule named : @typescript-eslint/parameter-properties that could help here I think.

@adamziel
Copy link
Collaborator

@copilot apply previous suggestion

Apply suggestion to use the existing @typescript-eslint/parameter-properties
rule instead of custom parameter property detection. The custom rule now
only handles enums and namespaces with value statements.

Co-authored-by: adamziel <205419+adamziel@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Nov 27, 2025

There is an existing Typescript Eslint rule named : @typescript-eslint/parameter-properties that could help here I think.

Applied in 5de6f73. Now using @typescript-eslint/parameter-properties for parameter properties, and the custom rule only handles enums and namespaces with value statements.

Copilot finished work on behalf of adamziel November 27, 2025 14:50
@mho22
Copy link
Collaborator

mho22 commented Nov 27, 2025

@adamziel actually the TS-eslint rule fixes the issue I had, I am not sure the two other issues this pull request tackles about enum and namespace are necessary.

@adamziel
Copy link
Collaborator

@copilot We don't need a custom packages/meta/src/eslint-plugin-playground-dev/no-unsupported-typescript-syntax.js rule and also undo the change to packages/docs/site/src/typedoc-model.ts – disable the rule for the offending declaration.

…perties

Per feedback, removed the custom no-unsupported-typescript-syntax rule
and restored typedoc-model.ts to use the original enum. The
@typescript-eslint/parameter-properties rule is sufficient for preventing
the Node.js type stripping errors.

Co-authored-by: adamziel <205419+adamziel@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Nov 27, 2025

@copilot We don't need a custom packages/meta/src/eslint-plugin-playground-dev/no-unsupported-typescript-syntax.js rule and also undo the change to packages/docs/site/src/typedoc-model.ts – disabl...

Done in f8f4f8a. Removed the custom no-unsupported-typescript-syntax rule and restored typedoc-model.ts to use the original enum. The PR now only adds the @typescript-eslint/parameter-properties rule.

Copilot finished work on behalf of adamziel November 27, 2025 21:47
@mho22 mho22 marked this pull request as ready for review November 27, 2025 22:06
@mho22 mho22 requested a review from a team as a code owner November 27, 2025 22:06
@adamziel adamziel merged commit 8fc99ee into trunk Nov 28, 2025
56 checks passed
@adamziel adamziel deleted the copilot/add-eslint-rule-typescript-nodescript branch November 28, 2025 17:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants