Merge pull request #3207 from Microsoft/declareModifierForInterface

Declare modifier for interface
This commit is contained in:
Yui
2015-05-19 13:23:32 -04:00
8 changed files with 39 additions and 11 deletions

View File

@@ -12361,9 +12361,6 @@ module ts {
else if ((node.kind === SyntaxKind.ImportDeclaration || node.kind === SyntaxKind.ImportEqualsDeclaration) && flags & NodeFlags.Ambient) {
return grammarErrorOnNode(lastDeclare, Diagnostics.A_declare_modifier_cannot_be_used_with_an_import_declaration, "declare");
}
else if (node.kind === SyntaxKind.InterfaceDeclaration && flags & NodeFlags.Ambient) {
return grammarErrorOnNode(lastDeclare, Diagnostics.A_declare_modifier_cannot_be_used_with_an_interface_declaration, "declare");
}
else if (node.kind === SyntaxKind.Parameter && (flags & NodeFlags.AccessibilityModifier) && isBindingPattern((<ParameterDeclaration>node).name)) {
return grammarErrorOnNode(node, Diagnostics.A_parameter_property_may_not_be_a_binding_pattern);
}

View File

@@ -0,0 +1,6 @@
//// [declareModifierOnTypeAlias.ts]
declare type Foo = string;
type Bar = number;
declare type Baz = Bar;
//// [declareModifierOnTypeAlias.js]

View File

@@ -0,0 +1,11 @@
=== tests/cases/compiler/declareModifierOnTypeAlias.ts ===
declare type Foo = string;
>Foo : Symbol(Foo, Decl(declareModifierOnTypeAlias.ts, 0, 0))
type Bar = number;
>Bar : Symbol(Bar, Decl(declareModifierOnTypeAlias.ts, 0, 26))
declare type Baz = Bar;
>Baz : Symbol(Baz, Decl(declareModifierOnTypeAlias.ts, 1, 18))
>Bar : Symbol(Bar, Decl(declareModifierOnTypeAlias.ts, 0, 26))

View File

@@ -0,0 +1,11 @@
=== tests/cases/compiler/declareModifierOnTypeAlias.ts ===
declare type Foo = string;
>Foo : string
type Bar = number;
>Bar : number
declare type Baz = Bar;
>Baz : number
>Bar : number

View File

@@ -1,8 +0,0 @@
tests/cases/conformance/parser/ecmascript5/InterfaceDeclarations/parserInterfaceDeclaration5.ts(1,1): error TS1045: A 'declare' modifier cannot be used with an interface declaration.
==== tests/cases/conformance/parser/ecmascript5/InterfaceDeclarations/parserInterfaceDeclaration5.ts (1 errors) ====
declare interface I {
~~~~~~~
!!! error TS1045: A 'declare' modifier cannot be used with an interface declaration.
}

View File

@@ -0,0 +1,4 @@
=== tests/cases/conformance/parser/ecmascript5/InterfaceDeclarations/parserInterfaceDeclaration5.ts ===
declare interface I {
>I : Symbol(I, Decl(parserInterfaceDeclaration5.ts, 0, 0))
}

View File

@@ -0,0 +1,4 @@
=== tests/cases/conformance/parser/ecmascript5/InterfaceDeclarations/parserInterfaceDeclaration5.ts ===
declare interface I {
>I : I
}

View File

@@ -0,0 +1,3 @@
declare type Foo = string;
type Bar = number;
declare type Baz = Bar;