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

Unusable with tight tsconfig #68

Closed
yoursunny opened this issue May 25, 2024 · 0 comments · Fixed by #69
Closed

Unusable with tight tsconfig #68

yoursunny opened this issue May 25, 2024 · 0 comments · Fixed by #69
Labels
bug Something isn't working
Milestone

Comments

@yoursunny
Copy link
Contributor

yoursunny commented May 25, 2024

@zenfs/core v0.12.5 is unusable in a downstream TypeScript project where the tsconfig.json has tight typecheck settings: noImplicitOverride, noImplicitReturns, noUncheckedIndexedAccess, noUnusedLocals.

Snippet to reproduce

tsconfig.json

{
  "compilerOptions": {
    "forceConsistentCasingInFileNames": true,
    "module": "es2022",
    "moduleResolution": "Node",
    "noEmitOnError": true,
    "noImplicitOverride": true,
    "noImplicitReturns": true,
    "noUncheckedIndexedAccess": true,
    "noUnusedLocals": true,
    "strict": true,
    "target": "ES2022",
    "types": [
      "node"
    ]
  },
  "include": [
    "main.ts"
  ],
  "exclude": [
    "**/node_modules"
  ]
}

package.json

{
  "private": true,
  "packageManager": "pnpm@9.1.2+sha256.19c17528f9ca20bd442e4ca42f00f1b9808a9cb419383cd04ba32ef19322aba7",
  "scripts": {
    "tsc": "tsc"
  },
  "dependencies": {
    "@types/node": "^20.12.12",
    "@zenfs/core": "^0.12.5",
    "typescript": "^5.4.5"
  }
}

main.ts

import { InMemory } from "@zenfs/core";

const fs = InMemory.create({});
await fs.empty();

Error messages

corepack pnpm tsc command gives the following errors:

node_modules/.pnpm/@zenfs+core@0.12.5/node_modules/@zenfs/core/src/backends/backend.ts(119,54): error TS2532: Object is possibly 'undefined'.
node_modules/.pnpm/@zenfs+core@0.12.5/node_modules/@zenfs/core/src/backends/fetch.ts(78,15): error TS4114: This member must have an 'override' modifier because it overrides a member in the base class 'IndexFS'.
node_modules/.pnpm/@zenfs+core@0.12.5/node_modules/@zenfs/core/src/backends/fetch.ts(101,9): error TS4114: This member must have an 'override' modifier because it overrides a member in the base class 'IndexFS'.
node_modules/.pnpm/@zenfs+core@0.12.5/node_modules/@zenfs/core/src/backends/index/fs.ts(15,15): error TS4114: This member must have an 'override' modifier because it overrides a member in the base class 'ReadonlyFS & FileSystem'.
node_modules/.pnpm/@zenfs+core@0.12.5/node_modules/@zenfs/core/src/backends/index/index.ts(54,9): error TS4114: This member must have an 'override' modifier because it overrides a member in the base class 'Map<string, Stats>'.
node_modules/.pnpm/@zenfs+core@0.12.5/node_modules/@zenfs/core/src/backends/overlay.ts(41,8): error TS4114: This member must have an 'override' modifier because it overrides a member in the base class 'FileSystem'.
node_modules/.pnpm/@zenfs+core@0.12.5/node_modules/@zenfs/core/src/backends/overlay.ts(72,9): error TS4114: This member must have an 'override' modifier because it overrides a member in the base class 'FileSystem'.
node_modules/.pnpm/@zenfs+core@0.12.5/node_modules/@zenfs/core/src/backends/overlay.ts(476,10): error TS6133: 'operateOnWritable' is declared but its value is never read.
node_modules/.pnpm/@zenfs+core@0.12.5/node_modules/@zenfs/core/src/backends/overlay.ts(487,16): error TS6133: 'operateOnWritableAsync' is declared but its value is never read.
node_modules/.pnpm/@zenfs+core@0.12.5/node_modules/@zenfs/core/src/backends/port/fs.ts(155,9): error TS4114: This member must have an 'override' modifier because it overrides a member in the base class 'AsyncFS & FileSystem'.
node_modules/.pnpm/@zenfs+core@0.12.5/node_modules/@zenfs/core/src/backends/port/fs.ts(173,15): error TS4114: This member must have an 'override' modifier because it overrides a member in the base class 'AsyncFS & FileSystem'.
node_modules/.pnpm/@zenfs+core@0.12.5/node_modules/@zenfs/core/src/backends/port/fs.ts(207,9): error TS4114: This member must have an 'override' modifier because it overrides a member in the base class 'AsyncFS & FileSystem'.
node_modules/.pnpm/@zenfs+core@0.12.5/node_modules/@zenfs/core/src/backends/store/fs.ts(34,15): error TS4114: This member must have an 'override' modifier because it overrides a member in the base class 'FileSystem'.
node_modules/.pnpm/@zenfs+core@0.12.5/node_modules/@zenfs/core/src/backends/store/fs.ts(53,9): error TS4114: This member must have an 'override' modifier because it overrides a member in the base class 'FileSystem'.
node_modules/.pnpm/@zenfs+core@0.12.5/node_modules/@zenfs/core/src/backends/store/fs.ts(98,9): error TS2322: Type 'bigint | undefined' is not assignable to type 'bigint'.
  Type 'undefined' is not assignable to type 'bigint'.
