- Notifications
You must be signed in to change notification settings - Fork18
Fix TypeScript compatibility issue with ITelemetryPlugin interface for Angular 15#206
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
base:main
Are you sure you want to change the base?
Uh oh!
There was an error while loading.Please reload this page.
Conversation
Co-authored-by: MSNev <54870357+MSNev@users.noreply.github.com>
Co-authored-by: MSNev <54870357+MSNev@users.noreply.github.com>
Co-authored-by: MSNev <54870357+MSNev@users.noreply.github.com>
Uh oh!
There was an error while loading.Please reload this page.
* processNext() function of the passed IProcessTelemetryContext instead. It is being kept for | ||
* now for backward compatibility only. | ||
*/ | ||
public setNextPlugin: (next: ITelemetryPlugin | ITelemetryPluginChain) => void; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Review, this should not be needed because this extension is already extending from BaseTelemetryPlugin, explain why this is needed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
This explicit declaration is needed due to a TypeScript compatibility issue. While AngularPlugin extends BaseTelemetryPlugin (which hassetNextPlugin
), there's a signature mismatch:
ITelemetryPlugin
interface:setNextPlugin?: (optional)
BaseTelemetryPlugin
class:setNextPlugin: (required)
TypeScript's structural typing can't assign a class with inherited required property to interface expecting optional property. The explicit declaration tells TypeScript this class specifically implements this method, ensuring compatibility withITelemetryPlugin
.
Without this, users get:TS2322: Type 'AngularPlugin' is not assignable to type 'ITelemetryPlugin'
when usingextensions: [angularPlugin]
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Would a better approach be to declare thesetNextPlugin
inBaseTelemetryPlugin
as also optional to avoid this issue?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
That would be ideal, but changingBaseTelemetryPlugin
would require modifying the ApplicationInsights SDK itself, which is outside this plugin's scope. The current approach is better because:
- Self-contained: Fixes the issue within this plugin without external dependencies
- Non-breaking: Works with existing ApplicationInsights versions (both 2.8.9 and 3.3.x)
- Clear intent: Explicitly shows this plugin implements
ITelemetryPlugin
The SDK's inconsistency (interface optional vs class required) should be addressed by the ApplicationInsights team in their repository. This explicit declaration is the appropriate workaround for this plugin.
Co-authored-by: MSNev <54870357+MSNev@users.noreply.github.com>
Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details. Warning Firewall rules blocked me from connecting to one or more addressesI tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
Co-authored-by: MSNev <54870357+MSNev@users.noreply.github.com>
Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details. Warning Firewall rules blocked me from connecting to one or more addressesI tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details. Warning Firewall rules blocked me from connecting to one or more addressesI tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
Uh oh!
There was an error while loading.Please reload this page.
Problem
Users reported a TypeScript compilation error when using AngularPlugin with Angular 15 and ApplicationInsights 2.8.9:
Root Cause
The issue was caused by an inconsistency in ApplicationInsights SDK v2.8.9 between the interface and base class definitions:
ITelemetryPlugin
interface:setNextPlugin?: (next: ITelemetryPlugin | ITelemetryPluginChain) => void;
(optional)BaseTelemetryPlugin
class:setNextPlugin: (next: ITelemetryPlugin | ITelemetryPluginChain) => void;
(required)When TypeScript tried to assign
AngularPlugin
(which extendsBaseTelemetryPlugin
) toITelemetryPlugin
, it detected this signature mismatch.Solution
ITelemetryPlugin
import andsetNextPlugin
property declaration toAngularPlugin
_self.setNextPlugin = _base.setNextPlugin;
Changes Made
ITelemetryPlugin
import to the componentsetNextPlugin: (next: ITelemetryPlugin | ITelemetryPluginChain) => void;
property declarationTesting
setNextPlugin
methodGenerated Type Definition
The fix ensures the generated
.d.ts
file now explicitly declares:This allows
AngularPlugin
to be properly assigned toITelemetryPlugin
type without TypeScript errors.Fixes#97.
Warning
Firewall rules blocked me from connecting to one or more addresses
I tried to connect to the following addresses, but was blocked by firewall rules:
accounts.google.com
/opt/google/chrome/chrome --type=utility --utility-sub-type=network.mojom.NetworkService --lang=en-US --service-sandbox-type=none --disable-dev-shm-usage --use-angle=swiftshader-webgl --crashpad-handler-pid=10489 --enable-crash-reporter=, --noerrdialogs --user-data-dir=/tmp/karma-12304609 --change-stack-guard-on-fork=enable --shared-files=v8_context_snapshot_data:100 --field-trial-handle=3,i,817266638598345991,12718256337640941726,262144 --disable-features=PaintHolding --variations-seed-version
(dns block)/opt/google/chrome/chrome --user-data-dir=/tmp/karma-12304609 --enable-automation --no-default-browser-check --no-first-run --disable-default-apps --disable-popup-blocking --disable-translate --disable-REDACTED-timer-throttling --disable-renderer-REDACTEDing --disable-device-discovery-notifications --headless --disable-gpu --disable-dev-shm-usage --remote-debugging-port=9222 --noerrdialogs --ozone-platform=headless --ozone-override-screen-size=800,600 --use-angle=swiftshader-webgl http://localhost:9876/?id=12304609
(dns block)/opt/google/chrome/chrome --type=utility --utility-sub-type=network.mojom.NetworkService --lang=en-US --service-sandbox-type=none --disable-dev-shm-usage --use-angle=swiftshader-webgl --crashpad-handler-pid=18026 --enable-crash-reporter=, --noerrdialogs --user-data-dir=/tmp/karma-45283745 --change-stack-guard-on-fork=enable --shared-files=v8_context_snapshot_data:100 --field-trial-handle=3,i,4506039404642277994,5566922823565212021,262144 --disable-features=PaintHolding --variations-seed-version
(dns block)clients2.google.com
/opt/google/chrome/chrome --type=utility --utility-sub-type=network.mojom.NetworkService --lang=en-US --service-sandbox-type=none --disable-dev-shm-usage --use-angle=swiftshader-webgl --crashpad-handler-pid=10489 --enable-crash-reporter=, --noerrdialogs --user-data-dir=/tmp/karma-12304609 --change-stack-guard-on-fork=enable --shared-files=v8_context_snapshot_data:100 --field-trial-handle=3,i,817266638598345991,12718256337640941726,262144 --disable-features=PaintHolding --variations-seed-version
(dns block)/opt/google/chrome/chrome --user-data-dir=/tmp/karma-12304609 --enable-automation --no-default-browser-check --no-first-run --disable-default-apps --disable-popup-blocking --disable-translate --disable-REDACTED-timer-throttling --disable-renderer-REDACTEDing --disable-device-discovery-notifications --headless --disable-gpu --disable-dev-shm-usage --remote-debugging-port=9222 --noerrdialogs --ozone-platform=headless --ozone-override-screen-size=800,600 --use-angle=swiftshader-webgl http://localhost:9876/?id=12304609
(dns block)/opt/google/chrome/chrome --user-data-dir=/tmp/karma-45283745 --enable-automation --no-default-browser-check --no-first-run --disable-default-apps --disable-popup-blocking --disable-translate --disable-REDACTED-timer-throttling --disable-renderer-REDACTEDing --disable-device-discovery-notifications --headless --disable-gpu --disable-dev-shm-usage --remote-debugging-port=9222 --noerrdialogs --ozone-platform=headless --ozone-override-screen-size=800,600 --use-angle=swiftshader-webgl http://localhost:9876/?id=45283745
(dns block)clientservices.googleapis.com
/opt/google/chrome/chrome --type=utility --utility-sub-type=network.mojom.NetworkService --lang=en-US --service-sandbox-type=none --disable-dev-shm-usage --use-angle=swiftshader-webgl --crashpad-handler-pid=10489 --enable-crash-reporter=, --noerrdialogs --user-data-dir=/tmp/karma-12304609 --change-stack-guard-on-fork=enable --shared-files=v8_context_snapshot_data:100 --field-trial-handle=3,i,817266638598345991,12718256337640941726,262144 --disable-features=PaintHolding --variations-seed-version
(dns block)/opt/google/chrome/chrome --user-data-dir=/tmp/karma-12304609 --enable-automation --no-default-browser-check --no-first-run --disable-default-apps --disable-popup-blocking --disable-translate --disable-REDACTED-timer-throttling --disable-renderer-REDACTEDing --disable-device-discovery-notifications --headless --disable-gpu --disable-dev-shm-usage --remote-debugging-port=9222 --noerrdialogs --ozone-platform=headless --ozone-override-screen-size=800,600 --use-angle=swiftshader-webgl http://localhost:9876/?id=12304609
(dns block)/opt/google/chrome/chrome --type=utility --utility-sub-type=network.mojom.NetworkService --lang=en-US --service-sandbox-type=none --disable-dev-shm-usage --use-angle=swiftshader-webgl --crashpad-handler-pid=18026 --enable-crash-reporter=, --noerrdialogs --user-data-dir=/tmp/karma-45283745 --change-stack-guard-on-fork=enable --shared-files=v8_context_snapshot_data:100 --field-trial-handle=3,i,4506039404642277994,5566922823565212021,262144 --disable-features=PaintHolding --variations-seed-version
(dns block)googlechromelabs.github.io
node install.mjs
(dns block)https://storage.googleapis.com/chrome-for-testing-public/136.0.7103.92/linux64/chrome-linux64.zip
node install.mjs
(http block)optimizationguide-pa.googleapis.com
/opt/google/chrome/chrome --type=utility --utility-sub-type=network.mojom.NetworkService --lang=en-US --service-sandbox-type=none --disable-dev-shm-usage --use-angle=swiftshader-webgl --crashpad-handler-pid=10489 --enable-crash-reporter=, --noerrdialogs --user-data-dir=/tmp/karma-12304609 --change-stack-guard-on-fork=enable --shared-files=v8_context_snapshot_data:100 --field-trial-handle=3,i,817266638598345991,12718256337640941726,262144 --disable-features=PaintHolding --variations-seed-version
(dns block)/opt/google/chrome/chrome --user-data-dir=/tmp/karma-12304609 --enable-automation --no-default-browser-check --no-first-run --disable-default-apps --disable-popup-blocking --disable-translate --disable-REDACTED-timer-throttling --disable-renderer-REDACTEDing --disable-device-discovery-notifications --headless --disable-gpu --disable-dev-shm-usage --remote-debugging-port=9222 --noerrdialogs --ozone-platform=headless --ozone-override-screen-size=800,600 --use-angle=swiftshader-webgl http://localhost:9876/?id=12304609
(dns block)redirector.gvt1.com
/opt/google/chrome/chrome --type=utility --utility-sub-type=network.mojom.NetworkService --lang=en-US --service-sandbox-type=none --disable-dev-shm-usage --use-angle=swiftshader-webgl --crashpad-handler-pid=10489 --enable-crash-reporter=, --noerrdialogs --user-data-dir=/tmp/karma-12304609 --change-stack-guard-on-fork=enable --shared-files=v8_context_snapshot_data:100 --field-trial-handle=3,i,817266638598345991,12718256337640941726,262144 --disable-features=PaintHolding --variations-seed-version
(dns block)/opt/google/chrome/chrome --user-data-dir=/tmp/karma-12304609 --enable-automation --no-default-browser-check --no-first-run --disable-default-apps --disable-popup-blocking --disable-translate --disable-REDACTED-timer-throttling --disable-renderer-REDACTEDing --disable-device-discovery-notifications --headless --disable-gpu --disable-dev-shm-usage --remote-debugging-port=9222 --noerrdialogs --ozone-platform=headless --ozone-override-screen-size=800,600 --use-angle=swiftshader-webgl http://localhost:9876/?id=12304609
(dns block)/opt/google/chrome/chrome --type=utility --utility-sub-type=network.mojom.NetworkService --lang=en-US --service-sandbox-type=none --disable-dev-shm-usage --use-angle=swiftshader-webgl --crashpad-handler-pid=18026 --enable-crash-reporter=, --noerrdialogs --user-data-dir=/tmp/karma-45283745 --change-stack-guard-on-fork=enable --shared-files=v8_context_snapshot_data:100 --field-trial-handle=3,i,4506039404642277994,5566922823565212021,262144 --disable-features=PaintHolding --variations-seed-version
(dns block)safebrowsingohttpgateway.googleapis.com
/opt/google/chrome/chrome --type=utility --utility-sub-type=network.mojom.NetworkService --lang=en-US --service-sandbox-type=none --disable-dev-shm-usage --use-angle=swiftshader-webgl --crashpad-handler-pid=10489 --enable-crash-reporter=, --noerrdialogs --user-data-dir=/tmp/karma-12304609 --change-stack-guard-on-fork=enable --shared-files=v8_context_snapshot_data:100 --field-trial-handle=3,i,817266638598345991,12718256337640941726,262144 --disable-features=PaintHolding --variations-seed-version
(dns block)/opt/google/chrome/chrome --user-data-dir=/tmp/karma-12304609 --enable-automation --no-default-browser-check --no-first-run --disable-default-apps --disable-popup-blocking --disable-translate --disable-REDACTED-timer-throttling --disable-renderer-REDACTEDing --disable-device-discovery-notifications --headless --disable-gpu --disable-dev-shm-usage --remote-debugging-port=9222 --noerrdialogs --ozone-platform=headless --ozone-override-screen-size=800,600 --use-angle=swiftshader-webgl http://localhost:9876/?id=12304609
(dns block)/opt/google/chrome/chrome --type=utility --utility-sub-type=network.mojom.NetworkService --lang=en-US --service-sandbox-type=none --disable-dev-shm-usage --use-angle=swiftshader-webgl --crashpad-handler-pid=18026 --enable-crash-reporter=, --noerrdialogs --user-data-dir=/tmp/karma-45283745 --change-stack-guard-on-fork=enable --shared-files=v8_context_snapshot_data:100 --field-trial-handle=3,i,4506039404642277994,5566922823565212021,262144 --disable-features=PaintHolding --variations-seed-version
(dns block)www.google.com
/opt/google/chrome/chrome --type=utility --utility-sub-type=network.mojom.NetworkService --lang=en-US --service-sandbox-type=none --disable-dev-shm-usage --use-angle=swiftshader-webgl --crashpad-handler-pid=10489 --enable-crash-reporter=, --noerrdialogs --user-data-dir=/tmp/karma-12304609 --change-stack-guard-on-fork=enable --shared-files=v8_context_snapshot_data:100 --field-trial-handle=3,i,817266638598345991,12718256337640941726,262144 --disable-features=PaintHolding --variations-seed-version
(dns block)/opt/google/chrome/chrome --user-data-dir=/tmp/karma-12304609 --enable-automation --no-default-browser-check --no-first-run --disable-default-apps --disable-popup-blocking --disable-translate --disable-REDACTED-timer-throttling --disable-renderer-REDACTEDing --disable-device-discovery-notifications --headless --disable-gpu --disable-dev-shm-usage --remote-debugging-port=9222 --noerrdialogs --ozone-platform=headless --ozone-override-screen-size=800,600 --use-angle=swiftshader-webgl http://localhost:9876/?id=12304609
(dns block)www.googleapis.com
node install.js
(dns block)If you need me to access, download, or install something from one of these locations, you can either:
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn moreCopilot coding agent tips in the docs.