typescript-go icon indicating copy to clipboard operation
typescript-go copied to clipboard

Issue with symbol - computed property name error

Open lukpsaxo opened this issue 6 months ago • 0 comments

The following file is ok in tsc and bad in tsgo

declare global {
  interface SymbolConstructor {
    readonly observable: symbol;
  }
}

type X = {
  [Symbol.observable](): any;
};

export {};

tsgo gives the following error:

test2.ts:8:3 - error TS1170: A computed property name in a type literal must refer to an expression whose type is a literal type or a 'unique symbol' type.

8   [Symbol.observable](): any;
    ~~~~~~~~~~~~~~~~~~~

tsc playground link: https://www.typescriptlang.org/play/?declaration=false&target=99&isolatedModules=true&ts=5.5.4#code/CYUwxgNghgTiAEBzCB7ARlC8DeAoeB8AlgHYAuIMAZlGAgMoCeAtmihAMIokDOZMAVzBkUMHPkKS4UYNwiN46HpQBuUNBBAAueDxZsIAbgkEAvrnO4yjAA4IAGvAC84yQQDaTVuwB0S1eqaALoAFACUOlAkjMamxrggAB42omQ4cUA

lukpsaxo avatar May 30 '25 07:05 lukpsaxo