Q:

TypeScript no error on non-matching return value

Why doesn't TypeScript complain about this?
async GetCategoriesBySet(set: Set): Promise<Result<Array<ProductCategory>>> {
  let categories: Array<ProductCategory> = []

  if (!set.theme || !set.subtheme || !set.title) {
    return Promise.resolve(new Result<Array<ProductCategory>>({res: null, err: "Set data is not valid"}))
  }

categories.push(await this.GetCategory(set.theme, {parent: (await this.GetCategory('Themes')).id}))

  return categories
}

The return value, categories, is of type Array<ProductCategory>, not a Promise, or even the wrapping Result class. So why is it happy to let me make this mistake? (And is there any way to get it to complain?)
Thanks in advance

A:

The return value, categories, is of type Array, not a Promise,

All async functions return a Promise. This is a part of the JavaScript spec. If you return a constant it is essentially Promise.resolveed. 

