diff --git a/.changeset/harmonize-phantom-t-getter.md b/.changeset/harmonize-phantom-t-getter.md index 970d4f18b2..99995cd8e2 100644 --- a/.changeset/harmonize-phantom-t-getter.md +++ b/.changeset/harmonize-phantom-t-getter.md @@ -2,4 +2,4 @@ '@backstage/backend-plugin-api': patch --- -Harmonized the phantom `.T` getter on `ExtensionPoint` to consistently return `null` instead of throwing. +Harmonized the phantom `.T` getter behavior on `ExtensionPoint` and `ServiceRef` to consistently return `null` instead of throwing, and added `toJSON()` parity for `ExtensionPoint`. diff --git a/packages/backend-plugin-api/src/services/system/types.ts b/packages/backend-plugin-api/src/services/system/types.ts index 925156d3ae..a97d577ec4 100644 --- a/packages/backend-plugin-api/src/services/system/types.ts +++ b/packages/backend-plugin-api/src/services/system/types.ts @@ -50,7 +50,7 @@ export type ServiceRef< /** * Utility for getting the type of the service, using `typeof serviceRef.T`. - * Attempting to actually read this value will result in an exception. + * Reading this value will always return `null`. It is only intended for use with `typeof serviceRef.T`. */ T: TService; diff --git a/packages/backend-plugin-api/src/wiring/types.ts b/packages/backend-plugin-api/src/wiring/types.ts index 9397cf597b..8d75c8923f 100644 --- a/packages/backend-plugin-api/src/wiring/types.ts +++ b/packages/backend-plugin-api/src/wiring/types.ts @@ -27,7 +27,7 @@ export type ExtensionPoint = { /** * Utility for getting the type of the extension point, using `typeof extensionPoint.T`. - * Attempting to actually read this value will result in an exception. + * Reading this value will always return `null`. It is only intended for use with `typeof extensionPoint.T`. */ T: T;