For Stealth Rock, it is weakness-reliant, but it is not immunity-reliant. The way it is currently handled is:
onSwitchIn: function (pokemon) {
let typeMod = this.clampIntRange(pokemon.runEffectiveness('Rock'), -6, 6);
this.damage(pokemon.maxhp * Math.pow(2, typeMod) / 8);
}...