node_modules/.pnpm/@zenfs+core@0.12.5/node_modules/@zenfs/core/src/backends/store/fs.ts(123,48): error TS2345: Argument of type 'bigint | undefined' is not assignable to parameter of type 'bigint'.
  Type 'undefined' is not assignable to type 'bigint'.
node_modules/.pnpm/@zenfs+core@0.12.5/node_modules/@zenfs/core/src/backends/store/fs.ts(127,22): error TS2345: Argument of type 'bigint | undefined' is not assignable to parameter of type 'bigint'.
  Type 'undefined' is not assignable to type 'bigint'.
node_modules/.pnpm/@zenfs+core@0.12.5/node_modules/@zenfs/core/src/backends/store/fs.ts(167,9): error TS2322: Type 'bigint | undefined' is not assignable to type 'bigint'.
  Type 'undefined' is not assignable to type 'bigint'.
node_modules/.pnpm/@zenfs+core@0.12.5/node_modules/@zenfs/core/src/backends/store/fs.ts(192,46): error TS2345: Argument of type 'bigint | undefined' is not assignable to parameter of type 'bigint'.
  Type 'undefined' is not assignable to type 'bigint'.
node_modules/.pnpm/@zenfs+core@0.12.5/node_modules/@zenfs/core/src/backends/store/fs.ts(196,20): error TS2345: Argument of type 'bigint | undefined' is not assignable to parameter of type 'bigint'.
  Type 'undefined' is not assignable to type 'bigint'.
node_modules/.pnpm/@zenfs+core@0.12.5/node_modules/@zenfs/core/src/backends/store/fs.ts(513,3): error TS2322: Type 'bigint | undefined' is not assignable to type 'bigint'.
  Type 'undefined' is not assignable to type 'bigint'.
node_modules/.pnpm/@zenfs+core@0.12.5/node_modules/@zenfs/core/src/backends/store/fs.ts(542,3): error TS2322: Type 'bigint | undefined' is not assignable to type 'bigint'.
  Type 'undefined' is not assignable to type 'bigint'.
node_modules/.pnpm/@zenfs+core@0.12.5/node_modules/@zenfs/core/src/backends/store/fs.ts(795,44): error TS2345: Argument of type 'bigint | undefined' is not assignable to parameter of type 'bigint'.
  Type 'undefined' is not assignable to type 'bigint'.
node_modules/.pnpm/@zenfs+core@0.12.5/node_modules/@zenfs/core/src/backends/store/fs.ts(818,21): error TS2345: Argument of type 'bigint | undefined' is not assignable to parameter of type 'bigint'.
  Type 'undefined' is not assignable to type 'bigint'.
node_modules/.pnpm/@zenfs+core@0.12.5/node_modules/@zenfs/core/src/backends/store/fs.ts(841,4): error TS2322: Type 'bigint | undefined' is not assignable to type 'bigint'.
  Type 'undefined' is not assignable to type 'bigint'.
node_modules/.pnpm/@zenfs+core@0.12.5/node_modules/@zenfs/core/src/emulation/async.ts(651,8): error TS6133: 'mode' is declared but its value is never read.
node_modules/.pnpm/@zenfs+core@0.12.5/node_modules/@zenfs/core/src/emulation/dir.ts(9,14): error TS2720: Class 'import("/home/ubuntu/zenfs-demo/node_modules/.pnpm/@zenfs+core@0.12.5/node_modules/@zenfs/core/src/emulation/dir").Dirent' incorrectly implements class 'import("fs").Dirent'. Did you mean to extend 'import("fs").Dirent' and inherit its members as a subclass?
  Property 'parentPath' is missing in type 'import("/home/ubuntu/zenfs-demo/node_modules/.pnpm/@zenfs+core@0.12.5/node_modules/@zenfs/core/src/emulation/dir").Dirent' but required in type 'import("fs").Dirent'.
node_modules/.pnpm/@zenfs+core@0.12.5/node_modules/@zenfs/core/src/emulation/dir.ts(95,2): error TS2416: Property 'read' in type 'Dir' is not assignable to the same property in base type 'Dir'.
  Type '{ (): Promise<Dirent | null>; (cb: Callback<[Dirent | null]>): void; }' is not assignable to type '{ (): Promise<Dirent | null>; (cb: (err: ErrnoException | null, dirEnt: Dirent | null) => void): void; }'.
node_modules/.pnpm/@zenfs+core@0.12.5/node_modules/@zenfs/core/src/emulation/dir.ts(96,2): error TS2416: Property 'read' in type 'Dir' is not assignable to the same property in base type 'Dir'.
  Type '{ (): Promise<Dirent | null>; (cb: Callback<[Dirent | null]>): void; }' is not assignable to type '{ (): Promise<Dirent | null>; (cb: (err: ErrnoException | null, dirEnt: Dirent | null) => void): void; }'.
node_modules/.pnpm/@zenfs+core@0.12.5/node_modules/@zenfs/core/src/emulation/dir.ts(97,2): error TS2416: Property 'read' in type 'Dir' is not assignable to the same property in base type 'Dir'.
  Type '{ (): Promise<Dirent | null>; (cb: Callback<[Dirent | null]>): void; }' is not assignable to type '{ (): Promise<Dirent | null>; (cb: (err: ErrnoException | null, dirEnt: Dirent | null) => void): void; }'.
node_modules/.pnpm/@zenfs+core@0.12.5/node_modules/@zenfs/core/src/emulation/dir.ts(110,2): error TS2416: Property 'readSync' in type 'Dir' is not assignable to the same property in base type 'Dir'.
  Type '() => import("/home/ubuntu/zenfs-demo/node_modules/.pnpm/@zenfs+core@0.12.5/node_modules/@zenfs/core/src/emulation/dir").Dirent | null' is not assignable to type '() => import("fs").Dirent | null'.
    Type 'import("/home/ubuntu/zenfs-demo/node_modules/.pnpm/@zenfs+core@0.12.5/node_modules/@zenfs/core/src/emulation/dir").Dirent | null' is not assignable to type 'import("fs").Dirent | null'.
node_modules/.pnpm/@zenfs+core@0.12.5/node_modules/@zenfs/core/src/emulation/dir.ts(123,2): error TS2416: Property '[Symbol.asyncIterator]' in type 'Dir' is not assignable to the same property in base type 'Dir'.
  Type '() => AsyncIterableIterator<import("/home/ubuntu/zenfs-demo/node_modules/.pnpm/@zenfs+core@0.12.5/node_modules/@zenfs/core/src/emulation/dir").Dirent>' is not assignable to type '() => AsyncIterableIterator<import("fs").Dirent>'.
    Type 'AsyncIterableIterator<import("/home/ubuntu/zenfs-demo/node_modules/.pnpm/@zenfs+core@0.12.5/node_modules/@zenfs/core/src/emulation/dir").Dirent>' is not assignable to type 'AsyncIterableIterator<import("fs").Dirent>'.
      Type 'import("/home/ubuntu/zenfs-demo/node_modules/.pnpm/@zenfs+core@0.12.5/node_modules/@zenfs/core/src/emulation/dir").Dirent' is not assignable to type 'import("fs").Dirent'.
