mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-29 16:29:19 -05:00
Merge pull request #3207 from Microsoft/declareModifierForInterface
Declare modifier for interface
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
6
tests/baselines/reference/declareModifierOnTypeAlias.js
Normal file
6
tests/baselines/reference/declareModifierOnTypeAlias.js
Normal file
@@ -0,0 +1,6 @@
|
||||
//// [declareModifierOnTypeAlias.ts]
|
||||
declare type Foo = string;
|
||||
type Bar = number;
|
||||
declare type Baz = Bar;
|
||||
|
||||
//// [declareModifierOnTypeAlias.js]
|
||||
11
tests/baselines/reference/declareModifierOnTypeAlias.symbols
Normal file
11
tests/baselines/reference/declareModifierOnTypeAlias.symbols
Normal 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))
|
||||
|
||||
11
tests/baselines/reference/declareModifierOnTypeAlias.types
Normal file
11
tests/baselines/reference/declareModifierOnTypeAlias.types
Normal 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
|
||||
|
||||
@@ -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.
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
=== tests/cases/conformance/parser/ecmascript5/InterfaceDeclarations/parserInterfaceDeclaration5.ts ===
|
||||
declare interface I {
|
||||
>I : Symbol(I, Decl(parserInterfaceDeclaration5.ts, 0, 0))
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
=== tests/cases/conformance/parser/ecmascript5/InterfaceDeclarations/parserInterfaceDeclaration5.ts ===
|
||||
declare interface I {
|
||||
>I : I
|
||||
}
|
||||
3
tests/cases/compiler/declareModifierOnTypeAlias.ts
Normal file
3
tests/cases/compiler/declareModifierOnTypeAlias.ts
Normal file
@@ -0,0 +1,3 @@
|
||||
declare type Foo = string;
|
||||
type Bar = number;
|
||||
declare type Baz = Bar;
|
||||
Reference in New Issue
Block a user