Skip to content

Overlooks arbitrary value for type asserted property (in object spread)Β #47650

@wclr

Description

@wclr

Bug Report

πŸ”Ž Search Terms

Checked for 4.5, and latest 4.6-beta

πŸ•— Version & Regression Information

⏯ Playground Link

Playground link with relevant code

πŸ’» Code

type Obj = {
  from: string
  to: string
}

type Dir = "from" | "to"

const dir: Dir = "to" as Dir
// the same for:
// declare const dir: Dir


declare const obj: Obj

const m: Obj = {
  ...obj,
  [dir]: 1, // no error, but should be
}

// this is working as expcted:
const dir2: Dir = "to"


const m2: Obj = {
  ...obj,
  [dir2]: 1, // error as should be
}

πŸ™ Actual behavior

Should not allow arbitrary value.

πŸ™‚ Expected behavior

Overlooks arbitrary value for type asserted property in object spread.

Metadata

Metadata

Assignees

No one assigned

    Labels

    DuplicateAn existing issue was already created

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions