Merge pull request #3567 from backstage/rugvip/impl

core-api: update ApiFactory type to correctly infer API type and disallow mismatched implementations
This commit is contained in:
Patrik Oldsberg
2020-12-04 17:30:53 +01:00
committed by GitHub
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: () => ({}),
})
```