Skip to main content

Extract public

Use ExtractPublic custom type when you want to extract public members of class. It could prove most useful when creating test doubles for your services or components1. You might be wondering why you couldn't simply do

class UserTestingService implements UserService

Good question! Perhaps unexpectedly, that would require you to implement private and protected members of UserService as well as public members. You can find a more detailed explanation here.

1. Usage

export class UserTestingService implements ExtractPublic<UserService>{
...
}

  1. Using this custom type with components could result in redundant code in test doubles since e.g. component could contain public methods used in templates which might be unnecessary in the testing double.