Skip to content

Methrat0n/Partial

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Partial

In Typescript, the Partial type constructor takes a simple type and return an equivalent type with every property now optional.

type Partial<T> = {
    [P in keyof T]?: T[P];
}

interface User {
  readonly name: string
}

type PartialUser = Partial[User]

const noUser: PartialUser = {}

It's useful when you need to build an instance from pieces and want to convert to the complete version of the type afterwards.

Now you can do the same in scala :

@Partial
final case class User(name: String)

PartialUser(Some("merlin"))

About

POC of the Partial macro from Typescript

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published