score:7

Accepted answer

Argument of type Partial is not assignable to parameter of type 'detail'

You can't assign a Partial of a type to the original type you made the partial from.

interface Details{
  name: string,
  phonenumber: number,
  IsActive: boolean
}

let partialDetails: Partial<Details> = {IsActive: false};
let details: Details = partialDetails // error

Playground

This makes sense because Details expects a value on all properties, but Partial<Details> can omit any of those properties. This makes the partial incompatible with the while type you made a partial of.

There's no easy "fixing" this. It depends on your app's logic. If you have a function that expects a whole Details then you have to pass it a whole Details, a Partial<Details> will not do.

score:2

If you intend to fill in extra fields on details later which is a very common JavaScript pattern just do this:

let pDt = {IsActive: false} as details;

Typescript is great when it's helping but it can often readily get in the way as well if you go overboard.

score:7

You can, in your case if you want to use Partial, cast it like this:

interface Details{
  name: string,
  phonenumber: number,
  IsActive: boolean
}

let partialDetails: Partial<Details> = {IsActive: false};
let details: Details = partialDetails as Details;

Related Query

More Query from same tag