rniemeyer / knockout-postbox

A small library that uses Knockout's native pub/sub capabilities to facilitate decoupled communication between separate view models or components.
MIT License
350 stars 55 forks source link

KO 3.5 #46

Open danparm opened 3 years ago

danparm commented 3 years ago

Looks like with the change to internal types with KO 3.5 there's now a conflict with KO Postbox requiring the external KO types. I'll do some more investigating but seeing as this project hasn't had an update in 4 years I will likely look for another solution.

rniemeyer commented 3 years ago

@danparm - I am happy to make an update, if we can figure out the issue. I’ll try to run it with 3.5 when I have a chance here. Do you get an error or how is the best way to see the problem? Thanks!

danparm commented 3 years ago

@rniemeyer I’ll try running 3.5 again locally. It’s really a two headed problem for me at the moment. I’m having to update the KO types in my source files since the names changed with the internal typing move. Will report back

danparm commented 3 years ago

One of the errors occurs when accessing postbox on the KO object: ko.postbox.publish(...); for example (TS) Property 'postbox' does not exist on type 'typeof import("/node_modules/knockout/build/types/knockout")

Then there's the issue of the interface properties. publishOn() for example throws a TS error because it doesn't exist on Observable (as an example)

I'm no Typescript guru but would a change to the interface names in the postbox types likely solve the problem?

danparm commented 3 years ago

I may have something but need to step away for a minute. Extending the KO types with the postbox types seemed to work for part of the issue.

danparm commented 3 years ago

Alright, probably didn't have to rename the interfaces but extending the internal KO types I was able to clear all the errors in one TS file (also after updating the KO types in that file to work with the new names). image

image

Just need to work on cleaning this up: image

danparm commented 3 years ago

Hit a wall with this though: image

This is where I'm running out of Typescript skills.

Updated my (postbox as KnockoutPostBox) to and export const pb: KnockoutPostBox in the postbox types.

Of course all of this is untested because I can't build my JS.