nextcloud-libraries / nextcloud-libraries/nextcloud-typings
[RFC] Modernize package
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 7
- Forks
- 2
- Avg merge
- 2m
- Merged PRs (30d)
- 5
Description
Problems:
- Namespaces are considered a legacy feature and its recommended to use ES modules instead
- Similar are Triple-Slash directives which we use to register the types
- Our current approach does not really allow to type event-bus events or app capabilities
To register types like for eventbus or capabilities we would need to add them to @types which is not likely a viable way. I also tested using different type roots configuration which also does not work as intended.
So I think the proper way nowadays would be to export the types directly as types and let the app declare them where needed.
Meaning we could e.g. have exports like:
import type { globals, OCP, OC } from '@nextcloud/typings'
// or if for a specific version:
import type { NextcloudGlobals, OCP, OC } from '@nextcloud/typings/v20'
which you then use in an app like this:
// in 'src/globals.d.ts'
import type { NextcloudGlobals, OCP } from '@nextcloud/typings/v20'
declare global {
interface Window extends NextcloudGlobals {
OCP
}
}
you could also type server events the same way:
// in 'src/eventbus.d.ts'
import type { CoreEvents } from '@nextcloud/typings/v31'
declare module '@nextcloud/event-bus' {
export interface NextcloudEvents extends CoreEvents { }
}
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Review the current namespace and triple-slash declaration structure in @nextcloud/typings, then compare it with the proposed versioned imports such as @nextcloud/typings/v20. Check the globals.d.ts and eventbus.d.ts augmentation examples; done means types can be imported directly and extended for globals and CoreEvents without the current registration approach.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- developer-experience
- Issue type
- Refactor
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100