node_modules/.pnpm/@zenfs+core@0.12.5/node_modules/@zenfs/core/src/emulation/path.ts(59,4): error TS2322: Type 'string | undefined' is not assignable to type 'string'.
  Type 'undefined' is not assignable to type 'string'.
node_modules/.pnpm/@zenfs+core@0.12.5/node_modules/@zenfs/core/src/emulation/promises.ts(711,9): error TS1360: Type '{ (path: PathLike, options?: BufferEncoding | (ObjectEncodingOptions & { withFileTypes?: false | undefined; recursive?: boolean | undefined; }) | null | undefined): Promise<...>; (path: PathLike, options: BufferEncodingOption & { ...; }): Promise<...>; (path: PathLike, options?: BufferEncoding | ... 2 more ... | und...' does not satisfy the expected type '{ (path: PathLike, options?: BufferEncoding | (ObjectEncodingOptions & { withFileTypes?: false | undefined; recursive?: boolean | undefined; }) | null | undefined): Promise<...>; (path: PathLike, options: "buffer" | { ...; }): Promise<...>; (path: PathLike, options?: BufferEncoding | ... 2 more ... | undefined): Pro...'.
  Types of parameters 'options' and 'options' are incompatible.
    Type 'ObjectEncodingOptions & { withFileTypes: true; recursive?: boolean | undefined; }' is not assignable to type 'BufferEncoding | (ObjectEncodingOptions & { withFileTypes?: false | undefined; recursive?: boolean | undefined; }) | null | undefined'.
      Type 'ObjectEncodingOptions & { withFileTypes: true; recursive?: boolean | undefined; }' is not assignable to type 'ObjectEncodingOptions & { withFileTypes?: false | undefined; recursive?: boolean | undefined; }'.
        Type 'ObjectEncodingOptions & { withFileTypes: true; recursive?: boolean | undefined; }' is not assignable to type '{ withFileTypes?: false | undefined; recursive?: boolean | undefined; }'.
          Types of property 'withFileTypes' are incompatible.
            Type 'true' is not assignable to type 'false'.
node_modules/.pnpm/@zenfs+core@0.12.5/node_modules/@zenfs/core/src/emulation/promises.ts(999,9): error TS1360: Type '(path: import("fs").PathLike, options?: import("fs").OpenDirOptions | undefined) => Promise<import("/home/ubuntu/zenfs-demo/node_modules/.pnpm/@zenfs+core@0.12.5/node_modules/@zenfs/core/src/emulation/dir").Dir>' does not satisfy the expected type '(path: import("fs").PathLike, options?: import("fs").OpenDirOptions | undefined) => Promise<import("fs").Dir>'.
  Type 'Promise<import("/home/ubuntu/zenfs-demo/node_modules/.pnpm/@zenfs+core@0.12.5/node_modules/@zenfs/core/src/emulation/dir").Dir>' is not assignable to type 'Promise<import("fs").Dir>'.
    Type 'import("/home/ubuntu/zenfs-demo/node_modules/.pnpm/@zenfs+core@0.12.5/node_modules/@zenfs/core/src/emulation/dir").Dir' is not assignable to type 'import("fs").Dir'.
      The types returned by 'read()' are incompatible between these types.
        Type 'Promise<import("/home/ubuntu/zenfs-demo/node_modules/.pnpm/@zenfs+core@0.12.5/node_modules/@zenfs/core/src/emulation/dir").Dirent | null>' is not assignable to type 'Promise<import("fs").Dirent | null>'.
          Type 'import("/home/ubuntu/zenfs-demo/node_modules/.pnpm/@zenfs+core@0.12.5/node_modules/@zenfs/core/src/emulation/dir").Dirent | null' is not assignable to type 'import("fs").Dirent | null'.
            Property 'parentPath' is missing in type 'import("/home/ubuntu/zenfs-demo/node_modules/.pnpm/@zenfs+core@0.12.5/node_modules/@zenfs/core/src/emulation/dir").Dirent' but required in type 'import("fs").Dirent'.
