Skip to content

Spread is allowed when target type has no properties matching spread sourceΒ #49471

Closed
@jtbandes

Description

@jtbandes

Bug Report

πŸ”Ž Search Terms

spread missing props

πŸ•— Version & Regression Information

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

⏯ Playground Link

Playground link

πŸ’» Code

function Foo(props: {x: string}) {
  Bar({y: "hi", ...props});
}
function Bar(_props: {y:string}) {
}

Or the React version of the same thing:

import React from 'react';

function Foo(props: {x: string}) {
  return <Bar y="hi" {...props}/>
}
function Bar(_props: {y:string}) {
  return <div/>
}

πŸ™ Actual behavior

Spread is allowed

πŸ™‚ Expected behavior

This should be an error because the spread source {x: string} does not overlap with the destination type {y: string}.

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