How to access static methods in TypeScript
typescript
Solution
You can import classes directly, which allows you to have the usage you want.
// usage
import { Logger } from 'path/logger.ts'
Logger.Log();
And the definition stays the same.
// path/logger.ts
export class Logger {
static Log() {
...
}
}
Problem
I'm trying to do this, but it's not working like I'd expect. (I'm using the AMD option) ``` //logger.ts export class Logger { static log(message: string) { //do stuff } } //main.ts import logger = module('services/logger'); logger.log("test"); //The property 'log' does not exist on value of type '"logger"' logger.Logger.log(); //works ``` How do you do logger.log()?