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

TypeScript compile errors after adding the library #219

Open
m3co-code opened this issue Nov 15, 2022 · 1 comment
Open

TypeScript compile errors after adding the library #219

m3co-code opened this issue Nov 15, 2022 · 1 comment

Comments

@m3co-code
Copy link

Hi and thank you for the lib! ⭐

I'm currently struggling to get it up and running in a NodeJS application developed with TypeScript. After just having done a yarn add @kafkajs/confluent-schema-registry (^3.3.0 in my package.json) I get a lot of TypeScript compile errors. Do you have some advice how I can mitigate those or do you have some recommendation with which settings TypeScript needs to be configured to make it work? Or is there a minimal NodeJS version required? We're currently running node v16.14.2.

Our current tsconfig.json looks like this:

{
  "compilerOptions": {
    "target": "es6",
    "module": "commonjs",
    "lib": ["es6"],
    "declaration": true,
    "outDir": "lib",
    "rootDir": "src",
    "strict": true,
    "noImplicitAny": true,
    "strictPropertyInitialization": false,
    "noUnusedLocals": true,
    "types": ["jest", "node"],
    "esModuleInterop": true,
    "experimentalDecorators": true,
    "emitDecoratorMetadata": true,
    "resolveJsonModule": true
  },
  "include": ["src/**/*"]
}

TypeScript compile errors I'm getting:

../../../node_modules/@kafkajs/confluent-schema-registry/node_modules/ajv/dist/types/jtd-schema.d.ts:93:14 - error TS2456: Type alias 'JTDDataDef' circularly references itself.

93 declare type JTDDataDef<S, D extends Record<string, unknown>> = (S extends {
                ~~~~~~~~~~

../../../node_modules/@kafkajs/confluent-schema-registry/node_modules/ajv/dist/types/jtd-schema.d.ts:95:5 - error TS2315: Type 'JTDDataDef' is not generic.

95 } ? JTDDataDef<D[S["ref"]], D> : S extends {
       ~~~~~~~~~~~~~~~~~~~~~~~~~~

../../../node_modules/@kafkajs/confluent-schema-registry/node_modules/ajv/dist/types/jtd-schema.d.ts:105:5 - error TS2315: Type 'JTDDataDef' is not generic.

105 } ? JTDDataDef<E, D>[] : S extends {
        ~~~~~~~~~~~~~~~~

../../../node_modules/@kafkajs/confluent-schema-registry/node_modules/ajv/dist/types/jtd-schema.d.ts:110:47 - error TS2315: Type 'JTDDataDef' is not generic.

110     -readonly [K in keyof S["properties"]]-?: JTDDataDef<S["properties"][K], D>;
                                                  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

../../../node_modules/@kafkajs/confluent-schema-registry/node_modules/ajv/dist/types/jtd-schema.d.ts:112:55 - error TS2315: Type 'JTDDataDef' is not generic.

112     -readonly [K in keyof S["optionalProperties"]]+?: JTDDataDef<S["optionalProperties"][K], D>;
                                                          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

../../../node_modules/@kafkajs/confluent-schema-registry/node_modules/ajv/dist/types/jtd-schema.d.ts:118:47 - error TS2315: Type 'JTDDataDef' is not generic.

118     -readonly [K in keyof S["properties"]]-?: JTDDataDef<S["properties"][K], D>;
                                                  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

../../../node_modules/@kafkajs/confluent-schema-registry/node_modules/ajv/dist/types/jtd-schema.d.ts:120:55 - error TS2315: Type 'JTDDataDef' is not generic.

120     -readonly [K in keyof S["optionalProperties"]]+?: JTDDataDef<S["optionalProperties"][K], D>;
                                                          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

../../../node_modules/@kafkajs/confluent-schema-registry/node_modules/ajv/dist/types/jtd-schema.d.ts:123:20 - error TS2315: Type 'JTDDataDef' is not generic.

123 } ? Record<string, JTDDataDef<V, D>> : S extends {
                       ~~~~~~~~~~~~~~~~

../../../node_modules/@kafkajs/confluent-schema-registry/node_modules/ajv/dist/types/jtd-schema.d.ts:127:32 - error TS2315: Type 'JTDDataDef' is not generic.

127     [K in keyof S["mapping"]]: JTDDataDef<S["mapping"][K], D> & {
                                   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

../../../node_modules/@kafkajs/confluent-schema-registry/node_modules/ajv/dist/types/jtd-schema.d.ts:135:5 - error TS2315: Type 'JTDDataDef' is not generic.

135 } ? JTDDataDef<S, S["definitions"]> : JTDDataDef<S, Record<string, never>>;
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

../../../node_modules/@kafkajs/confluent-schema-registry/node_modules/ajv/dist/types/jtd-schema.d.ts:135:39 - error TS2315: Type 'JTDDataDef' is not generic.

135 } ? JTDDataDef<S, S["definitions"]> : JTDDataDef<S, Record<string, never>>;
                                          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

../../../node_modules/avsc/types/index.d.ts:150:41 - error TS2304: Cannot find name 'Blob'.

150 export function createBlobDecoder(blob: Blob, opts?: Partial<DecoderOptions>): streams.BlockDecoder;

../../../node_modules/mappersmith/gateway/fetch.d.ts:18:46 - error TS2694: Namespace 'globalThis' has no exported member 'Response'.

18     createResponse(fetchResponse: globalThis.Response, data: string | ArrayBuffer | Buffer): Response<import("../response").ParsedJSON>;
                                                ~~~~~~~~

../../../node_modules/mappersmith/gateway/types.d.ts:17:35 - error TS2304: Cannot find name 'XMLHttpRequest'.

17     configure?: ((xmlHttpRequest: XMLHttpRequest) => void) | null;
                                     ~~~~~~~~~~~~~~

../../../node_modules/mappersmith/gateway/types.d.ts:19:50 - error TS2304: Cannot find name 'RequestInit'.

19 declare type FetchGatewayConfiguration = Partial<RequestInit>;
                                                    ~~~~~~~~~~~

../../../node_modules/mappersmith/gateway/xhr.d.ts:13:37 - error TS2304: Cannot find name 'XMLHttpRequest'.

13     configureBinary(xmlHttpRequest: XMLHttpRequest): void;
                                       ~~~~~~~~~~~~~~

../../../node_modules/mappersmith/gateway/xhr.d.ts:14:38 - error TS2304: Cannot find name 'XMLHttpRequest'.

14     configureTimeout(xmlHttpRequest: XMLHttpRequest): void;
                                        ~~~~~~~~~~~~~~

../../../node_modules/mappersmith/gateway/xhr.d.ts:15:40 - error TS2304: Cannot find name 'XMLHttpRequest'.

15     configureCallbacks(xmlHttpRequest: XMLHttpRequest): void;
                                          ~~~~~~~~~~~~~~

../../../node_modules/mappersmith/gateway/xhr.d.ts:17:36 - error TS2304: Cannot find name 'XMLHttpRequest'.

17     createResponse(xmlHttpRequest: XMLHttpRequest): Response<import("../response").ParsedJSON>;
                                      ~~~~~~~~~~~~~~

../../../node_modules/mappersmith/gateway/xhr.d.ts:18:32 - error TS2304: Cannot find name 'XMLHttpRequest'.

18     setHeaders(xmlHttpRequest: XMLHttpRequest, customHeaders: Headers): void;
                                  ~~~~~~~~~~~~~~

../../../node_modules/mappersmith/gateway/xhr.d.ts:19:18 - error TS2304: Cannot find name 'XMLHttpRequest'.

19     createXHR(): XMLHttpRequest;
                    ~~~~~~~~~~~~~~

../../../node_modules/mappersmith/manifest.d.ts:10:19 - error TS2304: Cannot find name 'fetch'.

10     fetch: typeof fetch | null;

Any help would be highly appreciated!

@m3co-code
Copy link
Author

I got it to compile for now if I add skipLibCheck to my tsconfig. But seems to be a quite unclean solution. So keeping the issue open.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant