镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

Primitives are assignable to weak types #16333

Description

interface Weak {
  a?: any,
  b?: any,
}
let x: Weak = 10;

Expected: Error on assigning 10 to x.
Actual: No error.

Activity

  1. sandersn commented on Jun 7, 2017

    @sandersn
    Member

    This happens because the apparent type of number, string, etc have toString, and toString is a known property of every object type, which includes every weak type.

  2. sandersn commented on Jun 7, 2017

    @sandersn
    Member

    Fixed in #16343

  3. locked and limited conversation to collaborators on Jun 14, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

BugA bug in TypeScriptFixedA PR has been merged for this issue

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions