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:
@@ -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: () => ({}),
|
||||
})
|
||||
```
|
||||
Reference in New Issue
Block a user