I have been playing around with PCF Controls in Dynamics 365 and have some tips for anyone wanting to dive in and give it a go. There are some great resources online which really helped which I have linked below.
While following the instructions in the guide, I ran into some strange errors when working with parameters.
Type ‘string | null’ is not assignable to type ‘string’. Type ‘null’ is not assignable to type ‘string’.
The fix for this is to make sure you have a default value for the value you’re trying to get. In this case, I had to default to empty string.
The following methods could be confusing as one is often called but not well documented (notifyOutputChanged) and the other appears to be never called (getOutputs).
In the getOutputs method you should be looking to set any of the bound fields from your ControlManifest. As shown below. When you call the notifyOutputChanged method it will call the getOutputs method and set any of the bound values you have set in there.
I hope this helps you if you are looking for reasons you are getting errors in your PCF control.