core-api: update ApiFactory type to correctly infer API type and disallow mismatched implementations

This commit is contained in:
Patrik Oldsberg
2020-12-04 13:50:37 +01:00
parent 4266967979
commit b6557c0988
5 changed files with 54 additions and 18 deletions
+23
View File
@@ -0,0 +1,23 @@
---
'@backstage/core-api': patch
'@backstage/dev-utils': patch
---
Update ApiFactory type to correctly infer API type and disallow mismatched implementations.
This fixes for example the following code:
```ts
interface MyApi {
myMethod(): void
}
const myApiRef = createApiRef<MyApi>({...});
createApiFactory({
api: myApiRef,
deps: {},
// This should've caused an error, since the empty object does not fully implement MyApi
factory: () => ({}),
})
```