mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Merge branch 'master' into release-1.7
This commit is contained in:
+105
-117
@@ -3714,7 +3714,9 @@ namespace ts {
|
||||
function getSignatureFromDeclaration(declaration: SignatureDeclaration): Signature {
|
||||
let links = getNodeLinks(declaration);
|
||||
if (!links.resolvedSignature) {
|
||||
let classType = declaration.kind === SyntaxKind.Constructor ? getDeclaredTypeOfClassOrInterface((<ClassDeclaration>declaration.parent).symbol) : undefined;
|
||||
let classType = declaration.kind === SyntaxKind.Constructor ?
|
||||
getDeclaredTypeOfClassOrInterface(getMergedSymbol((<ClassDeclaration>declaration.parent).symbol))
|
||||
: undefined;
|
||||
let typeParameters = classType ? classType.localTypeParameters :
|
||||
declaration.typeParameters ? getTypeParametersFromDeclaration(declaration.typeParameters) : undefined;
|
||||
let parameters: Symbol[] = [];
|
||||
@@ -8646,39 +8648,36 @@ namespace ts {
|
||||
*/
|
||||
function getEffectiveDecoratorFirstArgumentType(node: Node): Type {
|
||||
// The first argument to a decorator is its `target`.
|
||||
switch (node.kind) {
|
||||
case SyntaxKind.ClassDeclaration:
|
||||
case SyntaxKind.ClassExpression:
|
||||
// For a class decorator, the `target` is the type of the class (e.g. the
|
||||
// "static" or "constructor" side of the class)
|
||||
if (node.kind === SyntaxKind.ClassDeclaration) {
|
||||
// For a class decorator, the `target` is the type of the class (e.g. the
|
||||
// "static" or "constructor" side of the class)
|
||||
let classSymbol = getSymbolOfNode(node);
|
||||
return getTypeOfSymbol(classSymbol);
|
||||
}
|
||||
|
||||
if (node.kind === SyntaxKind.Parameter) {
|
||||
// For a parameter decorator, the `target` is the parent type of the
|
||||
// parameter's containing method.
|
||||
node = node.parent;
|
||||
if (node.kind === SyntaxKind.Constructor) {
|
||||
let classSymbol = getSymbolOfNode(node);
|
||||
return getTypeOfSymbol(classSymbol);
|
||||
|
||||
case SyntaxKind.Parameter:
|
||||
// For a parameter decorator, the `target` is the parent type of the
|
||||
// parameter's containing method.
|
||||
node = node.parent;
|
||||
if (node.kind === SyntaxKind.Constructor) {
|
||||
let classSymbol = getSymbolOfNode(node);
|
||||
return getTypeOfSymbol(classSymbol);
|
||||
}
|
||||
|
||||
// fall-through
|
||||
|
||||
case SyntaxKind.PropertyDeclaration:
|
||||
case SyntaxKind.MethodDeclaration:
|
||||
case SyntaxKind.GetAccessor:
|
||||
case SyntaxKind.SetAccessor:
|
||||
// For a property or method decorator, the `target` is the
|
||||
// "static"-side type of the parent of the member if the member is
|
||||
// declared "static"; otherwise, it is the "instance"-side type of the
|
||||
// parent of the member.
|
||||
return getParentTypeOfClassElement(<ClassElement>node);
|
||||
|
||||
default:
|
||||
Debug.fail("Unsupported decorator target.");
|
||||
return unknownType;
|
||||
}
|
||||
}
|
||||
|
||||
if (node.kind === SyntaxKind.PropertyDeclaration ||
|
||||
node.kind === SyntaxKind.MethodDeclaration ||
|
||||
node.kind === SyntaxKind.GetAccessor ||
|
||||
node.kind === SyntaxKind.SetAccessor) {
|
||||
// For a property or method decorator, the `target` is the
|
||||
// "static"-side type of the parent of the member if the member is
|
||||
// declared "static"; otherwise, it is the "instance"-side type of the
|
||||
// parent of the member.
|
||||
return getParentTypeOfClassElement(<ClassElement>node);
|
||||
}
|
||||
|
||||
Debug.fail("Unsupported decorator target.");
|
||||
return unknownType;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -8698,57 +8697,54 @@ namespace ts {
|
||||
*/
|
||||
function getEffectiveDecoratorSecondArgumentType(node: Node) {
|
||||
// The second argument to a decorator is its `propertyKey`
|
||||
switch (node.kind) {
|
||||
case SyntaxKind.ClassDeclaration:
|
||||
Debug.fail("Class decorators should not have a second synthetic argument.");
|
||||
return unknownType;
|
||||
if (node.kind === SyntaxKind.ClassDeclaration) {
|
||||
Debug.fail("Class decorators should not have a second synthetic argument.");
|
||||
return unknownType;
|
||||
}
|
||||
|
||||
case SyntaxKind.Parameter:
|
||||
node = node.parent;
|
||||
if (node.kind === SyntaxKind.Constructor) {
|
||||
// For a constructor parameter decorator, the `propertyKey` will be `undefined`.
|
||||
return anyType;
|
||||
}
|
||||
if (node.kind === SyntaxKind.Parameter) {
|
||||
node = node.parent;
|
||||
if (node.kind === SyntaxKind.Constructor) {
|
||||
// For a constructor parameter decorator, the `propertyKey` will be `undefined`.
|
||||
return anyType;
|
||||
}
|
||||
|
||||
// For a non-constructor parameter decorator, the `propertyKey` will be either
|
||||
// a string or a symbol, based on the name of the parameter's containing method.
|
||||
|
||||
// fall-through
|
||||
|
||||
case SyntaxKind.PropertyDeclaration:
|
||||
case SyntaxKind.MethodDeclaration:
|
||||
case SyntaxKind.GetAccessor:
|
||||
case SyntaxKind.SetAccessor:
|
||||
// The `propertyKey` for a property or method decorator will be a
|
||||
// string literal type if the member name is an identifier, number, or string;
|
||||
// otherwise, if the member name is a computed property name it will
|
||||
// be either string or symbol.
|
||||
let element = <ClassElement>node;
|
||||
switch (element.name.kind) {
|
||||
case SyntaxKind.Identifier:
|
||||
case SyntaxKind.NumericLiteral:
|
||||
case SyntaxKind.StringLiteral:
|
||||
return getStringLiteralType(<StringLiteral>element.name);
|
||||
|
||||
case SyntaxKind.ComputedPropertyName:
|
||||
let nameType = checkComputedPropertyName(<ComputedPropertyName>element.name);
|
||||
if (allConstituentTypesHaveKind(nameType, TypeFlags.ESSymbol)) {
|
||||
return nameType;
|
||||
}
|
||||
else {
|
||||
return stringType;
|
||||
}
|
||||
|
||||
default:
|
||||
Debug.fail("Unsupported property name.");
|
||||
return unknownType;
|
||||
}
|
||||
|
||||
|
||||
default:
|
||||
Debug.fail("Unsupported decorator target.");
|
||||
return unknownType;
|
||||
}
|
||||
|
||||
if (node.kind === SyntaxKind.PropertyDeclaration ||
|
||||
node.kind === SyntaxKind.MethodDeclaration ||
|
||||
node.kind === SyntaxKind.GetAccessor ||
|
||||
node.kind === SyntaxKind.SetAccessor) {
|
||||
// The `propertyKey` for a property or method decorator will be a
|
||||
// string literal type if the member name is an identifier, number, or string;
|
||||
// otherwise, if the member name is a computed property name it will
|
||||
// be either string or symbol.
|
||||
let element = <ClassElement>node;
|
||||
switch (element.name.kind) {
|
||||
case SyntaxKind.Identifier:
|
||||
case SyntaxKind.NumericLiteral:
|
||||
case SyntaxKind.StringLiteral:
|
||||
return getStringLiteralType(<StringLiteral>element.name);
|
||||
|
||||
case SyntaxKind.ComputedPropertyName:
|
||||
let nameType = checkComputedPropertyName(<ComputedPropertyName>element.name);
|
||||
if (allConstituentTypesHaveKind(nameType, TypeFlags.ESSymbol)) {
|
||||
return nameType;
|
||||
}
|
||||
else {
|
||||
return stringType;
|
||||
}
|
||||
|
||||
default:
|
||||
Debug.fail("Unsupported property name.");
|
||||
return unknownType;
|
||||
}
|
||||
}
|
||||
|
||||
Debug.fail("Unsupported decorator target.");
|
||||
return unknownType;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -8761,31 +8757,32 @@ namespace ts {
|
||||
function getEffectiveDecoratorThirdArgumentType(node: Node) {
|
||||
// The third argument to a decorator is either its `descriptor` for a method decorator
|
||||
// or its `parameterIndex` for a paramter decorator
|
||||
switch (node.kind) {
|
||||
case SyntaxKind.ClassDeclaration:
|
||||
Debug.fail("Class decorators should not have a third synthetic argument.");
|
||||
return unknownType;
|
||||
|
||||
case SyntaxKind.Parameter:
|
||||
// The `parameterIndex` for a parameter decorator is always a number
|
||||
return numberType;
|
||||
|
||||
case SyntaxKind.PropertyDeclaration:
|
||||
Debug.fail("Property decorators should not have a third synthetic argument.");
|
||||
return unknownType;
|
||||
|
||||
case SyntaxKind.MethodDeclaration:
|
||||
case SyntaxKind.GetAccessor:
|
||||
case SyntaxKind.SetAccessor:
|
||||
// The `descriptor` for a method decorator will be a `TypedPropertyDescriptor<T>`
|
||||
// for the type of the member.
|
||||
let propertyType = getTypeOfNode(node);
|
||||
return createTypedPropertyDescriptorType(propertyType);
|
||||
|
||||
default:
|
||||
Debug.fail("Unsupported decorator target.");
|
||||
return unknownType;
|
||||
if (node.kind === SyntaxKind.ClassDeclaration) {
|
||||
Debug.fail("Class decorators should not have a third synthetic argument.");
|
||||
return unknownType;
|
||||
}
|
||||
|
||||
if (node.kind === SyntaxKind.Parameter) {
|
||||
// The `parameterIndex` for a parameter decorator is always a number
|
||||
return numberType;
|
||||
}
|
||||
|
||||
if (node.kind === SyntaxKind.PropertyDeclaration) {
|
||||
Debug.fail("Property decorators should not have a third synthetic argument.");
|
||||
return unknownType;
|
||||
}
|
||||
|
||||
if (node.kind === SyntaxKind.MethodDeclaration ||
|
||||
node.kind === SyntaxKind.GetAccessor ||
|
||||
node.kind === SyntaxKind.SetAccessor) {
|
||||
// The `descriptor` for a method decorator will be a `TypedPropertyDescriptor<T>`
|
||||
// for the type of the member.
|
||||
let propertyType = getTypeOfNode(node);
|
||||
return createTypedPropertyDescriptorType(propertyType);
|
||||
}
|
||||
|
||||
Debug.fail("Unsupported decorator target.");
|
||||
return unknownType;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -11051,7 +11048,13 @@ namespace ts {
|
||||
|
||||
function getEffectiveDeclarationFlags(n: Node, flagsToCheck: NodeFlags): NodeFlags {
|
||||
let flags = getCombinedNodeFlags(n);
|
||||
if (n.parent.kind !== SyntaxKind.InterfaceDeclaration && isInAmbientContext(n)) {
|
||||
|
||||
// children of classes (even ambient classes) should not be marked as ambient or export
|
||||
// because those flags have no useful semantics there.
|
||||
if (n.parent.kind !== SyntaxKind.InterfaceDeclaration &&
|
||||
n.parent.kind !== SyntaxKind.ClassDeclaration &&
|
||||
n.parent.kind !== SyntaxKind.ClassExpression &&
|
||||
isInAmbientContext(n)) {
|
||||
if (!(flags & NodeFlags.Ambient)) {
|
||||
// It is nested in an ambient context, which means it is automatically exported
|
||||
flags |= NodeFlags.Export;
|
||||
@@ -12874,11 +12877,6 @@ namespace ts {
|
||||
}
|
||||
checkClassLikeDeclaration(node);
|
||||
|
||||
// Interfaces cannot be merged with non-ambient classes.
|
||||
if (getSymbolOfNode(node).flags & SymbolFlags.Interface && !isInAmbientContext(node)) {
|
||||
error(node, Diagnostics.Only_an_ambient_class_can_be_merged_with_an_interface);
|
||||
}
|
||||
|
||||
forEach(node.members, checkSourceElement);
|
||||
}
|
||||
|
||||
@@ -13164,16 +13162,6 @@ namespace ts {
|
||||
checkIndexConstraints(type);
|
||||
}
|
||||
}
|
||||
|
||||
// Interfaces cannot merge with non-ambient classes.
|
||||
if (symbol && symbol.declarations) {
|
||||
for (let declaration of symbol.declarations) {
|
||||
if (declaration.kind === SyntaxKind.ClassDeclaration && !isInAmbientContext(declaration)) {
|
||||
error(node, Diagnostics.Only_an_ambient_class_can_be_merged_with_an_interface);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
forEach(getInterfaceBaseTypeNodes(node), heritageElement => {
|
||||
if (!isSupportedExpressionWithTypeArguments(heritageElement)) {
|
||||
|
||||
@@ -77,6 +77,7 @@ namespace ts {
|
||||
"system": ModuleKind.System,
|
||||
"umd": ModuleKind.UMD,
|
||||
"es6": ModuleKind.ES6,
|
||||
"es2015": ModuleKind.ES2015,
|
||||
},
|
||||
description: Diagnostics.Specify_module_code_generation_Colon_commonjs_amd_system_umd_or_es6,
|
||||
paramType: Diagnostics.KIND,
|
||||
@@ -205,7 +206,12 @@ namespace ts {
|
||||
{
|
||||
name: "target",
|
||||
shortName: "t",
|
||||
type: { "es3": ScriptTarget.ES3, "es5": ScriptTarget.ES5, "es6": ScriptTarget.ES6 },
|
||||
type: {
|
||||
"es3": ScriptTarget.ES3,
|
||||
"es5": ScriptTarget.ES5,
|
||||
"es6": ScriptTarget.ES6,
|
||||
"es2015": ScriptTarget.ES2015,
|
||||
},
|
||||
description: Diagnostics.Specify_ECMAScript_target_version_Colon_ES3_default_ES5_or_ES6_experimental,
|
||||
paramType: Diagnostics.VERSION,
|
||||
error: Diagnostics.Argument_for_target_option_must_be_ES3_ES5_or_ES6
|
||||
|
||||
@@ -739,13 +739,12 @@ namespace ts {
|
||||
export function isSupportedSourceFileName(fileName: string) {
|
||||
if (!fileName) { return false; }
|
||||
|
||||
let dotIndex = fileName.lastIndexOf(".");
|
||||
if (dotIndex < 0) {
|
||||
return false;
|
||||
for (let extension of supportedExtensions) {
|
||||
if (fileExtensionIs(fileName, extension)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
let extension = fileName.slice(dotIndex, fileName.length);
|
||||
return supportedExtensions.indexOf(extension) >= 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
const extensionsToRemove = [".d.ts", ".ts", ".js", ".tsx", ".jsx"];
|
||||
@@ -846,7 +845,7 @@ namespace ts {
|
||||
export function copyListRemovingItem<T>(item: T, list: T[]) {
|
||||
let copiedList: T[] = [];
|
||||
for (var i = 0, len = list.length; i < len; i++) {
|
||||
if (list[i] != item) {
|
||||
if (list[i] !== item) {
|
||||
copiedList.push(list[i]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1620,10 +1620,6 @@
|
||||
"category": "Error",
|
||||
"code":2517
|
||||
},
|
||||
"Only an ambient class can be merged with an interface.": {
|
||||
"category": "Error",
|
||||
"code": 2518
|
||||
},
|
||||
"Duplicate identifier '{0}'. Compiler uses declaration '{1}' to support async functions.": {
|
||||
"category": "Error",
|
||||
"code": 2520
|
||||
|
||||
@@ -2103,6 +2103,7 @@ namespace ts {
|
||||
UMD = 3,
|
||||
System = 4,
|
||||
ES6 = 5,
|
||||
ES2015 = ES6,
|
||||
}
|
||||
|
||||
export const enum JsxEmit {
|
||||
@@ -2128,12 +2129,13 @@ namespace ts {
|
||||
ES3 = 0,
|
||||
ES5 = 1,
|
||||
ES6 = 2,
|
||||
ES2015 = ES6,
|
||||
Latest = ES6,
|
||||
}
|
||||
|
||||
export const enum LanguageVariant {
|
||||
Standard,
|
||||
JSX
|
||||
JSX,
|
||||
}
|
||||
|
||||
export interface ParsedCommandLine {
|
||||
|
||||
@@ -735,7 +735,7 @@ namespace ts.server {
|
||||
if (!(--project.projectService.directoryWatchersRefCount[directory])) {
|
||||
this.log("Close directory watcher for: " + directory);
|
||||
project.projectService.directoryWatchersForTsconfig[directory].close();
|
||||
project.projectService.directoryWatchersForTsconfig[directory] = undefined;
|
||||
delete project.projectService.directoryWatchersForTsconfig[directory];
|
||||
}
|
||||
}
|
||||
this.inferredProjects = copyListRemovingItem(project, this.inferredProjects);
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
//// [ambientClassMergesOverloadsWithInterface.ts]
|
||||
declare class C {
|
||||
baz(): any;
|
||||
foo(n: number): any;
|
||||
}
|
||||
interface C {
|
||||
foo(n: number): any;
|
||||
bar(): any;
|
||||
}
|
||||
|
||||
|
||||
//// [ambientClassMergesOverloadsWithInterface.js]
|
||||
@@ -0,0 +1,22 @@
|
||||
=== tests/cases/compiler/ambientClassMergesOverloadsWithInterface.ts ===
|
||||
declare class C {
|
||||
>C : Symbol(C, Decl(ambientClassMergesOverloadsWithInterface.ts, 0, 0), Decl(ambientClassMergesOverloadsWithInterface.ts, 3, 1))
|
||||
|
||||
baz(): any;
|
||||
>baz : Symbol(baz, Decl(ambientClassMergesOverloadsWithInterface.ts, 0, 17))
|
||||
|
||||
foo(n: number): any;
|
||||
>foo : Symbol(foo, Decl(ambientClassMergesOverloadsWithInterface.ts, 1, 15), Decl(ambientClassMergesOverloadsWithInterface.ts, 4, 13))
|
||||
>n : Symbol(n, Decl(ambientClassMergesOverloadsWithInterface.ts, 2, 8))
|
||||
}
|
||||
interface C {
|
||||
>C : Symbol(C, Decl(ambientClassMergesOverloadsWithInterface.ts, 0, 0), Decl(ambientClassMergesOverloadsWithInterface.ts, 3, 1))
|
||||
|
||||
foo(n: number): any;
|
||||
>foo : Symbol(foo, Decl(ambientClassMergesOverloadsWithInterface.ts, 1, 15), Decl(ambientClassMergesOverloadsWithInterface.ts, 4, 13))
|
||||
>n : Symbol(n, Decl(ambientClassMergesOverloadsWithInterface.ts, 5, 8))
|
||||
|
||||
bar(): any;
|
||||
>bar : Symbol(bar, Decl(ambientClassMergesOverloadsWithInterface.ts, 5, 24))
|
||||
}
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
=== tests/cases/compiler/ambientClassMergesOverloadsWithInterface.ts ===
|
||||
declare class C {
|
||||
>C : C
|
||||
|
||||
baz(): any;
|
||||
>baz : () => any
|
||||
|
||||
foo(n: number): any;
|
||||
>foo : { (n: number): any; (n: number): any; }
|
||||
>n : number
|
||||
}
|
||||
interface C {
|
||||
>C : C
|
||||
|
||||
foo(n: number): any;
|
||||
>foo : { (n: number): any; (n: number): any; }
|
||||
>n : number
|
||||
|
||||
bar(): any;
|
||||
>bar : () => any
|
||||
}
|
||||
|
||||
@@ -1,24 +1,18 @@
|
||||
tests/cases/compiler/augmentedTypesClass2.ts(4,7): error TS2518: Only an ambient class can be merged with an interface.
|
||||
tests/cases/compiler/augmentedTypesClass2.ts(10,11): error TS2518: Only an ambient class can be merged with an interface.
|
||||
tests/cases/compiler/augmentedTypesClass2.ts(16,7): error TS2300: Duplicate identifier 'c33'.
|
||||
tests/cases/compiler/augmentedTypesClass2.ts(21,6): error TS2300: Duplicate identifier 'c33'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/augmentedTypesClass2.ts (4 errors) ====
|
||||
==== tests/cases/compiler/augmentedTypesClass2.ts (2 errors) ====
|
||||
// Checking class with other things in type space not value space
|
||||
|
||||
// class then interface
|
||||
class c11 { // error
|
||||
~~~
|
||||
!!! error TS2518: Only an ambient class can be merged with an interface.
|
||||
class c11 {
|
||||
foo() {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
interface c11 { // error
|
||||
~~~
|
||||
!!! error TS2518: Only an ambient class can be merged with an interface.
|
||||
interface c11 {
|
||||
bar(): void;
|
||||
}
|
||||
|
||||
|
||||
@@ -2,13 +2,13 @@
|
||||
// Checking class with other things in type space not value space
|
||||
|
||||
// class then interface
|
||||
class c11 { // error
|
||||
class c11 {
|
||||
foo() {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
interface c11 { // error
|
||||
interface c11 {
|
||||
bar(): void;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
tests/cases/compiler/augmentedTypesInterface.ts(12,11): error TS2518: Only an ambient class can be merged with an interface.
|
||||
tests/cases/compiler/augmentedTypesInterface.ts(16,7): error TS2518: Only an ambient class can be merged with an interface.
|
||||
tests/cases/compiler/augmentedTypesInterface.ts(23,11): error TS2300: Duplicate identifier 'i3'.
|
||||
tests/cases/compiler/augmentedTypesInterface.ts(26,6): error TS2300: Duplicate identifier 'i3'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/augmentedTypesInterface.ts (4 errors) ====
|
||||
==== tests/cases/compiler/augmentedTypesInterface.ts (2 errors) ====
|
||||
// interface then interface
|
||||
|
||||
interface i {
|
||||
@@ -16,15 +14,11 @@ tests/cases/compiler/augmentedTypesInterface.ts(26,6): error TS2300: Duplicate i
|
||||
}
|
||||
|
||||
// interface then class
|
||||
interface i2 { // error
|
||||
~~
|
||||
!!! error TS2518: Only an ambient class can be merged with an interface.
|
||||
interface i2 {
|
||||
foo(): void;
|
||||
}
|
||||
|
||||
class i2 { // error
|
||||
~~
|
||||
!!! error TS2518: Only an ambient class can be merged with an interface.
|
||||
class i2 {
|
||||
bar() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -10,11 +10,11 @@ interface i {
|
||||
}
|
||||
|
||||
// interface then class
|
||||
interface i2 { // error
|
||||
interface i2 {
|
||||
foo(): void;
|
||||
}
|
||||
|
||||
class i2 { // error
|
||||
class i2 {
|
||||
bar() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,3 @@
|
||||
tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMergedDeclaration.ts(7,16): error TS2518: Only an ambient class can be merged with an interface.
|
||||
tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMergedDeclaration.ts(8,11): error TS2518: Only an ambient class can be merged with an interface.
|
||||
tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMergedDeclaration.ts(10,11): error TS2518: Only an ambient class can be merged with an interface.
|
||||
tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMergedDeclaration.ts(11,16): error TS2518: Only an ambient class can be merged with an interface.
|
||||
tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMergedDeclaration.ts(13,16): error TS2300: Duplicate identifier 'CC1'.
|
||||
tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMergedDeclaration.ts(14,7): error TS2300: Duplicate identifier 'CC1'.
|
||||
tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMergedDeclaration.ts(16,7): error TS2300: Duplicate identifier 'CC2'.
|
||||
@@ -20,7 +16,7 @@ tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbst
|
||||
tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMergedDeclaration.ts(39,1): error TS2511: Cannot create an instance of the abstract class 'DCC1'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMergedDeclaration.ts (20 errors) ====
|
||||
==== tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMergedDeclaration.ts (16 errors) ====
|
||||
abstract class CM {}
|
||||
module CM {}
|
||||
|
||||
@@ -28,18 +24,10 @@ tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbst
|
||||
abstract class MC {}
|
||||
|
||||
abstract class CI {}
|
||||
~~
|
||||
!!! error TS2518: Only an ambient class can be merged with an interface.
|
||||
interface CI {}
|
||||
~~
|
||||
!!! error TS2518: Only an ambient class can be merged with an interface.
|
||||
|
||||
interface IC {}
|
||||
~~
|
||||
!!! error TS2518: Only an ambient class can be merged with an interface.
|
||||
abstract class IC {}
|
||||
~~
|
||||
!!! error TS2518: Only an ambient class can be merged with an interface.
|
||||
|
||||
abstract class CC1 {}
|
||||
~~~
|
||||
|
||||
@@ -1,37 +1,25 @@
|
||||
tests/cases/conformance/classes/classDeclarations/classAndInterfaceWithSameName.ts(1,7): error TS2518: Only an ambient class can be merged with an interface.
|
||||
tests/cases/conformance/classes/classDeclarations/classAndInterfaceWithSameName.ts(1,11): error TS2300: Duplicate identifier 'foo'.
|
||||
tests/cases/conformance/classes/classDeclarations/classAndInterfaceWithSameName.ts(2,11): error TS2518: Only an ambient class can be merged with an interface.
|
||||
tests/cases/conformance/classes/classDeclarations/classAndInterfaceWithSameName.ts(2,15): error TS2300: Duplicate identifier 'foo'.
|
||||
tests/cases/conformance/classes/classDeclarations/classAndInterfaceWithSameName.ts(5,11): error TS2518: Only an ambient class can be merged with an interface.
|
||||
tests/cases/conformance/classes/classDeclarations/classAndInterfaceWithSameName.ts(6,9): error TS2300: Duplicate identifier 'bar'.
|
||||
tests/cases/conformance/classes/classDeclarations/classAndInterfaceWithSameName.ts(9,15): error TS2518: Only an ambient class can be merged with an interface.
|
||||
tests/cases/conformance/classes/classDeclarations/classAndInterfaceWithSameName.ts(10,9): error TS2300: Duplicate identifier 'bar'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/classes/classDeclarations/classAndInterfaceWithSameName.ts (8 errors) ====
|
||||
==== tests/cases/conformance/classes/classDeclarations/classAndInterfaceWithSameName.ts (4 errors) ====
|
||||
class C { foo: string; }
|
||||
~
|
||||
!!! error TS2518: Only an ambient class can be merged with an interface.
|
||||
~~~
|
||||
!!! error TS2300: Duplicate identifier 'foo'.
|
||||
interface C { foo: string; } // error
|
||||
~
|
||||
!!! error TS2518: Only an ambient class can be merged with an interface.
|
||||
interface C { foo: string; }
|
||||
~~~
|
||||
!!! error TS2300: Duplicate identifier 'foo'.
|
||||
|
||||
module M {
|
||||
class D {
|
||||
~
|
||||
!!! error TS2518: Only an ambient class can be merged with an interface.
|
||||
bar: string;
|
||||
~~~
|
||||
!!! error TS2300: Duplicate identifier 'bar'.
|
||||
}
|
||||
|
||||
interface D { // error
|
||||
~
|
||||
!!! error TS2518: Only an ambient class can be merged with an interface.
|
||||
interface D {
|
||||
bar: string;
|
||||
~~~
|
||||
!!! error TS2300: Duplicate identifier 'bar'.
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
//// [classAndInterfaceWithSameName.ts]
|
||||
class C { foo: string; }
|
||||
interface C { foo: string; } // error
|
||||
interface C { foo: string; }
|
||||
|
||||
module M {
|
||||
class D {
|
||||
bar: string;
|
||||
}
|
||||
|
||||
interface D { // error
|
||||
interface D {
|
||||
bar: string;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,52 +0,0 @@
|
||||
tests/cases/compiler/clinterfaces.ts(2,11): error TS2518: Only an ambient class can be merged with an interface.
|
||||
tests/cases/compiler/clinterfaces.ts(3,15): error TS2518: Only an ambient class can be merged with an interface.
|
||||
tests/cases/compiler/clinterfaces.ts(4,15): error TS2518: Only an ambient class can be merged with an interface.
|
||||
tests/cases/compiler/clinterfaces.ts(5,11): error TS2518: Only an ambient class can be merged with an interface.
|
||||
tests/cases/compiler/clinterfaces.ts(8,11): error TS2518: Only an ambient class can be merged with an interface.
|
||||
tests/cases/compiler/clinterfaces.ts(12,7): error TS2518: Only an ambient class can be merged with an interface.
|
||||
tests/cases/compiler/clinterfaces.ts(16,7): error TS2518: Only an ambient class can be merged with an interface.
|
||||
tests/cases/compiler/clinterfaces.ts(20,11): error TS2518: Only an ambient class can be merged with an interface.
|
||||
|
||||
|
||||
==== tests/cases/compiler/clinterfaces.ts (8 errors) ====
|
||||
module M {
|
||||
class C { }
|
||||
~
|
||||
!!! error TS2518: Only an ambient class can be merged with an interface.
|
||||
interface C { }
|
||||
~
|
||||
!!! error TS2518: Only an ambient class can be merged with an interface.
|
||||
interface D { }
|
||||
~
|
||||
!!! error TS2518: Only an ambient class can be merged with an interface.
|
||||
class D { }
|
||||
~
|
||||
!!! error TS2518: Only an ambient class can be merged with an interface.
|
||||
}
|
||||
|
||||
interface Foo<T> {
|
||||
~~~
|
||||
!!! error TS2518: Only an ambient class can be merged with an interface.
|
||||
a: string;
|
||||
}
|
||||
|
||||
class Foo<T>{
|
||||
~~~
|
||||
!!! error TS2518: Only an ambient class can be merged with an interface.
|
||||
b: number;
|
||||
}
|
||||
|
||||
class Bar<T>{
|
||||
~~~
|
||||
!!! error TS2518: Only an ambient class can be merged with an interface.
|
||||
b: number;
|
||||
}
|
||||
|
||||
interface Bar<T> {
|
||||
~~~
|
||||
!!! error TS2518: Only an ambient class can be merged with an interface.
|
||||
a: string;
|
||||
}
|
||||
|
||||
export = Foo;
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
=== tests/cases/compiler/clinterfaces.ts ===
|
||||
module M {
|
||||
>M : Symbol(M, Decl(clinterfaces.ts, 0, 0))
|
||||
|
||||
class C { }
|
||||
>C : Symbol(C, Decl(clinterfaces.ts, 0, 10), Decl(clinterfaces.ts, 1, 15))
|
||||
|
||||
interface C { }
|
||||
>C : Symbol(C, Decl(clinterfaces.ts, 0, 10), Decl(clinterfaces.ts, 1, 15))
|
||||
|
||||
interface D { }
|
||||
>D : Symbol(D, Decl(clinterfaces.ts, 2, 19), Decl(clinterfaces.ts, 3, 19))
|
||||
|
||||
class D { }
|
||||
>D : Symbol(D, Decl(clinterfaces.ts, 2, 19), Decl(clinterfaces.ts, 3, 19))
|
||||
}
|
||||
|
||||
interface Foo<T> {
|
||||
>Foo : Symbol(Foo, Decl(clinterfaces.ts, 5, 1), Decl(clinterfaces.ts, 9, 1))
|
||||
>T : Symbol(T, Decl(clinterfaces.ts, 7, 14), Decl(clinterfaces.ts, 11, 10))
|
||||
|
||||
a: string;
|
||||
>a : Symbol(a, Decl(clinterfaces.ts, 7, 18))
|
||||
}
|
||||
|
||||
class Foo<T>{
|
||||
>Foo : Symbol(Foo, Decl(clinterfaces.ts, 5, 1), Decl(clinterfaces.ts, 9, 1))
|
||||
>T : Symbol(T, Decl(clinterfaces.ts, 7, 14), Decl(clinterfaces.ts, 11, 10))
|
||||
|
||||
b: number;
|
||||
>b : Symbol(b, Decl(clinterfaces.ts, 11, 13))
|
||||
}
|
||||
|
||||
class Bar<T>{
|
||||
>Bar : Symbol(Bar, Decl(clinterfaces.ts, 13, 1), Decl(clinterfaces.ts, 17, 1))
|
||||
>T : Symbol(T, Decl(clinterfaces.ts, 15, 10), Decl(clinterfaces.ts, 19, 14))
|
||||
|
||||
b: number;
|
||||
>b : Symbol(b, Decl(clinterfaces.ts, 15, 13))
|
||||
}
|
||||
|
||||
interface Bar<T> {
|
||||
>Bar : Symbol(Bar, Decl(clinterfaces.ts, 13, 1), Decl(clinterfaces.ts, 17, 1))
|
||||
>T : Symbol(T, Decl(clinterfaces.ts, 15, 10), Decl(clinterfaces.ts, 19, 14))
|
||||
|
||||
a: string;
|
||||
>a : Symbol(a, Decl(clinterfaces.ts, 19, 18))
|
||||
}
|
||||
|
||||
export = Foo;
|
||||
>Foo : Symbol(Foo, Decl(clinterfaces.ts, 5, 1), Decl(clinterfaces.ts, 9, 1))
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
=== tests/cases/compiler/clinterfaces.ts ===
|
||||
module M {
|
||||
>M : typeof M
|
||||
|
||||
class C { }
|
||||
>C : C
|
||||
|
||||
interface C { }
|
||||
>C : C
|
||||
|
||||
interface D { }
|
||||
>D : D
|
||||
|
||||
class D { }
|
||||
>D : D
|
||||
}
|
||||
|
||||
interface Foo<T> {
|
||||
>Foo : Foo<T>
|
||||
>T : T
|
||||
|
||||
a: string;
|
||||
>a : string
|
||||
}
|
||||
|
||||
class Foo<T>{
|
||||
>Foo : Foo<T>
|
||||
>T : T
|
||||
|
||||
b: number;
|
||||
>b : number
|
||||
}
|
||||
|
||||
class Bar<T>{
|
||||
>Bar : Bar<T>
|
||||
>T : T
|
||||
|
||||
b: number;
|
||||
>b : number
|
||||
}
|
||||
|
||||
interface Bar<T> {
|
||||
>Bar : Bar<T>
|
||||
>T : T
|
||||
|
||||
a: string;
|
||||
>a : string
|
||||
}
|
||||
|
||||
export = Foo;
|
||||
>Foo : Foo<T>
|
||||
|
||||
@@ -1,19 +0,0 @@
|
||||
tests/cases/compiler/declInput.ts(1,11): error TS2518: Only an ambient class can be merged with an interface.
|
||||
tests/cases/compiler/declInput.ts(5,7): error TS2518: Only an ambient class can be merged with an interface.
|
||||
|
||||
|
||||
==== tests/cases/compiler/declInput.ts (2 errors) ====
|
||||
interface bar {
|
||||
~~~
|
||||
!!! error TS2518: Only an ambient class can be merged with an interface.
|
||||
|
||||
}
|
||||
|
||||
class bar {
|
||||
~~~
|
||||
!!! error TS2518: Only an ambient class can be merged with an interface.
|
||||
public f() { return ''; }
|
||||
public g() { return {a: <bar>null, b: undefined, c: void 4 }; }
|
||||
public h(x = 4, y = null, z = '') { x++; }
|
||||
}
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
=== tests/cases/compiler/declInput.ts ===
|
||||
interface bar {
|
||||
>bar : Symbol(bar, Decl(declInput.ts, 0, 0), Decl(declInput.ts, 2, 1))
|
||||
|
||||
}
|
||||
|
||||
class bar {
|
||||
>bar : Symbol(bar, Decl(declInput.ts, 0, 0), Decl(declInput.ts, 2, 1))
|
||||
|
||||
public f() { return ''; }
|
||||
>f : Symbol(f, Decl(declInput.ts, 4, 11))
|
||||
|
||||
public g() { return {a: <bar>null, b: undefined, c: void 4 }; }
|
||||
>g : Symbol(g, Decl(declInput.ts, 5, 27))
|
||||
>a : Symbol(a, Decl(declInput.ts, 6, 23))
|
||||
>bar : Symbol(bar, Decl(declInput.ts, 0, 0), Decl(declInput.ts, 2, 1))
|
||||
>b : Symbol(b, Decl(declInput.ts, 6, 36))
|
||||
>undefined : Symbol(undefined)
|
||||
>c : Symbol(c, Decl(declInput.ts, 6, 50))
|
||||
|
||||
public h(x = 4, y = null, z = '') { x++; }
|
||||
>h : Symbol(h, Decl(declInput.ts, 6, 65))
|
||||
>x : Symbol(x, Decl(declInput.ts, 7, 11))
|
||||
>y : Symbol(y, Decl(declInput.ts, 7, 17))
|
||||
>z : Symbol(z, Decl(declInput.ts, 7, 27))
|
||||
>x : Symbol(x, Decl(declInput.ts, 7, 11))
|
||||
}
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
=== tests/cases/compiler/declInput.ts ===
|
||||
interface bar {
|
||||
>bar : bar
|
||||
|
||||
}
|
||||
|
||||
class bar {
|
||||
>bar : bar
|
||||
|
||||
public f() { return ''; }
|
||||
>f : () => string
|
||||
>'' : string
|
||||
|
||||
public g() { return {a: <bar>null, b: undefined, c: void 4 }; }
|
||||
>g : () => { a: bar; b: any; c: any; }
|
||||
>{a: <bar>null, b: undefined, c: void 4 } : { a: bar; b: undefined; c: undefined; }
|
||||
>a : bar
|
||||
><bar>null : bar
|
||||
>bar : bar
|
||||
>null : null
|
||||
>b : undefined
|
||||
>undefined : undefined
|
||||
>c : undefined
|
||||
>void 4 : undefined
|
||||
>4 : number
|
||||
|
||||
public h(x = 4, y = null, z = '') { x++; }
|
||||
>h : (x?: number, y?: any, z?: string) => void
|
||||
>x : number
|
||||
>4 : number
|
||||
>y : any
|
||||
>null : null
|
||||
>z : string
|
||||
>'' : string
|
||||
>x++ : number
|
||||
>x : number
|
||||
}
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
tests/cases/conformance/es6/modules/m1.ts(2,22): error TS2652: Merged declaration 'Decl' cannot include a default export declaration. Consider adding a separate 'export default Decl' declaration instead.
|
||||
tests/cases/conformance/es6/modules/m1.ts(5,11): error TS2518: Only an ambient class can be merged with an interface.
|
||||
tests/cases/conformance/es6/modules/m1.ts(5,11): error TS2652: Merged declaration 'Decl' cannot include a default export declaration. Consider adding a separate 'export default Decl' declaration instead.
|
||||
tests/cases/conformance/es6/modules/m2.ts(1,20): error TS2307: Cannot find module 'm1'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/modules/m1.ts (3 errors) ====
|
||||
==== tests/cases/conformance/es6/modules/m1.ts (2 errors) ====
|
||||
|
||||
export default class Decl {
|
||||
~~~~
|
||||
@@ -13,8 +12,6 @@ tests/cases/conformance/es6/modules/m2.ts(1,20): error TS2307: Cannot find modul
|
||||
|
||||
interface Decl {
|
||||
~~~~
|
||||
!!! error TS2518: Only an ambient class can be merged with an interface.
|
||||
~~~~
|
||||
!!! error TS2652: Merged declaration 'Decl' cannot include a default export declaration. Consider adding a separate 'export default Decl' declaration instead.
|
||||
p1: number;
|
||||
p2: number;
|
||||
|
||||
@@ -1,21 +1,15 @@
|
||||
tests/cases/compiler/duplicateIdentifiersAcrossContainerBoundaries.ts(2,22): error TS2518: Only an ambient class can be merged with an interface.
|
||||
tests/cases/compiler/duplicateIdentifiersAcrossContainerBoundaries.ts(5,18): error TS2518: Only an ambient class can be merged with an interface.
|
||||
tests/cases/compiler/duplicateIdentifiersAcrossContainerBoundaries.ts(9,21): error TS2300: Duplicate identifier 'f'.
|
||||
tests/cases/compiler/duplicateIdentifiersAcrossContainerBoundaries.ts(12,18): error TS2300: Duplicate identifier 'f'.
|
||||
tests/cases/compiler/duplicateIdentifiersAcrossContainerBoundaries.ts(37,12): error TS2300: Duplicate identifier 'x'.
|
||||
tests/cases/compiler/duplicateIdentifiersAcrossContainerBoundaries.ts(41,16): error TS2300: Duplicate identifier 'x'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/duplicateIdentifiersAcrossContainerBoundaries.ts (6 errors) ====
|
||||
==== tests/cases/compiler/duplicateIdentifiersAcrossContainerBoundaries.ts (4 errors) ====
|
||||
module M {
|
||||
export interface I { }
|
||||
~
|
||||
!!! error TS2518: Only an ambient class can be merged with an interface.
|
||||
}
|
||||
module M {
|
||||
export class I { } // error
|
||||
~
|
||||
!!! error TS2518: Only an ambient class can be merged with an interface.
|
||||
export class I { }
|
||||
}
|
||||
|
||||
module M {
|
||||
|
||||
@@ -3,7 +3,7 @@ module M {
|
||||
export interface I { }
|
||||
}
|
||||
module M {
|
||||
export class I { } // error
|
||||
export class I { }
|
||||
}
|
||||
|
||||
module M {
|
||||
@@ -60,7 +60,7 @@ var M;
|
||||
}
|
||||
return I;
|
||||
})();
|
||||
M.I = I; // error
|
||||
M.I = I;
|
||||
})(M || (M = {}));
|
||||
var M;
|
||||
(function (M) {
|
||||
|
||||
@@ -1,24 +1,16 @@
|
||||
tests/cases/compiler/file1.ts(2,11): error TS2518: Only an ambient class can be merged with an interface.
|
||||
tests/cases/compiler/file1.ts(3,7): error TS2518: Only an ambient class can be merged with an interface.
|
||||
tests/cases/compiler/file1.ts(4,7): error TS2300: Duplicate identifier 'C2'.
|
||||
tests/cases/compiler/file1.ts(5,10): error TS2300: Duplicate identifier 'f'.
|
||||
tests/cases/compiler/file1.ts(9,12): error TS2300: Duplicate identifier 'x'.
|
||||
tests/cases/compiler/file2.ts(1,7): error TS2518: Only an ambient class can be merged with an interface.
|
||||
tests/cases/compiler/file2.ts(2,11): error TS2518: Only an ambient class can be merged with an interface.
|
||||
tests/cases/compiler/file2.ts(3,10): error TS2300: Duplicate identifier 'C2'.
|
||||
tests/cases/compiler/file2.ts(4,7): error TS2300: Duplicate identifier 'f'.
|
||||
tests/cases/compiler/file2.ts(7,8): error TS2433: A namespace declaration cannot be in a different file from a class or function with which it is merged
|
||||
tests/cases/compiler/file2.ts(8,16): error TS2300: Duplicate identifier 'x'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/file1.ts (5 errors) ====
|
||||
==== tests/cases/compiler/file1.ts (3 errors) ====
|
||||
|
||||
interface I { }
|
||||
~
|
||||
!!! error TS2518: Only an ambient class can be merged with an interface.
|
||||
class C1 { }
|
||||
~~
|
||||
!!! error TS2518: Only an ambient class can be merged with an interface.
|
||||
class C2 { }
|
||||
~~
|
||||
!!! error TS2300: Duplicate identifier 'C2'.
|
||||
@@ -39,13 +31,9 @@ tests/cases/compiler/file2.ts(8,16): error TS2300: Duplicate identifier 'x'.
|
||||
}
|
||||
}
|
||||
|
||||
==== tests/cases/compiler/file2.ts (6 errors) ====
|
||||
==== tests/cases/compiler/file2.ts (4 errors) ====
|
||||
class I { } // error -- cannot merge interface with non-ambient class
|
||||
~
|
||||
!!! error TS2518: Only an ambient class can be merged with an interface.
|
||||
interface C1 { } // error -- cannot merge interface with non-ambient class
|
||||
~~
|
||||
!!! error TS2518: Only an ambient class can be merged with an interface.
|
||||
function C2() { } // error -- cannot merge function with non-ambient class
|
||||
~~
|
||||
!!! error TS2300: Duplicate identifier 'C2'.
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
//// [es2015modulekind.ts]
|
||||
|
||||
export default class A
|
||||
{
|
||||
constructor ()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public B()
|
||||
{
|
||||
return 42;
|
||||
}
|
||||
}
|
||||
|
||||
//// [es2015modulekind.js]
|
||||
export default class A {
|
||||
constructor() {
|
||||
}
|
||||
B() {
|
||||
return 42;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
=== tests/cases/compiler/es2015modulekind.ts ===
|
||||
|
||||
export default class A
|
||||
>A : Symbol(A, Decl(es2015modulekind.ts, 0, 0))
|
||||
{
|
||||
constructor ()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public B()
|
||||
>B : Symbol(B, Decl(es2015modulekind.ts, 6, 5))
|
||||
{
|
||||
return 42;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
=== tests/cases/compiler/es2015modulekind.ts ===
|
||||
|
||||
export default class A
|
||||
>A : A
|
||||
{
|
||||
constructor ()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public B()
|
||||
>B : () => number
|
||||
{
|
||||
return 42;
|
||||
>42 : number
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
//// [es2015modulekindWithES6Target.ts]
|
||||
|
||||
export default class A
|
||||
{
|
||||
constructor ()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public B()
|
||||
{
|
||||
return 42;
|
||||
}
|
||||
}
|
||||
|
||||
//// [es2015modulekindWithES6Target.js]
|
||||
export default class A {
|
||||
constructor() {
|
||||
}
|
||||
B() {
|
||||
return 42;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
=== tests/cases/compiler/es2015modulekindWithES6Target.ts ===
|
||||
|
||||
export default class A
|
||||
>A : Symbol(A, Decl(es2015modulekindWithES6Target.ts, 0, 0))
|
||||
{
|
||||
constructor ()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public B()
|
||||
>B : Symbol(B, Decl(es2015modulekindWithES6Target.ts, 6, 5))
|
||||
{
|
||||
return 42;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
=== tests/cases/compiler/es2015modulekindWithES6Target.ts ===
|
||||
|
||||
export default class A
|
||||
>A : A
|
||||
{
|
||||
constructor ()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public B()
|
||||
>B : () => number
|
||||
{
|
||||
return 42;
|
||||
>42 : number
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
//// [es6modulekindWithES2015Target.ts]
|
||||
|
||||
export default class A
|
||||
{
|
||||
constructor ()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public B()
|
||||
{
|
||||
return 42;
|
||||
}
|
||||
}
|
||||
|
||||
//// [es6modulekindWithES2015Target.js]
|
||||
export default class A {
|
||||
constructor() {
|
||||
}
|
||||
B() {
|
||||
return 42;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
=== tests/cases/compiler/es6modulekindWithES2015Target.ts ===
|
||||
|
||||
export default class A
|
||||
>A : Symbol(A, Decl(es6modulekindWithES2015Target.ts, 0, 0))
|
||||
{
|
||||
constructor ()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public B()
|
||||
>B : Symbol(B, Decl(es6modulekindWithES2015Target.ts, 6, 5))
|
||||
{
|
||||
return 42;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
=== tests/cases/compiler/es6modulekindWithES2015Target.ts ===
|
||||
|
||||
export default class A
|
||||
>A : A
|
||||
{
|
||||
constructor ()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public B()
|
||||
>B : () => number
|
||||
{
|
||||
return 42;
|
||||
>42 : number
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
//// [interfaceClassMerging.ts]
|
||||
interface Foo {
|
||||
method(a: number): string;
|
||||
optionalMethod?(a: number): string;
|
||||
property: string;
|
||||
optionalProperty?: string;
|
||||
}
|
||||
|
||||
class Foo {
|
||||
additionalProperty: string;
|
||||
|
||||
additionalMethod(a: number): string {
|
||||
return this.method(0);
|
||||
}
|
||||
}
|
||||
|
||||
class Bar extends Foo {
|
||||
method(a: number) {
|
||||
return this.optionalProperty;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
var bar = new Bar();
|
||||
bar.method(0);
|
||||
bar.optionalMethod(1);
|
||||
bar.property;
|
||||
bar.optionalProperty;
|
||||
bar.additionalProperty;
|
||||
bar.additionalMethod(2);
|
||||
|
||||
var obj: {
|
||||
method(a: number): string;
|
||||
property: string;
|
||||
additionalProperty: string;
|
||||
additionalMethod(a: number): string;
|
||||
};
|
||||
|
||||
bar = obj;
|
||||
obj = bar;
|
||||
|
||||
|
||||
//// [interfaceClassMerging.js]
|
||||
var __extends = (this && this.__extends) || function (d, b) {
|
||||
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
|
||||
function __() { this.constructor = d; }
|
||||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
||||
};
|
||||
var Foo = (function () {
|
||||
function Foo() {
|
||||
}
|
||||
Foo.prototype.additionalMethod = function (a) {
|
||||
return this.method(0);
|
||||
};
|
||||
return Foo;
|
||||
})();
|
||||
var Bar = (function (_super) {
|
||||
__extends(Bar, _super);
|
||||
function Bar() {
|
||||
_super.apply(this, arguments);
|
||||
}
|
||||
Bar.prototype.method = function (a) {
|
||||
return this.optionalProperty;
|
||||
};
|
||||
return Bar;
|
||||
})(Foo);
|
||||
var bar = new Bar();
|
||||
bar.method(0);
|
||||
bar.optionalMethod(1);
|
||||
bar.property;
|
||||
bar.optionalProperty;
|
||||
bar.additionalProperty;
|
||||
bar.additionalMethod(2);
|
||||
var obj;
|
||||
bar = obj;
|
||||
obj = bar;
|
||||
@@ -0,0 +1,113 @@
|
||||
=== tests/cases/compiler/interfaceClassMerging.ts ===
|
||||
interface Foo {
|
||||
>Foo : Symbol(Foo, Decl(interfaceClassMerging.ts, 0, 0), Decl(interfaceClassMerging.ts, 5, 1))
|
||||
|
||||
method(a: number): string;
|
||||
>method : Symbol(method, Decl(interfaceClassMerging.ts, 0, 15))
|
||||
>a : Symbol(a, Decl(interfaceClassMerging.ts, 1, 11))
|
||||
|
||||
optionalMethod?(a: number): string;
|
||||
>optionalMethod : Symbol(optionalMethod, Decl(interfaceClassMerging.ts, 1, 30))
|
||||
>a : Symbol(a, Decl(interfaceClassMerging.ts, 2, 20))
|
||||
|
||||
property: string;
|
||||
>property : Symbol(property, Decl(interfaceClassMerging.ts, 2, 39))
|
||||
|
||||
optionalProperty?: string;
|
||||
>optionalProperty : Symbol(optionalProperty, Decl(interfaceClassMerging.ts, 3, 21))
|
||||
}
|
||||
|
||||
class Foo {
|
||||
>Foo : Symbol(Foo, Decl(interfaceClassMerging.ts, 0, 0), Decl(interfaceClassMerging.ts, 5, 1))
|
||||
|
||||
additionalProperty: string;
|
||||
>additionalProperty : Symbol(additionalProperty, Decl(interfaceClassMerging.ts, 7, 11))
|
||||
|
||||
additionalMethod(a: number): string {
|
||||
>additionalMethod : Symbol(additionalMethod, Decl(interfaceClassMerging.ts, 8, 31))
|
||||
>a : Symbol(a, Decl(interfaceClassMerging.ts, 10, 21))
|
||||
|
||||
return this.method(0);
|
||||
>this.method : Symbol(method, Decl(interfaceClassMerging.ts, 0, 15))
|
||||
>this : Symbol(Foo, Decl(interfaceClassMerging.ts, 0, 0), Decl(interfaceClassMerging.ts, 5, 1))
|
||||
>method : Symbol(method, Decl(interfaceClassMerging.ts, 0, 15))
|
||||
}
|
||||
}
|
||||
|
||||
class Bar extends Foo {
|
||||
>Bar : Symbol(Bar, Decl(interfaceClassMerging.ts, 13, 1))
|
||||
>Foo : Symbol(Foo, Decl(interfaceClassMerging.ts, 0, 0), Decl(interfaceClassMerging.ts, 5, 1))
|
||||
|
||||
method(a: number) {
|
||||
>method : Symbol(method, Decl(interfaceClassMerging.ts, 15, 23))
|
||||
>a : Symbol(a, Decl(interfaceClassMerging.ts, 16, 11))
|
||||
|
||||
return this.optionalProperty;
|
||||
>this.optionalProperty : Symbol(Foo.optionalProperty, Decl(interfaceClassMerging.ts, 3, 21))
|
||||
>this : Symbol(Bar, Decl(interfaceClassMerging.ts, 13, 1))
|
||||
>optionalProperty : Symbol(Foo.optionalProperty, Decl(interfaceClassMerging.ts, 3, 21))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
var bar = new Bar();
|
||||
>bar : Symbol(bar, Decl(interfaceClassMerging.ts, 22, 3))
|
||||
>Bar : Symbol(Bar, Decl(interfaceClassMerging.ts, 13, 1))
|
||||
|
||||
bar.method(0);
|
||||
>bar.method : Symbol(Bar.method, Decl(interfaceClassMerging.ts, 15, 23))
|
||||
>bar : Symbol(bar, Decl(interfaceClassMerging.ts, 22, 3))
|
||||
>method : Symbol(Bar.method, Decl(interfaceClassMerging.ts, 15, 23))
|
||||
|
||||
bar.optionalMethod(1);
|
||||
>bar.optionalMethod : Symbol(Foo.optionalMethod, Decl(interfaceClassMerging.ts, 1, 30))
|
||||
>bar : Symbol(bar, Decl(interfaceClassMerging.ts, 22, 3))
|
||||
>optionalMethod : Symbol(Foo.optionalMethod, Decl(interfaceClassMerging.ts, 1, 30))
|
||||
|
||||
bar.property;
|
||||
>bar.property : Symbol(Foo.property, Decl(interfaceClassMerging.ts, 2, 39))
|
||||
>bar : Symbol(bar, Decl(interfaceClassMerging.ts, 22, 3))
|
||||
>property : Symbol(Foo.property, Decl(interfaceClassMerging.ts, 2, 39))
|
||||
|
||||
bar.optionalProperty;
|
||||
>bar.optionalProperty : Symbol(Foo.optionalProperty, Decl(interfaceClassMerging.ts, 3, 21))
|
||||
>bar : Symbol(bar, Decl(interfaceClassMerging.ts, 22, 3))
|
||||
>optionalProperty : Symbol(Foo.optionalProperty, Decl(interfaceClassMerging.ts, 3, 21))
|
||||
|
||||
bar.additionalProperty;
|
||||
>bar.additionalProperty : Symbol(Foo.additionalProperty, Decl(interfaceClassMerging.ts, 7, 11))
|
||||
>bar : Symbol(bar, Decl(interfaceClassMerging.ts, 22, 3))
|
||||
>additionalProperty : Symbol(Foo.additionalProperty, Decl(interfaceClassMerging.ts, 7, 11))
|
||||
|
||||
bar.additionalMethod(2);
|
||||
>bar.additionalMethod : Symbol(Foo.additionalMethod, Decl(interfaceClassMerging.ts, 8, 31))
|
||||
>bar : Symbol(bar, Decl(interfaceClassMerging.ts, 22, 3))
|
||||
>additionalMethod : Symbol(Foo.additionalMethod, Decl(interfaceClassMerging.ts, 8, 31))
|
||||
|
||||
var obj: {
|
||||
>obj : Symbol(obj, Decl(interfaceClassMerging.ts, 30, 3))
|
||||
|
||||
method(a: number): string;
|
||||
>method : Symbol(method, Decl(interfaceClassMerging.ts, 30, 10))
|
||||
>a : Symbol(a, Decl(interfaceClassMerging.ts, 31, 11))
|
||||
|
||||
property: string;
|
||||
>property : Symbol(property, Decl(interfaceClassMerging.ts, 31, 30))
|
||||
|
||||
additionalProperty: string;
|
||||
>additionalProperty : Symbol(additionalProperty, Decl(interfaceClassMerging.ts, 32, 21))
|
||||
|
||||
additionalMethod(a: number): string;
|
||||
>additionalMethod : Symbol(additionalMethod, Decl(interfaceClassMerging.ts, 33, 31))
|
||||
>a : Symbol(a, Decl(interfaceClassMerging.ts, 34, 21))
|
||||
|
||||
};
|
||||
|
||||
bar = obj;
|
||||
>bar : Symbol(bar, Decl(interfaceClassMerging.ts, 22, 3))
|
||||
>obj : Symbol(obj, Decl(interfaceClassMerging.ts, 30, 3))
|
||||
|
||||
obj = bar;
|
||||
>obj : Symbol(obj, Decl(interfaceClassMerging.ts, 30, 3))
|
||||
>bar : Symbol(bar, Decl(interfaceClassMerging.ts, 22, 3))
|
||||
|
||||
@@ -0,0 +1,124 @@
|
||||
=== tests/cases/compiler/interfaceClassMerging.ts ===
|
||||
interface Foo {
|
||||
>Foo : Foo
|
||||
|
||||
method(a: number): string;
|
||||
>method : (a: number) => string
|
||||
>a : number
|
||||
|
||||
optionalMethod?(a: number): string;
|
||||
>optionalMethod : (a: number) => string
|
||||
>a : number
|
||||
|
||||
property: string;
|
||||
>property : string
|
||||
|
||||
optionalProperty?: string;
|
||||
>optionalProperty : string
|
||||
}
|
||||
|
||||
class Foo {
|
||||
>Foo : Foo
|
||||
|
||||
additionalProperty: string;
|
||||
>additionalProperty : string
|
||||
|
||||
additionalMethod(a: number): string {
|
||||
>additionalMethod : (a: number) => string
|
||||
>a : number
|
||||
|
||||
return this.method(0);
|
||||
>this.method(0) : string
|
||||
>this.method : (a: number) => string
|
||||
>this : this
|
||||
>method : (a: number) => string
|
||||
>0 : number
|
||||
}
|
||||
}
|
||||
|
||||
class Bar extends Foo {
|
||||
>Bar : Bar
|
||||
>Foo : Foo
|
||||
|
||||
method(a: number) {
|
||||
>method : (a: number) => string
|
||||
>a : number
|
||||
|
||||
return this.optionalProperty;
|
||||
>this.optionalProperty : string
|
||||
>this : this
|
||||
>optionalProperty : string
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
var bar = new Bar();
|
||||
>bar : Bar
|
||||
>new Bar() : Bar
|
||||
>Bar : typeof Bar
|
||||
|
||||
bar.method(0);
|
||||
>bar.method(0) : string
|
||||
>bar.method : (a: number) => string
|
||||
>bar : Bar
|
||||
>method : (a: number) => string
|
||||
>0 : number
|
||||
|
||||
bar.optionalMethod(1);
|
||||
>bar.optionalMethod(1) : string
|
||||
>bar.optionalMethod : (a: number) => string
|
||||
>bar : Bar
|
||||
>optionalMethod : (a: number) => string
|
||||
>1 : number
|
||||
|
||||
bar.property;
|
||||
>bar.property : string
|
||||
>bar : Bar
|
||||
>property : string
|
||||
|
||||
bar.optionalProperty;
|
||||
>bar.optionalProperty : string
|
||||
>bar : Bar
|
||||
>optionalProperty : string
|
||||
|
||||
bar.additionalProperty;
|
||||
>bar.additionalProperty : string
|
||||
>bar : Bar
|
||||
>additionalProperty : string
|
||||
|
||||
bar.additionalMethod(2);
|
||||
>bar.additionalMethod(2) : string
|
||||
>bar.additionalMethod : (a: number) => string
|
||||
>bar : Bar
|
||||
>additionalMethod : (a: number) => string
|
||||
>2 : number
|
||||
|
||||
var obj: {
|
||||
>obj : { method(a: number): string; property: string; additionalProperty: string; additionalMethod(a: number): string; }
|
||||
|
||||
method(a: number): string;
|
||||
>method : (a: number) => string
|
||||
>a : number
|
||||
|
||||
property: string;
|
||||
>property : string
|
||||
|
||||
additionalProperty: string;
|
||||
>additionalProperty : string
|
||||
|
||||
additionalMethod(a: number): string;
|
||||
>additionalMethod : (a: number) => string
|
||||
>a : number
|
||||
|
||||
};
|
||||
|
||||
bar = obj;
|
||||
>bar = obj : { method(a: number): string; property: string; additionalProperty: string; additionalMethod(a: number): string; }
|
||||
>bar : Bar
|
||||
>obj : { method(a: number): string; property: string; additionalProperty: string; additionalMethod(a: number): string; }
|
||||
|
||||
obj = bar;
|
||||
>obj = bar : Bar
|
||||
>obj : { method(a: number): string; property: string; additionalProperty: string; additionalMethod(a: number): string; }
|
||||
>bar : Bar
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
//// [interfaceClassMerging2.ts]
|
||||
interface Foo {
|
||||
interfaceFooMethod(): this;
|
||||
interfaceFooProperty: this;
|
||||
}
|
||||
|
||||
class Foo {
|
||||
classFooProperty: this;
|
||||
|
||||
classFooMethod(): this {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
interface Bar {
|
||||
interfaceBarMethod(): this;
|
||||
interfaceBarProperty: this;
|
||||
}
|
||||
|
||||
class Bar extends Foo {
|
||||
classBarProperty: this;
|
||||
|
||||
classBarMethod(): this {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
var bar = new Bar();
|
||||
bar.interfaceBarMethod().interfaceFooMethod().classBarMethod().classFooMethod();
|
||||
|
||||
|
||||
var foo = new Foo();
|
||||
|
||||
foo = bar;
|
||||
|
||||
|
||||
//// [interfaceClassMerging2.js]
|
||||
var __extends = (this && this.__extends) || function (d, b) {
|
||||
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
|
||||
function __() { this.constructor = d; }
|
||||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
||||
};
|
||||
var Foo = (function () {
|
||||
function Foo() {
|
||||
}
|
||||
Foo.prototype.classFooMethod = function () {
|
||||
return this;
|
||||
};
|
||||
return Foo;
|
||||
})();
|
||||
var Bar = (function (_super) {
|
||||
__extends(Bar, _super);
|
||||
function Bar() {
|
||||
_super.apply(this, arguments);
|
||||
}
|
||||
Bar.prototype.classBarMethod = function () {
|
||||
return this;
|
||||
};
|
||||
return Bar;
|
||||
})(Foo);
|
||||
var bar = new Bar();
|
||||
bar.interfaceBarMethod().interfaceFooMethod().classBarMethod().classFooMethod();
|
||||
var foo = new Foo();
|
||||
foo = bar;
|
||||
@@ -0,0 +1,76 @@
|
||||
=== tests/cases/compiler/interfaceClassMerging2.ts ===
|
||||
interface Foo {
|
||||
>Foo : Symbol(Foo, Decl(interfaceClassMerging2.ts, 0, 0), Decl(interfaceClassMerging2.ts, 3, 1))
|
||||
|
||||
interfaceFooMethod(): this;
|
||||
>interfaceFooMethod : Symbol(interfaceFooMethod, Decl(interfaceClassMerging2.ts, 0, 15))
|
||||
|
||||
interfaceFooProperty: this;
|
||||
>interfaceFooProperty : Symbol(interfaceFooProperty, Decl(interfaceClassMerging2.ts, 1, 31))
|
||||
}
|
||||
|
||||
class Foo {
|
||||
>Foo : Symbol(Foo, Decl(interfaceClassMerging2.ts, 0, 0), Decl(interfaceClassMerging2.ts, 3, 1))
|
||||
|
||||
classFooProperty: this;
|
||||
>classFooProperty : Symbol(classFooProperty, Decl(interfaceClassMerging2.ts, 5, 11))
|
||||
|
||||
classFooMethod(): this {
|
||||
>classFooMethod : Symbol(classFooMethod, Decl(interfaceClassMerging2.ts, 6, 27))
|
||||
|
||||
return this;
|
||||
>this : Symbol(Foo, Decl(interfaceClassMerging2.ts, 0, 0), Decl(interfaceClassMerging2.ts, 3, 1))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
interface Bar {
|
||||
>Bar : Symbol(Bar, Decl(interfaceClassMerging2.ts, 11, 1), Decl(interfaceClassMerging2.ts, 17, 1))
|
||||
|
||||
interfaceBarMethod(): this;
|
||||
>interfaceBarMethod : Symbol(interfaceBarMethod, Decl(interfaceClassMerging2.ts, 14, 15))
|
||||
|
||||
interfaceBarProperty: this;
|
||||
>interfaceBarProperty : Symbol(interfaceBarProperty, Decl(interfaceClassMerging2.ts, 15, 31))
|
||||
}
|
||||
|
||||
class Bar extends Foo {
|
||||
>Bar : Symbol(Bar, Decl(interfaceClassMerging2.ts, 11, 1), Decl(interfaceClassMerging2.ts, 17, 1))
|
||||
>Foo : Symbol(Foo, Decl(interfaceClassMerging2.ts, 0, 0), Decl(interfaceClassMerging2.ts, 3, 1))
|
||||
|
||||
classBarProperty: this;
|
||||
>classBarProperty : Symbol(classBarProperty, Decl(interfaceClassMerging2.ts, 19, 23))
|
||||
|
||||
classBarMethod(): this {
|
||||
>classBarMethod : Symbol(classBarMethod, Decl(interfaceClassMerging2.ts, 20, 27))
|
||||
|
||||
return this;
|
||||
>this : Symbol(Bar, Decl(interfaceClassMerging2.ts, 11, 1), Decl(interfaceClassMerging2.ts, 17, 1))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
var bar = new Bar();
|
||||
>bar : Symbol(bar, Decl(interfaceClassMerging2.ts, 28, 3))
|
||||
>Bar : Symbol(Bar, Decl(interfaceClassMerging2.ts, 11, 1), Decl(interfaceClassMerging2.ts, 17, 1))
|
||||
|
||||
bar.interfaceBarMethod().interfaceFooMethod().classBarMethod().classFooMethod();
|
||||
>bar.interfaceBarMethod().interfaceFooMethod().classBarMethod().classFooMethod : Symbol(Foo.classFooMethod, Decl(interfaceClassMerging2.ts, 6, 27))
|
||||
>bar.interfaceBarMethod().interfaceFooMethod().classBarMethod : Symbol(Bar.classBarMethod, Decl(interfaceClassMerging2.ts, 20, 27))
|
||||
>bar.interfaceBarMethod().interfaceFooMethod : Symbol(Foo.interfaceFooMethod, Decl(interfaceClassMerging2.ts, 0, 15))
|
||||
>bar.interfaceBarMethod : Symbol(Bar.interfaceBarMethod, Decl(interfaceClassMerging2.ts, 14, 15))
|
||||
>bar : Symbol(bar, Decl(interfaceClassMerging2.ts, 28, 3))
|
||||
>interfaceBarMethod : Symbol(Bar.interfaceBarMethod, Decl(interfaceClassMerging2.ts, 14, 15))
|
||||
>interfaceFooMethod : Symbol(Foo.interfaceFooMethod, Decl(interfaceClassMerging2.ts, 0, 15))
|
||||
>classBarMethod : Symbol(Bar.classBarMethod, Decl(interfaceClassMerging2.ts, 20, 27))
|
||||
>classFooMethod : Symbol(Foo.classFooMethod, Decl(interfaceClassMerging2.ts, 6, 27))
|
||||
|
||||
|
||||
var foo = new Foo();
|
||||
>foo : Symbol(foo, Decl(interfaceClassMerging2.ts, 32, 3))
|
||||
>Foo : Symbol(Foo, Decl(interfaceClassMerging2.ts, 0, 0), Decl(interfaceClassMerging2.ts, 3, 1))
|
||||
|
||||
foo = bar;
|
||||
>foo : Symbol(foo, Decl(interfaceClassMerging2.ts, 32, 3))
|
||||
>bar : Symbol(bar, Decl(interfaceClassMerging2.ts, 28, 3))
|
||||
|
||||
@@ -0,0 +1,83 @@
|
||||
=== tests/cases/compiler/interfaceClassMerging2.ts ===
|
||||
interface Foo {
|
||||
>Foo : Foo
|
||||
|
||||
interfaceFooMethod(): this;
|
||||
>interfaceFooMethod : () => this
|
||||
|
||||
interfaceFooProperty: this;
|
||||
>interfaceFooProperty : this
|
||||
}
|
||||
|
||||
class Foo {
|
||||
>Foo : Foo
|
||||
|
||||
classFooProperty: this;
|
||||
>classFooProperty : this
|
||||
|
||||
classFooMethod(): this {
|
||||
>classFooMethod : () => this
|
||||
|
||||
return this;
|
||||
>this : this
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
interface Bar {
|
||||
>Bar : Bar
|
||||
|
||||
interfaceBarMethod(): this;
|
||||
>interfaceBarMethod : () => this
|
||||
|
||||
interfaceBarProperty: this;
|
||||
>interfaceBarProperty : this
|
||||
}
|
||||
|
||||
class Bar extends Foo {
|
||||
>Bar : Bar
|
||||
>Foo : Foo
|
||||
|
||||
classBarProperty: this;
|
||||
>classBarProperty : this
|
||||
|
||||
classBarMethod(): this {
|
||||
>classBarMethod : () => this
|
||||
|
||||
return this;
|
||||
>this : this
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
var bar = new Bar();
|
||||
>bar : Bar
|
||||
>new Bar() : Bar
|
||||
>Bar : typeof Bar
|
||||
|
||||
bar.interfaceBarMethod().interfaceFooMethod().classBarMethod().classFooMethod();
|
||||
>bar.interfaceBarMethod().interfaceFooMethod().classBarMethod().classFooMethod() : Bar
|
||||
>bar.interfaceBarMethod().interfaceFooMethod().classBarMethod().classFooMethod : () => Bar
|
||||
>bar.interfaceBarMethod().interfaceFooMethod().classBarMethod() : Bar
|
||||
>bar.interfaceBarMethod().interfaceFooMethod().classBarMethod : () => Bar
|
||||
>bar.interfaceBarMethod().interfaceFooMethod() : Bar
|
||||
>bar.interfaceBarMethod().interfaceFooMethod : () => Bar
|
||||
>bar.interfaceBarMethod() : Bar
|
||||
>bar.interfaceBarMethod : () => Bar
|
||||
>bar : Bar
|
||||
>interfaceBarMethod : () => Bar
|
||||
>interfaceFooMethod : () => Bar
|
||||
>classBarMethod : () => Bar
|
||||
>classFooMethod : () => Bar
|
||||
|
||||
|
||||
var foo = new Foo();
|
||||
>foo : Foo
|
||||
>new Foo() : Foo
|
||||
>Foo : typeof Foo
|
||||
|
||||
foo = bar;
|
||||
>foo = bar : Bar
|
||||
>foo : Foo
|
||||
>bar : Bar
|
||||
|
||||
@@ -1,22 +0,0 @@
|
||||
tests/cases/compiler/interfaceDeclaration2.ts(4,11): error TS2518: Only an ambient class can be merged with an interface.
|
||||
tests/cases/compiler/interfaceDeclaration2.ts(5,7): error TS2518: Only an ambient class can be merged with an interface.
|
||||
|
||||
|
||||
==== tests/cases/compiler/interfaceDeclaration2.ts (2 errors) ====
|
||||
interface I1 { }
|
||||
module I1 { }
|
||||
|
||||
interface I2 { }
|
||||
~~
|
||||
!!! error TS2518: Only an ambient class can be merged with an interface.
|
||||
class I2 { }
|
||||
~~
|
||||
!!! error TS2518: Only an ambient class can be merged with an interface.
|
||||
|
||||
interface I3 { }
|
||||
function I3() { }
|
||||
|
||||
interface I4 { }
|
||||
var I4:number;
|
||||
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
=== tests/cases/compiler/interfaceDeclaration2.ts ===
|
||||
interface I1 { }
|
||||
>I1 : Symbol(I1, Decl(interfaceDeclaration2.ts, 0, 0), Decl(interfaceDeclaration2.ts, 0, 16))
|
||||
|
||||
module I1 { }
|
||||
>I1 : Symbol(I1, Decl(interfaceDeclaration2.ts, 0, 0), Decl(interfaceDeclaration2.ts, 0, 16))
|
||||
|
||||
interface I2 { }
|
||||
>I2 : Symbol(I2, Decl(interfaceDeclaration2.ts, 1, 13), Decl(interfaceDeclaration2.ts, 3, 16))
|
||||
|
||||
class I2 { }
|
||||
>I2 : Symbol(I2, Decl(interfaceDeclaration2.ts, 1, 13), Decl(interfaceDeclaration2.ts, 3, 16))
|
||||
|
||||
interface I3 { }
|
||||
>I3 : Symbol(I3, Decl(interfaceDeclaration2.ts, 4, 12), Decl(interfaceDeclaration2.ts, 6, 16))
|
||||
|
||||
function I3() { }
|
||||
>I3 : Symbol(I3, Decl(interfaceDeclaration2.ts, 4, 12), Decl(interfaceDeclaration2.ts, 6, 16))
|
||||
|
||||
interface I4 { }
|
||||
>I4 : Symbol(I4, Decl(interfaceDeclaration2.ts, 7, 17), Decl(interfaceDeclaration2.ts, 10, 3))
|
||||
|
||||
var I4:number;
|
||||
>I4 : Symbol(I4, Decl(interfaceDeclaration2.ts, 7, 17), Decl(interfaceDeclaration2.ts, 10, 3))
|
||||
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
=== tests/cases/compiler/interfaceDeclaration2.ts ===
|
||||
interface I1 { }
|
||||
>I1 : I1
|
||||
|
||||
module I1 { }
|
||||
>I1 : any
|
||||
|
||||
interface I2 { }
|
||||
>I2 : I2
|
||||
|
||||
class I2 { }
|
||||
>I2 : I2
|
||||
|
||||
interface I3 { }
|
||||
>I3 : I3
|
||||
|
||||
function I3() { }
|
||||
>I3 : () => void
|
||||
|
||||
interface I4 { }
|
||||
>I4 : I4
|
||||
|
||||
var I4:number;
|
||||
>I4 : number
|
||||
|
||||
|
||||
@@ -1,67 +0,0 @@
|
||||
tests/cases/conformance/classes/classDeclarations/file1.ts(11,7): error TS2518: Only an ambient class can be merged with an interface.
|
||||
tests/cases/conformance/classes/classDeclarations/file1.ts(13,11): error TS2518: Only an ambient class can be merged with an interface.
|
||||
tests/cases/conformance/classes/classDeclarations/file1.ts(15,11): error TS2518: Only an ambient class can be merged with an interface.
|
||||
tests/cases/conformance/classes/classDeclarations/file1.ts(17,7): error TS2518: Only an ambient class can be merged with an interface.
|
||||
|
||||
|
||||
==== tests/cases/conformance/classes/classDeclarations/file1.ts (4 errors) ====
|
||||
|
||||
|
||||
declare class C1 { }
|
||||
|
||||
interface C1 { }
|
||||
|
||||
interface C2 { }
|
||||
|
||||
declare class C2 { }
|
||||
|
||||
class C3 { } // error -- cannot merge non-ambient class and interface
|
||||
~~
|
||||
!!! error TS2518: Only an ambient class can be merged with an interface.
|
||||
|
||||
interface C3 { } // error -- cannot merge non-ambient class and interface
|
||||
~~
|
||||
!!! error TS2518: Only an ambient class can be merged with an interface.
|
||||
|
||||
interface C4 { } // error -- cannot merge non-ambient class and interface
|
||||
~~
|
||||
!!! error TS2518: Only an ambient class can be merged with an interface.
|
||||
|
||||
class C4 { } // error -- cannot merge non-ambient class and interface
|
||||
~~
|
||||
!!! error TS2518: Only an ambient class can be merged with an interface.
|
||||
|
||||
interface C5 {
|
||||
x1: number;
|
||||
}
|
||||
|
||||
declare class C5 {
|
||||
x2: number;
|
||||
}
|
||||
|
||||
interface C5 {
|
||||
x3: number;
|
||||
}
|
||||
|
||||
interface C5 {
|
||||
x4: number;
|
||||
}
|
||||
|
||||
// checks if properties actually were merged
|
||||
var c5 : C5;
|
||||
c5.x1;
|
||||
c5.x2;
|
||||
c5.x3;
|
||||
c5.x4;
|
||||
|
||||
==== tests/cases/conformance/classes/classDeclarations/file2.ts (0 errors) ====
|
||||
|
||||
declare class C6 { }
|
||||
|
||||
interface C7 { }
|
||||
|
||||
==== tests/cases/conformance/classes/classDeclarations/file3.ts (0 errors) ====
|
||||
|
||||
interface C6 { }
|
||||
|
||||
declare class C7 { }
|
||||
@@ -11,13 +11,13 @@ interface C2 { }
|
||||
|
||||
declare class C2 { }
|
||||
|
||||
class C3 { } // error -- cannot merge non-ambient class and interface
|
||||
class C3 { }
|
||||
|
||||
interface C3 { } // error -- cannot merge non-ambient class and interface
|
||||
interface C3 { }
|
||||
|
||||
interface C4 { } // error -- cannot merge non-ambient class and interface
|
||||
interface C4 { }
|
||||
|
||||
class C4 { } // error -- cannot merge non-ambient class and interface
|
||||
class C4 { }
|
||||
|
||||
interface C5 {
|
||||
x1: number;
|
||||
@@ -59,12 +59,12 @@ var C3 = (function () {
|
||||
function C3() {
|
||||
}
|
||||
return C3;
|
||||
})(); // error -- cannot merge non-ambient class and interface
|
||||
})();
|
||||
var C4 = (function () {
|
||||
function C4() {
|
||||
}
|
||||
return C4;
|
||||
})(); // error -- cannot merge non-ambient class and interface
|
||||
})();
|
||||
// checks if properties actually were merged
|
||||
var c5;
|
||||
c5.x1;
|
||||
|
||||
@@ -0,0 +1,96 @@
|
||||
=== tests/cases/conformance/classes/classDeclarations/file1.ts ===
|
||||
|
||||
|
||||
declare class C1 { }
|
||||
>C1 : Symbol(C1, Decl(file1.ts, 0, 0), Decl(file1.ts, 2, 20))
|
||||
|
||||
interface C1 { }
|
||||
>C1 : Symbol(C1, Decl(file1.ts, 0, 0), Decl(file1.ts, 2, 20))
|
||||
|
||||
interface C2 { }
|
||||
>C2 : Symbol(C2, Decl(file1.ts, 4, 16), Decl(file1.ts, 6, 16))
|
||||
|
||||
declare class C2 { }
|
||||
>C2 : Symbol(C2, Decl(file1.ts, 4, 16), Decl(file1.ts, 6, 16))
|
||||
|
||||
class C3 { }
|
||||
>C3 : Symbol(C3, Decl(file1.ts, 8, 20), Decl(file1.ts, 10, 12))
|
||||
|
||||
interface C3 { }
|
||||
>C3 : Symbol(C3, Decl(file1.ts, 8, 20), Decl(file1.ts, 10, 12))
|
||||
|
||||
interface C4 { }
|
||||
>C4 : Symbol(C4, Decl(file1.ts, 12, 16), Decl(file1.ts, 14, 16))
|
||||
|
||||
class C4 { }
|
||||
>C4 : Symbol(C4, Decl(file1.ts, 12, 16), Decl(file1.ts, 14, 16))
|
||||
|
||||
interface C5 {
|
||||
>C5 : Symbol(C5, Decl(file1.ts, 16, 12), Decl(file1.ts, 20, 1), Decl(file1.ts, 24, 1), Decl(file1.ts, 28, 1))
|
||||
|
||||
x1: number;
|
||||
>x1 : Symbol(x1, Decl(file1.ts, 18, 14))
|
||||
}
|
||||
|
||||
declare class C5 {
|
||||
>C5 : Symbol(C5, Decl(file1.ts, 16, 12), Decl(file1.ts, 20, 1), Decl(file1.ts, 24, 1), Decl(file1.ts, 28, 1))
|
||||
|
||||
x2: number;
|
||||
>x2 : Symbol(x2, Decl(file1.ts, 22, 18))
|
||||
}
|
||||
|
||||
interface C5 {
|
||||
>C5 : Symbol(C5, Decl(file1.ts, 16, 12), Decl(file1.ts, 20, 1), Decl(file1.ts, 24, 1), Decl(file1.ts, 28, 1))
|
||||
|
||||
x3: number;
|
||||
>x3 : Symbol(x3, Decl(file1.ts, 26, 14))
|
||||
}
|
||||
|
||||
interface C5 {
|
||||
>C5 : Symbol(C5, Decl(file1.ts, 16, 12), Decl(file1.ts, 20, 1), Decl(file1.ts, 24, 1), Decl(file1.ts, 28, 1))
|
||||
|
||||
x4: number;
|
||||
>x4 : Symbol(x4, Decl(file1.ts, 30, 14))
|
||||
}
|
||||
|
||||
// checks if properties actually were merged
|
||||
var c5 : C5;
|
||||
>c5 : Symbol(c5, Decl(file1.ts, 35, 3))
|
||||
>C5 : Symbol(C5, Decl(file1.ts, 16, 12), Decl(file1.ts, 20, 1), Decl(file1.ts, 24, 1), Decl(file1.ts, 28, 1))
|
||||
|
||||
c5.x1;
|
||||
>c5.x1 : Symbol(C5.x1, Decl(file1.ts, 18, 14))
|
||||
>c5 : Symbol(c5, Decl(file1.ts, 35, 3))
|
||||
>x1 : Symbol(C5.x1, Decl(file1.ts, 18, 14))
|
||||
|
||||
c5.x2;
|
||||
>c5.x2 : Symbol(C5.x2, Decl(file1.ts, 22, 18))
|
||||
>c5 : Symbol(c5, Decl(file1.ts, 35, 3))
|
||||
>x2 : Symbol(C5.x2, Decl(file1.ts, 22, 18))
|
||||
|
||||
c5.x3;
|
||||
>c5.x3 : Symbol(C5.x3, Decl(file1.ts, 26, 14))
|
||||
>c5 : Symbol(c5, Decl(file1.ts, 35, 3))
|
||||
>x3 : Symbol(C5.x3, Decl(file1.ts, 26, 14))
|
||||
|
||||
c5.x4;
|
||||
>c5.x4 : Symbol(C5.x4, Decl(file1.ts, 30, 14))
|
||||
>c5 : Symbol(c5, Decl(file1.ts, 35, 3))
|
||||
>x4 : Symbol(C5.x4, Decl(file1.ts, 30, 14))
|
||||
|
||||
=== tests/cases/conformance/classes/classDeclarations/file2.ts ===
|
||||
|
||||
declare class C6 { }
|
||||
>C6 : Symbol(C6, Decl(file2.ts, 0, 0), Decl(file3.ts, 0, 0))
|
||||
|
||||
interface C7 { }
|
||||
>C7 : Symbol(C7, Decl(file2.ts, 1, 20), Decl(file3.ts, 1, 16))
|
||||
|
||||
=== tests/cases/conformance/classes/classDeclarations/file3.ts ===
|
||||
|
||||
interface C6 { }
|
||||
>C6 : Symbol(C6, Decl(file2.ts, 0, 0), Decl(file3.ts, 0, 0))
|
||||
|
||||
declare class C7 { }
|
||||
>C7 : Symbol(C7, Decl(file2.ts, 1, 20), Decl(file3.ts, 1, 16))
|
||||
|
||||
@@ -0,0 +1,96 @@
|
||||
=== tests/cases/conformance/classes/classDeclarations/file1.ts ===
|
||||
|
||||
|
||||
declare class C1 { }
|
||||
>C1 : C1
|
||||
|
||||
interface C1 { }
|
||||
>C1 : C1
|
||||
|
||||
interface C2 { }
|
||||
>C2 : C2
|
||||
|
||||
declare class C2 { }
|
||||
>C2 : C2
|
||||
|
||||
class C3 { }
|
||||
>C3 : C3
|
||||
|
||||
interface C3 { }
|
||||
>C3 : C3
|
||||
|
||||
interface C4 { }
|
||||
>C4 : C4
|
||||
|
||||
class C4 { }
|
||||
>C4 : C4
|
||||
|
||||
interface C5 {
|
||||
>C5 : C5
|
||||
|
||||
x1: number;
|
||||
>x1 : number
|
||||
}
|
||||
|
||||
declare class C5 {
|
||||
>C5 : C5
|
||||
|
||||
x2: number;
|
||||
>x2 : number
|
||||
}
|
||||
|
||||
interface C5 {
|
||||
>C5 : C5
|
||||
|
||||
x3: number;
|
||||
>x3 : number
|
||||
}
|
||||
|
||||
interface C5 {
|
||||
>C5 : C5
|
||||
|
||||
x4: number;
|
||||
>x4 : number
|
||||
}
|
||||
|
||||
// checks if properties actually were merged
|
||||
var c5 : C5;
|
||||
>c5 : C5
|
||||
>C5 : C5
|
||||
|
||||
c5.x1;
|
||||
>c5.x1 : number
|
||||
>c5 : C5
|
||||
>x1 : number
|
||||
|
||||
c5.x2;
|
||||
>c5.x2 : number
|
||||
>c5 : C5
|
||||
>x2 : number
|
||||
|
||||
c5.x3;
|
||||
>c5.x3 : number
|
||||
>c5 : C5
|
||||
>x3 : number
|
||||
|
||||
c5.x4;
|
||||
>c5.x4 : number
|
||||
>c5 : C5
|
||||
>x4 : number
|
||||
|
||||
=== tests/cases/conformance/classes/classDeclarations/file2.ts ===
|
||||
|
||||
declare class C6 { }
|
||||
>C6 : C6
|
||||
|
||||
interface C7 { }
|
||||
>C7 : C7
|
||||
|
||||
=== tests/cases/conformance/classes/classDeclarations/file3.ts ===
|
||||
|
||||
interface C6 { }
|
||||
>C6 : C6
|
||||
|
||||
declare class C7 { }
|
||||
>C7 : C7
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
//// [tests/cases/compiler/moduleMergeConstructor.ts] ////
|
||||
|
||||
//// [foo.d.ts]
|
||||
|
||||
declare module "foo" {
|
||||
export class Foo {
|
||||
constructor();
|
||||
method1(): any;
|
||||
}
|
||||
}
|
||||
|
||||
//// [foo-ext.d.ts]
|
||||
declare module "foo" {
|
||||
export interface Foo {
|
||||
method2(): any;
|
||||
}
|
||||
}
|
||||
|
||||
//// [index.ts]
|
||||
import * as foo from "foo";
|
||||
|
||||
class Test {
|
||||
bar: foo.Foo;
|
||||
constructor() {
|
||||
this.bar = new foo.Foo();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//// [index.js]
|
||||
define(["require", "exports", "foo"], function (require, exports, foo) {
|
||||
var Test = (function () {
|
||||
function Test() {
|
||||
this.bar = new foo.Foo();
|
||||
}
|
||||
return Test;
|
||||
})();
|
||||
});
|
||||
@@ -0,0 +1,45 @@
|
||||
=== tests/cases/compiler/foo.d.ts ===
|
||||
|
||||
declare module "foo" {
|
||||
export class Foo {
|
||||
>Foo : Symbol(Foo, Decl(foo.d.ts, 1, 22), Decl(foo-ext.d.ts, 0, 22))
|
||||
|
||||
constructor();
|
||||
method1(): any;
|
||||
>method1 : Symbol(method1, Decl(foo.d.ts, 3, 22))
|
||||
}
|
||||
}
|
||||
|
||||
=== tests/cases/compiler/foo-ext.d.ts ===
|
||||
declare module "foo" {
|
||||
export interface Foo {
|
||||
>Foo : Symbol(Foo, Decl(foo.d.ts, 1, 22), Decl(foo-ext.d.ts, 0, 22))
|
||||
|
||||
method2(): any;
|
||||
>method2 : Symbol(method2, Decl(foo-ext.d.ts, 1, 26))
|
||||
}
|
||||
}
|
||||
|
||||
=== tests/cases/compiler/index.ts ===
|
||||
import * as foo from "foo";
|
||||
>foo : Symbol(foo, Decl(index.ts, 0, 6))
|
||||
|
||||
class Test {
|
||||
>Test : Symbol(Test, Decl(index.ts, 0, 27))
|
||||
|
||||
bar: foo.Foo;
|
||||
>bar : Symbol(bar, Decl(index.ts, 2, 12))
|
||||
>foo : Symbol(foo, Decl(index.ts, 0, 6))
|
||||
>Foo : Symbol(foo.Foo, Decl(foo.d.ts, 1, 22), Decl(foo-ext.d.ts, 0, 22))
|
||||
|
||||
constructor() {
|
||||
this.bar = new foo.Foo();
|
||||
>this.bar : Symbol(bar, Decl(index.ts, 2, 12))
|
||||
>this : Symbol(Test, Decl(index.ts, 0, 27))
|
||||
>bar : Symbol(bar, Decl(index.ts, 2, 12))
|
||||
>foo.Foo : Symbol(foo.Foo, Decl(foo.d.ts, 1, 22), Decl(foo-ext.d.ts, 0, 22))
|
||||
>foo : Symbol(foo, Decl(index.ts, 0, 6))
|
||||
>Foo : Symbol(foo.Foo, Decl(foo.d.ts, 1, 22), Decl(foo-ext.d.ts, 0, 22))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
=== tests/cases/compiler/foo.d.ts ===
|
||||
|
||||
declare module "foo" {
|
||||
export class Foo {
|
||||
>Foo : Foo
|
||||
|
||||
constructor();
|
||||
method1(): any;
|
||||
>method1 : () => any
|
||||
}
|
||||
}
|
||||
|
||||
=== tests/cases/compiler/foo-ext.d.ts ===
|
||||
declare module "foo" {
|
||||
export interface Foo {
|
||||
>Foo : Foo
|
||||
|
||||
method2(): any;
|
||||
>method2 : () => any
|
||||
}
|
||||
}
|
||||
|
||||
=== tests/cases/compiler/index.ts ===
|
||||
import * as foo from "foo";
|
||||
>foo : typeof foo
|
||||
|
||||
class Test {
|
||||
>Test : Test
|
||||
|
||||
bar: foo.Foo;
|
||||
>bar : foo.Foo
|
||||
>foo : any
|
||||
>Foo : foo.Foo
|
||||
|
||||
constructor() {
|
||||
this.bar = new foo.Foo();
|
||||
>this.bar = new foo.Foo() : foo.Foo
|
||||
>this.bar : foo.Foo
|
||||
>this : this
|
||||
>bar : foo.Foo
|
||||
>new foo.Foo() : foo.Foo
|
||||
>foo.Foo : typeof foo.Foo
|
||||
>foo : typeof foo
|
||||
>Foo : typeof foo.Foo
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,13 +11,9 @@ tests/cases/compiler/nameCollisions.ts(33,11): error TS2300: Duplicate identifie
|
||||
tests/cases/compiler/nameCollisions.ts(34,14): error TS2300: Duplicate identifier 'C'.
|
||||
tests/cases/compiler/nameCollisions.ts(36,14): error TS2300: Duplicate identifier 'C2'.
|
||||
tests/cases/compiler/nameCollisions.ts(37,11): error TS2300: Duplicate identifier 'C2'.
|
||||
tests/cases/compiler/nameCollisions.ts(42,11): error TS2518: Only an ambient class can be merged with an interface.
|
||||
tests/cases/compiler/nameCollisions.ts(43,15): error TS2518: Only an ambient class can be merged with an interface.
|
||||
tests/cases/compiler/nameCollisions.ts(45,15): error TS2518: Only an ambient class can be merged with an interface.
|
||||
tests/cases/compiler/nameCollisions.ts(46,11): error TS2518: Only an ambient class can be merged with an interface.
|
||||
|
||||
|
||||
==== tests/cases/compiler/nameCollisions.ts (17 errors) ====
|
||||
==== tests/cases/compiler/nameCollisions.ts (13 errors) ====
|
||||
module T {
|
||||
var x = 2;
|
||||
~
|
||||
@@ -86,16 +82,8 @@ tests/cases/compiler/nameCollisions.ts(46,11): error TS2518: Only an ambient cla
|
||||
interface fi { } // ok
|
||||
|
||||
class cli { }
|
||||
~~~
|
||||
!!! error TS2518: Only an ambient class can be merged with an interface.
|
||||
interface cli { } // error
|
||||
~~~
|
||||
!!! error TS2518: Only an ambient class can be merged with an interface.
|
||||
interface cli { }
|
||||
|
||||
interface cli2 { }
|
||||
~~~~
|
||||
!!! error TS2518: Only an ambient class can be merged with an interface.
|
||||
class cli2 { } // error
|
||||
~~~~
|
||||
!!! error TS2518: Only an ambient class can be merged with an interface.
|
||||
class cli2 { }
|
||||
}
|
||||
@@ -41,10 +41,10 @@ module T {
|
||||
interface fi { } // ok
|
||||
|
||||
class cli { }
|
||||
interface cli { } // error
|
||||
interface cli { }
|
||||
|
||||
interface cli2 { }
|
||||
class cli2 { } // error
|
||||
class cli2 { }
|
||||
}
|
||||
|
||||
//// [nameCollisions.js]
|
||||
@@ -102,5 +102,5 @@ var T;
|
||||
function cli2() {
|
||||
}
|
||||
return cli2;
|
||||
})(); // error
|
||||
})();
|
||||
})(T || (T = {}));
|
||||
|
||||
@@ -1,13 +1,10 @@
|
||||
tests/cases/compiler/templateStringsArrayTypeDefinedInES5Mode.ts(2,7): error TS2518: Only an ambient class can be merged with an interface.
|
||||
tests/cases/compiler/templateStringsArrayTypeDefinedInES5Mode.ts(8,3): error TS2345: Argument of type '{}' is not assignable to parameter of type 'TemplateStringsArray'.
|
||||
Property 'raw' is missing in type '{}'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/templateStringsArrayTypeDefinedInES5Mode.ts (2 errors) ====
|
||||
==== tests/cases/compiler/templateStringsArrayTypeDefinedInES5Mode.ts (1 errors) ====
|
||||
|
||||
class TemplateStringsArray {
|
||||
~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2518: Only an ambient class can be merged with an interface.
|
||||
}
|
||||
|
||||
function f(x: TemplateStringsArray, y: number, z: number) {
|
||||
|
||||
@@ -1,13 +1,10 @@
|
||||
tests/cases/compiler/templateStringsArrayTypeRedefinedInES6Mode.ts(2,7): error TS2518: Only an ambient class can be merged with an interface.
|
||||
tests/cases/compiler/templateStringsArrayTypeRedefinedInES6Mode.ts(8,3): error TS2345: Argument of type '{}' is not assignable to parameter of type 'TemplateStringsArray'.
|
||||
Property 'raw' is missing in type '{}'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/templateStringsArrayTypeRedefinedInES6Mode.ts (2 errors) ====
|
||||
==== tests/cases/compiler/templateStringsArrayTypeRedefinedInES6Mode.ts (1 errors) ====
|
||||
|
||||
class TemplateStringsArray {
|
||||
~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2518: Only an ambient class can be merged with an interface.
|
||||
}
|
||||
|
||||
function f(x: TemplateStringsArray, y: number, z: number) {
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
declare class C {
|
||||
baz(): any;
|
||||
foo(n: number): any;
|
||||
}
|
||||
interface C {
|
||||
foo(n: number): any;
|
||||
bar(): any;
|
||||
}
|
||||
@@ -1,13 +1,13 @@
|
||||
// Checking class with other things in type space not value space
|
||||
|
||||
// class then interface
|
||||
class c11 { // error
|
||||
class c11 {
|
||||
foo() {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
interface c11 { // error
|
||||
interface c11 {
|
||||
bar(): void;
|
||||
}
|
||||
|
||||
|
||||
@@ -9,11 +9,11 @@ interface i {
|
||||
}
|
||||
|
||||
// interface then class
|
||||
interface i2 { // error
|
||||
interface i2 {
|
||||
foo(): void;
|
||||
}
|
||||
|
||||
class i2 { // error
|
||||
class i2 {
|
||||
bar() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ module M {
|
||||
export interface I { }
|
||||
}
|
||||
module M {
|
||||
export class I { } // error
|
||||
export class I { }
|
||||
}
|
||||
|
||||
module M {
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
// @target: es2015
|
||||
// @sourcemap: false
|
||||
// @declaration: false
|
||||
// @module: es2015
|
||||
|
||||
export default class A
|
||||
{
|
||||
constructor ()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public B()
|
||||
{
|
||||
return 42;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
// @target: es6
|
||||
// @sourcemap: false
|
||||
// @declaration: false
|
||||
// @module: es2015
|
||||
|
||||
export default class A
|
||||
{
|
||||
constructor ()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public B()
|
||||
{
|
||||
return 42;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
// @target: es2015
|
||||
// @sourcemap: false
|
||||
// @declaration: false
|
||||
// @module: es6
|
||||
|
||||
export default class A
|
||||
{
|
||||
constructor ()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public B()
|
||||
{
|
||||
return 42;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
interface Foo {
|
||||
method(a: number): string;
|
||||
optionalMethod?(a: number): string;
|
||||
property: string;
|
||||
optionalProperty?: string;
|
||||
}
|
||||
|
||||
class Foo {
|
||||
additionalProperty: string;
|
||||
|
||||
additionalMethod(a: number): string {
|
||||
return this.method(0);
|
||||
}
|
||||
}
|
||||
|
||||
class Bar extends Foo {
|
||||
method(a: number) {
|
||||
return this.optionalProperty;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
var bar = new Bar();
|
||||
bar.method(0);
|
||||
bar.optionalMethod(1);
|
||||
bar.property;
|
||||
bar.optionalProperty;
|
||||
bar.additionalProperty;
|
||||
bar.additionalMethod(2);
|
||||
|
||||
var obj: {
|
||||
method(a: number): string;
|
||||
property: string;
|
||||
additionalProperty: string;
|
||||
additionalMethod(a: number): string;
|
||||
};
|
||||
|
||||
bar = obj;
|
||||
obj = bar;
|
||||
@@ -0,0 +1,35 @@
|
||||
interface Foo {
|
||||
interfaceFooMethod(): this;
|
||||
interfaceFooProperty: this;
|
||||
}
|
||||
|
||||
class Foo {
|
||||
classFooProperty: this;
|
||||
|
||||
classFooMethod(): this {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
interface Bar {
|
||||
interfaceBarMethod(): this;
|
||||
interfaceBarProperty: this;
|
||||
}
|
||||
|
||||
class Bar extends Foo {
|
||||
classBarProperty: this;
|
||||
|
||||
classBarMethod(): this {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
var bar = new Bar();
|
||||
bar.interfaceBarMethod().interfaceFooMethod().classBarMethod().classFooMethod();
|
||||
|
||||
|
||||
var foo = new Foo();
|
||||
|
||||
foo = bar;
|
||||
@@ -0,0 +1,26 @@
|
||||
// @module: amd
|
||||
|
||||
// @filename: foo.d.ts
|
||||
declare module "foo" {
|
||||
export class Foo {
|
||||
constructor();
|
||||
method1(): any;
|
||||
}
|
||||
}
|
||||
|
||||
// @filename: foo-ext.d.ts
|
||||
declare module "foo" {
|
||||
export interface Foo {
|
||||
method2(): any;
|
||||
}
|
||||
}
|
||||
|
||||
// @filename: index.ts
|
||||
import * as foo from "foo";
|
||||
|
||||
class Test {
|
||||
bar: foo.Foo;
|
||||
constructor() {
|
||||
this.bar = new foo.Foo();
|
||||
}
|
||||
}
|
||||
@@ -40,8 +40,8 @@ module T {
|
||||
interface fi { } // ok
|
||||
|
||||
class cli { }
|
||||
interface cli { } // error
|
||||
interface cli { }
|
||||
|
||||
interface cli2 { }
|
||||
class cli2 { } // error
|
||||
class cli2 { }
|
||||
}
|
||||
@@ -1,12 +1,12 @@
|
||||
class C { foo: string; }
|
||||
interface C { foo: string; } // error
|
||||
interface C { foo: string; }
|
||||
|
||||
module M {
|
||||
class D {
|
||||
bar: string;
|
||||
}
|
||||
|
||||
interface D { // error
|
||||
interface D {
|
||||
bar: string;
|
||||
}
|
||||
}
|
||||
@@ -10,13 +10,13 @@ interface C2 { }
|
||||
|
||||
declare class C2 { }
|
||||
|
||||
class C3 { } // error -- cannot merge non-ambient class and interface
|
||||
class C3 { }
|
||||
|
||||
interface C3 { } // error -- cannot merge non-ambient class and interface
|
||||
interface C3 { }
|
||||
|
||||
interface C4 { } // error -- cannot merge non-ambient class and interface
|
||||
interface C4 { }
|
||||
|
||||
class C4 { } // error -- cannot merge non-ambient class and interface
|
||||
class C4 { }
|
||||
|
||||
interface C5 {
|
||||
x1: number;
|
||||
|
||||
Reference in New Issue
Block a user