How to override/hide methods with optional parameters

Topics: Language Specification
Jan 30, 2013 at 8:51 PM
Edited Jan 30, 2013 at 8:54 PM

Please see comments below:

class MyClassA {
	constructor(optionalParam?: any) {
	}
	
	initialize(optionalParam?: any) {
	}	
}

class MyClassB extends MyClassA {
	constructor(requiredParam: any) {
		super(requiredParam);
		// OK.
	}
	
	// I want to override this method and make the param required
	// I can add the private modifier but I want it to
	// be public and hide the method with optionalParam
	initialize(requiredParam: any) {
		// compiler error!
	}
}

How can I do this?

Thanks,
Omid

Coordinator
Jan 30, 2013 at 11:54 PM
See answer on StackOverflow - http://stackoverflow.com/a/14616094/1704166
Apr 12, 2014 at 12:31 AM
Looks like compiler now accepts this kind of parameter override. (tested with TSC 1.0)