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 types are not working #50

Open
moltar opened this issue Mar 2, 2023 · 9 comments
Open

TypeScript types are not working #50

moltar opened this issue Mar 2, 2023 · 9 comments

Comments

@moltar
Copy link

moltar commented Mar 2, 2023

When I install [email protected], I still get the type errors:

Could not find a declaration file for module 'native-file-system-adapter'. '.../node_modules/native-file-system-adapter/src/es6.js' implicitly has an 'any' type.
  Try `npm i --save-dev @types/native-file-system-adapter` if it exists or add a new declaration (.d.ts) file containing `declare module 'native-file-system-adapter';`ts(7016

Related issue: #39

@djpetti
Copy link

djpetti commented Mar 8, 2023

I fixed this by editing the "types" key in node_modules/native-file-system-adapter/package.json, and removing the leading slash in front of "types/mod.d.ts". It looks like this is fixed in master.

@AviDuda
Copy link

AviDuda commented Apr 29, 2023

In the meantime, you can fix types in your project by adding this to a file named e.g. native-file-system-adapter.d.ts:

declare module "native-file-system-adapter" {
  export * from "native-file-system-adapter/types/mod";
}

@linonetwo
Copy link

@jimmywarting Helps, please release a new version!

@jcbhmr
Copy link

jcbhmr commented Jun 5, 2023

@jimmywarting Would it be worthwhile to put the .d.ts files right next to the corresponding .js files so that the automatic sibling .d.ts detection works? 🤔 Then you wouldn't need any custom types: ... exports since any TS tool will just look for a same-name file with .replace(".js", ".d.ts")~ish logic.

@jimmywarting
Copy link
Owner

maybe. don't care so much where they end up anyway. they are auto generated when publishing anyway

@ChasonZheng
Copy link

In the meantime, you can fix types in your project by adding this to a file named e.g. native-file-system-adapter.d.ts:

declare module "native-file-system-adapter" {
  export * from "native-file-system-adapter/types/mod";
}

it worked

@creatxrgithub
Copy link

creatxrgithub commented Dec 8, 2023

in package.json modify the value

  "types": "../types/mod.d.ts",

now, it works:

import { showDirectoryPicker, showOpenFilePicker } from 'native-file-system-adapter/mod';

or modify package.json

  "types": "./types/mod.d.ts",

now, it works:

import { showDirectoryPicker, showOpenFilePicker } from 'native-file-system-adapter';

@spookyuser
Copy link

spookyuser commented Dec 18, 2023

Here's a patch for pnpm

Just save it in a folder called patches, next to your project package.json, then pnpm i native-file-system-adapter like normal and it should fix the types :)

@eavonius
Copy link

This is fixed in the main trunk, can we get a release to npm?

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

10 participants