MCPcopy Index your code
hub / github.com/mobxjs/mobx / assertNotDecorated

Function assertNotDecorated

packages/mobx/src/api/decorators.ts:53–65  ·  view source on GitHub ↗
(prototype: object, annotation: Annotation, key: PropertyKey)

Source from the content-addressed store, hash-verified

51}
52
53function assertNotDecorated(prototype: object, annotation: Annotation, key: PropertyKey) {
54 if (__DEV__ && !isOverride(annotation) && hasProp(prototype[storedAnnotationsSymbol], key)) {
55 const fieldName = `${prototype.constructor.name}.prototype.${key.toString()}`
56 const currentAnnotationType = prototype[storedAnnotationsSymbol][key].annotationType_
57 const requestedAnnotationType = annotation.annotationType_
58 die(
59 `Cannot apply '@${requestedAnnotationType}' to '${fieldName}':` +
60 `\nThe field is already decorated with '@${currentAnnotationType}'.` +
61 `\nRe-decorating fields is not allowed.` +
62 `\nUse '@override' decorator for methods overridden by subclass.`
63 )
64 }
65}
66
67/**
68 * Collects annotations from prototypes and stores them on target (instance)

Callers 1

storeAnnotationFunction · 0.85

Calls 4

isOverrideFunction · 0.85
hasPropFunction · 0.85
dieFunction · 0.85
toStringMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…