-
Notifications
You must be signed in to change notification settings - Fork 12
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
Redeclaration of Node_2 class causes type incompatibilty #1127
Comments
AH! I encountered the EXACT issue yesterday, couldn't fid the time to investigate :) |
Guessing this is coming from #1118 ? 🤔 |
Sorry, this is beyond my skills... I think the problem comes from the way the types are imported in the dav code: import type { Node } from '../files/node' This seems to make the type part of the dav module, thus ending up replicated in import { Node } from '@nextcloud/files' Imports are generated only for references to external packages. I don't know how to do that for code from the same package, but that looks to me like a common task for developing library code. It's not only the |
Hey! Can you try with this instead? import type { Node } from '@nextcloud/files'
import { resultToNode } from '@nextcloud/files/dav'
function test(node: Node) {
return node
}
const node = resultToNode(...)
test(node) |
Still does not work for me. I have no experience in testing local libraries. Anything wrong with these steps? cd $HOME
git clone https://github.com/nextcloud-libraries/nextcloud-files.git
cd nextcloud-files
git checkout fix/imports
npm run build
cd $HOME/my-project
npm install --no-save $HOME/nextcloud-files/ Creating your test code in my project directory, and passing some compatible argument to resultToNode(), still gives this TS error:
As you can see from the message, the module is correctly loaded from the local path. My real code also gives the same error as before. |
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 theNode_2
class, which is a verbatim copy of theNode_2
class from the main module. Some functions, likeresultToNode()
, return an instance of the class from thedav
module. This causes Problems with code that expects aNode
orINode
from the main module:As said, the declarations are 100% identical, but Typescript sees them as different types. There are some ugly workarounds:
resultToNode() as unknown as INode
(the intermediate cast tounknown
is required to work around the perceived type incompatibility)Node_2
from thedav
module, 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:
The text was updated successfully, but these errors were encountered: