Skip to content

Instantly share code, notes, and snippets.

@omochi omochi/Vector2.ts
Last active Aug 29, 2015

Embed
What would you like to do?
// 実行方法
// $ tsc --module commonjs *.ts
// $ node entry.js
import Vector2 = require("./Vector2");
import Vector3 = require("./Vector3");
var a = new Vector2(0, 0);
console.log(a.toVector3(1));
var b = new Vector3(0, 0, 1);
console.log(b.toVector2());
{ x: 0, y: 0, z: 1 }
/Users/omochi/temp/test5/Vector3.js:9
return new Vector2(this.x, this.y);
^
TypeError: object is not a function
at Vector3.toVector2 (/Users/omochi/temp/test5/Vector3.js:9:16)
at Object.<anonymous> (/Users/omochi/temp/test5/entry.js:8:15)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Function.Module.runMain (module.js:497:10)
at startup (node.js:119:16)
at node.js:906:3
import Vector3 = require("./Vector3");
class Vector2 {
constructor(public x: number, public y: number){
}
toVector3(z: number): Vector3{
return new Vector3(this.x, this.y, z);
}
}
export = Vector2;
import Vector2 = require("./Vector2");
class Vector3 {
constructor(public x: number, public y: number, public z: number){
}
toVector2(): Vector2 {
return new Vector2(this.x, this.y);
}
}
export = Vector3;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.