Ian Boyd
Ian Boyd

Reputation: 257047

How to reference a class in another TypeScript file?

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

Upvotes: 8

Views: 16620

Answers (1)

Fenton
Fenton

Reputation: 251242

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();
};

Upvotes: 13

Related Questions