Closed OracPrime closed 3 years ago
You shouldn't have to add the ! operator. Take a look at a typescript example here: https://github.com/dsuryd/dotNetify/tree/master/Demo/React/HelloWorld.WebPack
If you enable "strictNullChecks": true,
in your tsconfig.json then you get
[tsl] ERROR in C:\github\dotNetify\Demo\React\HelloWorld.WebPack\src\HelloWorld.tsx(14,5) TS2532: Object is possibly 'undefined'.
I suspect increasing numbers of typescript devs will want strictNullChecks.
Thanks. I'll put in the backlog for supporting the strictNullChecks
flag in future release.
I was struggling to understand (from my massively distant understanding of your code) why dotnetify.connect couldn't/didn't work. Surely the codebase knows which flavour it is running?
The intent for dotnetify.connect
is to support other frameworks that are not explicitly supported (for example, Angular). But you may be right, there's a problem with the code. It could've been broken after Typescript conversion. So thanks again for pointing out these issues. Keep'em coming :)
Should be resolved with v4.1.1.
Excellent, thank you. I can confirm that 4.1.1 allows me to write the code I expected
I have a react component class using dotnetify. To avoid getting too far behind, I've upgraded dotnetify to 4.1, and typescript has started complaining. My component has a vm member, which I have changed to IDotnetifyVM from the old dotnetifyVM; this is fine. However when I try to initialise it with
this.vm = dotnetify.react.connect('vmname',this)
then I get a warning that react may be undefined and need to use
this.vm = dotnetify.react!.connect('vmname',this)
instead. This seems to be a messy workaround (although clearly not the end of the world). Is there a preferred way of doing it? I had a guess at
this.vm = dotnetify.connect('vmname',this)
but that fails to hook up the events.What's the "preferred" way of doing this now in a typescript world?