Help converting C# to Unityscript

I have been following the tutorial at noobtuts - Unity 2D Pong Game to make a quick pong game. Instead of writing it in C# i have been converting it to javascript (unityscript) as i read/write the code. I am having trouble translating part of the code to unityscript. Hoping someone can help me.

void OnCollisionEnter2D(Collision2D col) {
    // Hit the left Racket?
    if (col.gameObject.name == "RacketLeft") {
        // Calculate hit Factor
        float y=hitFactor(transform.position,
                          col.transform.position,
                          ((BoxCollider2D)col.collider).size.y);

        // Calculate direction, set length to 1
        Vector2 dir = new Vector2(1, y).normalized;

        // Set Velocity with dir * speed
        rigidbody2D.velocity = dir * speed;
    }

    // Hit the right Racket?
    if (col.gameObject.name == "RacketRight") {
        // Calculate hit Factor
        float y=hitFactor(transform.position,
                          col.transform.position,
                          ((BoxCollider2D)col.collider).size.y);

        // Calculate direction, set length to 1
        Vector2 dir = new Vector2(-1, y).normalized;
        
        // Set Velocity with dir * speed
        rigidbody2D.velocity = dir * speed;
    }
}

What i have.

#pragma strict

var speed : float = 2;
private var y : float;
private var dir : Vector2;
function Start () {
	rigidbody2D.velocity = Vector2.one.normalized * speed;
}
function hitFactor(ballPos : Vector2, racketPos: Vector2, racketHeight : float) : float{
	return (ballPos.y - racketPos.y) / racketHeight;
}
function OnCollisionEnter2D(coll: Collision2D) {
	if(coll.gameObject.name == "RacketLeft") {
		y = hitFactor(transform.position, coll.transform.position, 0.64);
		dir = Vector2(1, y).normalized;
		rigidbody2D.velocity = dir * speed;
	}
	
	if(coll.gameObject.name == "RacketRight") {
		y = hitFactor(transform.position, coll.transform.position, 0.64);
		dir = Vector2(-1, y).normalized;
		rigidbody2D.velocity = dir * speed;
	}
}

I tried hard coding the paddle height but the ball seems to move funny after that. The real issue is what does ((Boxcollider2D)col.collider).size.y) convert to in Unityscript

Generic answer for ‘help me convert this script’

Several methods work. In preferred order

  1. Understand what the script does in the first place, and why it works. Then write it from scratch in the new language
  2. Use the documentation. There is a button that lets you pick between syntax and examples in JavaScript and C#
  3. Use your awesome googling skills that found you this script in the first place to find and download a script in the correct language. Cut and paste into your project.
  4. Post your code on Unity Answers.

The key difference between the two languages is syntax. Typing is important as well, depending on how lazy your original JavaScript writer was. All the methods work exactly the same.

Incidentally casting in UnityScript is done using the ‘as’ keyword. Try

(col.collider as Boxcollider2D).size.y;