Skip to content

[Suggestion] Global object properties should not surface on type level indexing #18118

Closed
@gcnew

Description

@gcnew

TypeScript Version: nightly (2.6.0-dev.20170829)

Code

type Point = { x: number, y: number }
type Mapped = Record<'x'|'y', number>
type IndexSignature = { [x: string]: never }

// All of the following have type: `() => Object`
type Test1 = Point['valueOf']
type Test2 = Mapped['valueOf'] 
type Test3 = IndexSignature['valueOf']

Expected behavior:
Test1, Test2 and Test3 should all be errors.

User provided types should be considered "exact". No properties should be inherited from Object. The current behaviour is of little use, however it's quite confusing and really gets in the way of type level programming.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Working as IntendedThe behavior described is the intended behavior; this is not a bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions