-
Notifications
You must be signed in to change notification settings - Fork 13.2k
Closed
Labels
FixedA PR has been merged for this issueA PR has been merged for this issueSuggestionAn idea for TypeScriptAn idea for TypeScript
Description
Sometimes a class/function has a few supporting small types, like the example below.
In foo.ts:
interface IOptions {...}
interface IResult {...}
function foo(options: IOptions): IResult {...}
export = foo;Then in another file:
import foo = require("foo");
var options: IOptions = {...};
var result = foo(options);This doesn't work because IOptions and IResult have be exported too. But then you'll have to write:
import fooMod = require("foo");
var options: fooMod.IOptions = {...};
var result = fooMod.foo(options);It's also possible to put IOptions and IResult in separate files. But those two types are small and tightly coupled to foo, so it's easier to maintain them in the same file as foo. Also, you'll need to write 3 import statements to import them all.
Why not support the following (like Python's from module import *)?
In foo.ts:
export interface IOptions {...}
export interface IResult {...}
export function foo(options: IOptions): IResult {...}Then in another file:
import * = require("foo");
var options: IOptions = {...};
var result = foo(options);Metadata
Metadata
Assignees
Labels
FixedA PR has been merged for this issueA PR has been merged for this issueSuggestionAn idea for TypeScriptAn idea for TypeScript