Short bad answer
interface IPerson { name: string; } var person = function(name: string) : void { this.name = name; } let funcPerson = <IPerson>(new (<any>(person("John Doe"))));
This works and compiles with the noImplicitAny flag.
Longer answer
Just convert it to a class:
class person { constructor(public name: string) { } } let classPerson = person("John Doe");
Compiled for:
var person = (function () { function person(name) { this.name = name; } return person; })(); var classPerson = new person("Jane Doe");
This is IIFE , which in the simple case does not matter what has ever been compared with the implementation of var person = function... This is exactly the same.
Converting a new function to a class is useful. This makes the code readable, easier to reorganize, and easier to extend / modify in the future. It also has better type information (in this case you don't even need an interface).
In short, I cannot justify using a new version of functions over the class version of this solution. Both versions result in identical objects (see classPerson and funcPerson above).
Third option
If you have a working .js file that you want to use with typescript, you need to write a .d.ts file. In this case, you can do something like this:
person.js
var person = function(name) { this.name = name; }
person.d.ts
interface PersonStatic { name:string; new(name: string) : PersonStatic; } declare var person: PersonStatic;
When you use this, you can:
/// <reference path="your.d.ts"/> var p = new person("Jane Doe");
and it will work.
In this case, the person.js file must be present at runtime for javascript to execute correctly. A file with the extension .d.ts above is a basic example, if you decide to go this route, I recommend that you first read about creating .d.ts files before downloading.