Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't use exactOptionalPropertyTypes because of: error TS2420: Class 'TelemetryConfiguration' incorrectly implements interface 'TelemetryConfig' #194

Open
jamesharv opened this issue Jan 9, 2025 · 1 comment
Labels
bug Something isn't working

Comments

@jamesharv
Copy link

jamesharv commented Jan 9, 2025

Description

When using typescript, and when typescript is configured to use the compiler option exactOptionalPropertyTypes there is an error compiling this library.

node_modules/@openfga/sdk/dist/telemetry/configuration.d.ts:27:22 - error TS2420: Class 'TelemetryConfiguration' incorrectly implements interface 'TelemetryConfig'.
  Types of property 'metrics' are incompatible.
    Type 'Partial<Record<TelemetryMetric, TelemetryMetricConfig>> | undefined' is not assignable to type 'Partial<Record<TelemetryMetric, TelemetryMetricConfig>>'.
      Type 'undefined' is not assignable to type 'Partial<Record<TelemetryMetric, TelemetryMetricConfig>>'.

27 export declare class TelemetryConfiguration implements TelemetryConfig {
                        ~~~~~~~~~~~~~~~~~~~~~~


Found 1 error in node_modules/@openfga/sdk/dist/telemetry/configuration.d.ts:27

Version of SDK

0.7.0

Version of node

22.12.0

Version of npm

10.9.0

Version of OpenFGA (if known)

N/A

OpenFGA Flags/Custom Configuration Applicable

N/A

Reproduction

mkdir exact-optional-props-repro
cd exact-optional-props-repro
npm init -y
npm i -E @openfga/[email protected] [email protected]
echo 'import { OpenFgaClient } from "@openfga/sdk";' > index.ts
npx tsc --init
npx tsc --exactOptionalPropertyTypes --skipLibCheck false

Output

Wrote to exact-optional-props-repro/package.json:

{
  "name": "exact-optional-props-repro",
  "version": "1.0.0",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "description": ""
}




added 13 packages, and audited 14 packages in 3s

1 package is looking for funding
  run `npm fund` for details

found 0 vulnerabilities

Created a new tsconfig.json with:                                                                                       
                                                                                                                     TS 
  target: es2016
  module: commonjs
  strict: true
  esModuleInterop: true
  skipLibCheck: true
  forceConsistentCasingInFileNames: true


You can learn more at https://aka.ms/tsconfig
node_modules/@openfga/sdk/dist/telemetry/configuration.d.ts:27:22 - error TS2420: Class 'TelemetryConfiguration' incorrectly implements interface 'TelemetryConfig'.
  Types of property 'metrics' are incompatible.
    Type 'Partial<Record<TelemetryMetric, TelemetryMetricConfig>> | undefined' is not assignable to type 'Partial<Record<TelemetryMetric, TelemetryMetricConfig>>'.
      Type 'undefined' is not assignable to type 'Partial<Record<TelemetryMetric, TelemetryMetricConfig>>'.

27 export declare class TelemetryConfiguration implements TelemetryConfig {
                        ~~~~~~~~~~~~~~~~~~~~~~


Found 1 error in node_modules/@openfga/sdk/dist/telemetry/configuration.d.ts:27

Expected behavior

Should be able to use the exactOptionalPropertyTypes option, and compile a project using the library.

@jamesharv jamesharv added the bug Something isn't working label Jan 9, 2025
@guillempuche
Copy link

Interested

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: Backlog
Development

No branches or pull requests

2 participants