node_modules/.pnpm/@zenfs+core@0.12.5/node_modules/@zenfs/core/src/emulation/sync.ts(485,8): error TS6133: 'recursive' is declared but its value is never read.
node_modules/.pnpm/@zenfs+core@0.12.5/node_modules/@zenfs/core/src/emulation/sync.ts(539,13): error TS1360: Type '{ (path: PathLike, options?: BufferEncoding | { recursive?: boolean | undefined; encoding?: BufferEncoding | null | undefined; withFileTypes?: false | undefined; } | null | undefined): string[]; (path: PathLike, options: "buffer" | { ...; }): Buffer[]; (path: PathLike, options: { ...; }): Dirent[]; (path: PathLike, ...' does not satisfy the expected type '{ (path: PathLike, options?: BufferEncoding | { encoding: BufferEncoding | null; withFileTypes?: false | undefined; recursive?: boolean | undefined; } | null | undefined): string[]; (path: PathLike, options: "buffer" | { ...; }): Buffer[]; (path: PathLike, options?: BufferEncoding | ... 2 more ... | undefined): stri...'.
  Types of parameters 'options' and 'options' are incompatible.
    Type 'ObjectEncodingOptions & { withFileTypes: true; recursive?: boolean | undefined; }' is not assignable to type 'BufferEncoding | { recursive?: boolean | undefined; encoding?: BufferEncoding | null | undefined; withFileTypes?: false | undefined; } | null | undefined'.
      Type 'ObjectEncodingOptions & { withFileTypes: true; recursive?: boolean | undefined; }' is not assignable to type '{ recursive?: boolean | undefined; encoding?: BufferEncoding | null | undefined; withFileTypes?: false | undefined; }'.
        Types of property 'withFileTypes' are incompatible.
          Type 'true' is not assignable to type 'false'.
node_modules/.pnpm/@zenfs+core@0.12.5/node_modules/@zenfs/core/src/emulation/sync.ts(835,13): error TS1360: Type '(path: import("fs").PathLike, options?: import("fs").OpenDirOptions | undefined) => import("/home/ubuntu/zenfs-demo/node_modules/.pnpm/@zenfs+core@0.12.5/node_modules/@zenfs/core/src/emulation/dir").Dir' does not satisfy the expected type '(path: import("fs").PathLike, options?: import("fs").OpenDirOptions | undefined) => import("fs").Dir'.
  Type 'import("/home/ubuntu/zenfs-demo/node_modules/.pnpm/@zenfs+core@0.12.5/node_modules/@zenfs/core/src/emulation/dir").Dir' is not assignable to type 'import("fs").Dir'.
node_modules/.pnpm/@zenfs+core@0.12.5/node_modules/@zenfs/core/src/error.ts(289,9): error TS4114: This member must have an 'override' modifier because it overrides a member in the base class 'Error'.
node_modules/.pnpm/@zenfs+core@0.12.5/node_modules/@zenfs/core/src/file.ts(675,15): error TS4114: This member must have an 'override' modifier because it overrides a member in the base class 'PreloadFile<T>'.
node_modules/.pnpm/@zenfs+core@0.12.5/node_modules/@zenfs/core/src/file.ts(681,9): error TS4114: This member must have an 'override' modifier because it overrides a member in the base class 'PreloadFile<T>'.
node_modules/.pnpm/@zenfs+core@0.12.5/node_modules/@zenfs/core/src/file.ts(687,15): error TS4114: This member must have an 'override' modifier because it overrides a member in the base class 'PreloadFile<T>'.
node_modules/.pnpm/@zenfs+core@0.12.5/node_modules/@zenfs/core/src/file.ts(693,9): error TS4114: This member must have an 'override' modifier because it overrides a member in the base class 'PreloadFile<T>'.
node_modules/.pnpm/@zenfs+core@0.12.5/node_modules/@zenfs/core/src/filesystem.ts(247,16): error TS4114: This member must have an 'override' modifier because it overrides a member in the base class 'FileSystem'.
node_modules/.pnpm/@zenfs+core@0.12.5/node_modules/@zenfs/core/src/filesystem.ts(369,16): error TS4114: This member must have an 'override' modifier because it overrides a member in the base class 'FileSystem'.
node_modules/.pnpm/@zenfs+core@0.12.5/node_modules/@zenfs/core/src/filesystem.ts(387,10): error TS4114: This member must have an 'override' modifier because it overrides a member in the base class 'FileSystem'.
node_modules/.pnpm/@zenfs+core@0.12.5/node_modules/@zenfs/core/src/filesystem.ts(465,10): error TS4114: This member must have an 'override' modifier because it overrides a member in the base class 'FileSystem'.
node_modules/.pnpm/@zenfs+core@0.12.5/node_modules/@zenfs/core/src/filesystem.ts(552,10): error TS4114: This member must have an 'override' modifier because it overrides a member in the base class 'FileSystem'.
node_modules/.pnpm/@zenfs+core@0.12.5/node_modules/@zenfs/core/src/utils.ts(89,14): error TS2345: Argument of type 'number | undefined' is not assignable to parameter of type 'number'.
  Type 'undefined' is not assignable to type 'number'.
node_modules/.pnpm/@zenfs+core@0.12.5/node_modules/@zenfs/core/src/utils.ts(90,31): error TS2345: Argument of type 'number | undefined' is not assignable to parameter of type 'number'.
  Type 'undefined' is not assignable to type 'number'.
node_modules/.pnpm/@zenfs+core@0.12.5/node_modules/@zenfs/core/src/utils.ts(91,31): error TS2345: Argument of type 'number | undefined' is not assignable to parameter of type 'number'.
  Type 'undefined' is not assignable to type 'number'.
node_modules/.pnpm/@zenfs+core@0.12.5/node_modules/@zenfs/core/src/utils.ts(92,31): error TS2345: Argument of type 'number | undefined' is not assignable to parameter of type 'number'.
  Type 'undefined' is not assignable to type 'number'.
node_modules/.pnpm/@zenfs+core@0.12.5/node_modules/@zenfs/core/src/utils.ts(97,4): error TS2322: Type 'number | undefined' is not assignable to type 'number'.
  Type 'undefined' is not assignable to type 'number'.
node_modules/.pnpm/@zenfs+core@0.12.5/node_modules/@zenfs/core/src/utils.ts(107,21): error TS18048: 'dy' is possibly 'undefined'.
node_modules/.pnpm/@zenfs+core@0.12.5/node_modules/@zenfs/core/src/utils.ts(107,43): error TS18048: 'dy' is possibly 'undefined'.
node_modules/.pnpm/@zenfs+core@0.12.5/node_modules/@zenfs/core/src/utils.ts(107,62): error TS18048: 'dy' is possibly 'undefined'.
node_modules/.pnpm/@zenfs+core@0.12.5/node_modules/@zenfs/core/src/utils.ts(108,4): error TS2322: Type 'number | undefined' is not assignable to type 'number'.
  Type 'undefined' is not assignable to type 'number'.

Potential solution

@zenfs/core package should publish only .js and .d.ts files, not the original TypeScript source code, so that the ZenFS TypeScript source code would not be typechecked in downstream projects.
microsoft/TypeScript#47387 (comment)

yoursunny added a commit to yoursunny/zenfs-core that referenced this issue May 25, 2024
yoursunny added a commit to yoursunny/zenfs-core that referenced this issue May 26, 2024
@james-pre james-pre added the bug Something isn't working label May 29, 2024
@james-pre james-pre added this to the 1.0 milestone May 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants