Skip to content

"sufficiently overlaps" on class instance depends on class staticsΒ #43754

Closed
@evmar

Description

@evmar

Bug Report

πŸ”Ž Search Terms

sufficiently overlaps class namespace

πŸ•— Version & Regression Information

TS 4.2, TS v4.3.0-dev.20210420

  • This is the behavior in every version I tried, and I reviewed the FAQ for entries about compatibility

⏯ Playground Link

Playground link with relevant code

πŸ’» Code

class C1 { foo() {} }
new C1() as Record<string, unknown>;  // error, as expected

class C2 { foo() {} }
namespace C2 { export const unrelated = 3; }
new C2() as Record<string, unknown>;  // allowed!?

πŸ™ Actual behavior

The existence of the field in the C2 namespace somehow affects the assignability calculation of the instance.

πŸ™‚ Expected behavior

I would expect these namespace-level properties to not get involved (?) in the assignability of instances.

Either both succeed or both fail.

Metadata

Metadata

Assignees

Labels

BugA bug in TypeScriptFix AvailableA PR has been opened for this issueHelp WantedYou can do this

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions