Skip to content

Usages of Partial accept primitives #14224

@glazar

Description

@glazar

TypeScript Version: 2.2

Code

interface ComponentState {
  a: string;
  b: number;
  c: boolean;
}

const setState = (state: Partial<ComponentState>) => {
   ....
}

setState(1)
setState("1")
setState(true)

Expected behavior:

Primitives should not be allowed to be passed in arguments.
Primitives should be excluded when using Partial.

The new object type, added with 2.2, can be used implicitly when using Partial construct without having to explicitly use it to have a workaround for this issue.

Actual behavior:

Usages of Partial accept primitives, even though the intent is that primitives be excluded.
Can explicitly also use the new object type, added with 2.2, to have a workaround for this issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Design LimitationConstraints of the existing architecture prevent this from being fixed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions