Skip to content

Issue with symbol - computed property name error #983

Closed
@lukpsaxo

Description

@lukpsaxo

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Domain: Type CheckingRelated to type checking, grammar checking

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions