mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-15 03:23:08 -06:00
commit
7d372bf6dc
@ -1356,6 +1356,8 @@ namespace ts {
|
||||
case SyntaxKind.ImportSpecifier:
|
||||
case SyntaxKind.ExportSpecifier:
|
||||
return declareSymbolAndAddToSymbolTable(<Declaration>node, SymbolFlags.Alias, SymbolFlags.AliasExcludes);
|
||||
case SyntaxKind.GlobalModuleExportDeclaration:
|
||||
return bindGlobalModuleExportDeclaration(<GlobalModuleExportDeclaration>node);
|
||||
case SyntaxKind.ImportClause:
|
||||
return bindImportClause(<ImportClause>node);
|
||||
case SyntaxKind.ExportDeclaration:
|
||||
@ -1405,6 +1407,33 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
function bindGlobalModuleExportDeclaration(node: GlobalModuleExportDeclaration) {
|
||||
if (node.modifiers && node.modifiers.length) {
|
||||
file.bindDiagnostics.push(createDiagnosticForNode(node, Diagnostics.Modifiers_cannot_appear_here));
|
||||
}
|
||||
|
||||
if (node.parent.kind !== SyntaxKind.SourceFile) {
|
||||
file.bindDiagnostics.push(createDiagnosticForNode(node, Diagnostics.Global_module_exports_may_only_appear_at_top_level));
|
||||
return;
|
||||
}
|
||||
else {
|
||||
const parent = node.parent as SourceFile;
|
||||
|
||||
if (!isExternalModule(parent)) {
|
||||
file.bindDiagnostics.push(createDiagnosticForNode(node, Diagnostics.Global_module_exports_may_only_appear_in_module_files));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!parent.isDeclarationFile) {
|
||||
file.bindDiagnostics.push(createDiagnosticForNode(node, Diagnostics.Global_module_exports_may_only_appear_in_declaration_files));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
file.symbol.globalExports = file.symbol.globalExports || {};
|
||||
declareSymbol(file.symbol.globalExports, file.symbol, node, SymbolFlags.Alias, SymbolFlags.AliasExcludes);
|
||||
}
|
||||
|
||||
function bindExportDeclaration(node: ExportDeclaration) {
|
||||
if (!container.symbol || !container.symbol.exports) {
|
||||
// Export * in some sort of block construct
|
||||
|
||||
@ -992,6 +992,10 @@ namespace ts {
|
||||
return getExternalModuleMember(<ImportDeclaration>node.parent.parent.parent, node);
|
||||
}
|
||||
|
||||
function getTargetOfGlobalModuleExportDeclaration(node: GlobalModuleExportDeclaration): Symbol {
|
||||
return resolveExternalModuleSymbol(node.parent.symbol);
|
||||
}
|
||||
|
||||
function getTargetOfExportSpecifier(node: ExportSpecifier): Symbol {
|
||||
return (<ExportDeclaration>node.parent.parent).moduleSpecifier ?
|
||||
getExternalModuleMember(<ExportDeclaration>node.parent.parent, node) :
|
||||
@ -1016,6 +1020,8 @@ namespace ts {
|
||||
return getTargetOfExportSpecifier(<ExportSpecifier>node);
|
||||
case SyntaxKind.ExportAssignment:
|
||||
return getTargetOfExportAssignment(<ExportAssignment>node);
|
||||
case SyntaxKind.GlobalModuleExportDeclaration:
|
||||
return getTargetOfGlobalModuleExportDeclaration(<GlobalModuleExportDeclaration>node);
|
||||
}
|
||||
}
|
||||
|
||||
@ -15282,7 +15288,6 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function checkSourceElement(node: Node): void {
|
||||
if (!node) {
|
||||
return;
|
||||
@ -16393,6 +16398,9 @@ namespace ts {
|
||||
if (file.moduleAugmentations.length) {
|
||||
(augmentations || (augmentations = [])).push(file.moduleAugmentations);
|
||||
}
|
||||
if (file.wasReferenced && file.symbol && file.symbol.globalExports) {
|
||||
mergeSymbolTable(globals, file.symbol.globalExports);
|
||||
}
|
||||
});
|
||||
|
||||
if (augmentations) {
|
||||
|
||||
@ -831,6 +831,18 @@
|
||||
"category": "Error",
|
||||
"code": 1313
|
||||
},
|
||||
"Global module exports may only appear in module files.": {
|
||||
"category": "Error",
|
||||
"code": 1314
|
||||
},
|
||||
"Global module exports may only appear in declaration files.": {
|
||||
"category": "Error",
|
||||
"code": 1315
|
||||
},
|
||||
"Global module exports may only appear at top level.": {
|
||||
"category": "Error",
|
||||
"code": 1316
|
||||
},
|
||||
"Duplicate identifier '{0}'.": {
|
||||
"category": "Error",
|
||||
"code": 2300
|
||||
|
||||
@ -301,6 +301,9 @@ namespace ts {
|
||||
case SyntaxKind.ImportClause:
|
||||
return visitNode(cbNode, (<ImportClause>node).name) ||
|
||||
visitNode(cbNode, (<ImportClause>node).namedBindings);
|
||||
case SyntaxKind.GlobalModuleExportDeclaration:
|
||||
return visitNode(cbNode, (<GlobalModuleExportDeclaration>node).name);
|
||||
|
||||
case SyntaxKind.NamespaceImport:
|
||||
return visitNode(cbNode, (<NamespaceImport>node).name);
|
||||
case SyntaxKind.NamedImports:
|
||||
@ -1125,7 +1128,7 @@ namespace ts {
|
||||
if (token === SyntaxKind.DefaultKeyword) {
|
||||
return lookAhead(nextTokenIsClassOrFunction);
|
||||
}
|
||||
return token !== SyntaxKind.AsteriskToken && token !== SyntaxKind.OpenBraceToken && canFollowModifier();
|
||||
return token !== SyntaxKind.AsteriskToken && token !== SyntaxKind.AsKeyword && token !== SyntaxKind.OpenBraceToken && canFollowModifier();
|
||||
}
|
||||
if (token === SyntaxKind.DefaultKeyword) {
|
||||
return nextTokenIsClassOrFunction();
|
||||
@ -4400,7 +4403,8 @@ namespace ts {
|
||||
continue;
|
||||
|
||||
case SyntaxKind.GlobalKeyword:
|
||||
return nextToken() === SyntaxKind.OpenBraceToken;
|
||||
nextToken();
|
||||
return token === SyntaxKind.OpenBraceToken || token === SyntaxKind.Identifier || token === SyntaxKind.ExportKeyword;
|
||||
|
||||
case SyntaxKind.ImportKeyword:
|
||||
nextToken();
|
||||
@ -4409,7 +4413,8 @@ namespace ts {
|
||||
case SyntaxKind.ExportKeyword:
|
||||
nextToken();
|
||||
if (token === SyntaxKind.EqualsToken || token === SyntaxKind.AsteriskToken ||
|
||||
token === SyntaxKind.OpenBraceToken || token === SyntaxKind.DefaultKeyword) {
|
||||
token === SyntaxKind.OpenBraceToken || token === SyntaxKind.DefaultKeyword ||
|
||||
token === SyntaxKind.AsKeyword) {
|
||||
return true;
|
||||
}
|
||||
continue;
|
||||
@ -4593,9 +4598,15 @@ namespace ts {
|
||||
return parseImportDeclarationOrImportEqualsDeclaration(fullStart, decorators, modifiers);
|
||||
case SyntaxKind.ExportKeyword:
|
||||
nextToken();
|
||||
return token === SyntaxKind.DefaultKeyword || token === SyntaxKind.EqualsToken ?
|
||||
parseExportAssignment(fullStart, decorators, modifiers) :
|
||||
parseExportDeclaration(fullStart, decorators, modifiers);
|
||||
switch (token) {
|
||||
case SyntaxKind.DefaultKeyword:
|
||||
case SyntaxKind.EqualsToken:
|
||||
return parseExportAssignment(fullStart, decorators, modifiers);
|
||||
case SyntaxKind.AsKeyword:
|
||||
return parseGlobalModuleExportDeclaration(fullStart, decorators, modifiers);
|
||||
default:
|
||||
return parseExportDeclaration(fullStart, decorators, modifiers);
|
||||
}
|
||||
default:
|
||||
if (decorators || modifiers) {
|
||||
// We reached this point because we encountered decorators and/or modifiers and assumed a declaration
|
||||
@ -5264,6 +5275,20 @@ namespace ts {
|
||||
return nextToken() === SyntaxKind.SlashToken;
|
||||
}
|
||||
|
||||
function parseGlobalModuleExportDeclaration(fullStart: number, decorators: NodeArray<Decorator>, modifiers: ModifiersArray): GlobalModuleExportDeclaration {
|
||||
const exportDeclaration = <GlobalModuleExportDeclaration>createNode(SyntaxKind.GlobalModuleExportDeclaration, fullStart);
|
||||
exportDeclaration.decorators = decorators;
|
||||
exportDeclaration.modifiers = modifiers;
|
||||
parseExpected(SyntaxKind.AsKeyword);
|
||||
parseExpected(SyntaxKind.NamespaceKeyword);
|
||||
|
||||
exportDeclaration.name = parseIdentifier();
|
||||
|
||||
parseExpected(SyntaxKind.SemicolonToken);
|
||||
|
||||
return finishNode(exportDeclaration);
|
||||
}
|
||||
|
||||
function parseImportDeclarationOrImportEqualsDeclaration(fullStart: number, decorators: NodeArray<Decorator>, modifiers: ModifiersArray): ImportEqualsDeclaration | ImportDeclaration {
|
||||
parseExpected(SyntaxKind.ImportKeyword);
|
||||
const afterImportPos = scanner.getStartPos();
|
||||
|
||||
@ -1286,7 +1286,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
function processRootFile(fileName: string, isDefaultLib: boolean) {
|
||||
processSourceFile(normalizePath(fileName), isDefaultLib);
|
||||
processSourceFile(normalizePath(fileName), isDefaultLib, /*isReference*/ true);
|
||||
}
|
||||
|
||||
function fileReferenceIsEqualTo(a: FileReference, b: FileReference): boolean {
|
||||
@ -1380,7 +1380,10 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
function processSourceFile(fileName: string, isDefaultLib: boolean, refFile?: SourceFile, refPos?: number, refEnd?: number) {
|
||||
/**
|
||||
* 'isReference' indicates whether the file was brought in via a reference directive (rather than an import declaration)
|
||||
*/
|
||||
function processSourceFile(fileName: string, isDefaultLib: boolean, isReference: boolean, refFile?: SourceFile, refPos?: number, refEnd?: number) {
|
||||
let diagnosticArgument: string[];
|
||||
let diagnostic: DiagnosticMessage;
|
||||
if (hasExtension(fileName)) {
|
||||
@ -1388,7 +1391,7 @@ namespace ts {
|
||||
diagnostic = Diagnostics.File_0_has_unsupported_extension_The_only_supported_extensions_are_1;
|
||||
diagnosticArgument = [fileName, "'" + supportedExtensions.join("', '") + "'"];
|
||||
}
|
||||
else if (!findSourceFile(fileName, toPath(fileName, currentDirectory, getCanonicalFileName), isDefaultLib, refFile, refPos, refEnd)) {
|
||||
else if (!findSourceFile(fileName, toPath(fileName, currentDirectory, getCanonicalFileName), isDefaultLib, isReference, refFile, refPos, refEnd)) {
|
||||
diagnostic = Diagnostics.File_0_not_found;
|
||||
diagnosticArgument = [fileName];
|
||||
}
|
||||
@ -1398,13 +1401,13 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
else {
|
||||
const nonTsFile: SourceFile = options.allowNonTsExtensions && findSourceFile(fileName, toPath(fileName, currentDirectory, getCanonicalFileName), isDefaultLib, refFile, refPos, refEnd);
|
||||
const nonTsFile: SourceFile = options.allowNonTsExtensions && findSourceFile(fileName, toPath(fileName, currentDirectory, getCanonicalFileName), isDefaultLib, isReference, refFile, refPos, refEnd);
|
||||
if (!nonTsFile) {
|
||||
if (options.allowNonTsExtensions) {
|
||||
diagnostic = Diagnostics.File_0_not_found;
|
||||
diagnosticArgument = [fileName];
|
||||
}
|
||||
else if (!forEach(supportedExtensions, extension => findSourceFile(fileName + extension, toPath(fileName + extension, currentDirectory, getCanonicalFileName), isDefaultLib, refFile, refPos, refEnd))) {
|
||||
else if (!forEach(supportedExtensions, extension => findSourceFile(fileName + extension, toPath(fileName + extension, currentDirectory, getCanonicalFileName), isDefaultLib, isReference, refFile, refPos, refEnd))) {
|
||||
diagnostic = Diagnostics.File_0_not_found;
|
||||
fileName += ".ts";
|
||||
diagnosticArgument = [fileName];
|
||||
@ -1433,7 +1436,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
// Get source file from normalized fileName
|
||||
function findSourceFile(fileName: string, path: Path, isDefaultLib: boolean, refFile?: SourceFile, refPos?: number, refEnd?: number): SourceFile {
|
||||
function findSourceFile(fileName: string, path: Path, isDefaultLib: boolean, isReference: boolean, refFile?: SourceFile, refPos?: number, refEnd?: number): SourceFile {
|
||||
if (filesByName.contains(path)) {
|
||||
const file = filesByName.get(path);
|
||||
// try to check if we've already seen this file but with a different casing in path
|
||||
@ -1442,6 +1445,10 @@ namespace ts {
|
||||
reportFileNamesDifferOnlyInCasingError(fileName, file.fileName, refFile, refPos, refEnd);
|
||||
}
|
||||
|
||||
if (file) {
|
||||
file.wasReferenced = file.wasReferenced || isReference;
|
||||
}
|
||||
|
||||
return file;
|
||||
}
|
||||
|
||||
@ -1458,6 +1465,7 @@ namespace ts {
|
||||
|
||||
filesByName.set(path, file);
|
||||
if (file) {
|
||||
file.wasReferenced = file.wasReferenced || isReference;
|
||||
file.path = path;
|
||||
|
||||
if (host.useCaseSensitiveFileNames()) {
|
||||
@ -1495,7 +1503,7 @@ namespace ts {
|
||||
function processReferencedFiles(file: SourceFile, basePath: string) {
|
||||
forEach(file.referencedFiles, ref => {
|
||||
const referencedFileName = resolveTripleslashReference(ref.fileName, file.fileName);
|
||||
processSourceFile(referencedFileName, /*isDefaultLib*/ false, file, ref.pos, ref.end);
|
||||
processSourceFile(referencedFileName, /*isDefaultLib*/ false, /*isReference*/ true, file, ref.pos, ref.end);
|
||||
});
|
||||
}
|
||||
|
||||
@ -1521,7 +1529,7 @@ namespace ts {
|
||||
i < file.imports.length;
|
||||
|
||||
if (shouldAddFile) {
|
||||
const importedFile = findSourceFile(resolution.resolvedFileName, toPath(resolution.resolvedFileName, currentDirectory, getCanonicalFileName), /*isDefaultLib*/ false, file, skipTrivia(file.text, file.imports[i].pos), file.imports[i].end);
|
||||
const importedFile = findSourceFile(resolution.resolvedFileName, toPath(resolution.resolvedFileName, currentDirectory, getCanonicalFileName), /*isDefaultLib*/ false, /*isReference*/ false, file, skipTrivia(file.text, file.imports[i].pos), file.imports[i].end);
|
||||
|
||||
if (importedFile && resolution.isExternalLibraryImport) {
|
||||
// Since currently irrespective of allowJs, we only look for supportedTypeScript extension external module files,
|
||||
|
||||
@ -274,6 +274,7 @@ namespace ts {
|
||||
ModuleDeclaration,
|
||||
ModuleBlock,
|
||||
CaseBlock,
|
||||
GlobalModuleExportDeclaration,
|
||||
ImportEqualsDeclaration,
|
||||
ImportDeclaration,
|
||||
ImportClause,
|
||||
@ -1326,6 +1327,12 @@ namespace ts {
|
||||
name: Identifier;
|
||||
}
|
||||
|
||||
// @kind(SyntaxKind.GlobalModuleImport)
|
||||
export interface GlobalModuleExportDeclaration extends DeclarationStatement {
|
||||
name: Identifier;
|
||||
moduleReference: LiteralLikeNode;
|
||||
}
|
||||
|
||||
// @kind(SyntaxKind.ExportDeclaration)
|
||||
export interface ExportDeclaration extends DeclarationStatement {
|
||||
exportClause?: NamedExports;
|
||||
@ -1539,6 +1546,8 @@ namespace ts {
|
||||
/* @internal */ externalModuleIndicator: Node;
|
||||
// The first node that causes this file to be a CommonJS module
|
||||
/* @internal */ commonJsModuleIndicator: Node;
|
||||
// True if the file was a root file in a compilation or a /// reference targets
|
||||
/* @internal */ wasReferenced?: boolean;
|
||||
|
||||
/* @internal */ identifiers: Map<string>;
|
||||
/* @internal */ nodeCount: number;
|
||||
@ -1997,6 +2006,7 @@ namespace ts {
|
||||
|
||||
members?: SymbolTable; // Class, interface or literal instance members
|
||||
exports?: SymbolTable; // Module exports
|
||||
globalExports?: SymbolTable; // Conditional global UMD exports
|
||||
/* @internal */ id?: number; // Unique id (used to look up SymbolLinks)
|
||||
/* @internal */ mergeId?: number; // Merge id (used to look up merged symbol)
|
||||
/* @internal */ parent?: Symbol; // Parent symbol
|
||||
|
||||
@ -1474,6 +1474,7 @@ namespace ts {
|
||||
// export default ...
|
||||
export function isAliasSymbolDeclaration(node: Node): boolean {
|
||||
return node.kind === SyntaxKind.ImportEqualsDeclaration ||
|
||||
node.kind === SyntaxKind.GlobalModuleExportDeclaration ||
|
||||
node.kind === SyntaxKind.ImportClause && !!(<ImportClause>node).name ||
|
||||
node.kind === SyntaxKind.NamespaceImport ||
|
||||
node.kind === SyntaxKind.ImportSpecifier ||
|
||||
|
||||
@ -88,7 +88,7 @@ class CompilerBaselineRunner extends RunnerBase {
|
||||
toBeCompiled = [];
|
||||
otherFiles = [];
|
||||
|
||||
if (/require\(/.test(lastUnit.content) || /reference\spath/.test(lastUnit.content)) {
|
||||
if (testCaseContent.settings["noImplicitReferences"] || /require\(/.test(lastUnit.content) || /reference\spath/.test(lastUnit.content)) {
|
||||
toBeCompiled.push({ unitName: this.makeUnitName(lastUnit.name, rootDir), content: lastUnit.content });
|
||||
units.forEach(unit => {
|
||||
if (unit.name !== lastUnit.name) {
|
||||
|
||||
@ -896,7 +896,8 @@ namespace Harness {
|
||||
{ name: "fileName", type: "string" },
|
||||
{ name: "libFiles", type: "string" },
|
||||
{ name: "noErrorTruncation", type: "boolean" },
|
||||
{ name: "suppressOutputPathCheck", type: "boolean" }
|
||||
{ name: "suppressOutputPathCheck", type: "boolean" },
|
||||
{ name: "noImplicitReferences", type: "boolean" }
|
||||
];
|
||||
|
||||
let optionsIndex: ts.Map<ts.CommandLineOption>;
|
||||
|
||||
50
tests/baselines/reference/umd-augmentation-1.js
Normal file
50
tests/baselines/reference/umd-augmentation-1.js
Normal file
@ -0,0 +1,50 @@
|
||||
//// [tests/cases/conformance/externalModules/umd-augmentation-1.ts] ////
|
||||
|
||||
//// [index.d.ts]
|
||||
|
||||
export as namespace Math2d;
|
||||
|
||||
export interface Point {
|
||||
x: number;
|
||||
y: number;
|
||||
}
|
||||
|
||||
export class Vector implements Point {
|
||||
x: number;
|
||||
y: number;
|
||||
constructor(x: number, y: number);
|
||||
|
||||
translate(dx: number, dy: number): Vector;
|
||||
}
|
||||
|
||||
export function getLength(p: Vector): number;
|
||||
|
||||
//// [math2d-augment.d.ts]
|
||||
import * as Math2d from 'math2d';
|
||||
// Augment the module
|
||||
declare module 'math2d' {
|
||||
// Add a method to the class
|
||||
interface Vector {
|
||||
reverse(): Math2d.Point;
|
||||
}
|
||||
}
|
||||
|
||||
//// [b.ts]
|
||||
/// <reference path="math2d-augment.d.ts" />
|
||||
import * as m from 'math2d';
|
||||
let v = new m.Vector(3, 2);
|
||||
let magnitude = m.getLength(v);
|
||||
let p: m.Point = v.translate(5, 5);
|
||||
p = v.reverse();
|
||||
var t = p.x;
|
||||
|
||||
|
||||
//// [b.js]
|
||||
"use strict";
|
||||
/// <reference path="math2d-augment.d.ts" />
|
||||
var m = require('math2d');
|
||||
var v = new m.Vector(3, 2);
|
||||
var magnitude = m.getLength(v);
|
||||
var p = v.translate(5, 5);
|
||||
p = v.reverse();
|
||||
var t = p.x;
|
||||
95
tests/baselines/reference/umd-augmentation-1.symbols
Normal file
95
tests/baselines/reference/umd-augmentation-1.symbols
Normal file
@ -0,0 +1,95 @@
|
||||
=== tests/cases/conformance/externalModules/b.ts ===
|
||||
/// <reference path="math2d-augment.d.ts" />
|
||||
import * as m from 'math2d';
|
||||
>m : Symbol(m, Decl(b.ts, 1, 6))
|
||||
|
||||
let v = new m.Vector(3, 2);
|
||||
>v : Symbol(v, Decl(b.ts, 2, 3))
|
||||
>m.Vector : Symbol(m.Vector, Decl(index.d.ts, 6, 1), Decl(math2d-augment.d.ts, 2, 25))
|
||||
>m : Symbol(m, Decl(b.ts, 1, 6))
|
||||
>Vector : Symbol(m.Vector, Decl(index.d.ts, 6, 1), Decl(math2d-augment.d.ts, 2, 25))
|
||||
|
||||
let magnitude = m.getLength(v);
|
||||
>magnitude : Symbol(magnitude, Decl(b.ts, 3, 3))
|
||||
>m.getLength : Symbol(m.getLength, Decl(index.d.ts, 14, 1))
|
||||
>m : Symbol(m, Decl(b.ts, 1, 6))
|
||||
>getLength : Symbol(m.getLength, Decl(index.d.ts, 14, 1))
|
||||
>v : Symbol(v, Decl(b.ts, 2, 3))
|
||||
|
||||
let p: m.Point = v.translate(5, 5);
|
||||
>p : Symbol(p, Decl(b.ts, 4, 3))
|
||||
>m : Symbol(m, Decl(b.ts, 1, 6))
|
||||
>Point : Symbol(m.Point, Decl(index.d.ts, 1, 27))
|
||||
>v.translate : Symbol(m.Vector.translate, Decl(index.d.ts, 11, 35))
|
||||
>v : Symbol(v, Decl(b.ts, 2, 3))
|
||||
>translate : Symbol(m.Vector.translate, Decl(index.d.ts, 11, 35))
|
||||
|
||||
p = v.reverse();
|
||||
>p : Symbol(p, Decl(b.ts, 4, 3))
|
||||
>v.reverse : Symbol(m.Vector.reverse, Decl(math2d-augment.d.ts, 4, 19))
|
||||
>v : Symbol(v, Decl(b.ts, 2, 3))
|
||||
>reverse : Symbol(m.Vector.reverse, Decl(math2d-augment.d.ts, 4, 19))
|
||||
|
||||
var t = p.x;
|
||||
>t : Symbol(t, Decl(b.ts, 6, 3))
|
||||
>p.x : Symbol(m.Point.x, Decl(index.d.ts, 3, 24))
|
||||
>p : Symbol(p, Decl(b.ts, 4, 3))
|
||||
>x : Symbol(m.Point.x, Decl(index.d.ts, 3, 24))
|
||||
|
||||
=== tests/cases/conformance/externalModules/node_modules/math2d/index.d.ts ===
|
||||
|
||||
export as namespace Math2d;
|
||||
|
||||
export interface Point {
|
||||
>Point : Symbol(Point, Decl(index.d.ts, 1, 27))
|
||||
|
||||
x: number;
|
||||
>x : Symbol(x, Decl(index.d.ts, 3, 24))
|
||||
|
||||
y: number;
|
||||
>y : Symbol(y, Decl(index.d.ts, 4, 11))
|
||||
}
|
||||
|
||||
export class Vector implements Point {
|
||||
>Vector : Symbol(Vector, Decl(index.d.ts, 6, 1), Decl(math2d-augment.d.ts, 2, 25))
|
||||
>Point : Symbol(Point, Decl(index.d.ts, 1, 27))
|
||||
|
||||
x: number;
|
||||
>x : Symbol(x, Decl(index.d.ts, 8, 38))
|
||||
|
||||
y: number;
|
||||
>y : Symbol(y, Decl(index.d.ts, 9, 11))
|
||||
|
||||
constructor(x: number, y: number);
|
||||
>x : Symbol(x, Decl(index.d.ts, 11, 13))
|
||||
>y : Symbol(y, Decl(index.d.ts, 11, 23))
|
||||
|
||||
translate(dx: number, dy: number): Vector;
|
||||
>translate : Symbol(translate, Decl(index.d.ts, 11, 35))
|
||||
>dx : Symbol(dx, Decl(index.d.ts, 13, 11))
|
||||
>dy : Symbol(dy, Decl(index.d.ts, 13, 22))
|
||||
>Vector : Symbol(Vector, Decl(index.d.ts, 6, 1), Decl(math2d-augment.d.ts, 2, 25))
|
||||
}
|
||||
|
||||
export function getLength(p: Vector): number;
|
||||
>getLength : Symbol(getLength, Decl(index.d.ts, 14, 1))
|
||||
>p : Symbol(p, Decl(index.d.ts, 16, 26))
|
||||
>Vector : Symbol(Vector, Decl(index.d.ts, 6, 1), Decl(math2d-augment.d.ts, 2, 25))
|
||||
|
||||
=== tests/cases/conformance/externalModules/math2d-augment.d.ts ===
|
||||
import * as Math2d from 'math2d';
|
||||
>Math2d : Symbol(Math2d, Decl(math2d-augment.d.ts, 0, 6))
|
||||
|
||||
// Augment the module
|
||||
declare module 'math2d' {
|
||||
// Add a method to the class
|
||||
interface Vector {
|
||||
>Vector : Symbol(Vector, Decl(index.d.ts, 6, 1), Decl(math2d-augment.d.ts, 2, 25))
|
||||
|
||||
reverse(): Math2d.Point;
|
||||
>reverse : Symbol(reverse, Decl(math2d-augment.d.ts, 4, 19))
|
||||
>Math2d : Symbol(Math2d, Decl(math2d-augment.d.ts, 0, 6))
|
||||
>Point : Symbol(Point, Decl(index.d.ts, 1, 27))
|
||||
}
|
||||
}
|
||||
|
||||
105
tests/baselines/reference/umd-augmentation-1.types
Normal file
105
tests/baselines/reference/umd-augmentation-1.types
Normal file
@ -0,0 +1,105 @@
|
||||
=== tests/cases/conformance/externalModules/b.ts ===
|
||||
/// <reference path="math2d-augment.d.ts" />
|
||||
import * as m from 'math2d';
|
||||
>m : typeof m
|
||||
|
||||
let v = new m.Vector(3, 2);
|
||||
>v : m.Vector
|
||||
>new m.Vector(3, 2) : m.Vector
|
||||
>m.Vector : typeof m.Vector
|
||||
>m : typeof m
|
||||
>Vector : typeof m.Vector
|
||||
>3 : number
|
||||
>2 : number
|
||||
|
||||
let magnitude = m.getLength(v);
|
||||
>magnitude : number
|
||||
>m.getLength(v) : number
|
||||
>m.getLength : (p: m.Vector) => number
|
||||
>m : typeof m
|
||||
>getLength : (p: m.Vector) => number
|
||||
>v : m.Vector
|
||||
|
||||
let p: m.Point = v.translate(5, 5);
|
||||
>p : m.Point
|
||||
>m : any
|
||||
>Point : m.Point
|
||||
>v.translate(5, 5) : m.Vector
|
||||
>v.translate : (dx: number, dy: number) => m.Vector
|
||||
>v : m.Vector
|
||||
>translate : (dx: number, dy: number) => m.Vector
|
||||
>5 : number
|
||||
>5 : number
|
||||
|
||||
p = v.reverse();
|
||||
>p = v.reverse() : m.Point
|
||||
>p : m.Point
|
||||
>v.reverse() : m.Point
|
||||
>v.reverse : () => m.Point
|
||||
>v : m.Vector
|
||||
>reverse : () => m.Point
|
||||
|
||||
var t = p.x;
|
||||
>t : number
|
||||
>p.x : number
|
||||
>p : m.Point
|
||||
>x : number
|
||||
|
||||
=== tests/cases/conformance/externalModules/node_modules/math2d/index.d.ts ===
|
||||
|
||||
export as namespace Math2d;
|
||||
>Math2d : any
|
||||
|
||||
export interface Point {
|
||||
>Point : Point
|
||||
|
||||
x: number;
|
||||
>x : number
|
||||
|
||||
y: number;
|
||||
>y : number
|
||||
}
|
||||
|
||||
export class Vector implements Point {
|
||||
>Vector : Vector
|
||||
>Point : Point
|
||||
|
||||
x: number;
|
||||
>x : number
|
||||
|
||||
y: number;
|
||||
>y : number
|
||||
|
||||
constructor(x: number, y: number);
|
||||
>x : number
|
||||
>y : number
|
||||
|
||||
translate(dx: number, dy: number): Vector;
|
||||
>translate : (dx: number, dy: number) => Vector
|
||||
>dx : number
|
||||
>dy : number
|
||||
>Vector : Vector
|
||||
}
|
||||
|
||||
export function getLength(p: Vector): number;
|
||||
>getLength : (p: Vector) => number
|
||||
>p : Vector
|
||||
>Vector : Vector
|
||||
|
||||
=== tests/cases/conformance/externalModules/math2d-augment.d.ts ===
|
||||
import * as Math2d from 'math2d';
|
||||
>Math2d : typeof Math2d
|
||||
|
||||
// Augment the module
|
||||
declare module 'math2d' {
|
||||
// Add a method to the class
|
||||
interface Vector {
|
||||
>Vector : Vector
|
||||
|
||||
reverse(): Math2d.Point;
|
||||
>reverse : () => Point
|
||||
>Math2d : any
|
||||
>Point : Point
|
||||
}
|
||||
}
|
||||
|
||||
49
tests/baselines/reference/umd-augmentation-2.js
Normal file
49
tests/baselines/reference/umd-augmentation-2.js
Normal file
@ -0,0 +1,49 @@
|
||||
//// [tests/cases/conformance/externalModules/umd-augmentation-2.ts] ////
|
||||
|
||||
//// [index.d.ts]
|
||||
|
||||
export as namespace Math2d;
|
||||
|
||||
export interface Point {
|
||||
x: number;
|
||||
y: number;
|
||||
}
|
||||
|
||||
export class Vector implements Point {
|
||||
x: number;
|
||||
y: number;
|
||||
constructor(x: number, y: number);
|
||||
|
||||
translate(dx: number, dy: number): Vector;
|
||||
}
|
||||
|
||||
export function getLength(p: Vector): number;
|
||||
|
||||
//// [math2d-augment.d.ts]
|
||||
import * as Math2d from 'math2d';
|
||||
// Augment the module
|
||||
declare module 'math2d' {
|
||||
// Add a method to the class
|
||||
interface Vector {
|
||||
reverse(): Math2d.Point;
|
||||
}
|
||||
}
|
||||
|
||||
//// [a.ts]
|
||||
/// <reference path="node_modules/math2d/index.d.ts" />
|
||||
/// <reference path="math2d-augment.d.ts" />
|
||||
let v = new Math2d.Vector(3, 2);
|
||||
let magnitude = Math2d.getLength(v);
|
||||
let p: Math2d.Point = v.translate(5, 5);
|
||||
p = v.reverse();
|
||||
var t = p.x;
|
||||
|
||||
|
||||
//// [a.js]
|
||||
/// <reference path="node_modules/math2d/index.d.ts" />
|
||||
/// <reference path="math2d-augment.d.ts" />
|
||||
var v = new exports.Math2d.Vector(3, 2);
|
||||
var magnitude = exports.Math2d.getLength(v);
|
||||
var p = v.translate(5, 5);
|
||||
p = v.reverse();
|
||||
var t = p.x;
|
||||
93
tests/baselines/reference/umd-augmentation-2.symbols
Normal file
93
tests/baselines/reference/umd-augmentation-2.symbols
Normal file
@ -0,0 +1,93 @@
|
||||
=== tests/cases/conformance/externalModules/a.ts ===
|
||||
/// <reference path="node_modules/math2d/index.d.ts" />
|
||||
/// <reference path="math2d-augment.d.ts" />
|
||||
let v = new Math2d.Vector(3, 2);
|
||||
>v : Symbol(v, Decl(a.ts, 2, 3))
|
||||
>Math2d.Vector : Symbol(Math2d.Vector, Decl(index.d.ts, 6, 1))
|
||||
>Math2d : Symbol(Math2d, Decl(index.d.ts, 0, 0))
|
||||
>Vector : Symbol(Math2d.Vector, Decl(index.d.ts, 6, 1))
|
||||
|
||||
let magnitude = Math2d.getLength(v);
|
||||
>magnitude : Symbol(magnitude, Decl(a.ts, 3, 3))
|
||||
>Math2d.getLength : Symbol(Math2d.getLength, Decl(index.d.ts, 14, 1))
|
||||
>Math2d : Symbol(Math2d, Decl(index.d.ts, 0, 0))
|
||||
>getLength : Symbol(Math2d.getLength, Decl(index.d.ts, 14, 1))
|
||||
>v : Symbol(v, Decl(a.ts, 2, 3))
|
||||
|
||||
let p: Math2d.Point = v.translate(5, 5);
|
||||
>p : Symbol(p, Decl(a.ts, 4, 3))
|
||||
>Math2d : Symbol(Math2d, Decl(index.d.ts, 0, 0))
|
||||
>Point : Symbol(Math2d.Point, Decl(index.d.ts, 1, 27))
|
||||
>v.translate : Symbol(Vector.translate, Decl(index.d.ts, 11, 35))
|
||||
>v : Symbol(v, Decl(a.ts, 2, 3))
|
||||
>translate : Symbol(Vector.translate, Decl(index.d.ts, 11, 35))
|
||||
|
||||
p = v.reverse();
|
||||
>p : Symbol(p, Decl(a.ts, 4, 3))
|
||||
>v.reverse : Symbol(Vector.reverse, Decl(math2d-augment.d.ts, 4, 19))
|
||||
>v : Symbol(v, Decl(a.ts, 2, 3))
|
||||
>reverse : Symbol(Vector.reverse, Decl(math2d-augment.d.ts, 4, 19))
|
||||
|
||||
var t = p.x;
|
||||
>t : Symbol(t, Decl(a.ts, 6, 3))
|
||||
>p.x : Symbol(Math2d.Point.x, Decl(index.d.ts, 3, 24))
|
||||
>p : Symbol(p, Decl(a.ts, 4, 3))
|
||||
>x : Symbol(Math2d.Point.x, Decl(index.d.ts, 3, 24))
|
||||
|
||||
=== tests/cases/conformance/externalModules/node_modules/math2d/index.d.ts ===
|
||||
|
||||
export as namespace Math2d;
|
||||
|
||||
export interface Point {
|
||||
>Point : Symbol(Point, Decl(index.d.ts, 1, 27))
|
||||
|
||||
x: number;
|
||||
>x : Symbol(x, Decl(index.d.ts, 3, 24))
|
||||
|
||||
y: number;
|
||||
>y : Symbol(y, Decl(index.d.ts, 4, 11))
|
||||
}
|
||||
|
||||
export class Vector implements Point {
|
||||
>Vector : Symbol(Vector, Decl(index.d.ts, 6, 1), Decl(math2d-augment.d.ts, 2, 25))
|
||||
>Point : Symbol(Point, Decl(index.d.ts, 1, 27))
|
||||
|
||||
x: number;
|
||||
>x : Symbol(x, Decl(index.d.ts, 8, 38))
|
||||
|
||||
y: number;
|
||||
>y : Symbol(y, Decl(index.d.ts, 9, 11))
|
||||
|
||||
constructor(x: number, y: number);
|
||||
>x : Symbol(x, Decl(index.d.ts, 11, 13))
|
||||
>y : Symbol(y, Decl(index.d.ts, 11, 23))
|
||||
|
||||
translate(dx: number, dy: number): Vector;
|
||||
>translate : Symbol(translate, Decl(index.d.ts, 11, 35))
|
||||
>dx : Symbol(dx, Decl(index.d.ts, 13, 11))
|
||||
>dy : Symbol(dy, Decl(index.d.ts, 13, 22))
|
||||
>Vector : Symbol(Vector, Decl(index.d.ts, 6, 1), Decl(math2d-augment.d.ts, 2, 25))
|
||||
}
|
||||
|
||||
export function getLength(p: Vector): number;
|
||||
>getLength : Symbol(getLength, Decl(index.d.ts, 14, 1))
|
||||
>p : Symbol(p, Decl(index.d.ts, 16, 26))
|
||||
>Vector : Symbol(Vector, Decl(index.d.ts, 6, 1), Decl(math2d-augment.d.ts, 2, 25))
|
||||
|
||||
=== tests/cases/conformance/externalModules/math2d-augment.d.ts ===
|
||||
import * as Math2d from 'math2d';
|
||||
>Math2d : Symbol(Math2d, Decl(math2d-augment.d.ts, 0, 6))
|
||||
|
||||
// Augment the module
|
||||
declare module 'math2d' {
|
||||
// Add a method to the class
|
||||
interface Vector {
|
||||
>Vector : Symbol(Vector, Decl(index.d.ts, 6, 1), Decl(math2d-augment.d.ts, 2, 25))
|
||||
|
||||
reverse(): Math2d.Point;
|
||||
>reverse : Symbol(reverse, Decl(math2d-augment.d.ts, 4, 19))
|
||||
>Math2d : Symbol(Math2d, Decl(math2d-augment.d.ts, 0, 6))
|
||||
>Point : Symbol(Point, Decl(index.d.ts, 1, 27))
|
||||
}
|
||||
}
|
||||
|
||||
103
tests/baselines/reference/umd-augmentation-2.types
Normal file
103
tests/baselines/reference/umd-augmentation-2.types
Normal file
@ -0,0 +1,103 @@
|
||||
=== tests/cases/conformance/externalModules/a.ts ===
|
||||
/// <reference path="node_modules/math2d/index.d.ts" />
|
||||
/// <reference path="math2d-augment.d.ts" />
|
||||
let v = new Math2d.Vector(3, 2);
|
||||
>v : Vector
|
||||
>new Math2d.Vector(3, 2) : Vector
|
||||
>Math2d.Vector : typeof Math2d.Vector
|
||||
>Math2d : typeof Math2d
|
||||
>Vector : typeof Math2d.Vector
|
||||
>3 : number
|
||||
>2 : number
|
||||
|
||||
let magnitude = Math2d.getLength(v);
|
||||
>magnitude : number
|
||||
>Math2d.getLength(v) : number
|
||||
>Math2d.getLength : (p: Vector) => number
|
||||
>Math2d : typeof Math2d
|
||||
>getLength : (p: Vector) => number
|
||||
>v : Vector
|
||||
|
||||
let p: Math2d.Point = v.translate(5, 5);
|
||||
>p : Math2d.Point
|
||||
>Math2d : any
|
||||
>Point : Math2d.Point
|
||||
>v.translate(5, 5) : Vector
|
||||
>v.translate : (dx: number, dy: number) => Vector
|
||||
>v : Vector
|
||||
>translate : (dx: number, dy: number) => Vector
|
||||
>5 : number
|
||||
>5 : number
|
||||
|
||||
p = v.reverse();
|
||||
>p = v.reverse() : Math2d.Point
|
||||
>p : Math2d.Point
|
||||
>v.reverse() : Math2d.Point
|
||||
>v.reverse : () => Math2d.Point
|
||||
>v : Vector
|
||||
>reverse : () => Math2d.Point
|
||||
|
||||
var t = p.x;
|
||||
>t : number
|
||||
>p.x : number
|
||||
>p : Math2d.Point
|
||||
>x : number
|
||||
|
||||
=== tests/cases/conformance/externalModules/node_modules/math2d/index.d.ts ===
|
||||
|
||||
export as namespace Math2d;
|
||||
>Math2d : any
|
||||
|
||||
export interface Point {
|
||||
>Point : Point
|
||||
|
||||
x: number;
|
||||
>x : number
|
||||
|
||||
y: number;
|
||||
>y : number
|
||||
}
|
||||
|
||||
export class Vector implements Point {
|
||||
>Vector : Vector
|
||||
>Point : Point
|
||||
|
||||
x: number;
|
||||
>x : number
|
||||
|
||||
y: number;
|
||||
>y : number
|
||||
|
||||
constructor(x: number, y: number);
|
||||
>x : number
|
||||
>y : number
|
||||
|
||||
translate(dx: number, dy: number): Vector;
|
||||
>translate : (dx: number, dy: number) => Vector
|
||||
>dx : number
|
||||
>dy : number
|
||||
>Vector : Vector
|
||||
}
|
||||
|
||||
export function getLength(p: Vector): number;
|
||||
>getLength : (p: Vector) => number
|
||||
>p : Vector
|
||||
>Vector : Vector
|
||||
|
||||
=== tests/cases/conformance/externalModules/math2d-augment.d.ts ===
|
||||
import * as Math2d from 'math2d';
|
||||
>Math2d : typeof Math2d
|
||||
|
||||
// Augment the module
|
||||
declare module 'math2d' {
|
||||
// Add a method to the class
|
||||
interface Vector {
|
||||
>Vector : Vector
|
||||
|
||||
reverse(): Math2d.Point;
|
||||
>reverse : () => Point
|
||||
>Math2d : any
|
||||
>Point : Point
|
||||
}
|
||||
}
|
||||
|
||||
56
tests/baselines/reference/umd-augmentation-3.js
Normal file
56
tests/baselines/reference/umd-augmentation-3.js
Normal file
@ -0,0 +1,56 @@
|
||||
//// [tests/cases/conformance/externalModules/umd-augmentation-3.ts] ////
|
||||
|
||||
//// [index.d.ts]
|
||||
|
||||
export as namespace Math2d;
|
||||
|
||||
export = M2D;
|
||||
|
||||
declare namespace M2D {
|
||||
interface Point {
|
||||
x: number;
|
||||
y: number;
|
||||
}
|
||||
|
||||
class Vector implements Point {
|
||||
x: number;
|
||||
y: number;
|
||||
constructor(x: number, y: number);
|
||||
|
||||
translate(dx: number, dy: number): Vector;
|
||||
}
|
||||
|
||||
function getLength(p: Vector): number;
|
||||
|
||||
}
|
||||
|
||||
|
||||
//// [math2d-augment.d.ts]
|
||||
import * as Math2d from 'math2d';
|
||||
// Augment the module
|
||||
declare module 'math2d' {
|
||||
// Add a method to the class
|
||||
interface Vector {
|
||||
reverse(): Math2d.Point;
|
||||
}
|
||||
}
|
||||
|
||||
//// [b.ts]
|
||||
/// <reference path="math2d-augment.d.ts" />
|
||||
import * as m from 'math2d';
|
||||
let v = new m.Vector(3, 2);
|
||||
let magnitude = m.getLength(v);
|
||||
let p: m.Point = v.translate(5, 5);
|
||||
p = v.reverse();
|
||||
var t = p.x;
|
||||
|
||||
|
||||
//// [b.js]
|
||||
"use strict";
|
||||
/// <reference path="math2d-augment.d.ts" />
|
||||
var m = require('math2d');
|
||||
var v = new m.Vector(3, 2);
|
||||
var magnitude = m.getLength(v);
|
||||
var p = v.translate(5, 5);
|
||||
p = v.reverse();
|
||||
var t = p.x;
|
||||
104
tests/baselines/reference/umd-augmentation-3.symbols
Normal file
104
tests/baselines/reference/umd-augmentation-3.symbols
Normal file
@ -0,0 +1,104 @@
|
||||
=== tests/cases/conformance/externalModules/b.ts ===
|
||||
/// <reference path="math2d-augment.d.ts" />
|
||||
import * as m from 'math2d';
|
||||
>m : Symbol(m, Decl(b.ts, 1, 6))
|
||||
|
||||
let v = new m.Vector(3, 2);
|
||||
>v : Symbol(v, Decl(b.ts, 2, 3))
|
||||
>m.Vector : Symbol(m.Vector, Decl(index.d.ts, 9, 2), Decl(math2d-augment.d.ts, 2, 25))
|
||||
>m : Symbol(m, Decl(b.ts, 1, 6))
|
||||
>Vector : Symbol(m.Vector, Decl(index.d.ts, 9, 2), Decl(math2d-augment.d.ts, 2, 25))
|
||||
|
||||
let magnitude = m.getLength(v);
|
||||
>magnitude : Symbol(magnitude, Decl(b.ts, 3, 3))
|
||||
>m.getLength : Symbol(m.getLength, Decl(index.d.ts, 17, 2))
|
||||
>m : Symbol(m, Decl(b.ts, 1, 6))
|
||||
>getLength : Symbol(m.getLength, Decl(index.d.ts, 17, 2))
|
||||
>v : Symbol(v, Decl(b.ts, 2, 3))
|
||||
|
||||
let p: m.Point = v.translate(5, 5);
|
||||
>p : Symbol(p, Decl(b.ts, 4, 3))
|
||||
>m : Symbol(m, Decl(b.ts, 1, 6))
|
||||
>Point : Symbol(m.Point, Decl(index.d.ts, 5, 23))
|
||||
>v.translate : Symbol(m.Vector.translate, Decl(index.d.ts, 14, 36))
|
||||
>v : Symbol(v, Decl(b.ts, 2, 3))
|
||||
>translate : Symbol(m.Vector.translate, Decl(index.d.ts, 14, 36))
|
||||
|
||||
p = v.reverse();
|
||||
>p : Symbol(p, Decl(b.ts, 4, 3))
|
||||
>v.reverse : Symbol(m.Vector.reverse, Decl(math2d-augment.d.ts, 4, 19))
|
||||
>v : Symbol(v, Decl(b.ts, 2, 3))
|
||||
>reverse : Symbol(m.Vector.reverse, Decl(math2d-augment.d.ts, 4, 19))
|
||||
|
||||
var t = p.x;
|
||||
>t : Symbol(t, Decl(b.ts, 6, 3))
|
||||
>p.x : Symbol(m.Point.x, Decl(index.d.ts, 6, 18))
|
||||
>p : Symbol(p, Decl(b.ts, 4, 3))
|
||||
>x : Symbol(m.Point.x, Decl(index.d.ts, 6, 18))
|
||||
|
||||
=== tests/cases/conformance/externalModules/node_modules/math2d/index.d.ts ===
|
||||
|
||||
export as namespace Math2d;
|
||||
|
||||
export = M2D;
|
||||
>M2D : Symbol(M2D, Decl(index.d.ts, 3, 13))
|
||||
|
||||
declare namespace M2D {
|
||||
>M2D : Symbol(, Decl(index.d.ts, 3, 13), Decl(math2d-augment.d.ts, 0, 33))
|
||||
|
||||
interface Point {
|
||||
>Point : Symbol(Point, Decl(index.d.ts, 5, 23))
|
||||
|
||||
x: number;
|
||||
>x : Symbol(x, Decl(index.d.ts, 6, 18))
|
||||
|
||||
y: number;
|
||||
>y : Symbol(y, Decl(index.d.ts, 7, 12))
|
||||
}
|
||||
|
||||
class Vector implements Point {
|
||||
>Vector : Symbol(Vector, Decl(index.d.ts, 9, 2), Decl(math2d-augment.d.ts, 2, 25))
|
||||
>Point : Symbol(Point, Decl(index.d.ts, 5, 23))
|
||||
|
||||
x: number;
|
||||
>x : Symbol(x, Decl(index.d.ts, 11, 32))
|
||||
|
||||
y: number;
|
||||
>y : Symbol(y, Decl(index.d.ts, 12, 12))
|
||||
|
||||
constructor(x: number, y: number);
|
||||
>x : Symbol(x, Decl(index.d.ts, 14, 14))
|
||||
>y : Symbol(y, Decl(index.d.ts, 14, 24))
|
||||
|
||||
translate(dx: number, dy: number): Vector;
|
||||
>translate : Symbol(translate, Decl(index.d.ts, 14, 36))
|
||||
>dx : Symbol(dx, Decl(index.d.ts, 16, 12))
|
||||
>dy : Symbol(dy, Decl(index.d.ts, 16, 23))
|
||||
>Vector : Symbol(Vector, Decl(index.d.ts, 9, 2), Decl(math2d-augment.d.ts, 2, 25))
|
||||
}
|
||||
|
||||
function getLength(p: Vector): number;
|
||||
>getLength : Symbol(getLength, Decl(index.d.ts, 17, 2))
|
||||
>p : Symbol(p, Decl(index.d.ts, 19, 20))
|
||||
>Vector : Symbol(Vector, Decl(index.d.ts, 9, 2), Decl(math2d-augment.d.ts, 2, 25))
|
||||
|
||||
}
|
||||
|
||||
|
||||
=== tests/cases/conformance/externalModules/math2d-augment.d.ts ===
|
||||
import * as Math2d from 'math2d';
|
||||
>Math2d : Symbol(Math2d, Decl(math2d-augment.d.ts, 0, 6))
|
||||
|
||||
// Augment the module
|
||||
declare module 'math2d' {
|
||||
// Add a method to the class
|
||||
interface Vector {
|
||||
>Vector : Symbol(Vector, Decl(index.d.ts, 9, 2), Decl(math2d-augment.d.ts, 2, 25))
|
||||
|
||||
reverse(): Math2d.Point;
|
||||
>reverse : Symbol(reverse, Decl(math2d-augment.d.ts, 4, 19))
|
||||
>Math2d : Symbol(Math2d, Decl(math2d-augment.d.ts, 0, 6))
|
||||
>Point : Symbol(Point, Decl(index.d.ts, 5, 23))
|
||||
}
|
||||
}
|
||||
|
||||
114
tests/baselines/reference/umd-augmentation-3.types
Normal file
114
tests/baselines/reference/umd-augmentation-3.types
Normal file
@ -0,0 +1,114 @@
|
||||
=== tests/cases/conformance/externalModules/b.ts ===
|
||||
/// <reference path="math2d-augment.d.ts" />
|
||||
import * as m from 'math2d';
|
||||
>m : typeof m
|
||||
|
||||
let v = new m.Vector(3, 2);
|
||||
>v : m.Vector
|
||||
>new m.Vector(3, 2) : m.Vector
|
||||
>m.Vector : typeof m.Vector
|
||||
>m : typeof m
|
||||
>Vector : typeof m.Vector
|
||||
>3 : number
|
||||
>2 : number
|
||||
|
||||
let magnitude = m.getLength(v);
|
||||
>magnitude : number
|
||||
>m.getLength(v) : number
|
||||
>m.getLength : (p: m.Vector) => number
|
||||
>m : typeof m
|
||||
>getLength : (p: m.Vector) => number
|
||||
>v : m.Vector
|
||||
|
||||
let p: m.Point = v.translate(5, 5);
|
||||
>p : m.Point
|
||||
>m : any
|
||||
>Point : m.Point
|
||||
>v.translate(5, 5) : m.Vector
|
||||
>v.translate : (dx: number, dy: number) => m.Vector
|
||||
>v : m.Vector
|
||||
>translate : (dx: number, dy: number) => m.Vector
|
||||
>5 : number
|
||||
>5 : number
|
||||
|
||||
p = v.reverse();
|
||||
>p = v.reverse() : m.Point
|
||||
>p : m.Point
|
||||
>v.reverse() : m.Point
|
||||
>v.reverse : () => m.Point
|
||||
>v : m.Vector
|
||||
>reverse : () => m.Point
|
||||
|
||||
var t = p.x;
|
||||
>t : number
|
||||
>p.x : number
|
||||
>p : m.Point
|
||||
>x : number
|
||||
|
||||
=== tests/cases/conformance/externalModules/node_modules/math2d/index.d.ts ===
|
||||
|
||||
export as namespace Math2d;
|
||||
>Math2d : any
|
||||
|
||||
export = M2D;
|
||||
>M2D : typeof M2D
|
||||
|
||||
declare namespace M2D {
|
||||
>M2D : typeof
|
||||
|
||||
interface Point {
|
||||
>Point : Point
|
||||
|
||||
x: number;
|
||||
>x : number
|
||||
|
||||
y: number;
|
||||
>y : number
|
||||
}
|
||||
|
||||
class Vector implements Point {
|
||||
>Vector : Vector
|
||||
>Point : Point
|
||||
|
||||
x: number;
|
||||
>x : number
|
||||
|
||||
y: number;
|
||||
>y : number
|
||||
|
||||
constructor(x: number, y: number);
|
||||
>x : number
|
||||
>y : number
|
||||
|
||||
translate(dx: number, dy: number): Vector;
|
||||
>translate : (dx: number, dy: number) => Vector
|
||||
>dx : number
|
||||
>dy : number
|
||||
>Vector : Vector
|
||||
}
|
||||
|
||||
function getLength(p: Vector): number;
|
||||
>getLength : (p: Vector) => number
|
||||
>p : Vector
|
||||
>Vector : Vector
|
||||
|
||||
}
|
||||
|
||||
|
||||
=== tests/cases/conformance/externalModules/math2d-augment.d.ts ===
|
||||
import * as Math2d from 'math2d';
|
||||
>Math2d : typeof Math2d
|
||||
|
||||
// Augment the module
|
||||
declare module 'math2d' {
|
||||
// Add a method to the class
|
||||
interface Vector {
|
||||
>Vector : Vector
|
||||
|
||||
reverse(): Math2d.Point;
|
||||
>reverse : () => Point
|
||||
>Math2d : any
|
||||
>Point : Point
|
||||
}
|
||||
}
|
||||
|
||||
55
tests/baselines/reference/umd-augmentation-4.js
Normal file
55
tests/baselines/reference/umd-augmentation-4.js
Normal file
@ -0,0 +1,55 @@
|
||||
//// [tests/cases/conformance/externalModules/umd-augmentation-4.ts] ////
|
||||
|
||||
//// [index.d.ts]
|
||||
|
||||
export as namespace Math2d;
|
||||
|
||||
export = M2D;
|
||||
|
||||
declare namespace M2D {
|
||||
interface Point {
|
||||
x: number;
|
||||
y: number;
|
||||
}
|
||||
|
||||
class Vector implements Point {
|
||||
x: number;
|
||||
y: number;
|
||||
constructor(x: number, y: number);
|
||||
|
||||
translate(dx: number, dy: number): Vector;
|
||||
}
|
||||
|
||||
function getLength(p: Vector): number;
|
||||
|
||||
}
|
||||
|
||||
|
||||
//// [math2d-augment.d.ts]
|
||||
import * as Math2d from 'math2d';
|
||||
// Augment the module
|
||||
declare module 'math2d' {
|
||||
// Add a method to the class
|
||||
interface Vector {
|
||||
reverse(): Math2d.Point;
|
||||
}
|
||||
}
|
||||
|
||||
//// [a.ts]
|
||||
/// <reference path="node_modules/math2d/index.d.ts" />
|
||||
/// <reference path="math2d-augment.d.ts" />
|
||||
let v = new Math2d.Vector(3, 2);
|
||||
let magnitude = Math2d.getLength(v);
|
||||
let p: Math2d.Point = v.translate(5, 5);
|
||||
p = v.reverse();
|
||||
var t = p.x;
|
||||
|
||||
|
||||
//// [a.js]
|
||||
/// <reference path="node_modules/math2d/index.d.ts" />
|
||||
/// <reference path="math2d-augment.d.ts" />
|
||||
var v = new exports.Math2d.Vector(3, 2);
|
||||
var magnitude = exports.Math2d.getLength(v);
|
||||
var p = v.translate(5, 5);
|
||||
p = v.reverse();
|
||||
var t = p.x;
|
||||
102
tests/baselines/reference/umd-augmentation-4.symbols
Normal file
102
tests/baselines/reference/umd-augmentation-4.symbols
Normal file
@ -0,0 +1,102 @@
|
||||
=== tests/cases/conformance/externalModules/a.ts ===
|
||||
/// <reference path="node_modules/math2d/index.d.ts" />
|
||||
/// <reference path="math2d-augment.d.ts" />
|
||||
let v = new Math2d.Vector(3, 2);
|
||||
>v : Symbol(v, Decl(a.ts, 2, 3))
|
||||
>Math2d.Vector : Symbol(Math2d.Vector, Decl(index.d.ts, 9, 2), Decl(math2d-augment.d.ts, 2, 25))
|
||||
>Math2d : Symbol(Math2d, Decl(index.d.ts, 0, 0))
|
||||
>Vector : Symbol(Math2d.Vector, Decl(index.d.ts, 9, 2), Decl(math2d-augment.d.ts, 2, 25))
|
||||
|
||||
let magnitude = Math2d.getLength(v);
|
||||
>magnitude : Symbol(magnitude, Decl(a.ts, 3, 3))
|
||||
>Math2d.getLength : Symbol(Math2d.getLength, Decl(index.d.ts, 17, 2))
|
||||
>Math2d : Symbol(Math2d, Decl(index.d.ts, 0, 0))
|
||||
>getLength : Symbol(Math2d.getLength, Decl(index.d.ts, 17, 2))
|
||||
>v : Symbol(v, Decl(a.ts, 2, 3))
|
||||
|
||||
let p: Math2d.Point = v.translate(5, 5);
|
||||
>p : Symbol(p, Decl(a.ts, 4, 3))
|
||||
>Math2d : Symbol(Math2d, Decl(index.d.ts, 0, 0))
|
||||
>Point : Symbol(Math2d.Point, Decl(index.d.ts, 5, 23))
|
||||
>v.translate : Symbol(Math2d.Vector.translate, Decl(index.d.ts, 14, 36))
|
||||
>v : Symbol(v, Decl(a.ts, 2, 3))
|
||||
>translate : Symbol(Math2d.Vector.translate, Decl(index.d.ts, 14, 36))
|
||||
|
||||
p = v.reverse();
|
||||
>p : Symbol(p, Decl(a.ts, 4, 3))
|
||||
>v.reverse : Symbol(Math2d.Vector.reverse, Decl(math2d-augment.d.ts, 4, 19))
|
||||
>v : Symbol(v, Decl(a.ts, 2, 3))
|
||||
>reverse : Symbol(Math2d.Vector.reverse, Decl(math2d-augment.d.ts, 4, 19))
|
||||
|
||||
var t = p.x;
|
||||
>t : Symbol(t, Decl(a.ts, 6, 3))
|
||||
>p.x : Symbol(Math2d.Point.x, Decl(index.d.ts, 6, 18))
|
||||
>p : Symbol(p, Decl(a.ts, 4, 3))
|
||||
>x : Symbol(Math2d.Point.x, Decl(index.d.ts, 6, 18))
|
||||
|
||||
=== tests/cases/conformance/externalModules/node_modules/math2d/index.d.ts ===
|
||||
|
||||
export as namespace Math2d;
|
||||
|
||||
export = M2D;
|
||||
>M2D : Symbol(M2D, Decl(index.d.ts, 3, 13))
|
||||
|
||||
declare namespace M2D {
|
||||
>M2D : Symbol(Math2d, Decl(index.d.ts, 3, 13), Decl(math2d-augment.d.ts, 0, 33))
|
||||
|
||||
interface Point {
|
||||
>Point : Symbol(Point, Decl(index.d.ts, 5, 23))
|
||||
|
||||
x: number;
|
||||
>x : Symbol(x, Decl(index.d.ts, 6, 18))
|
||||
|
||||
y: number;
|
||||
>y : Symbol(y, Decl(index.d.ts, 7, 12))
|
||||
}
|
||||
|
||||
class Vector implements Point {
|
||||
>Vector : Symbol(Vector, Decl(index.d.ts, 9, 2), Decl(math2d-augment.d.ts, 2, 25))
|
||||
>Point : Symbol(Point, Decl(index.d.ts, 5, 23))
|
||||
|
||||
x: number;
|
||||
>x : Symbol(x, Decl(index.d.ts, 11, 32))
|
||||
|
||||
y: number;
|
||||
>y : Symbol(y, Decl(index.d.ts, 12, 12))
|
||||
|
||||
constructor(x: number, y: number);
|
||||
>x : Symbol(x, Decl(index.d.ts, 14, 14))
|
||||
>y : Symbol(y, Decl(index.d.ts, 14, 24))
|
||||
|
||||
translate(dx: number, dy: number): Vector;
|
||||
>translate : Symbol(translate, Decl(index.d.ts, 14, 36))
|
||||
>dx : Symbol(dx, Decl(index.d.ts, 16, 12))
|
||||
>dy : Symbol(dy, Decl(index.d.ts, 16, 23))
|
||||
>Vector : Symbol(Vector, Decl(index.d.ts, 9, 2), Decl(math2d-augment.d.ts, 2, 25))
|
||||
}
|
||||
|
||||
function getLength(p: Vector): number;
|
||||
>getLength : Symbol(getLength, Decl(index.d.ts, 17, 2))
|
||||
>p : Symbol(p, Decl(index.d.ts, 19, 20))
|
||||
>Vector : Symbol(Vector, Decl(index.d.ts, 9, 2), Decl(math2d-augment.d.ts, 2, 25))
|
||||
|
||||
}
|
||||
|
||||
|
||||
=== tests/cases/conformance/externalModules/math2d-augment.d.ts ===
|
||||
import * as Math2d from 'math2d';
|
||||
>Math2d : Symbol(Math2d, Decl(math2d-augment.d.ts, 0, 6))
|
||||
|
||||
// Augment the module
|
||||
declare module 'math2d' {
|
||||
// Add a method to the class
|
||||
interface Vector {
|
||||
>Vector : Symbol(Vector, Decl(index.d.ts, 9, 2), Decl(math2d-augment.d.ts, 2, 25))
|
||||
|
||||
reverse(): Math2d.Point;
|
||||
>reverse : Symbol(reverse, Decl(math2d-augment.d.ts, 4, 19))
|
||||
>Math2d : Symbol(Math2d, Decl(math2d-augment.d.ts, 0, 6))
|
||||
>Point : Symbol(Point, Decl(index.d.ts, 5, 23))
|
||||
}
|
||||
}
|
||||
|
||||
112
tests/baselines/reference/umd-augmentation-4.types
Normal file
112
tests/baselines/reference/umd-augmentation-4.types
Normal file
@ -0,0 +1,112 @@
|
||||
=== tests/cases/conformance/externalModules/a.ts ===
|
||||
/// <reference path="node_modules/math2d/index.d.ts" />
|
||||
/// <reference path="math2d-augment.d.ts" />
|
||||
let v = new Math2d.Vector(3, 2);
|
||||
>v : Math2d.Vector
|
||||
>new Math2d.Vector(3, 2) : Math2d.Vector
|
||||
>Math2d.Vector : typeof Math2d.Vector
|
||||
>Math2d : typeof Math2d
|
||||
>Vector : typeof Math2d.Vector
|
||||
>3 : number
|
||||
>2 : number
|
||||
|
||||
let magnitude = Math2d.getLength(v);
|
||||
>magnitude : number
|
||||
>Math2d.getLength(v) : number
|
||||
>Math2d.getLength : (p: Math2d.Vector) => number
|
||||
>Math2d : typeof Math2d
|
||||
>getLength : (p: Math2d.Vector) => number
|
||||
>v : Math2d.Vector
|
||||
|
||||
let p: Math2d.Point = v.translate(5, 5);
|
||||
>p : Math2d.Point
|
||||
>Math2d : any
|
||||
>Point : Math2d.Point
|
||||
>v.translate(5, 5) : Math2d.Vector
|
||||
>v.translate : (dx: number, dy: number) => Math2d.Vector
|
||||
>v : Math2d.Vector
|
||||
>translate : (dx: number, dy: number) => Math2d.Vector
|
||||
>5 : number
|
||||
>5 : number
|
||||
|
||||
p = v.reverse();
|
||||
>p = v.reverse() : Math2d.Point
|
||||
>p : Math2d.Point
|
||||
>v.reverse() : Math2d.Point
|
||||
>v.reverse : () => Math2d.Point
|
||||
>v : Math2d.Vector
|
||||
>reverse : () => Math2d.Point
|
||||
|
||||
var t = p.x;
|
||||
>t : number
|
||||
>p.x : number
|
||||
>p : Math2d.Point
|
||||
>x : number
|
||||
|
||||
=== tests/cases/conformance/externalModules/node_modules/math2d/index.d.ts ===
|
||||
|
||||
export as namespace Math2d;
|
||||
>Math2d : any
|
||||
|
||||
export = M2D;
|
||||
>M2D : typeof M2D
|
||||
|
||||
declare namespace M2D {
|
||||
>M2D : typeof Math2d
|
||||
|
||||
interface Point {
|
||||
>Point : Point
|
||||
|
||||
x: number;
|
||||
>x : number
|
||||
|
||||
y: number;
|
||||
>y : number
|
||||
}
|
||||
|
||||
class Vector implements Point {
|
||||
>Vector : Vector
|
||||
>Point : Point
|
||||
|
||||
x: number;
|
||||
>x : number
|
||||
|
||||
y: number;
|
||||
>y : number
|
||||
|
||||
constructor(x: number, y: number);
|
||||
>x : number
|
||||
>y : number
|
||||
|
||||
translate(dx: number, dy: number): Vector;
|
||||
>translate : (dx: number, dy: number) => Vector
|
||||
>dx : number
|
||||
>dy : number
|
||||
>Vector : Vector
|
||||
}
|
||||
|
||||
function getLength(p: Vector): number;
|
||||
>getLength : (p: Vector) => number
|
||||
>p : Vector
|
||||
>Vector : Vector
|
||||
|
||||
}
|
||||
|
||||
|
||||
=== tests/cases/conformance/externalModules/math2d-augment.d.ts ===
|
||||
import * as Math2d from 'math2d';
|
||||
>Math2d : typeof Math2d
|
||||
|
||||
// Augment the module
|
||||
declare module 'math2d' {
|
||||
// Add a method to the class
|
||||
interface Vector {
|
||||
>Vector : Vector
|
||||
|
||||
reverse(): Math2d.Point;
|
||||
>reverse : () => Point
|
||||
>Math2d : any
|
||||
>Point : Point
|
||||
}
|
||||
}
|
||||
|
||||
57
tests/baselines/reference/umd-errors.errors.txt
Normal file
57
tests/baselines/reference/umd-errors.errors.txt
Normal file
@ -0,0 +1,57 @@
|
||||
tests/cases/conformance/externalModules/err1.d.ts(3,1): error TS1314: Global module exports may only appear in module files.
|
||||
tests/cases/conformance/externalModules/err2.d.ts(3,2): error TS1316: Global module exports may only appear at top level.
|
||||
tests/cases/conformance/externalModules/err3.d.ts(3,1): error TS1184: Modifiers cannot appear here.
|
||||
tests/cases/conformance/externalModules/err3.d.ts(4,1): error TS1184: Modifiers cannot appear here.
|
||||
tests/cases/conformance/externalModules/err3.d.ts(5,1): error TS1184: Modifiers cannot appear here.
|
||||
tests/cases/conformance/externalModules/err3.d.ts(6,7): error TS1134: Variable declaration expected.
|
||||
tests/cases/conformance/externalModules/err4.d.ts(3,2): error TS1316: Global module exports may only appear at top level.
|
||||
tests/cases/conformance/externalModules/err5.ts(3,1): error TS1315: Global module exports may only appear in declaration files.
|
||||
|
||||
|
||||
==== tests/cases/conformance/externalModules/err1.d.ts (1 errors) ====
|
||||
|
||||
// Illegal, can't be in script file
|
||||
export as namespace Foo;
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS1314: Global module exports may only appear in module files.
|
||||
|
||||
==== tests/cases/conformance/externalModules/err2.d.ts (1 errors) ====
|
||||
// Illegal, can't be in external ambient module
|
||||
declare module "Foo" {
|
||||
export as namespace Bar;
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS1316: Global module exports may only appear at top level.
|
||||
}
|
||||
|
||||
==== tests/cases/conformance/externalModules/err3.d.ts (4 errors) ====
|
||||
// Illegal, can't have modifiers
|
||||
export var p;
|
||||
static export as namespace oo1;
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS1184: Modifiers cannot appear here.
|
||||
declare export as namespace oo2;
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS1184: Modifiers cannot appear here.
|
||||
public export as namespace oo3;
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS1184: Modifiers cannot appear here.
|
||||
const export as namespace oo4;
|
||||
~~~~~~
|
||||
!!! error TS1134: Variable declaration expected.
|
||||
|
||||
==== tests/cases/conformance/externalModules/err4.d.ts (1 errors) ====
|
||||
// Illegal, must be at top-level
|
||||
export namespace B {
|
||||
export as namespace C1;
|
||||
~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS1316: Global module exports may only appear at top level.
|
||||
}
|
||||
|
||||
==== tests/cases/conformance/externalModules/err5.ts (1 errors) ====
|
||||
// Illegal, may not appear in implementation files
|
||||
export var v;
|
||||
export as namespace C2;
|
||||
~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS1315: Global module exports may only appear in declaration files.
|
||||
|
||||
|
||||
36
tests/baselines/reference/umd-errors.js
Normal file
36
tests/baselines/reference/umd-errors.js
Normal file
@ -0,0 +1,36 @@
|
||||
//// [tests/cases/conformance/externalModules/umd-errors.ts] ////
|
||||
|
||||
//// [err1.d.ts]
|
||||
|
||||
// Illegal, can't be in script file
|
||||
export as namespace Foo;
|
||||
|
||||
//// [err2.d.ts]
|
||||
// Illegal, can't be in external ambient module
|
||||
declare module "Foo" {
|
||||
export as namespace Bar;
|
||||
}
|
||||
|
||||
//// [err3.d.ts]
|
||||
// Illegal, can't have modifiers
|
||||
export var p;
|
||||
static export as namespace oo1;
|
||||
declare export as namespace oo2;
|
||||
public export as namespace oo3;
|
||||
const export as namespace oo4;
|
||||
|
||||
//// [err4.d.ts]
|
||||
// Illegal, must be at top-level
|
||||
export namespace B {
|
||||
export as namespace C1;
|
||||
}
|
||||
|
||||
//// [err5.ts]
|
||||
// Illegal, may not appear in implementation files
|
||||
export var v;
|
||||
export as namespace C2;
|
||||
|
||||
|
||||
|
||||
//// [err5.js]
|
||||
"use strict";
|
||||
21
tests/baselines/reference/umd1.js
Normal file
21
tests/baselines/reference/umd1.js
Normal file
@ -0,0 +1,21 @@
|
||||
//// [tests/cases/conformance/externalModules/umd1.ts] ////
|
||||
|
||||
//// [foo.d.ts]
|
||||
|
||||
export var x: number;
|
||||
export function fn(): void;
|
||||
export interface Thing { n: typeof x }
|
||||
export as namespace Foo;
|
||||
|
||||
//// [a.ts]
|
||||
/// <reference path="foo.d.ts" />
|
||||
Foo.fn();
|
||||
let x: Foo.Thing;
|
||||
let y: number = x.n;
|
||||
|
||||
|
||||
//// [a.js]
|
||||
/// <reference path="foo.d.ts" />
|
||||
exports.Foo.fn();
|
||||
var x;
|
||||
var y = x.n;
|
||||
33
tests/baselines/reference/umd1.symbols
Normal file
33
tests/baselines/reference/umd1.symbols
Normal file
@ -0,0 +1,33 @@
|
||||
=== tests/cases/conformance/externalModules/a.ts ===
|
||||
/// <reference path="foo.d.ts" />
|
||||
Foo.fn();
|
||||
>Foo.fn : Symbol(Foo.fn, Decl(foo.d.ts, 1, 21))
|
||||
>Foo : Symbol(Foo, Decl(foo.d.ts, 3, 38))
|
||||
>fn : Symbol(Foo.fn, Decl(foo.d.ts, 1, 21))
|
||||
|
||||
let x: Foo.Thing;
|
||||
>x : Symbol(x, Decl(a.ts, 2, 3))
|
||||
>Foo : Symbol(Foo, Decl(foo.d.ts, 3, 38))
|
||||
>Thing : Symbol(Foo.Thing, Decl(foo.d.ts, 2, 27))
|
||||
|
||||
let y: number = x.n;
|
||||
>y : Symbol(y, Decl(a.ts, 3, 3))
|
||||
>x.n : Symbol(Foo.Thing.n, Decl(foo.d.ts, 3, 24))
|
||||
>x : Symbol(x, Decl(a.ts, 2, 3))
|
||||
>n : Symbol(Foo.Thing.n, Decl(foo.d.ts, 3, 24))
|
||||
|
||||
=== tests/cases/conformance/externalModules/foo.d.ts ===
|
||||
|
||||
export var x: number;
|
||||
>x : Symbol(x, Decl(foo.d.ts, 1, 10))
|
||||
|
||||
export function fn(): void;
|
||||
>fn : Symbol(fn, Decl(foo.d.ts, 1, 21))
|
||||
|
||||
export interface Thing { n: typeof x }
|
||||
>Thing : Symbol(Thing, Decl(foo.d.ts, 2, 27))
|
||||
>n : Symbol(n, Decl(foo.d.ts, 3, 24))
|
||||
>x : Symbol(x, Decl(foo.d.ts, 1, 10))
|
||||
|
||||
export as namespace Foo;
|
||||
|
||||
35
tests/baselines/reference/umd1.types
Normal file
35
tests/baselines/reference/umd1.types
Normal file
@ -0,0 +1,35 @@
|
||||
=== tests/cases/conformance/externalModules/a.ts ===
|
||||
/// <reference path="foo.d.ts" />
|
||||
Foo.fn();
|
||||
>Foo.fn() : void
|
||||
>Foo.fn : () => void
|
||||
>Foo : typeof Foo
|
||||
>fn : () => void
|
||||
|
||||
let x: Foo.Thing;
|
||||
>x : Foo.Thing
|
||||
>Foo : any
|
||||
>Thing : Foo.Thing
|
||||
|
||||
let y: number = x.n;
|
||||
>y : number
|
||||
>x.n : number
|
||||
>x : Foo.Thing
|
||||
>n : number
|
||||
|
||||
=== tests/cases/conformance/externalModules/foo.d.ts ===
|
||||
|
||||
export var x: number;
|
||||
>x : number
|
||||
|
||||
export function fn(): void;
|
||||
>fn : () => void
|
||||
|
||||
export interface Thing { n: typeof x }
|
||||
>Thing : Thing
|
||||
>n : number
|
||||
>x : number
|
||||
|
||||
export as namespace Foo;
|
||||
>Foo : any
|
||||
|
||||
19
tests/baselines/reference/umd2.errors.txt
Normal file
19
tests/baselines/reference/umd2.errors.txt
Normal file
@ -0,0 +1,19 @@
|
||||
tests/cases/conformance/externalModules/a.ts(1,1): error TS2304: Cannot find name 'Foo'.
|
||||
tests/cases/conformance/externalModules/a.ts(2,8): error TS2503: Cannot find namespace 'Foo'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/externalModules/a.ts (2 errors) ====
|
||||
Foo.fn();
|
||||
~~~
|
||||
!!! error TS2304: Cannot find name 'Foo'.
|
||||
let x: Foo.Thing;
|
||||
~~~
|
||||
!!! error TS2503: Cannot find namespace 'Foo'.
|
||||
let y: number = x.n;
|
||||
|
||||
==== tests/cases/conformance/externalModules/foo.d.ts (0 errors) ====
|
||||
|
||||
export var x: number;
|
||||
export function fn(): void;
|
||||
export as namespace Foo;
|
||||
|
||||
18
tests/baselines/reference/umd2.js
Normal file
18
tests/baselines/reference/umd2.js
Normal file
@ -0,0 +1,18 @@
|
||||
//// [tests/cases/conformance/externalModules/umd2.ts] ////
|
||||
|
||||
//// [foo.d.ts]
|
||||
|
||||
export var x: number;
|
||||
export function fn(): void;
|
||||
export as namespace Foo;
|
||||
|
||||
//// [a.ts]
|
||||
Foo.fn();
|
||||
let x: Foo.Thing;
|
||||
let y: number = x.n;
|
||||
|
||||
|
||||
//// [a.js]
|
||||
Foo.fn();
|
||||
var x;
|
||||
var y = x.n;
|
||||
22
tests/baselines/reference/umd3.js
Normal file
22
tests/baselines/reference/umd3.js
Normal file
@ -0,0 +1,22 @@
|
||||
//// [tests/cases/conformance/externalModules/umd3.ts] ////
|
||||
|
||||
//// [foo.d.ts]
|
||||
|
||||
export var x: number;
|
||||
export function fn(): void;
|
||||
export interface Thing { n: typeof x }
|
||||
export as namespace Foo;
|
||||
|
||||
//// [a.ts]
|
||||
import * as Foo from './foo';
|
||||
Foo.fn();
|
||||
let x: Foo.Thing;
|
||||
let y: number = x.n;
|
||||
|
||||
|
||||
//// [a.js]
|
||||
"use strict";
|
||||
var Foo = require('./foo');
|
||||
Foo.fn();
|
||||
var x;
|
||||
var y = x.n;
|
||||
35
tests/baselines/reference/umd3.symbols
Normal file
35
tests/baselines/reference/umd3.symbols
Normal file
@ -0,0 +1,35 @@
|
||||
=== tests/cases/conformance/externalModules/a.ts ===
|
||||
import * as Foo from './foo';
|
||||
>Foo : Symbol(Foo, Decl(a.ts, 0, 6))
|
||||
|
||||
Foo.fn();
|
||||
>Foo.fn : Symbol(Foo.fn, Decl(foo.d.ts, 1, 21))
|
||||
>Foo : Symbol(Foo, Decl(a.ts, 0, 6))
|
||||
>fn : Symbol(Foo.fn, Decl(foo.d.ts, 1, 21))
|
||||
|
||||
let x: Foo.Thing;
|
||||
>x : Symbol(x, Decl(a.ts, 2, 3))
|
||||
>Foo : Symbol(Foo, Decl(a.ts, 0, 6))
|
||||
>Thing : Symbol(Foo.Thing, Decl(foo.d.ts, 2, 27))
|
||||
|
||||
let y: number = x.n;
|
||||
>y : Symbol(y, Decl(a.ts, 3, 3))
|
||||
>x.n : Symbol(Foo.Thing.n, Decl(foo.d.ts, 3, 24))
|
||||
>x : Symbol(x, Decl(a.ts, 2, 3))
|
||||
>n : Symbol(Foo.Thing.n, Decl(foo.d.ts, 3, 24))
|
||||
|
||||
=== tests/cases/conformance/externalModules/foo.d.ts ===
|
||||
|
||||
export var x: number;
|
||||
>x : Symbol(x, Decl(foo.d.ts, 1, 10))
|
||||
|
||||
export function fn(): void;
|
||||
>fn : Symbol(fn, Decl(foo.d.ts, 1, 21))
|
||||
|
||||
export interface Thing { n: typeof x }
|
||||
>Thing : Symbol(Thing, Decl(foo.d.ts, 2, 27))
|
||||
>n : Symbol(n, Decl(foo.d.ts, 3, 24))
|
||||
>x : Symbol(x, Decl(foo.d.ts, 1, 10))
|
||||
|
||||
export as namespace Foo;
|
||||
|
||||
37
tests/baselines/reference/umd3.types
Normal file
37
tests/baselines/reference/umd3.types
Normal file
@ -0,0 +1,37 @@
|
||||
=== tests/cases/conformance/externalModules/a.ts ===
|
||||
import * as Foo from './foo';
|
||||
>Foo : typeof Foo
|
||||
|
||||
Foo.fn();
|
||||
>Foo.fn() : void
|
||||
>Foo.fn : () => void
|
||||
>Foo : typeof Foo
|
||||
>fn : () => void
|
||||
|
||||
let x: Foo.Thing;
|
||||
>x : Foo.Thing
|
||||
>Foo : any
|
||||
>Thing : Foo.Thing
|
||||
|
||||
let y: number = x.n;
|
||||
>y : number
|
||||
>x.n : number
|
||||
>x : Foo.Thing
|
||||
>n : number
|
||||
|
||||
=== tests/cases/conformance/externalModules/foo.d.ts ===
|
||||
|
||||
export var x: number;
|
||||
>x : number
|
||||
|
||||
export function fn(): void;
|
||||
>fn : () => void
|
||||
|
||||
export interface Thing { n: typeof x }
|
||||
>Thing : Thing
|
||||
>n : number
|
||||
>x : number
|
||||
|
||||
export as namespace Foo;
|
||||
>Foo : any
|
||||
|
||||
22
tests/baselines/reference/umd4.js
Normal file
22
tests/baselines/reference/umd4.js
Normal file
@ -0,0 +1,22 @@
|
||||
//// [tests/cases/conformance/externalModules/umd4.ts] ////
|
||||
|
||||
//// [foo.d.ts]
|
||||
|
||||
export var x: number;
|
||||
export function fn(): void;
|
||||
export interface Thing { n: typeof x }
|
||||
export as namespace Foo;
|
||||
|
||||
//// [a.ts]
|
||||
import * as Bar from './foo';
|
||||
Bar.fn();
|
||||
let x: Bar.Thing;
|
||||
let y: number = x.n;
|
||||
|
||||
|
||||
//// [a.js]
|
||||
"use strict";
|
||||
var Bar = require('./foo');
|
||||
Bar.fn();
|
||||
var x;
|
||||
var y = x.n;
|
||||
35
tests/baselines/reference/umd4.symbols
Normal file
35
tests/baselines/reference/umd4.symbols
Normal file
@ -0,0 +1,35 @@
|
||||
=== tests/cases/conformance/externalModules/a.ts ===
|
||||
import * as Bar from './foo';
|
||||
>Bar : Symbol(Bar, Decl(a.ts, 0, 6))
|
||||
|
||||
Bar.fn();
|
||||
>Bar.fn : Symbol(Bar.fn, Decl(foo.d.ts, 1, 21))
|
||||
>Bar : Symbol(Bar, Decl(a.ts, 0, 6))
|
||||
>fn : Symbol(Bar.fn, Decl(foo.d.ts, 1, 21))
|
||||
|
||||
let x: Bar.Thing;
|
||||
>x : Symbol(x, Decl(a.ts, 2, 3))
|
||||
>Bar : Symbol(Bar, Decl(a.ts, 0, 6))
|
||||
>Thing : Symbol(Bar.Thing, Decl(foo.d.ts, 2, 27))
|
||||
|
||||
let y: number = x.n;
|
||||
>y : Symbol(y, Decl(a.ts, 3, 3))
|
||||
>x.n : Symbol(Bar.Thing.n, Decl(foo.d.ts, 3, 24))
|
||||
>x : Symbol(x, Decl(a.ts, 2, 3))
|
||||
>n : Symbol(Bar.Thing.n, Decl(foo.d.ts, 3, 24))
|
||||
|
||||
=== tests/cases/conformance/externalModules/foo.d.ts ===
|
||||
|
||||
export var x: number;
|
||||
>x : Symbol(x, Decl(foo.d.ts, 1, 10))
|
||||
|
||||
export function fn(): void;
|
||||
>fn : Symbol(fn, Decl(foo.d.ts, 1, 21))
|
||||
|
||||
export interface Thing { n: typeof x }
|
||||
>Thing : Symbol(Thing, Decl(foo.d.ts, 2, 27))
|
||||
>n : Symbol(n, Decl(foo.d.ts, 3, 24))
|
||||
>x : Symbol(x, Decl(foo.d.ts, 1, 10))
|
||||
|
||||
export as namespace Foo;
|
||||
|
||||
37
tests/baselines/reference/umd4.types
Normal file
37
tests/baselines/reference/umd4.types
Normal file
@ -0,0 +1,37 @@
|
||||
=== tests/cases/conformance/externalModules/a.ts ===
|
||||
import * as Bar from './foo';
|
||||
>Bar : typeof Bar
|
||||
|
||||
Bar.fn();
|
||||
>Bar.fn() : void
|
||||
>Bar.fn : () => void
|
||||
>Bar : typeof Bar
|
||||
>fn : () => void
|
||||
|
||||
let x: Bar.Thing;
|
||||
>x : Bar.Thing
|
||||
>Bar : any
|
||||
>Thing : Bar.Thing
|
||||
|
||||
let y: number = x.n;
|
||||
>y : number
|
||||
>x.n : number
|
||||
>x : Bar.Thing
|
||||
>n : number
|
||||
|
||||
=== tests/cases/conformance/externalModules/foo.d.ts ===
|
||||
|
||||
export var x: number;
|
||||
>x : number
|
||||
|
||||
export function fn(): void;
|
||||
>fn : () => void
|
||||
|
||||
export interface Thing { n: typeof x }
|
||||
>Thing : Thing
|
||||
>n : number
|
||||
>x : number
|
||||
|
||||
export as namespace Foo;
|
||||
>Foo : any
|
||||
|
||||
20
tests/baselines/reference/umd5.errors.txt
Normal file
20
tests/baselines/reference/umd5.errors.txt
Normal file
@ -0,0 +1,20 @@
|
||||
tests/cases/conformance/externalModules/a.ts(6,9): error TS2304: Cannot find name 'Foo'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/externalModules/a.ts (1 errors) ====
|
||||
import * as Bar from './foo';
|
||||
Bar.fn();
|
||||
let x: Bar.Thing;
|
||||
let y: number = x.n;
|
||||
// should error
|
||||
let z = Foo;
|
||||
~~~
|
||||
!!! error TS2304: Cannot find name 'Foo'.
|
||||
|
||||
==== tests/cases/conformance/externalModules/foo.d.ts (0 errors) ====
|
||||
|
||||
export var x: number;
|
||||
export function fn(): void;
|
||||
export interface Thing { n: typeof x }
|
||||
export as namespace Foo;
|
||||
|
||||
26
tests/baselines/reference/umd5.js
Normal file
26
tests/baselines/reference/umd5.js
Normal file
@ -0,0 +1,26 @@
|
||||
//// [tests/cases/conformance/externalModules/umd5.ts] ////
|
||||
|
||||
//// [foo.d.ts]
|
||||
|
||||
export var x: number;
|
||||
export function fn(): void;
|
||||
export interface Thing { n: typeof x }
|
||||
export as namespace Foo;
|
||||
|
||||
//// [a.ts]
|
||||
import * as Bar from './foo';
|
||||
Bar.fn();
|
||||
let x: Bar.Thing;
|
||||
let y: number = x.n;
|
||||
// should error
|
||||
let z = Foo;
|
||||
|
||||
|
||||
//// [a.js]
|
||||
"use strict";
|
||||
var Bar = require('./foo');
|
||||
Bar.fn();
|
||||
var x;
|
||||
var y = x.n;
|
||||
// should error
|
||||
var z = Foo;
|
||||
18
tests/baselines/reference/umd6.js
Normal file
18
tests/baselines/reference/umd6.js
Normal file
@ -0,0 +1,18 @@
|
||||
//// [tests/cases/conformance/externalModules/umd6.ts] ////
|
||||
|
||||
//// [foo.d.ts]
|
||||
|
||||
declare namespace Thing {
|
||||
export function fn(): number;
|
||||
}
|
||||
export = Thing;
|
||||
export as namespace Foo;
|
||||
|
||||
//// [a.ts]
|
||||
/// <reference path="foo.d.ts" />
|
||||
let y: number = Foo.fn();
|
||||
|
||||
|
||||
//// [a.js]
|
||||
/// <reference path="foo.d.ts" />
|
||||
var y = exports.Foo.fn();
|
||||
21
tests/baselines/reference/umd6.symbols
Normal file
21
tests/baselines/reference/umd6.symbols
Normal file
@ -0,0 +1,21 @@
|
||||
=== tests/cases/conformance/externalModules/a.ts ===
|
||||
/// <reference path="foo.d.ts" />
|
||||
let y: number = Foo.fn();
|
||||
>y : Symbol(y, Decl(a.ts, 1, 3))
|
||||
>Foo.fn : Symbol(Foo.fn, Decl(foo.d.ts, 1, 25))
|
||||
>Foo : Symbol(Foo, Decl(foo.d.ts, 4, 15))
|
||||
>fn : Symbol(Foo.fn, Decl(foo.d.ts, 1, 25))
|
||||
|
||||
=== tests/cases/conformance/externalModules/foo.d.ts ===
|
||||
|
||||
declare namespace Thing {
|
||||
>Thing : Symbol(Thing, Decl(foo.d.ts, 0, 0))
|
||||
|
||||
export function fn(): number;
|
||||
>fn : Symbol(fn, Decl(foo.d.ts, 1, 25))
|
||||
}
|
||||
export = Thing;
|
||||
>Thing : Symbol(Thing, Decl(foo.d.ts, 0, 0))
|
||||
|
||||
export as namespace Foo;
|
||||
|
||||
23
tests/baselines/reference/umd6.types
Normal file
23
tests/baselines/reference/umd6.types
Normal file
@ -0,0 +1,23 @@
|
||||
=== tests/cases/conformance/externalModules/a.ts ===
|
||||
/// <reference path="foo.d.ts" />
|
||||
let y: number = Foo.fn();
|
||||
>y : number
|
||||
>Foo.fn() : number
|
||||
>Foo.fn : () => number
|
||||
>Foo : typeof Foo
|
||||
>fn : () => number
|
||||
|
||||
=== tests/cases/conformance/externalModules/foo.d.ts ===
|
||||
|
||||
declare namespace Thing {
|
||||
>Thing : typeof Thing
|
||||
|
||||
export function fn(): number;
|
||||
>fn : () => number
|
||||
}
|
||||
export = Thing;
|
||||
>Thing : typeof Thing
|
||||
|
||||
export as namespace Foo;
|
||||
>Foo : any
|
||||
|
||||
16
tests/baselines/reference/umd7.js
Normal file
16
tests/baselines/reference/umd7.js
Normal file
@ -0,0 +1,16 @@
|
||||
//// [tests/cases/conformance/externalModules/umd7.ts] ////
|
||||
|
||||
//// [foo.d.ts]
|
||||
|
||||
declare function Thing(): number;
|
||||
export = Thing;
|
||||
export as namespace Foo;
|
||||
|
||||
//// [a.ts]
|
||||
/// <reference path="foo.d.ts" />
|
||||
let y: number = Foo();
|
||||
|
||||
|
||||
//// [a.js]
|
||||
/// <reference path="foo.d.ts" />
|
||||
var y = exports.Foo();
|
||||
16
tests/baselines/reference/umd7.symbols
Normal file
16
tests/baselines/reference/umd7.symbols
Normal file
@ -0,0 +1,16 @@
|
||||
=== tests/cases/conformance/externalModules/a.ts ===
|
||||
/// <reference path="foo.d.ts" />
|
||||
let y: number = Foo();
|
||||
>y : Symbol(y, Decl(a.ts, 1, 3))
|
||||
>Foo : Symbol(Foo, Decl(foo.d.ts, 2, 15))
|
||||
|
||||
=== tests/cases/conformance/externalModules/foo.d.ts ===
|
||||
|
||||
declare function Thing(): number;
|
||||
>Thing : Symbol(Thing, Decl(foo.d.ts, 0, 0))
|
||||
|
||||
export = Thing;
|
||||
>Thing : Symbol(Thing, Decl(foo.d.ts, 0, 0))
|
||||
|
||||
export as namespace Foo;
|
||||
|
||||
18
tests/baselines/reference/umd7.types
Normal file
18
tests/baselines/reference/umd7.types
Normal file
@ -0,0 +1,18 @@
|
||||
=== tests/cases/conformance/externalModules/a.ts ===
|
||||
/// <reference path="foo.d.ts" />
|
||||
let y: number = Foo();
|
||||
>y : number
|
||||
>Foo() : number
|
||||
>Foo : () => number
|
||||
|
||||
=== tests/cases/conformance/externalModules/foo.d.ts ===
|
||||
|
||||
declare function Thing(): number;
|
||||
>Thing : () => number
|
||||
|
||||
export = Thing;
|
||||
>Thing : () => number
|
||||
|
||||
export as namespace Foo;
|
||||
>Foo : any
|
||||
|
||||
21
tests/baselines/reference/umd8.js
Normal file
21
tests/baselines/reference/umd8.js
Normal file
@ -0,0 +1,21 @@
|
||||
//// [tests/cases/conformance/externalModules/umd8.ts] ////
|
||||
|
||||
//// [foo.d.ts]
|
||||
|
||||
declare class Thing {
|
||||
foo(): number;
|
||||
}
|
||||
export = Thing;
|
||||
export as namespace Foo;
|
||||
|
||||
//// [a.ts]
|
||||
/// <reference path="foo.d.ts" />
|
||||
let y: Foo;
|
||||
y.foo();
|
||||
|
||||
|
||||
|
||||
//// [a.js]
|
||||
/// <reference path="foo.d.ts" />
|
||||
var y;
|
||||
y.foo();
|
||||
25
tests/baselines/reference/umd8.symbols
Normal file
25
tests/baselines/reference/umd8.symbols
Normal file
@ -0,0 +1,25 @@
|
||||
=== tests/cases/conformance/externalModules/a.ts ===
|
||||
/// <reference path="foo.d.ts" />
|
||||
let y: Foo;
|
||||
>y : Symbol(y, Decl(a.ts, 1, 3))
|
||||
>Foo : Symbol(Foo, Decl(foo.d.ts, 4, 15))
|
||||
|
||||
y.foo();
|
||||
>y.foo : Symbol(Foo.foo, Decl(foo.d.ts, 1, 21))
|
||||
>y : Symbol(y, Decl(a.ts, 1, 3))
|
||||
>foo : Symbol(Foo.foo, Decl(foo.d.ts, 1, 21))
|
||||
|
||||
|
||||
=== tests/cases/conformance/externalModules/foo.d.ts ===
|
||||
|
||||
declare class Thing {
|
||||
>Thing : Symbol(Thing, Decl(foo.d.ts, 0, 0))
|
||||
|
||||
foo(): number;
|
||||
>foo : Symbol(foo, Decl(foo.d.ts, 1, 21))
|
||||
}
|
||||
export = Thing;
|
||||
>Thing : Symbol(Thing, Decl(foo.d.ts, 0, 0))
|
||||
|
||||
export as namespace Foo;
|
||||
|
||||
27
tests/baselines/reference/umd8.types
Normal file
27
tests/baselines/reference/umd8.types
Normal file
@ -0,0 +1,27 @@
|
||||
=== tests/cases/conformance/externalModules/a.ts ===
|
||||
/// <reference path="foo.d.ts" />
|
||||
let y: Foo;
|
||||
>y : Foo
|
||||
>Foo : Foo
|
||||
|
||||
y.foo();
|
||||
>y.foo() : number
|
||||
>y.foo : () => number
|
||||
>y : Foo
|
||||
>foo : () => number
|
||||
|
||||
|
||||
=== tests/cases/conformance/externalModules/foo.d.ts ===
|
||||
|
||||
declare class Thing {
|
||||
>Thing : Thing
|
||||
|
||||
foo(): number;
|
||||
>foo : () => number
|
||||
}
|
||||
export = Thing;
|
||||
>Thing : Thing
|
||||
|
||||
export as namespace Foo;
|
||||
>Foo : any
|
||||
|
||||
@ -0,0 +1,39 @@
|
||||
// @module: commonjs
|
||||
// @noImplicitReferences: true
|
||||
|
||||
// @filename: node_modules/math2d/index.d.ts
|
||||
export as namespace Math2d;
|
||||
|
||||
export interface Point {
|
||||
x: number;
|
||||
y: number;
|
||||
}
|
||||
|
||||
export class Vector implements Point {
|
||||
x: number;
|
||||
y: number;
|
||||
constructor(x: number, y: number);
|
||||
|
||||
translate(dx: number, dy: number): Vector;
|
||||
}
|
||||
|
||||
export function getLength(p: Vector): number;
|
||||
|
||||
// @filename: math2d-augment.d.ts
|
||||
import * as Math2d from 'math2d';
|
||||
// Augment the module
|
||||
declare module 'math2d' {
|
||||
// Add a method to the class
|
||||
interface Vector {
|
||||
reverse(): Math2d.Point;
|
||||
}
|
||||
}
|
||||
|
||||
// @filename: b.ts
|
||||
/// <reference path="math2d-augment.d.ts" />
|
||||
import * as m from 'math2d';
|
||||
let v = new m.Vector(3, 2);
|
||||
let magnitude = m.getLength(v);
|
||||
let p: m.Point = v.translate(5, 5);
|
||||
p = v.reverse();
|
||||
var t = p.x;
|
||||
@ -0,0 +1,39 @@
|
||||
// @module: commonjs
|
||||
// @noImplicitReferences: true
|
||||
|
||||
// @filename: node_modules/math2d/index.d.ts
|
||||
export as namespace Math2d;
|
||||
|
||||
export interface Point {
|
||||
x: number;
|
||||
y: number;
|
||||
}
|
||||
|
||||
export class Vector implements Point {
|
||||
x: number;
|
||||
y: number;
|
||||
constructor(x: number, y: number);
|
||||
|
||||
translate(dx: number, dy: number): Vector;
|
||||
}
|
||||
|
||||
export function getLength(p: Vector): number;
|
||||
|
||||
// @filename: math2d-augment.d.ts
|
||||
import * as Math2d from 'math2d';
|
||||
// Augment the module
|
||||
declare module 'math2d' {
|
||||
// Add a method to the class
|
||||
interface Vector {
|
||||
reverse(): Math2d.Point;
|
||||
}
|
||||
}
|
||||
|
||||
// @filename: a.ts
|
||||
/// <reference path="node_modules/math2d/index.d.ts" />
|
||||
/// <reference path="math2d-augment.d.ts" />
|
||||
let v = new Math2d.Vector(3, 2);
|
||||
let magnitude = Math2d.getLength(v);
|
||||
let p: Math2d.Point = v.translate(5, 5);
|
||||
p = v.reverse();
|
||||
var t = p.x;
|
||||
@ -0,0 +1,45 @@
|
||||
// @module: commonjs
|
||||
// @noImplicitReferences: true
|
||||
|
||||
// @filename: node_modules/math2d/index.d.ts
|
||||
export as namespace Math2d;
|
||||
|
||||
export = M2D;
|
||||
|
||||
declare namespace M2D {
|
||||
interface Point {
|
||||
x: number;
|
||||
y: number;
|
||||
}
|
||||
|
||||
class Vector implements Point {
|
||||
x: number;
|
||||
y: number;
|
||||
constructor(x: number, y: number);
|
||||
|
||||
translate(dx: number, dy: number): Vector;
|
||||
}
|
||||
|
||||
function getLength(p: Vector): number;
|
||||
|
||||
}
|
||||
|
||||
|
||||
// @filename: math2d-augment.d.ts
|
||||
import * as Math2d from 'math2d';
|
||||
// Augment the module
|
||||
declare module 'math2d' {
|
||||
// Add a method to the class
|
||||
interface Vector {
|
||||
reverse(): Math2d.Point;
|
||||
}
|
||||
}
|
||||
|
||||
// @filename: b.ts
|
||||
/// <reference path="math2d-augment.d.ts" />
|
||||
import * as m from 'math2d';
|
||||
let v = new m.Vector(3, 2);
|
||||
let magnitude = m.getLength(v);
|
||||
let p: m.Point = v.translate(5, 5);
|
||||
p = v.reverse();
|
||||
var t = p.x;
|
||||
@ -0,0 +1,45 @@
|
||||
// @module: commonjs
|
||||
// @noImplicitReferences: true
|
||||
|
||||
// @filename: node_modules/math2d/index.d.ts
|
||||
export as namespace Math2d;
|
||||
|
||||
export = M2D;
|
||||
|
||||
declare namespace M2D {
|
||||
interface Point {
|
||||
x: number;
|
||||
y: number;
|
||||
}
|
||||
|
||||
class Vector implements Point {
|
||||
x: number;
|
||||
y: number;
|
||||
constructor(x: number, y: number);
|
||||
|
||||
translate(dx: number, dy: number): Vector;
|
||||
}
|
||||
|
||||
function getLength(p: Vector): number;
|
||||
|
||||
}
|
||||
|
||||
|
||||
// @filename: math2d-augment.d.ts
|
||||
import * as Math2d from 'math2d';
|
||||
// Augment the module
|
||||
declare module 'math2d' {
|
||||
// Add a method to the class
|
||||
interface Vector {
|
||||
reverse(): Math2d.Point;
|
||||
}
|
||||
}
|
||||
|
||||
// @filename: a.ts
|
||||
/// <reference path="node_modules/math2d/index.d.ts" />
|
||||
/// <reference path="math2d-augment.d.ts" />
|
||||
let v = new Math2d.Vector(3, 2);
|
||||
let magnitude = Math2d.getLength(v);
|
||||
let p: Math2d.Point = v.translate(5, 5);
|
||||
p = v.reverse();
|
||||
var t = p.x;
|
||||
31
tests/cases/conformance/externalModules/umd-errors.ts
Normal file
31
tests/cases/conformance/externalModules/umd-errors.ts
Normal file
@ -0,0 +1,31 @@
|
||||
// @module: commonjs
|
||||
|
||||
// @filename: err1.d.ts
|
||||
// Illegal, can't be in script file
|
||||
export as namespace Foo;
|
||||
|
||||
// @filename: err2.d.ts
|
||||
// Illegal, can't be in external ambient module
|
||||
declare module "Foo" {
|
||||
export as namespace Bar;
|
||||
}
|
||||
|
||||
// @filename: err3.d.ts
|
||||
// Illegal, can't have modifiers
|
||||
export var p;
|
||||
static export as namespace oo1;
|
||||
declare export as namespace oo2;
|
||||
public export as namespace oo3;
|
||||
const export as namespace oo4;
|
||||
|
||||
// @filename: err4.d.ts
|
||||
// Illegal, must be at top-level
|
||||
export namespace B {
|
||||
export as namespace C1;
|
||||
}
|
||||
|
||||
// @filename: err5.ts
|
||||
// Illegal, may not appear in implementation files
|
||||
export var v;
|
||||
export as namespace C2;
|
||||
|
||||
14
tests/cases/conformance/externalModules/umd1.ts
Normal file
14
tests/cases/conformance/externalModules/umd1.ts
Normal file
@ -0,0 +1,14 @@
|
||||
// @module: commonjs
|
||||
// @noImplicitReferences: true
|
||||
|
||||
// @filename: foo.d.ts
|
||||
export var x: number;
|
||||
export function fn(): void;
|
||||
export interface Thing { n: typeof x }
|
||||
export as namespace Foo;
|
||||
|
||||
// @filename: a.ts
|
||||
/// <reference path="foo.d.ts" />
|
||||
Foo.fn();
|
||||
let x: Foo.Thing;
|
||||
let y: number = x.n;
|
||||
12
tests/cases/conformance/externalModules/umd2.ts
Normal file
12
tests/cases/conformance/externalModules/umd2.ts
Normal file
@ -0,0 +1,12 @@
|
||||
// @module: commonjs
|
||||
// @noImplicitReferences: true
|
||||
|
||||
// @filename: foo.d.ts
|
||||
export var x: number;
|
||||
export function fn(): void;
|
||||
export as namespace Foo;
|
||||
|
||||
// @filename: a.ts
|
||||
Foo.fn();
|
||||
let x: Foo.Thing;
|
||||
let y: number = x.n;
|
||||
14
tests/cases/conformance/externalModules/umd3.ts
Normal file
14
tests/cases/conformance/externalModules/umd3.ts
Normal file
@ -0,0 +1,14 @@
|
||||
// @module: commonjs
|
||||
// @noImplicitReferences: true
|
||||
|
||||
// @filename: foo.d.ts
|
||||
export var x: number;
|
||||
export function fn(): void;
|
||||
export interface Thing { n: typeof x }
|
||||
export as namespace Foo;
|
||||
|
||||
// @filename: a.ts
|
||||
import * as Foo from './foo';
|
||||
Foo.fn();
|
||||
let x: Foo.Thing;
|
||||
let y: number = x.n;
|
||||
14
tests/cases/conformance/externalModules/umd4.ts
Normal file
14
tests/cases/conformance/externalModules/umd4.ts
Normal file
@ -0,0 +1,14 @@
|
||||
// @module: commonjs
|
||||
// @noImplicitReferences: true
|
||||
|
||||
// @filename: foo.d.ts
|
||||
export var x: number;
|
||||
export function fn(): void;
|
||||
export interface Thing { n: typeof x }
|
||||
export as namespace Foo;
|
||||
|
||||
// @filename: a.ts
|
||||
import * as Bar from './foo';
|
||||
Bar.fn();
|
||||
let x: Bar.Thing;
|
||||
let y: number = x.n;
|
||||
16
tests/cases/conformance/externalModules/umd5.ts
Normal file
16
tests/cases/conformance/externalModules/umd5.ts
Normal file
@ -0,0 +1,16 @@
|
||||
// @module: commonjs
|
||||
// @noImplicitReferences: true
|
||||
|
||||
// @filename: foo.d.ts
|
||||
export var x: number;
|
||||
export function fn(): void;
|
||||
export interface Thing { n: typeof x }
|
||||
export as namespace Foo;
|
||||
|
||||
// @filename: a.ts
|
||||
import * as Bar from './foo';
|
||||
Bar.fn();
|
||||
let x: Bar.Thing;
|
||||
let y: number = x.n;
|
||||
// should error
|
||||
let z = Foo;
|
||||
13
tests/cases/conformance/externalModules/umd6.ts
Normal file
13
tests/cases/conformance/externalModules/umd6.ts
Normal file
@ -0,0 +1,13 @@
|
||||
// @module: commonjs
|
||||
// @noImplicitReferences: true
|
||||
|
||||
// @filename: foo.d.ts
|
||||
declare namespace Thing {
|
||||
export function fn(): number;
|
||||
}
|
||||
export = Thing;
|
||||
export as namespace Foo;
|
||||
|
||||
// @filename: a.ts
|
||||
/// <reference path="foo.d.ts" />
|
||||
let y: number = Foo.fn();
|
||||
11
tests/cases/conformance/externalModules/umd7.ts
Normal file
11
tests/cases/conformance/externalModules/umd7.ts
Normal file
@ -0,0 +1,11 @@
|
||||
// @module: commonjs
|
||||
// @noImplicitReferences: true
|
||||
|
||||
// @filename: foo.d.ts
|
||||
declare function Thing(): number;
|
||||
export = Thing;
|
||||
export as namespace Foo;
|
||||
|
||||
// @filename: a.ts
|
||||
/// <reference path="foo.d.ts" />
|
||||
let y: number = Foo();
|
||||
15
tests/cases/conformance/externalModules/umd8.ts
Normal file
15
tests/cases/conformance/externalModules/umd8.ts
Normal file
@ -0,0 +1,15 @@
|
||||
// @module: commonjs
|
||||
// @noImplicitReferences: true
|
||||
|
||||
// @filename: foo.d.ts
|
||||
declare class Thing {
|
||||
foo(): number;
|
||||
}
|
||||
export = Thing;
|
||||
export as namespace Foo;
|
||||
|
||||
// @filename: a.ts
|
||||
/// <reference path="foo.d.ts" />
|
||||
let y: Foo;
|
||||
y.foo();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user