mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Merge pull request #6742 from Microsoft/augmentExportEquals
allow augmentation for entities exported via 'export='
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
// @module: amd
|
||||
// @filename: file1.ts
|
||||
var x = 1;
|
||||
export = x;
|
||||
|
||||
// @filename: file2.ts
|
||||
|
||||
import x = require("./file1");
|
||||
|
||||
// augmentation for './file1'
|
||||
// should error since './file1' does not have namespace meaning
|
||||
declare module "./file1" {
|
||||
interface A { a }
|
||||
}
|
||||
|
||||
// @filename: file3.ts
|
||||
import x = require("./file1");
|
||||
import "./file2";
|
||||
let a: x.A; // should not work
|
||||
@@ -0,0 +1,22 @@
|
||||
// @module: amd
|
||||
|
||||
// @filename: file1.d.ts
|
||||
declare module "file1" {
|
||||
var x: number;
|
||||
export = x;
|
||||
}
|
||||
|
||||
// @filename: file2.ts
|
||||
/// <reference path="file1.d.ts"/>
|
||||
import x = require("file1");
|
||||
|
||||
// augmentation for 'file1'
|
||||
// should error since 'file1' does not have namespace meaning
|
||||
declare module "file1" {
|
||||
interface A { a }
|
||||
}
|
||||
|
||||
// @filename: file3.ts
|
||||
import x = require("file1");
|
||||
import "file2";
|
||||
let a: x.A; // should not work
|
||||
@@ -0,0 +1,19 @@
|
||||
// @module: amd
|
||||
|
||||
// @filename: file1.ts
|
||||
function foo() {}
|
||||
export = foo;
|
||||
|
||||
// @filename: file2.ts
|
||||
import x = require("./file1");
|
||||
|
||||
// should error since './file1' does not have namespace meaning
|
||||
declare module "./file1" {
|
||||
interface A { a }
|
||||
}
|
||||
|
||||
// @filename: file3.ts
|
||||
// @filename: file3.ts
|
||||
import x = require("./file1");
|
||||
import "./file2";
|
||||
let a: x.A; // should not work
|
||||
@@ -0,0 +1,22 @@
|
||||
// @module: amd
|
||||
|
||||
// @filename: file1.d.ts
|
||||
declare module "file1" {
|
||||
function foo(): void;
|
||||
export = foo;
|
||||
}
|
||||
|
||||
// @filename: file2.ts
|
||||
|
||||
/// <reference path="file1.d.ts"/>
|
||||
import x = require("file1");
|
||||
|
||||
// should error since './file1' does not have namespace meaning
|
||||
declare module "file1" {
|
||||
interface A { a }
|
||||
}
|
||||
|
||||
// @filename: file3.ts
|
||||
import x = require("file1");
|
||||
import "file2";
|
||||
let a: x.A; // should not work
|
||||
@@ -0,0 +1,24 @@
|
||||
// @module: amd
|
||||
|
||||
// @filename: file1.ts
|
||||
function foo() {}
|
||||
namespace foo {
|
||||
export var v = 1;
|
||||
}
|
||||
export = foo;
|
||||
|
||||
// @filename: file2.ts
|
||||
import x = require("./file1");
|
||||
x.b = 1;
|
||||
|
||||
// OK - './file1' is a namespace
|
||||
declare module "./file1" {
|
||||
interface A { a }
|
||||
let b: number;
|
||||
}
|
||||
|
||||
// @filename: file3.ts
|
||||
import * as x from "./file1";
|
||||
import "./file2";
|
||||
let a: x.A;
|
||||
let b = x.b;
|
||||
@@ -0,0 +1,27 @@
|
||||
// @module: amd
|
||||
// @filename: file1.d.ts
|
||||
declare module "file1" {
|
||||
function foo(): void;
|
||||
namespace foo {
|
||||
export var v: number;
|
||||
}
|
||||
export = foo;
|
||||
}
|
||||
|
||||
|
||||
// @filename: file2.ts
|
||||
/// <reference path="file1.d.ts"/>
|
||||
import x = require("file1");
|
||||
x.b = 1;
|
||||
|
||||
// OK - './file1' is a namespace
|
||||
declare module "file1" {
|
||||
interface A { a }
|
||||
let b: number;
|
||||
}
|
||||
|
||||
// @filename: file3.ts
|
||||
import * as x from "file1";
|
||||
import "file2";
|
||||
let a: x.A;
|
||||
let b = x.b;
|
||||
@@ -0,0 +1,24 @@
|
||||
// @module: amd
|
||||
|
||||
// @filename: file1.ts
|
||||
class foo {}
|
||||
namespace foo {
|
||||
export var v = 1;
|
||||
}
|
||||
export = foo;
|
||||
|
||||
// @filename: file2.ts
|
||||
import x = require("./file1");
|
||||
x.b = 1;
|
||||
|
||||
// OK - './file1' is a namespace
|
||||
declare module "./file1" {
|
||||
interface A { a }
|
||||
let b: number;
|
||||
}
|
||||
|
||||
// @filename: file3.ts
|
||||
import * as x from "./file1";
|
||||
import "./file2";
|
||||
let a: x.A;
|
||||
let b = x.b;
|
||||
@@ -0,0 +1,28 @@
|
||||
// @module: amd
|
||||
|
||||
// @filename: file1.d.ts
|
||||
declare module "file1" {
|
||||
class foo {}
|
||||
namespace foo {
|
||||
export var v: number;
|
||||
}
|
||||
export = foo;
|
||||
}
|
||||
|
||||
|
||||
// @filename: file2.ts
|
||||
/// <reference path="file1.d.ts"/>
|
||||
import x = require("file1");
|
||||
x.b = 1;
|
||||
|
||||
// OK - './file1' is a namespace
|
||||
declare module "file1" {
|
||||
interface A { a }
|
||||
let b: number;
|
||||
}
|
||||
|
||||
// @filename: file3.ts
|
||||
import * as x from "file1";
|
||||
import "file2";
|
||||
let a: x.A;
|
||||
let b = x.b;
|
||||
@@ -0,0 +1,82 @@
|
||||
// @module: amd
|
||||
|
||||
// @filename: express.d.ts
|
||||
|
||||
declare module Express {
|
||||
export interface Request { }
|
||||
export interface Response { }
|
||||
export interface Application { }
|
||||
}
|
||||
|
||||
declare module "express" {
|
||||
function e(): e.Express;
|
||||
namespace e {
|
||||
interface IRoute {
|
||||
all(...handler: RequestHandler[]): IRoute;
|
||||
}
|
||||
|
||||
interface IRouterMatcher<T> {
|
||||
(name: string|RegExp, ...handlers: RequestHandler[]): T;
|
||||
}
|
||||
|
||||
interface IRouter<T> extends RequestHandler {
|
||||
route(path: string): IRoute;
|
||||
}
|
||||
|
||||
export function Router(options?: any): Router;
|
||||
|
||||
export interface Router extends IRouter<Router> {}
|
||||
|
||||
interface Errback { (err: Error): void; }
|
||||
|
||||
interface Request extends Express.Request {
|
||||
|
||||
get (name: string): string;
|
||||
}
|
||||
|
||||
interface Response extends Express.Response {
|
||||
charset: string;
|
||||
}
|
||||
|
||||
interface ErrorRequestHandler {
|
||||
(err: any, req: Request, res: Response, next: Function): any;
|
||||
}
|
||||
|
||||
interface RequestHandler {
|
||||
(req: Request, res: Response, next: Function): any;
|
||||
}
|
||||
|
||||
interface Handler extends RequestHandler {}
|
||||
|
||||
interface RequestParamHandler {
|
||||
(req: Request, res: Response, next: Function, param: any): any;
|
||||
}
|
||||
|
||||
interface Application extends IRouter<Application>, Express.Application {
|
||||
routes: any;
|
||||
}
|
||||
|
||||
interface Express extends Application {
|
||||
createApplication(): Application;
|
||||
}
|
||||
|
||||
var static: any;
|
||||
}
|
||||
|
||||
export = e;
|
||||
}
|
||||
|
||||
// @filename: augmentation.ts
|
||||
/// <reference path="express.d.ts"/>
|
||||
import * as e from "express";
|
||||
declare module "express" {
|
||||
interface Request {
|
||||
id: number;
|
||||
}
|
||||
}
|
||||
|
||||
// @filename: consumer.ts
|
||||
import { Request } from "express";
|
||||
import "./augmentation";
|
||||
let x: Request;
|
||||
const y = x.id;
|
||||
@@ -0,0 +1,28 @@
|
||||
// @module: amd
|
||||
|
||||
// @filename: file1.ts
|
||||
class foo {}
|
||||
namespace foo {
|
||||
export class A {}
|
||||
export namespace B { export let a; }
|
||||
}
|
||||
export = foo;
|
||||
|
||||
// @filename: file2.ts
|
||||
import x = require("./file1");
|
||||
x.B.b = 1;
|
||||
|
||||
// OK - './file1' is a namespace
|
||||
declare module "./file1" {
|
||||
interface A { a: number }
|
||||
namespace B {
|
||||
export let b: number;
|
||||
}
|
||||
}
|
||||
|
||||
// @filename: file3.ts
|
||||
import * as x from "./file1";
|
||||
import "./file2";
|
||||
let a: x.A;
|
||||
let b = a.a;
|
||||
let c = x.B.b;
|
||||
@@ -0,0 +1,26 @@
|
||||
// @module: amd
|
||||
|
||||
// @filename: file1.d.ts
|
||||
declare module "file1" {
|
||||
class foo {}
|
||||
namespace foo {
|
||||
class A {}
|
||||
}
|
||||
export = foo;
|
||||
}
|
||||
|
||||
|
||||
// @filename: file2.ts
|
||||
/// <reference path="file1.d.ts"/>
|
||||
import x = require("file1");
|
||||
|
||||
// OK - './file1' is a namespace
|
||||
declare module "file1" {
|
||||
interface A { a: number }
|
||||
}
|
||||
|
||||
// @filename: file3.ts
|
||||
import * as x from "file1";
|
||||
import "file2";
|
||||
let a: x.A;
|
||||
let b = a.a;
|
||||
Reference in New Issue
Block a user