BabylonJS/Babylon.js · error
Unknown interceptor type: ${type}
Error message
Unknown interceptor type: ${type} What it means
useInterceptObservable's internal watcher supports a fixed set of interceptor types (e.g. "property" and observable watching). When the hook is given a type value that the switch statement does not recognize, it throws because no interceptor could be registered — the watched target would silently never notify. The message includes the offending type for diagnosis.
Source
Thrown at packages/dev/inspector-v2/src/hooks/instrumentationHooks.ts:37
const observable = useMemo(() => new Observable<void>(), []);
const watcher = useWatcher();
// Whenever the type, target, or property key changes, we need to set up a new interceptor.
useEffect(() => {
let interceptToken: Nullable<IDisposable> = null;
if (target) {
if (type === "function") {
interceptToken = InterceptFunction(target, propertyKey, {
afterCall: () => {
observable.notifyObservers();
},
});
} else if (type === "property") {
interceptToken = watcher.watchProperty(target, propertyKey, () => observable.notifyObservers());
} else {
throw new Error(`Unknown interceptor type: ${type}`);
}
}
// When the effect is cleaned up, we need to dispose of the interceptor.
return () => {
interceptToken?.dispose();
};
}, [type, target, propertyKey, observable]);
return observable;
}
View on GitHub (pinned to 0592b347b8)
Solutions
- Use one of the supported literal types exactly as defined in instrumentationHooks.ts (e.g. "property").
- Type the parameter as a union of the supported literals so invalid values fail at compile time.
- Log the computed type before calling the hook to find where the bad value originates.
- Check the changelog of inspector-v2 for renamed interceptor types after upgrading.
Example fix
// before
useInterceptObservable(target, key, { type: kind }); // kind: string = "proprety"
// after
const validTypes = ["property", "observable"] as const;
type InterceptorType = (typeof validTypes)[number];
const kind: InterceptorType = "property";
useInterceptObservable(target, key, { type: kind }); Defensive patterns
Strategy: type-guard
Validate before calling
const SUPPORTED_TYPES = ["property", "observable"] as const;
if (!SUPPORTED_TYPES.includes(type as any)) {
throw new TypeError(`Unsupported interceptor type: ${type}`);
} Type guard
function isInterceptorType(v: string): v is "property" | "observable" {
return v === "property" || v === "observable";
} Try / catch
try {
useInterceptObservable(target, key, { type });
} catch (e) {
if (e instanceof Error && e.message.startsWith("Unknown interceptor type")) {
console.error("Bad interceptor type:", type);
} else {
throw e;
}
} Prevention
- Type the type parameter as a string literal union, not string.
- Keep wrapper hooks in sync with instrumentationHooks.ts supported types.
- Grep the changelog when upgrading inspector-v2 versions.
- Unit-test each wrapper hook with its declared type literal.
When it happens
Trigger: Passing a type string to useInterceptObservable (or its wrapper hooks) that is not one of the supported literals — e.g. a typo like "propert" or "observable", a renamed type after a library update, or a dynamic type computed at runtime.
Common situations: Upgrading inspector-v2 where interceptor type literals changed; writing a generic wrapper that forwards a user-supplied type string without validation; copy-pasting a hook call from docs of a different version.
Understand the failure class
Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.
Related errors
- At least one hook must be provided.
- Unsupported buffer type
- updateWrappedNativeTexture: target InternalTexture was not p
- Unsupported data for createImageBitmap.
- Unsupported type: ${outputType}
AI-assisted analysis of BabylonJS/Babylon.js@0592b347b8 (2026-08-30).
Data as JSON: /api/errors/3f3256661e2c6327.
Report an issue: GitHub.