Skip to content

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

Open
@jamesharv

Description

@jamesharv

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    Status

    Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions