Closed Tulipesz closed 2 years ago
Where are you importing AceBase
from?
Where are you importing
AceBase
from?
import { AceBase } from 'acebase'
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?
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:
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.
Inside module typing:
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?
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:
My node_modules/@types
:
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
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?
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!
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!
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.Temporarily:
Thx for the project and i appreciate any help.