-
Notifications
You must be signed in to change notification settings - Fork 12
Closed
Description
I migrated my application to use the new dav module introduced in v3.10, but ran into a problem:
dist/dav.d.ts contains a redeclaration of the Node_2 class, which is a verbatim copy of the Node_2 class from the main module. Some functions, like resultToNode(), return an instance of the class from the dav module. This causes Problems with code that expects a Node or INode from the main module:
error TS2345: Argument of type 'Node_2' is not assignable to parameter of type 'INode'.
The types returned by 'clone()' are incompatible between these types.
Type 'Node_2' is not assignable to type 'import("<project_path>/node_modules/@nextcloud/files/dist/index").Node'.
Types have separate declarations of a private property '_data'.
As said, the declarations are 100% identical, but Typescript sees them as different types. There are some ugly workarounds:
- Explicit cast:
resultToNode() as unknown as INode(the intermediate cast tounknownis required to work around the perceived type incompatibility) - Change consuming code to allow a
Node_2from thedavmodule, but that looks more like an internal class name.
The redeclaration looks accidental to me. Should't there be only the Node_2 class from the main module?
Pseudocode to reproduce:
import { INode } from '@nextcloud/files'
import { resultToNode } from '@nextcloud/files/dav'
function test(node: INode) // same problem with Node
{
return node
}
const node = resultToNode(...)
test(node) // results in above errorReactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels