Open raphaelmenges opened 5 months ago
Make sure you have the correct tsconfig.
I looked up the type definition and the methods are neither defined in 8.2.0 nor in 9.0.0. I am not sure why my typecheck did not complain before.
The methods are inherited from Conf
.
I have checked the electron-store
module inside my node_modules
directory. The type-fest
dependency is contained within the electron-store
module and the type definitions are found. The conf
module however is installed on the same level as the electron-store
module. I assume the conf
module is required by multiple of my dependencies (perhaps one of your other nice modules!) and npm
decided to install it on that level. I have not listed the conf
in my package.json
. When I change the path in the index.d.ts
to conf
of the electron-store
module as follows, the type check in index.d.ts
is fixed but the type check problem in my project persists:
import {type Except} from 'type-fest';
import Conf, {type Options as ConfigOptions} from '../conf/dist/source/types';
export {Schema} from '../conf/dist/source/types';
I am using over 1k (sub-)dependencies in the Electron project that just work fine how I setup the ESM environment, including native modules. Thus, I assume something with electron-store
or conf
might be broken. Perhaps you have an idea, otherwise I will try to make a minimal project that reproduces the issue!
same problem
I also have the same problem.
I'm also having the same problem, and would also like to reiterate @raphaelmenges comment:
I am using over 1k (sub-)dependencies in the Electron project that just work fine how I setup the ESM environment, including native modules. Thus, I assume something with electron-store or conf might be broken.
After using the latest version, I also encountered the same problem and had to use Anyscript!
Can you confirm you have "type": "module"
in your package.json and "module": "node16", "moduleResolution": "node16"
in your tsconfig?
I tried adding this to an existing TypeScript project and it compiles fine for me (npm run build
): https://github.com/sindresorhus/got/commit/40026f1acc81d8d78a8c66225bc22a5edbef68a2
Can you confirm you have
"type": "module"
in your package.json and"module": "node16", "moduleResolution": "node16"
in your tsconfig?
I have "type": "module"
in my package.json and "module": "esnext", "target": "esnext", "moduleResolution": "node"
in my tsconfig. When changing the latter to "module": "node16", "moduleResolution": "node16"
, my own code does no more compile via Typescript due to problems with path resolving. I am using the following (popular?) template: https://github.com/cawa-93/vite-electron-builder/tree/main
PS: Using the mentioned template, I could reproduce the error in a minimal fashion: https://github.com/raphaelmenges/electron-store-type-error
TypeScript does not treat your project as fully ESM unless you have moduleResolution
set to either node16
or nodenext
.
I am using the following (popular?) template: cawa-93/vite-electron-builder@main
Then I suggest opening an issue there. That config is incorrect.
@sindresorhus hi, I added code that solves this error, please have a look at it https://github.com/sindresorhus/conf/pull/193
Locking this as it seems clear the culprit is incorrect tsconfig.
Here is an example of a correct tsconfig: https://github.com/sindresorhus/tsconfig/blob/main/tsconfig.json
Hi 👋,
I have upgraded the electron-store from
8.2.0
to9.0.0
. Thanks for moving to ESM!Suddenly, Typescript complains that the methods
get
,set
, ordelete
are not available forElectronStore
. I looked up the type definition and the methods are neither defined in8.2.0
nor in9.0.0
. I am not sure why my typecheck did not complain before.Perhaps I am missing something in migrating from
8.2.0
to9.0.0
?