@types/xxxx package and had problems.Definitions by: in index.d.ts) so they can respond.The types for fs-extra reference some members from @types/node directly that are only present in Node 12+. This causes compilation to fail when combined with @types/node@10, which should work because fs-extra supports Node 10. The problem is that since fs-extra re-exports members from the native fs, those have been copied into @types/fs-extra. I believe it would be better to not do that manually and instead if possible re-export typeof import('fs') so that it picks up whatever is in the environment. Unfortunately I don't have time to work on this myself.
node_modules/@types/fs-extra/index.d.ts:188:87 - error TS2694: Namespace '"fs"' has no exported member 'Dir'.
188 export function opendir(path: string, cb: (err: NodeJS.ErrnoException | null, dir: fs.Dir) => void): void;
~~~
node_modules/@types/fs-extra/index.d.ts:191:17 - error TS2694: Namespace '"fs"' has no exported member 'OpenDirOptions'.
191 options: fs.OpenDirOptions,
~~~~~~~~~~~~~~
node_modules/@types/fs-extra/index.d.ts:192:53 - error TS2694: Namespace '"fs"' has no exported member 'Dir'.
192 cb: (err: NodeJS.ErrnoException | null, dir: fs.Dir) => void,
~~~
node_modules/@types/fs-extra/index.d.ts:194:52 - error TS2694: Namespace '"fs"' has no exported member 'OpenDirOptions'.
194 export function opendir(path: string, options?: fs.OpenDirOptions): Promise<fs.Dir>;
~~~~~~~~~~~~~~
node_modules/@types/fs-extra/index.d.ts:194:80 - error TS2694: Namespace '"fs"' has no exported member 'Dir'.
194 export function opendir(path: string, options?: fs.OpenDirOptions): Promise<fs.Dir>;
~~~
node_modules/@types/fs-extra/index.d.ts:265:52 - error TS2694: Namespace 'NodeJS' has no exported member 'ArrayBufferView'.
265 export function writev(fd: number, buffers: NodeJS.ArrayBufferView[], position: number, cb: (err: NodeJS.ErrnoException | null, bytesWritten: number, buffers: NodeJS.ArrayBufferView[]) => void): void;
~~~~~~~~~~~~~~~
node_modules/@types/fs-extra/index.d.ts:265:167 - error TS2694: Namespace 'NodeJS' has no exported member 'ArrayBufferView'.
265 export function writev(fd: number, buffers: NodeJS.ArrayBufferView[], position: number, cb: (err: NodeJS.ErrnoException | null, bytesWritten: number, buffers: NodeJS.ArrayBufferView[]) => void): void;
~~~~~~~~~~~~~~~
node_modules/@types/fs-extra/index.d.ts:266:52 - error TS2694: Namespace 'NodeJS' has no exported member 'ArrayBufferView'.
266 export function writev(fd: number, buffers: NodeJS.ArrayBufferView[], cb: (err: NodeJS.ErrnoException | null, bytesWritten: number, buffers: NodeJS.ArrayBufferView[]) => void): void;
~~~~~~~~~~~~~~~
node_modules/@types/fs-extra/index.d.ts:266:149 - error TS2694: Namespace 'NodeJS' has no exported member 'ArrayBufferView'.
266 export function writev(fd: number, buffers: NodeJS.ArrayBufferView[], cb: (err: NodeJS.ErrnoException | null, bytesWritten: number, buffers: NodeJS.ArrayBufferView[]) => void): void;
~~~~~~~~~~~~~~~
node_modules/@types/fs-extra/index.d.ts:267:52 - error TS2694: Namespace 'NodeJS' has no exported member 'ArrayBufferView'.
267 export function writev(fd: number, buffers: NodeJS.ArrayBufferView[], position?: number): Promise<WritevResult>;
~~~~~~~~~~~~~~~
@frangio
The types for
fs-extrareference some members from@types/nodedirectly that are only present in Node 12+.
Which members are that? Can you post an error message or something like that?
I forgot to specify, I'm sorry. I've edited the original post with the error messages.
Same issue here.
@peterblazejewicz can you take a look?
@frangio I can reproduce the error. Unfortunately I don't have a solution for that beside upgrading @types/node to 14.x or downgrading @types/fs-extra to 8.1.0.
We are already exporting * from 'fs', but since fs-extra adds a promisified version of opendir() and writev(), these need to be reflected in the types. Since there is no conditional types export yet AFAIK, there is not much we can do in my opinion.
The "forward declarations" feature in TypeScript's 4.0 roadmap may be of use here.
Alternatively, I've built a package which is similar to fs-extra in that it re-exports promisified Node.js functions and solves the issue using mapped types. The same approach could be used here, but it would increase the complexity of the type definitions.
@peterblazejewicz can you take a look?
Yes, sorry for delay. I can see the problem, not sure myself how to properly manage different iterations of node versions and types
For some reason if I npm install @types/node the package manager install a v10.10 version of node??? That's odd. So I forced npm to install the latest version of @types/[email protected] and that seemed to fix it
Most helpful comment
@frangio I can reproduce the error. Unfortunately I don't have a solution for that beside upgrading
@types/nodeto 14.x or downgrading@types/fs-extrato 8.1.0.We are already exporting
* from 'fs', but since fs-extra adds a promisified version ofopendir()andwritev(), these need to be reflected in the types. Since there is no conditional types export yet AFAIK, there is not much we can do in my opinion.