Compiler error on extension method

Topics: Language Specification
Nov 5, 2012 at 9:15 AM
Edited Nov 5, 2012 at 9:17 AM

I'm trying to create an extension method for class but seems somethig is wrong. Below is the code, the output JS-file is correct but the compiler twice times shows an error "test.ts(10,16): The property 'close' does not exist on value of type 'Test'"

What should be corrected ? The code is compiled ok with built-in types. I need to extend my own classes.

class Test {
interface Test
Test.prototype.close  = function() {}
var t = new Test();


Nov 5, 2012 at 4:40 PM

We currently don't support mixins/extension methods directly, though we would like some kind of support for this in the future.  

You can fake them up now by mixing together interfaces instead of using classes.  There's some discussion about ways to do this here: