-
Notifications
You must be signed in to change notification settings - Fork 370
Add ESLint rule for Node.js type stripping compatibility #2951
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add ESLint rule for Node.js type stripping compatibility #2951
Conversation
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>
|
There is an existing Typescript Eslint rule named : @typescript-eslint/parameter-properties that could help here I think. |
|
@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>
Applied in 5de6f73. Now using |
|
@adamziel actually the TS-eslint rule fixes the issue I had, I am not sure the two other issues this pull request tackles about |
|
@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 |
…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>
Done in f8f4f8a. Removed the custom |
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:Implementation details
Added the existing
@typescript-eslint/parameter-propertiesESLint rule to prevent TypeScript parameter properties that are unsupported by Node.js type stripping.constructor(private foo: string)→ explicit property + assignmentFixed existing violations:
blueprints-v1-handler.ts,blueprints-v2-handler.ts,website-page.ts,code-editor.tsx— converted parameter properties to explicit declarationsTesting Instructions (or ideally a Blueprint)
Verify the rule catches new violations:
Original prompt
💡 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.