In this new version, we define the two types we build our logic around, reusing the first one inside the second one, as follows:
type internetCompany = [ `Facebook(string) | `Google(string) | `Twitter(string) ];
type platformCompany = [ internetCompany | `Amazon(string) | `Uber(string) ]
Based on that, we make our function evolve as follows (using platformCompany to allow all the variants to be accepted for the company parameter):
let apps = (company: platformCompany) : string => {
switch (company) {
| `Facebook(str) => switch str {
| "social" => "facebook, messenger, instagram"
| "business" => "facebook ads"
}
| `Google(str) => switch str {
| "social" => "google+, gmail"
| "business" =>...