You need to ensure the node type is the one with not readonly opacity so TypeScript doesn’t give you a warning. You can filter selection to include only the node types your plugin accepts.
This problem occurs even with a simple RectangleNode that should allow setting opacity.