google / google/schema-dts

Cannot 'implement' Person from class

Open
#28 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
1.2k
Forks
57
PR merge metrics
No merged PRs in 30d

Description

When I try to implement 'Person' on a class like:

```JS
import { Person as PersonSchema } from 'schema-dts';
export class Person implements PersonSchema { ... }
```

TS errors with
```
A class can only implement an object type or intersection of object types with statically known members.
```

Which can be solved by editing this snippet:
```JS
export declare type Person = ({
"@type": "Person";
} & PersonBase) | Patient;
```
to
```JS
export declare type Person = ({
"@type": "Person";
} & PersonBase);
```

Obviously, this case is true for any type declaration in the pattern `(...) | [TYPE]`. The same applies to extending interfaces.
What is the reason for this pattern? Is it intended?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.