Skip to content

Uncaught uninitialized class member with Symbol key #40617

Description

@soul-codes

TypeScript Version: 4.1.0-dev.20200917

Search Terms:
symbol class member uninitialized

Code

const Foo = Symbol()

class WithFoo {
  [Foo]: any[]; // this shouldn't be allowed without an initialization in a constructor
  Foo: any[]; // compare with this, which errors as expected
}

console.log(new WithFoo()[Foo].length) // uncaught uninitialized symbol member, oops

Expected behavior:
An error like Property 'Foo' has no initializer and is not definitely assigned in the constructor should also be emitted for the symbolic property Foo.

Actual behavior:
No such error is thrown.

Playground Link:
here

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScript

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions