[GH-ISSUE #220] Multiple TypeScript errors when using package acebase #102

Closed
opened 2026-05-23 08:30:48 -06:00 by gitea-mirror · 3 comments
Owner

Originally created by @Septh on GitHub (Apr 26, 2023).
Original GitHub issue: https://github.com/appy-one/acebase/issues/220

This minimalist TypeScript code:

import { AceBase } from 'acebase'

ends up with TypeScript reporting 6 errors.

(expand to reveal screenshot, text-only version is below)

image

Stephan@Bombasse-III MINGW64 ~/Dev/zz_tests/acebase
$ tsc
node_modules/acebase/dist/types/storage/binary/index.d.ts:267:5 - error TS2416: Property 'getChildren' in type 'AceBaseStorage' is not assignable to the same property in base type 'Storage'.
  Type '(path: string, options?: { keyFilter?: string[] | number[] | undefined; tid?: string | number | undefined; async?: boolean | undefined; } | undefined) => { next(valueCallback: (child: BinaryNodeInfo) => boolean | void, useAsync?: boolean | undefined): Promise<...>; }' is not assignable to type '(path: string, options?: { keyFilter?: string[] | number[] | undefined; tid?: string | number | undefined; async?: boolean | undefined; } | undefined) => { next: (callback: (child: NodeInfo) => boolean | ... 1 more ... | Promise<...>) => Promise<...>; }'.
    Call signature return types '{ next(valueCallback: (child: BinaryNodeInfo) => boolean | void, useAsync?: boolean | undefined): Promise<boolean>; }' and '{ next: (callback: (child: NodeInfo) => boolean | void | Promise<boolean | void>) => Promise<boolean>; }' are incompatible.
      The types of 'next' are incompatible between these types.
        Types of parameters 'valueCallback' and 'callback' are incompatible.
          Type 'boolean | void | Promise<boolean | void>' is not assignable to type 'boolean | void'.
            Type 'Promise<boolean | void>' is not assignable to type 'boolean | void'.

267     getChildren(path: string, options?: {
        ~~~~~~~~~~~

node_modules/acebase/dist/types/storage/custom/index.d.ts:187:5 - error TS2416: Property 'getChildren' in type 'CustomStorage' is not assignable to the same property in base type 'Storage'.
  Type '(path: string, options?: { transaction?: CustomStorageTransaction | undefined; keyFilter?: string[] | number[] | undefined; } | undefined) => { next(valueCallback: (child: NodeInfo) => boolean): Promise<...>; }' is not assignable to type '(path: string, options?: { keyFilter?: string[] | number[] | undefined; tid?: string | number | undefined; async?: boolean | undefined; } | undefined) => { next: (callback: (child: NodeInfo) => boolean | ... 1 more ... | Promise<...>) => Promise<...>; }'.
    Call signature return types '{ next(valueCallback: (child: NodeInfo) => boolean): Promise<boolean>; }' and '{ next:(callback: (child: NodeInfo) => boolean | void | Promise<boolean | void>) => Promise<boolean>; }' are incompatible.
      The types of 'next' are incompatible between these types.
        Types of parameters 'valueCallback' and 'callback' are incompatible.
          Type 'boolean | void | Promise<boolean | void>' is not assignable to type 'boolean'.
            Type 'void' is not assignable to type 'boolean'.

187     getChildren(path: string, options?: {
        ~~~~~~~~~~~

node_modules/acebase/dist/types/storage/custom/local-storage/transaction.d.ts:23:5 - error TS2416: Property 'childrenOf' in type 'LocalStorageTransaction' is not assignable to the same property in base type 'CustomStorageTransaction'.
  Type '(path: string, include: { metadata?: boolean | undefined; value?: boolean | undefined; }, checkCallback: (path:string) => boolean, addCallback: (path: string, node: ICustomStorageNodeMetaData | ICustomStorageNode) => boolean) => Promise<...>' is not assignable to type '(path: string, include: { metadata: boolean; value: boolean; }, checkCallback: (childPath: string) => boolean, addCallback?: ((childPath: string, node?: ICustomStorageNodeMetaData | ICustomStorageNode| undefined) => boolean) | undefined) => Promise<...>'.
    Types of parameters 'addCallback' and 'addCallback' are incompatible.
      Type '((childPath: string, node?: ICustomStorageNodeMetaData | ICustomStorageNode | undefined) => boolean) | undefined' is not assignable to type '(path: string, node: ICustomStorageNodeMetaData | ICustomStorageNode) => boolean'.
        Type 'undefined' is not assignable to type '(path: string, node: ICustomStorageNodeMetaData | ICustomStorageNode) => boolean'.

23     childrenOf(path: string, include: {
       ~~~~~~~~~~

node_modules/acebase/dist/types/storage/custom/local-storage/transaction.d.ts:27:5 - error TS2416: Property 'descendantsOf' in type 'LocalStorageTransaction' is not assignable to the same property in base type 'CustomStorageTransaction'.
  Type '(path: string, include: { metadata?: boolean | undefined; value?: boolean | undefined; }, checkCallback: (path:string) => boolean, addCallback: (path: string, node: ICustomStorageNodeMetaData | ICustomStorageNode) => boolean) => Promise<...>' is not assignable to type '(path: string, include: { metadata: boolean; value: boolean; }, checkCallback: (descPath: string, metadata?: ICustomStorageNodeMetaData | undefined) => boolean, addCallback?: ((descPath: string, node?: ICustomStorageNodeMetaData | ... 1 more ... | undefined) => boolean) | undefined) => Promise<...>'.
    Types of parameters 'addCallback' and 'addCallback' are incompatible.
      Type '((descPath: string, node?: ICustomStorageNodeMetaData | ICustomStorageNode | undefined) => boolean) | undefined' is not assignable to type '(path: string, node: ICustomStorageNodeMetaData | ICustomStorageNode) => boolean'.
        Type 'undefined' is not assignable to type '(path: string, node: ICustomStorageNodeMetaData | ICustomStorageNode) => boolean'.

27     descendantsOf(path: string, include: {
       ~~~~~~~~~~~~~

node_modules/acebase/dist/types/storage/mssql/index.d.ts:138:5 - error TS2416: Property 'getChildren' in type 'MSSQLStorage' is not assignable to the same property in base type 'Storage'.
  Type '(path: string, options?: { keyFilter?: (string | number)[] | undefined; tid?: string | number | undefined; } | undefined) => { next(valueCallback: (child: MSSQLNodeInfo) => boolean): Promise<...>; }' is not assignable to type '(path: string, options?: { keyFilter?: string[] | number[] | undefined; tid?: string | number | undefined; async?: boolean |undefined; } | undefined) => { next: (callback: (child: NodeInfo) => boolean | ... 1 more ... | Promise<...>) => Promise<...>; }'.
    Call signature return types '{ next(valueCallback: (child: MSSQLNodeInfo) => boolean): Promise<boolean>; }' and '{ next: (callback: (child: NodeInfo) => boolean | void | Promise<boolean | void>) => Promise<boolean>; }' are incompatible.
      The types of 'next' are incompatible between these types.
        Types of parameters 'valueCallback' and 'callback' are incompatible.
          Type 'boolean | void | Promise<boolean | void>' is not assignable to type 'boolean'.

138     getChildren(path: string, options?: {
        ~~~~~~~~~~~

node_modules/acebase/dist/types/storage/sqlite/index.d.ts:70:5 - error TS2416: Property 'getChildren' in type 'SQLiteStorage' is not assignable to the same property in base type 'Storage'.
  Type '(path: string, options?: { keyFilter?: (string | number)[] | undefined; tid?: string | number | undefined; } | undefined) => { next(valueCallback: (child: SQLiteNodeInfo) => boolean): Promise<...>; }' is not assignable to type '(path: string, options?: { keyFilter?: string[] | number[] | undefined; tid?: string | number | undefined; async?: boolean | undefined; } | undefined) => { next: (callback: (child: NodeInfo) => boolean | ... 1 more ... | Promise<...>) => Promise<...>; }'.
    Call signature return types '{ next(valueCallback: (child: SQLiteNodeInfo) => boolean): Promise<boolean>; }' and '{next: (callback: (child: NodeInfo) => boolean | void | Promise<boolean | void>) => Promise<boolean>; }' are incompatible.
      The types of 'next' are incompatible between these types.
        Types of parameters 'valueCallback' and 'callback' are incompatible.
          Type 'boolean | void | Promise<boolean | void>' is not assignable to type 'boolean'.

70     getChildren(path: string, options?: {
       ~~~~~~~~~~~


Found 6 errors in 5 files.

Errors  Files
     1  node_modules/acebase/dist/types/storage/binary/index.d.ts:267
     1  node_modules/acebase/dist/types/storage/custom/index.d.ts:187
     2  node_modules/acebase/dist/types/storage/custom/local-storage/transaction.d.ts:23
     1  node_modules/acebase/dist/types/storage/mssql/index.d.ts:138
     1  node_modules/acebase/dist/types/storage/sqlite/index.d.ts:70

Stephan@Bombasse-III MINGW64 ~/Dev/zz_tests/acebase
$

AceBase 1.28.2, tested with both TypeScript 4.9.5 and 5.0.4 (note that I have "skipLibCheck": false in tconfig.json).

Originally created by @Septh on GitHub (Apr 26, 2023). Original GitHub issue: https://github.com/appy-one/acebase/issues/220 This minimalist TypeScript code: ```ts import { AceBase } from 'acebase' ``` ends up with TypeScript reporting 6 errors. <details><summary>(expand to reveal screenshot, text-only version is below)</summary> ![image](https://user-images.githubusercontent.com/11949623/234641960-28935cb0-3e72-4bd7-a1a1-baed93cacea0.png) </details> ```text Stephan@Bombasse-III MINGW64 ~/Dev/zz_tests/acebase $ tsc node_modules/acebase/dist/types/storage/binary/index.d.ts:267:5 - error TS2416: Property 'getChildren' in type 'AceBaseStorage' is not assignable to the same property in base type 'Storage'. Type '(path: string, options?: { keyFilter?: string[] | number[] | undefined; tid?: string | number | undefined; async?: boolean | undefined; } | undefined) => { next(valueCallback: (child: BinaryNodeInfo) => boolean | void, useAsync?: boolean | undefined): Promise<...>; }' is not assignable to type '(path: string, options?: { keyFilter?: string[] | number[] | undefined; tid?: string | number | undefined; async?: boolean | undefined; } | undefined) => { next: (callback: (child: NodeInfo) => boolean | ... 1 more ... | Promise<...>) => Promise<...>; }'. Call signature return types '{ next(valueCallback: (child: BinaryNodeInfo) => boolean | void, useAsync?: boolean | undefined): Promise<boolean>; }' and '{ next: (callback: (child: NodeInfo) => boolean | void | Promise<boolean | void>) => Promise<boolean>; }' are incompatible. The types of 'next' are incompatible between these types. Types of parameters 'valueCallback' and 'callback' are incompatible. Type 'boolean | void | Promise<boolean | void>' is not assignable to type 'boolean | void'. Type 'Promise<boolean | void>' is not assignable to type 'boolean | void'. 267 getChildren(path: string, options?: { ~~~~~~~~~~~ node_modules/acebase/dist/types/storage/custom/index.d.ts:187:5 - error TS2416: Property 'getChildren' in type 'CustomStorage' is not assignable to the same property in base type 'Storage'. Type '(path: string, options?: { transaction?: CustomStorageTransaction | undefined; keyFilter?: string[] | number[] | undefined; } | undefined) => { next(valueCallback: (child: NodeInfo) => boolean): Promise<...>; }' is not assignable to type '(path: string, options?: { keyFilter?: string[] | number[] | undefined; tid?: string | number | undefined; async?: boolean | undefined; } | undefined) => { next: (callback: (child: NodeInfo) => boolean | ... 1 more ... | Promise<...>) => Promise<...>; }'. Call signature return types '{ next(valueCallback: (child: NodeInfo) => boolean): Promise<boolean>; }' and '{ next:(callback: (child: NodeInfo) => boolean | void | Promise<boolean | void>) => Promise<boolean>; }' are incompatible. The types of 'next' are incompatible between these types. Types of parameters 'valueCallback' and 'callback' are incompatible. Type 'boolean | void | Promise<boolean | void>' is not assignable to type 'boolean'. Type 'void' is not assignable to type 'boolean'. 187 getChildren(path: string, options?: { ~~~~~~~~~~~ node_modules/acebase/dist/types/storage/custom/local-storage/transaction.d.ts:23:5 - error TS2416: Property 'childrenOf' in type 'LocalStorageTransaction' is not assignable to the same property in base type 'CustomStorageTransaction'. Type '(path: string, include: { metadata?: boolean | undefined; value?: boolean | undefined; }, checkCallback: (path:string) => boolean, addCallback: (path: string, node: ICustomStorageNodeMetaData | ICustomStorageNode) => boolean) => Promise<...>' is not assignable to type '(path: string, include: { metadata: boolean; value: boolean; }, checkCallback: (childPath: string) => boolean, addCallback?: ((childPath: string, node?: ICustomStorageNodeMetaData | ICustomStorageNode| undefined) => boolean) | undefined) => Promise<...>'. Types of parameters 'addCallback' and 'addCallback' are incompatible. Type '((childPath: string, node?: ICustomStorageNodeMetaData | ICustomStorageNode | undefined) => boolean) | undefined' is not assignable to type '(path: string, node: ICustomStorageNodeMetaData | ICustomStorageNode) => boolean'. Type 'undefined' is not assignable to type '(path: string, node: ICustomStorageNodeMetaData | ICustomStorageNode) => boolean'. 23 childrenOf(path: string, include: { ~~~~~~~~~~ node_modules/acebase/dist/types/storage/custom/local-storage/transaction.d.ts:27:5 - error TS2416: Property 'descendantsOf' in type 'LocalStorageTransaction' is not assignable to the same property in base type 'CustomStorageTransaction'. Type '(path: string, include: { metadata?: boolean | undefined; value?: boolean | undefined; }, checkCallback: (path:string) => boolean, addCallback: (path: string, node: ICustomStorageNodeMetaData | ICustomStorageNode) => boolean) => Promise<...>' is not assignable to type '(path: string, include: { metadata: boolean; value: boolean; }, checkCallback: (descPath: string, metadata?: ICustomStorageNodeMetaData | undefined) => boolean, addCallback?: ((descPath: string, node?: ICustomStorageNodeMetaData | ... 1 more ... | undefined) => boolean) | undefined) => Promise<...>'. Types of parameters 'addCallback' and 'addCallback' are incompatible. Type '((descPath: string, node?: ICustomStorageNodeMetaData | ICustomStorageNode | undefined) => boolean) | undefined' is not assignable to type '(path: string, node: ICustomStorageNodeMetaData | ICustomStorageNode) => boolean'. Type 'undefined' is not assignable to type '(path: string, node: ICustomStorageNodeMetaData | ICustomStorageNode) => boolean'. 27 descendantsOf(path: string, include: { ~~~~~~~~~~~~~ node_modules/acebase/dist/types/storage/mssql/index.d.ts:138:5 - error TS2416: Property 'getChildren' in type 'MSSQLStorage' is not assignable to the same property in base type 'Storage'. Type '(path: string, options?: { keyFilter?: (string | number)[] | undefined; tid?: string | number | undefined; } | undefined) => { next(valueCallback: (child: MSSQLNodeInfo) => boolean): Promise<...>; }' is not assignable to type '(path: string, options?: { keyFilter?: string[] | number[] | undefined; tid?: string | number | undefined; async?: boolean |undefined; } | undefined) => { next: (callback: (child: NodeInfo) => boolean | ... 1 more ... | Promise<...>) => Promise<...>; }'. Call signature return types '{ next(valueCallback: (child: MSSQLNodeInfo) => boolean): Promise<boolean>; }' and '{ next: (callback: (child: NodeInfo) => boolean | void | Promise<boolean | void>) => Promise<boolean>; }' are incompatible. The types of 'next' are incompatible between these types. Types of parameters 'valueCallback' and 'callback' are incompatible. Type 'boolean | void | Promise<boolean | void>' is not assignable to type 'boolean'. 138 getChildren(path: string, options?: { ~~~~~~~~~~~ node_modules/acebase/dist/types/storage/sqlite/index.d.ts:70:5 - error TS2416: Property 'getChildren' in type 'SQLiteStorage' is not assignable to the same property in base type 'Storage'. Type '(path: string, options?: { keyFilter?: (string | number)[] | undefined; tid?: string | number | undefined; } | undefined) => { next(valueCallback: (child: SQLiteNodeInfo) => boolean): Promise<...>; }' is not assignable to type '(path: string, options?: { keyFilter?: string[] | number[] | undefined; tid?: string | number | undefined; async?: boolean | undefined; } | undefined) => { next: (callback: (child: NodeInfo) => boolean | ... 1 more ... | Promise<...>) => Promise<...>; }'. Call signature return types '{ next(valueCallback: (child: SQLiteNodeInfo) => boolean): Promise<boolean>; }' and '{next: (callback: (child: NodeInfo) => boolean | void | Promise<boolean | void>) => Promise<boolean>; }' are incompatible. The types of 'next' are incompatible between these types. Types of parameters 'valueCallback' and 'callback' are incompatible. Type 'boolean | void | Promise<boolean | void>' is not assignable to type 'boolean'. 70 getChildren(path: string, options?: { ~~~~~~~~~~~ Found 6 errors in 5 files. Errors Files 1 node_modules/acebase/dist/types/storage/binary/index.d.ts:267 1 node_modules/acebase/dist/types/storage/custom/index.d.ts:187 2 node_modules/acebase/dist/types/storage/custom/local-storage/transaction.d.ts:23 1 node_modules/acebase/dist/types/storage/mssql/index.d.ts:138 1 node_modules/acebase/dist/types/storage/sqlite/index.d.ts:70 Stephan@Bombasse-III MINGW64 ~/Dev/zz_tests/acebase $ ``` AceBase `1.28.2`, tested with both TypeScript `4.9.5` and `5.0.4` (note that I have `"skipLibCheck": false` in `tconfig.json`).
Author
Owner

@appy-one commented on GitHub (Apr 26, 2023):

Hi @Septh I tried to reproduce but can only when setting skipLibCheck to false.
Check out the following minimal project:

package.json:

{
  "name": "issue220",
  "version": "1.0.0",
  "main": "dist/index.js",
  "dependencies": {
    "acebase": "^1.28.2"
  },
  "devDependencies": {
    "typescript": "^5.0.4"
  }
}

tsconfig.json:

{
  "compilerOptions": {
    "target": "ESNext",
    "module": "ESNext",
    "moduleResolution": "nodenext",
    "rootDir": "./src",
    "outDir": "./dist",
    "esModuleInterop": false,
    "strict": true,
    "skipLibCheck": true
  }
}

src/index.ts:

import { AceBase } from "acebase";

Running npx tsc yields no errors. Setting skipLibCheck to false will yield the errors you posted.
I will take a look at the errors, because they should not be there in the first place, but it does look like there is something wrong with your configuration. Are you sure tsc is picking up your tsconfig.json? You did mention tconfig.json, which might a typo or misspelling of the actual file?

<!-- gh-comment-id:1523946363 --> @appy-one commented on GitHub (Apr 26, 2023): Hi @Septh I tried to reproduce but can only when setting `skipLibCheck` to `false`. Check out the following minimal project: _package.json_: ```json { "name": "issue220", "version": "1.0.0", "main": "dist/index.js", "dependencies": { "acebase": "^1.28.2" }, "devDependencies": { "typescript": "^5.0.4" } } ``` _tsconfig.json_: ```json { "compilerOptions": { "target": "ESNext", "module": "ESNext", "moduleResolution": "nodenext", "rootDir": "./src", "outDir": "./dist", "esModuleInterop": false, "strict": true, "skipLibCheck": true } } ``` _src/index.ts_: ```ts import { AceBase } from "acebase"; ``` Running `npx tsc` yields no errors. Setting `skipLibCheck` to `false` will yield the errors you posted. I will take a look at the errors, because they should not be there in the first place, but it does look like there is something wrong with your configuration. Are you sure `tsc` is picking up your `tsconfig.json`? You did mention `tconfig.json`, which might a typo or misspelling of the actual file?
Author
Owner

@Septh commented on GitHub (Apr 27, 2023):

Thanks. You're right of course, this is a typo from me - I did mean tsconfig.json. And yes, the errors only show when skipLibCheck is false (which is the default anyway).

<!-- gh-comment-id:1524547115 --> @Septh commented on GitHub (Apr 27, 2023): Thanks. You're right of course, this is a typo from me - I did mean `tsconfig.json`. And yes, the errors only show when `skipLibCheck` is `false` (which is the default anyway).
Author
Owner

@appy-one commented on GitHub (Apr 30, 2023):

Updating to v1.28.4 should fix this!

Sponsor AceBase Spread the word contribute

<!-- gh-comment-id:1528995349 --> @appy-one commented on GitHub (Apr 30, 2023): Updating to v1.28.4 should fix this! [![Sponsor AceBase](https://user-images.githubusercontent.com/26569719/168233053-8e56b243-4140-40ab-9a30-4cb3cc149bfe.svg)](https://github.com/sponsors/appy-one) [![Spread the word](https://user-images.githubusercontent.com/26569719/169265089-3d593555-e1ad-4390-986b-877ac2c38a47.svg)](https://twitter.com/intent/tweet?button=&url=https://github.com/appy-one/acebase&text=I'm+using+@AcebaseRealtime+in+my+project+to+make+my+life+easier!&button=) [![contribute](https://user-images.githubusercontent.com/26569719/169265318-30c4c6a5-7c89-46a0-a7a2-ef433a8192f4.svg)](https://github.com/appy-one/acebase#contributing)
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: github-starred/acebase#102
No description provided.