(prototype: any, key: PropertyKey, annotation: Annotation)
| 27 | * so it can be inspected later by `makeObservable` called from constructor |
| 28 | */ |
| 29 | export function storeAnnotation(prototype: any, key: PropertyKey, annotation: Annotation) { |
| 30 | if (!hasProp(prototype, storedAnnotationsSymbol)) { |
| 31 | addHiddenProp(prototype, storedAnnotationsSymbol, { |
| 32 | // Inherit annotations |
| 33 | ...prototype[storedAnnotationsSymbol] |
| 34 | }) |
| 35 | } |
| 36 | // @override must override something |
| 37 | if (__DEV__ && isOverride(annotation) && !hasProp(prototype[storedAnnotationsSymbol], key)) { |
| 38 | const fieldName = `${prototype.constructor.name}.prototype.${key.toString()}` |
| 39 | die( |
| 40 | `'${fieldName}' is decorated with 'override', ` + |
| 41 | `but no such decorated member was found on prototype.` |
| 42 | ) |
| 43 | } |
| 44 | // Cannot re-decorate |
| 45 | assertNotDecorated(prototype, annotation, key) |
| 46 | |
| 47 | // Ignore override |
| 48 | if (!isOverride(annotation)) { |
| 49 | prototype[storedAnnotationsSymbol][key] = annotation |
| 50 | } |
| 51 | } |
| 52 | |
| 53 | function assertNotDecorated(prototype: object, annotation: Annotation, key: PropertyKey) { |
| 54 | if (__DEV__ && !isOverride(annotation) && hasProp(prototype[storedAnnotationsSymbol], key)) { |
no test coverage detected
searching dependent graphs…