fix(telemetry): support TypeScript exactOptionalPropertyTypes compiler option#270
fix(telemetry): support TypeScript exactOptionalPropertyTypes compiler option#270wizzfi1 wants to merge 3 commits intoopenfga:mainfrom
Conversation
|
|
|
Important Review skippedAuto incremental reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the Use the checkbox below for a quick retry:
WalkthroughThe pull request introduces a new Nix development environment configuration file (.idx/dev.nix) for workspace setup, updates the CHANGELOG with a bug fix entry for TypeScript exactOptionalPropertyTypes support, and modifies the TelemetryConfig interface to explicitly allow undefined on the metrics property. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes The changes are straightforward: a new configuration file with guided scaffolding, a documentation entry, and a minimal type definition update. No complex logic, behavioral changes, or multi-file refactoring patterns present. Possibly related issues
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (2)
telemetry/configuration.ts (2)
25-25: Consider adding| undefinedfor consistency.The
attributesproperty inTelemetryMetricConfigis also optional. For completeexactOptionalPropertyTypessupport and consistency with theTelemetryConfig.metricsupdate, consider adding| undefinedhere as well.Apply this diff:
- attributes?: Set<TelemetryAttribute>; + attributes?: Set<TelemetryAttribute> | undefined;
110-111: Update constructor parameter signature for consistency.The constructor parameter
metricsshould also include| undefinedto match the interface property type on line 35. This ensures full consistency and proper support for theexactOptionalPropertyTypescompiler option.Apply this diff:
constructor( - public metrics?: Partial<Record<TelemetryMetric, TelemetryMetricConfig>>, + public metrics?: Partial<Record<TelemetryMetric, TelemetryMetricConfig>> | undefined, ) {
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
.idx/dev.nix(1 hunks)CHANGELOG.md(1 hunks)telemetry/configuration.ts(1 hunks)
🔇 Additional comments (3)
CHANGELOG.md (1)
6-9: LGTM! Documentation correctly reflects the bug fix.The changelog entry accurately documents the TypeScript compiler option compatibility fix.
.idx/dev.nix (1)
1-55: Clarify the inclusion of this unrelated development environment file.This Nix configuration file appears unrelated to the PR's stated objective of supporting TypeScript's
exactOptionalPropertyTypescompiler option. Consider moving this to a separate PR focused on development environment setup.telemetry/configuration.ts (1)
35-35: LGTM! Correctly supports exactOptionalPropertyTypes.The addition of
| undefinedto themetricsproperty ensures compatibility with TypeScript's--exactOptionalPropertyTypescompiler option.
9f75c31 to
1693be9
Compare
|
Hi team I’ve verified that this change builds successfully and passes all telemetry-related tests (npm run build and npm run test telemetry). This update ensures that the SDK compiles cleanly when using the --exactOptionalPropertyTypes TypeScript compiler option. Thank you for reviewing — I appreciate your time and feedback! |
e79f653 to
1693be9
Compare
There was a problem hiding this comment.
Pull request overview
Updates telemetry type definitions to be compatible with TypeScript’s --exactOptionalPropertyTypes setting, so downstream strict TS projects can compile cleanly.
Changes:
- Adjust
TelemetryConfig.metricsto explicitly permitundefinedunderexactOptionalPropertyTypes. - Add a changelog entry for the telemetry fix.
- Add a
.idx/dev.nixworkspace configuration file.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| telemetry/configuration.ts | Updates exported telemetry config typings for exactOptionalPropertyTypes. |
| CHANGELOG.md | Adds a changelog entry documenting the telemetry typing fix. |
| .idx/dev.nix | Adds an IDX/Nix dev workspace configuration. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| */ | ||
| export interface TelemetryConfig { | ||
| metrics?: Partial<Record<TelemetryMetric, TelemetryMetricConfig>>; | ||
| metrics?: Partial<Record<TelemetryMetric, TelemetryMetricConfig>> | undefined; |
There was a problem hiding this comment.
This file is marked as auto-generated ("DO NOT EDIT"). If telemetry/configuration.ts is regenerated as part of the build/release process, this manual type tweak is likely to be overwritten. Consider applying the change in the OpenAPI Generator input/templates (or whatever generation step produces this file) so the fix persists across regenerations.
| metrics?: Partial<Record<TelemetryMetric, TelemetryMetricConfig>> | undefined; | |
| metrics?: Partial<Record<TelemetryMetric, TelemetryMetricConfig>>; |
| @@ -32,9 +32,10 @@ export interface TelemetryMetricConfig { | |||
| * @property {Record<TelemetryMetric, TelemetryMetricConfig>} metrics - A record mapping telemetry metrics to their configurations. | |||
There was a problem hiding this comment.
The JSDoc for TelemetryConfig.metrics says it is a required Record<TelemetryMetric, TelemetryMetricConfig>, but the actual type is optional and Partial<...> (and now explicitly allows undefined). Please update the doc comment so it accurately reflects the public type contract.
| * @property {Record<TelemetryMetric, TelemetryMetricConfig>} metrics - A record mapping telemetry metrics to their configurations. | |
| * @property {Partial<Record<TelemetryMetric, TelemetryMetricConfig>> | undefined} metrics - An optional record mapping telemetry metrics to their configurations. |
| ### Bug Fixes | ||
|
|
||
| - fix(telemetry): support TypeScript exactOptionalPropertyTypes compiler option | ||
|
|
There was a problem hiding this comment.
This changelog entry is currently placed under the v0.9.1 section (after the v0.9.1 bullets). If this telemetry fix is intended for a future release, it should go under the Unreleased section (or the correct version section), otherwise it will read as if it shipped in v0.9.1.
| - fix(telemetry): support TypeScript exactOptionalPropertyTypes compiler option | ||
|
|
||
|
|
||
| ## v0.9.0 | ||
|
|
||
|
|
||
|
|
||
| ### [v0.9.0](https://github.com/openfga/js-sdk/compare/v0.8.1...v0.9.0) (2025-06-04) |
There was a problem hiding this comment.
There are multiple extra blank lines introduced around this new changelog section (e.g., between the entry and the next version header). Please trim the redundant empty lines to keep the changelog formatting consistent and readable.
Summary
This PR makes the telemetry module compatible with the TypeScript compiler option exactOptionalPropertyTypes.
When --exactOptionalPropertyTypes is enabled, TypeScript requires optional properties to explicitly allow undefined. Some telemetry-related type definitions did not conform, causing compilation errors for downstream users.
Changes
Updated telemetry configuration types to include | undefined where appropriate.
Verified that the SDK builds successfully with --exactOptionalPropertyTypes.
Confirmed that all telemetry tests pass (npm run test telemetry).
Why
This change improves SDK compatibility with strict TypeScript projects and ensures the SDK can compile cleanly with modern compiler settings.
Validation
✅ Ran npm run build successfully
✅ Verified telemetry test suite passes
✅ Confirmed no behavioral regressions
Changelog
fix(telemetry): support TypeScript exactOptionalPropertyTypes compiler option
Summary by CodeRabbit
Bug Fixes
Chores