Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to reference a class in another TypeScript file?

Tags:

typescript

How do i get access to classes in another .ts file in TypeScript?

e.g.

app.ts

window.onload = () => {
   /// <reference path="TilingEngine/SofRenderer.ts" >
   var drawingTool = new SofRenderer();
};

TilingEngine/SofRenderer.ts

class SofRenderer {
}

Fails to compile, with the error:

Could not find symbol 'SofRenderer'.

See also

  • How can I import an external file with TypeScript? (i'm not using node)
  • How do I import other TypeScript files? (i'm not using modules)
like image 605
Ian Boyd Avatar asked Jun 21 '13 18:06

Ian Boyd


1 Answers

Your reference comment should be at the top of your file and be self-closing. Like this:

///<reference path="TilingEngine/SofRenderer.ts" />
window.onload = () => {
   var drawingTool = new SofRenderer();
};
like image 91
Fenton Avatar answered Oct 21 '22 18:10

Fenton