{"record":{"id":"447f861e1a135504","repo":"dotnet/aspnetcore","slug":"the-property-identifier-is-not-defined-or-is","errorCode":null,"errorMessage":"The property '${identifier}' is not defined or is not readable.","messagePattern":"The property '(.+?)' is not defined or is not readable\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/JSInterop/Microsoft.JSInterop.JS/src/src/Microsoft.JSInterop.ts","lineNumber":641,"sourceCode":"      switch (callType) {\n      case JSCallType.FunctionCall:\n          const func = parent[memberName];\n          if (func instanceof Function) {\n              return func.bind(parent);\n          }\n          throw new Error(`The value '${identifier}' is not a function.`);\n\n      case JSCallType.ConstructorCall:\n          const ctor = parent[memberName];\n          if (ctor instanceof Function) {\n              const bound = ctor.bind(parent);\n              return (...args: any[]) => new bound(...args);\n          }\n          throw new Error(`The value '${identifier}' is not a function.`);\n\n      case JSCallType.GetValue:\n          if (!isReadableProperty(parent, memberName)) {\n              throw new Error(`The property '${identifier}' is not defined or is not readable.`);\n          }\n          return () => parent[memberName];\n      case JSCallType.SetValue:\n          if (!isWritableProperty(parent, memberName)) {\n              throw new Error(`The property '${identifier}' is not writable.`);\n          }\n          return (...args: any[]) => parent[memberName] = args[0];\n      }\n  }\n\n  function isReadableProperty(obj: any, propName: string) {\n      // Return false for missing property.\n      if (!(propName in obj)) {\n          return false;\n      }\n\n      // If the property is present we examine its descriptor, potentially needing to walk up the prototype chain.\n      while (obj !== undefined) {","sourceCodeStart":623,"sourceCodeEnd":659,"githubUrl":"https://github.com/dotnet/aspnetcore/blob/294cab2f9b2e03af6b953820c7ab497c3c8b7ad9/src/JSInterop/Microsoft.JSInterop.JS/src/src/Microsoft.JSInterop.ts#L623-L659","documentation":"Thrown in the JSCallType.GetValue branch when isReadableProperty(parent, memberName) is false. isReadableProperty (line 652) walks the prototype chain checking descriptors: it returns false if the property is not 'in' the object, has no getter/setter and no value, or the descriptor lacks a 'value'/'get'. The message covers both 'not defined' and 'not readable' so the dev inspects the descriptor.","triggerScenarios":"Reading a property that does not exist on the object; reading a property defined only by a setter (write-only); reading a Symbol-keyed property the walker cannot see; reading a property whose getter throws is not this error (that throws the getter's error), but a property with only a setter is.","commonSituations":"Accessing a property added later by a polyfill that hasn't loaded; typo; version mismatch; trying to read an internal property removed between releases; write-only DOM properties.","solutions":["Verify the property exists on the instance or its prototype chain (prop in obj).","Check the descriptor via Object.getOwnPropertyDescriptor across the chain; add a getter/value if it's setter-only.","Ensure polyfills that define the property have loaded before the read.","Wrap the interop call in try/catch and provide a default."],"exampleFix":"// before\nawait JS.InvokeAsync<object>(\"element.somethingWriteOnly\");\n\n// after\n// expose a readable accessor in a shim\nexport function getSafe(o, k) {\n  const desc = Object.getOwnPropertyDescriptor(o, k) ?? {};\n  return ('value' in desc || desc.get) ? o[k] : undefined;\n}","handlingStrategy":"type-guard","validationCode":"// shim: safely read\nexport function readProp(obj, id) {\n  const desc = Object.getOwnPropertyDescriptor(obj, id) ?? {};\n  return ('value' in desc || !!desc.get) ? obj[id] : undefined;\n}","typeGuard":"function isReadable(o:any, k:string):boolean {\n  if (!(k in o)) return false;\n  while (o) { const d = Object.getOwnPropertyDescriptor(o, k); if (d) return 'value' in d || !!d.get; o = Object.getPrototypeOf(o); }\n  return false;\n}","tryCatchPattern":"try { await JS.InvokeAsync('el.prop'); } catch (e) { if (/not defined or is not readable/i.test(e.message)) { return undefined; } throw e; }","preventionTips":["Check the property descriptor before relying on reads.","Ensure polyfills that define the property have loaded.","Prefer accessor wrapper functions over direct property interop."],"tags":["blazor","jsinterop","properties","descriptor","read"],"analyzedSha":"294cab2f9b2e03af6b953820c7ab497c3c8b7ad9","analyzedAt":"2026-08-06T20:08:02.189Z","schemaVersion":2},"datasetVersion":"2026-08-06T23:17:07.152Z"}