[GH-ISSUE #145] Property 'ref' does not exist on type 'AceBase'. #81

Closed
opened 2026-05-23 08:29:37 -06:00 by gitea-mirror · 10 comments
Owner

Originally created by @Tulipesz on GitHub (Aug 28, 2022).
Original GitHub issue: https://github.com/appy-one/acebase/issues/145

Hi!
I'm building a project with electron + typescript but the only types that appear for me are "ready" and "close".
Strange that the lib supports typing, I don't know what's going on.
The only way to get around the error is to add
// @ts-expect-error
before the line, but it doesn't seem like the right thing to do.

Screenshot_1

Temporarily:

Screenshot_2

Thx for the project and i appreciate any help.

Originally created by @Tulipesz on GitHub (Aug 28, 2022). Original GitHub issue: https://github.com/appy-one/acebase/issues/145 Hi! I'm building a project with electron + typescript but the only types that appear for me are "ready" and "close". Strange that the lib supports typing, I don't know what's going on. The only way to get around the error is to add `// @ts-expect-error` before the line, but it doesn't seem like the right thing to do. ![Screenshot_1](https://user-images.githubusercontent.com/43249004/187100016-c9f52348-6634-4d7f-a316-328ca24ef1aa.png) Temporarily: ![Screenshot_2](https://user-images.githubusercontent.com/43249004/187100212-2224273b-af6a-4cc4-b4e0-e52b85e12da7.png) Thx for the project and i appreciate any help.
Author
Owner

@appy-one commented on GitHub (Aug 29, 2022):

Where are you importing AceBase from?

<!-- gh-comment-id:1229922161 --> @appy-one commented on GitHub (Aug 29, 2022): Where are you importing `AceBase` from?
Author
Owner

@Tulipesz commented on GitHub (Aug 29, 2022):

Where are you importing AceBase from?

import { AceBase } from 'acebase'

<!-- gh-comment-id:1230663671 --> @Tulipesz commented on GitHub (Aug 29, 2022): > Where are you importing `AceBase` from? `import { AceBase } from 'acebase'`
Author
Owner

@appy-one commented on GitHub (Aug 29, 2022):

That looks ok. I tried reproducing today by creating a basic Electron app with TypeScript and AceBase, but everything worked as expected so there must be something else wrong in your project. Did you install acebase througn npm/yarn? And which version are you using?

<!-- gh-comment-id:1230677168 --> @appy-one commented on GitHub (Aug 29, 2022): That looks ok. I tried reproducing today by creating a basic Electron app with TypeScript and AceBase, but everything worked as expected so there must be something else wrong in your project. Did you install acebase througn npm/yarn? And which version are you using?
Author
Owner

@Tulipesz commented on GitHub (Aug 29, 2022):

Isso parece ok. Tentei reproduzir hoje criando um aplicativo Electron básico com TypeScript e AceBase, mas tudo funcionou como esperado, então deve haver algo mais errado em seu projeto. Você instalou o acebase através do npm/yarn? E qual versão você está usando?

Installed through yarn:
yarn add acebase

My package.json dependencies:
code

I don't really bother with problems specific to my projects, but this is very strange to me since the whole acebase project is typed.

<!-- gh-comment-id:1230696481 --> @Tulipesz commented on GitHub (Aug 29, 2022): > Isso parece ok. Tentei reproduzir hoje criando um aplicativo Electron básico com TypeScript e AceBase, mas tudo funcionou como esperado, então deve haver algo mais errado em seu projeto. Você instalou o acebase através do npm/yarn? E qual versão você está usando? Installed through yarn: `yarn add acebase` My package.json dependencies: ![code](https://user-images.githubusercontent.com/43249004/187272808-366b6776-eab3-446a-b8b6-30607635632b.png) I don't really bother with problems specific to my projects, but this is very strange to me since the whole acebase project is typed.
Author
Owner

@Tulipesz commented on GitHub (Aug 29, 2022):

Inside module typing:
Screenshot_2
Screenshot_4

<!-- gh-comment-id:1230716991 --> @Tulipesz commented on GitHub (Aug 29, 2022): Inside module typing: ![Screenshot_2](https://user-images.githubusercontent.com/43249004/187275270-4e268dff-2a74-4647-a18c-265061f3acb3.png) ![Screenshot_4](https://user-images.githubusercontent.com/43249004/187275275-5aededfb-0536-48db-8c17-1310082b38e8.png)
Author
Owner

@appy-one commented on GitHub (Aug 29, 2022):

That's very strange! Can you try opening up acebase-core/package.json and acebase-core/types/index.d.ts to see if that changes anything?

<!-- gh-comment-id:1230727675 --> @appy-one commented on GitHub (Aug 29, 2022): That's very strange! Can you try opening up `acebase-core/package.json` and `acebase-core/types/index.d.ts` to see if that changes anything?
Author
Owner

@Tulipesz commented on GitHub (Aug 29, 2022):

I think the problem is in tsconfig.json, acebase does not create its typing in the @types folder of node_modules.
My "typeRoots" in tsconfig.json:
code

My node_modules/@types:
Screenshot_5

In the acebase-core folder all types are inside the "types" folder, how does the acebase module know that it has to get the types from this folder? By default, typescript looks for folders with @types when not specified:
https://www.typescriptlang.org/tsconfig#typeRoots

Screenshot_6

<!-- gh-comment-id:1230765578 --> @Tulipesz commented on GitHub (Aug 29, 2022): I think the problem is in tsconfig.json, acebase does not create its typing in the `@types` folder of node_modules. My "typeRoots" in tsconfig.json: ![code](https://user-images.githubusercontent.com/43249004/187278776-37ef64ea-2c97-4028-a1f8-8ed2335e5a50.png) My `node_modules/@types`: ![Screenshot_5](https://user-images.githubusercontent.com/43249004/187281120-366db49f-e89c-4787-acde-4818e292ac5c.png) In the acebase-core folder all types are inside the "types" folder, how does the acebase module know that it has to get the types from this folder? By default, typescript looks for folders with @types when not specified: https://www.typescriptlang.org/tsconfig#typeRoots ![Screenshot_6](https://user-images.githubusercontent.com/43249004/187282577-720f6068-483c-4041-9c39-33e93bdd3633.png)
Author
Owner

@appy-one commented on GitHub (Aug 29, 2022):

Why are you using typeRoots? Each package that has typings has a types entry in its package.json file. If it doesn't, you'd need to install a @types/[packagename] dependency for it (when available). Both acebase and acebase-core have their types location specified in their package.json so there's no need to install anything else, or to manually specify other locations. Maybe you should try commenting out / removing the typeRoots entry in your tsconfig.json and see what happens?

<!-- gh-comment-id:1230858721 --> @appy-one commented on GitHub (Aug 29, 2022): Why are you using `typeRoots`? Each package that has typings has a `types` entry in its `package.json` file. If it doesn't, you'd need to install a `@types/[packagename]` dependency for it (when available). Both `acebase` and `acebase-core` have their types location specified in their `package.json` so there's no need to install anything else, or to manually specify other locations. Maybe you should try commenting out / removing the `typeRoots` entry in your `tsconfig.json` and see what happens?
Author
Owner

@Tulipesz commented on GitHub (Aug 30, 2022):

Thanks a lot for the help @appy-one ! And thanks for the explanation of the types entry in package.json, I didn't know that.

The problem was in my tsconfig.json even but in the moduleResolution entry. As I created my project through a template (https://github.com/Devtography/electron-react-typescript-webpack-boilerplate), it already came with the typeRoots setted (but it works with it set anyway), the problem is that the moduleResolution came set as "Node16" and according to this discussion:
https://github.com/microsoft/TypeScript/issues/49160#issuecomment-1137482639
some libs are breaking when the "moduleResolution": "Node16" and in package.json has the exports entry (to be able to support cjs and esm in the same package). I just changed the moduleResolution entry in my tsconfig.json to "Node" and everything is working perfectly.
Again thanks a lot for the help!

<!-- gh-comment-id:1231036935 --> @Tulipesz commented on GitHub (Aug 30, 2022): Thanks a lot for the help @appy-one ! And thanks for the explanation of the `types` entry in `package.json`, I didn't know that. The problem was in my `tsconfig.json` even but in the `moduleResolution` entry. As I created my project through a template (https://github.com/Devtography/electron-react-typescript-webpack-boilerplate), it already came with the `typeRoots` setted (but it works with it set anyway), the problem is that the `moduleResolution` came set as `"Node16"` and according to this discussion: https://github.com/microsoft/TypeScript/issues/49160#issuecomment-1137482639 some libs are breaking when the `"moduleResolution": "Node16"` and in `package.json` has the `exports` entry (to be able to support cjs and esm in the same package). I just changed the `moduleResolution` entry in my `tsconfig.json` to `"Node"` and everything is working perfectly. Again thanks a lot for the help!
Author
Owner

@appy-one commented on GitHub (Aug 30, 2022):

Thanks for your research @Tulipesz! I'm now also generating index.d.ts files into the CommonJS and ESM distribution folders that simply export all types from the right location. I've published the changes with acebase-core v1.22.0. After updating (reinstall acebase dependency), you should be able to use Node16 module resolution without issues!

<!-- gh-comment-id:1232025197 --> @appy-one commented on GitHub (Aug 30, 2022): Thanks for your research @Tulipesz! I'm now also [generating `index.d.ts` files into the CommonJS and ESM distribution folders](https://github.com/appy-one/acebase-core/commit/6eafbbacddbbd2929e8ade671c770790dc06f7c2) that simply export all types from the right location. I've published the changes with `acebase-core` v1.22.0. After updating (reinstall `acebase` dependency), you should be able to use Node16 module resolution without issues!
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#81
No description provided.