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

Unable to compile without other dependencies, Dropbox, Emscripten, HTML5FS &etc.? #263

Open
SamuelMarks opened this issue Nov 28, 2018 · 11 comments

Comments

@SamuelMarks
Copy link

SamuelMarks commented Nov 28, 2018

Related: #200 #233

Using a package that recommends BrowserFS, so I run npm i -S browserfs; npm i -D @types/browserfs. Then I import it like so:

import * as BrowserFS from 'browserfs';
import FS, { FSModule } from 'browserfs/dist/node/core/FS';

Now I get these errors (Angular 7.1 app):

ERROR in node_modules/browserfs/dist/node/backend/Dropbox.d.ts(2,23): error TS2688: Cannot find type definition file for 'dropboxjs'.
node_modules/browserfs/dist/node/backend/Dropbox.d.ts(18,13): error TS2503: Cannot find namespace 'Dropbox'.
node_modules/browserfs/dist/node/backend/Dropbox.d.ts(44,25): error TS2503: Cannot find namespace 'Dropbox'.
node_modules/browserfs/dist/node/backend/Dropbox.d.ts(54,68): error TS2503: Cannot find namespace 'Dropbox'.
node_modules/browserfs/dist/node/backend/Dropbox.d.ts(59,21): error TS2503: Cannot find namespace 'Dropbox'.
node_modules/browserfs/dist/node/backend/Dropbox.d.ts(65,51): error TS2503: Cannot find namespace 'Dropbox'.
node_modules/browserfs/dist/node/backend/Dropbox.d.ts(93,18): error TS2503: Cannot find namespace 'Dropbox'.
node_modules/browserfs/dist/node/backend/Emscripten.d.ts(19,19): error TS2304: Cannot find name 'NodeBuffer'.
node_modules/browserfs/dist/node/backend/Emscripten.d.ts(20,23): error TS2304: Cannot find name 'NodeBuffer'.
node_modules/browserfs/dist/node/backend/Emscripten.d.ts(21,18): error TS2304: Cannot find name 'NodeBuffer'.
node_modules/browserfs/dist/node/backend/Emscripten.d.ts(22,22): error TS2304: Cannot find name 'NodeBuffer'.
node_modules/browserfs/dist/node/backend/HTML5FS.d.ts(1,23): error TS2688: Cannot find type definition file for 'filesystem'.
node_modules/browserfs/dist/node/backend/HTML5FS.d.ts(10,37): error TS2304: Cannot find name 'FileEntry'.
node_modules/browserfs/dist/node/backend/HTML5FS.d.ts(32,9): error TS2304: Cannot find name 'FileSystem'.
node_modules/browserfs/dist/node/core/node_fs_stats.d.ts(18,22): error TS2720: Class 'import("proj-name/node_modules/browserfs/dist/node/core/node_fs_stats").default' incorrectly implements class 'import("fs").Stats'. Did you mean to extend 'import("fs").Stats' and inherit its members as a subclass?
  Property 'atimeMs' is missing in type 'Stats'.

Am I doing something wrong?


EDIT: Progress thus far has been made by:

npm i -D @types/dropboxjs @types/node @types/filesystem

Adding below export default class Stats implements fs.Stats { in node_modules/browserfs/dist/node/core/node_fs_stats.d.ts:

atimeMs: number;
mtimeMs: number;
ctimeMs: number;
birthtimeMs: number;

Replaced NodeBuffer with Buffer in node_modules/browserfs/dist/node/backend/Emscripten.d.ts.

@bmfs
Copy link

bmfs commented Dec 3, 2018

Are you using the ForkTsCheckerWebpackPlugin in webpack?

@abhishiv
Copy link

abhishiv commented Dec 17, 2018

I'm also having this problem but only with Stats class

node_modules/browserfs/dist/node/core/node_fs_stats.d.ts:18:22 - error TS2720: Class 'import("/Users/abhishiv/work/gratico/kernel/node_modules/browserfs/dist/node/core/node_fs_stats").default' incorrectly implements class 'import("fs").Stats'. Did you mean to extend 'import("fs").Stats' and inherit its members as a subclass?

Trying to exclude the .d.ts file via tsconfig.json didn't work as usual - probably because of this

  "exclude": [
    "node_modules/browserfs/dist/node/backend/HTML5FS.d.ts",
    "node_modules/browserfs/dist/node/core/node_fs_stats.d.ts",
    "node_modules/browserfs/dist/node/backend/Emscripten.d.ts",
    "node_modules/browserfs/dist/node/backend/Dropbox.d.ts",
    "node_modules",
    "build"
  ]

EDIT:
As mentioned in the message, changing implements to extends in node_fs_stats.d.ts does fix the error, and I can compile my project

//Stats/// <reference types="node" /> // comment this out as well
export default class Stats extends fs.Stats {

@shawn-bandy-urbag
Copy link

I was able to alleviate the two errors above by matching the version of the types in my project's package.json to those in browserfs (1.4.3):

    "@types/dropboxjs": "0.0.28",
    "@types/filesystem": "0.0.29",
    "@types/node": "~7.0",
    "browserfs": "^1.4.3",

@jvilk
Copy link
Owner

jvilk commented May 29, 2019

I'm happy to accept PRs that improve compatibility here.

@dsl400
Copy link

dsl400 commented Aug 8, 2019

Help!!

npm i -D @types/browserfs
npm ERR! code E404
npm ERR! 404 Not Found - GET https://registry.npmjs.org/@types%2fbrowserfs - Not found
npm ERR! 404
npm ERR! 404  '@types/browserfs@latest' is not in the npm registry.

any suggestion would be appreciated

@jcoutch
Copy link

jcoutch commented Aug 16, 2019

@dsl400 - There is no types package for BrowserFS, since BrowserFS is already written in TypeScript. :-)

@NickStrupat
Copy link

@jcoutch you're right, but it's broken.

@jsmith
Copy link

jsmith commented Mar 5, 2020

Jumping on this thread to add my solution. Since I'm only really using a subset of the API I just created a simple type file and modified my tsconfig.json file to point the compiler in the right direction 😄

// browserfs.d.ts
declare module 'browserfs' {
  export function configure(o: { fs: string, options: any }, onError: (e?: Error) => void): void;
}
// tsconfig.json
{
    ...
    "paths": {
      "browserfs": [
        "src/types/browserfs.d.ts"
      ]
    },
    ...
}

@kevzettler
Copy link

I followed shawn-bandy-urbag suggestion and installed explicit versions in to my host project.

"@types/dropboxjs": "0.0.28",
"@types/filesystem": "0.0.29",
"@types/node": "~7.0",
"browserfs": "^1.4.3",

I tried to create a PR to fixe theses issues but couldn't figure out how to get the SharedArrayBuffer reference exporting to the consumer projects.

@james-pre
Copy link
Collaborator

@SamuelMarks @abhishiv

Does this bug still exist?

@james-pre
Copy link
Collaborator

Closing (stale). If you would like to reopen this issue, please do so by creating a new issue in the relevant repositories of @browser-fs

@james-pre james-pre closed this as not planned Won't fix, can't repro, duplicate, stale Oct 25, 2023
Repository owner locked and limited conversation to collaborators Oct 25, 2023
@james-pre james-pre reopened this May 17, 2024
Repository owner unlocked this conversation May 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests