dotnet/aspnetcore · error
The property '${identifier}' is not defined or is not readab
Error message
The property '${identifier}' is not defined or is not readable. What it means
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.
Source
Thrown at src/JSInterop/Microsoft.JSInterop.JS/src/src/Microsoft.JSInterop.ts:641
switch (callType) {
case JSCallType.FunctionCall:
const func = parent[memberName];
if (func instanceof Function) {
return func.bind(parent);
}
throw new Error(`The value '${identifier}' is not a function.`);
case JSCallType.ConstructorCall:
const ctor = parent[memberName];
if (ctor instanceof Function) {
const bound = ctor.bind(parent);
return (...args: any[]) => new bound(...args);
}
throw new Error(`The value '${identifier}' is not a function.`);
case JSCallType.GetValue:
if (!isReadableProperty(parent, memberName)) {
throw new Error(`The property '${identifier}' is not defined or is not readable.`);
}
return () => parent[memberName];
case JSCallType.SetValue:
if (!isWritableProperty(parent, memberName)) {
throw new Error(`The property '${identifier}' is not writable.`);
}
return (...args: any[]) => parent[memberName] = args[0];
}
}
function isReadableProperty(obj: any, propName: string) {
// Return false for missing property.
if (!(propName in obj)) {
return false;
}
// If the property is present we examine its descriptor, potentially needing to walk up the prototype chain.
while (obj !== undefined) {View on GitHub (pinned to 294cab2f9b)
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.
Example fix
// before
await JS.InvokeAsync<object>("element.somethingWriteOnly");
// after
// expose a readable accessor in a shim
export function getSafe(o, k) {
const desc = Object.getOwnPropertyDescriptor(o, k) ?? {};
return ('value' in desc || desc.get) ? o[k] : undefined;
} Defensive patterns
Strategy: type-guard
Validate before calling
// shim: safely read
export function readProp(obj, id) {
const desc = Object.getOwnPropertyDescriptor(obj, id) ?? {};
return ('value' in desc || !!desc.get) ? obj[id] : undefined;
} Type guard
function isReadable(o:any, k:string):boolean {
if (!(k in o)) return false;
while (o) { const d = Object.getOwnPropertyDescriptor(o, k); if (d) return 'value' in d || !!d.get; o = Object.getPrototypeOf(o); }
return false;
} Try / catch
try { await JS.InvokeAsync('el.prop'); } catch (e) { if (/not defined or is not readable/i.test(e.message)) { return undefined; } throw e; } Prevention
- Check the property descriptor before relying on reads.
- Ensure polyfills that define the property have loaded.
- Prefer accessor wrapper functions over direct property interop.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- The property '${identifier}' is not writable.
- Cannot create a JSObjectReference from the value '${jsObject
- Cannot create a JSStreamReference from the value '${streamRe
- Supplied value is not a typed array or blob.
- Cannot create a JSStreamReference from the value '${streamRe
AI-assisted analysis of dotnet/aspnetcore@294cab2f9b (2026-08-06).
Data as JSON: /api/errors/447f861e1a135504.
Report an issue: GitHub.