Skip to content

"Unique symbol" returned from the function becomes "symbol" #24506

@Lodin

Description

@Lodin

TypeScript Version: 3.0.0-dev.20180530

Search Terms:
unique symbol, property, dynamic class creation

Code

const create = () => { 
  const prop = Symbol();

  return {
    cls: class A {
      public [prop]: string = 'str'; // works as expected
    },
    prop,
  };
}

const { cls, prop } = create();

class B extends cls { 
  public [prop]: string = 'test'; // Error: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type.
}

Expected behavior:
No error.

Actual behavior:
When unique symbol is returned from function, it becames symbol that forbids working with class properties defined inside the function as well as class itself.

Playground Link:
Link

Related Issues:
Didn't find any

Metadata

Metadata

Assignees

No one assigned

    Labels

    Design LimitationConstraints of the existing architecture prevent this from being fixed

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions