oxc-project / oxc

⚓ A collection of JavaScript tools written in Rust.
https://oxc.rs
MIT License
11.88k stars 426 forks source link

isolatedDeclarations does not support well-known symbols as properties #4016

Open MichaelMitchell-at opened 3 months ago

MichaelMitchell-at commented 3 months ago

Tested version: 0.16.3

> require('oxc-transform').isolatedDeclaration('hello.ts', `
    export class Foo {
      [Symbol.hasInstance](): boolean {
        return false;
      }
    }
`)
{
  sourceText: 'export declare class Foo {}\n',
  errors: [
    'TS9038: Computed property names on class or object literals cannot be inferred with --isolatedDeclarations.'
  ]
}

Expected:

export declare class Foo {
    [Symbol.hasInstance](): boolean;
}

Actual:

export declare class Foo {}

TS behavior for reference

Dunqing commented 3 months ago

https://www.typescriptlang.org/play/?noCheck=true&isolatedDeclarations=true&isolatedModules=true#code/KYDwDg9gTgLgBAYwDYEMDOa4DEITgbwCg44BtAZQE8BbAIwiQDoALdASQDs0YUOFgAugAoAlAC449BsF4FiJOFGAwArlA5wAZiiRpgAbnkBfQkaA

TypeScript reports the same error

MichaelMitchell-at commented 3 months ago

This was fixed in a more recent version of TypeScript, specifically in this PR: https://github.com/microsoft/TypeScript/pull/58771

If you switch the version used in the playground to nightly, the error no longer exists.

Dunqing commented 3 months ago

This was fixed in a more recent version of TypeScript, specifically in this PR: microsoft/TypeScript#58771

If you switch the version used in the playground to nightly, the error no longer exists.

Thank you for your mentioning this. We will support this soon

Dunqing commented 3 months ago

It may be released in TypeScript 5.6, So it's not a high priority at the moment for us. If anyone is interested, feel free to send a PR!