mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-15 12:51:30 -05:00
Merge pull request #197 from Microsoft/locals_exports
Alternative proposal for grouping exported and local declarations
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
==== tests/cases/compiler/anonymousModules.ts (12 errors) ====
|
||||
==== tests/cases/compiler/anonymousModules.ts (13 errors) ====
|
||||
module {
|
||||
~
|
||||
!!! ';' expected.
|
||||
@@ -18,13 +18,15 @@
|
||||
export var bar = 1;
|
||||
~~~~~~
|
||||
!!! Statement expected.
|
||||
~~~
|
||||
!!! Individual declarations in merged declaration bar must be all exported or all local.
|
||||
}
|
||||
~
|
||||
!!! Declaration or statement expected.
|
||||
|
||||
var bar = 2;
|
||||
~~~
|
||||
!!! Duplicate identifier 'bar'.
|
||||
!!! Individual declarations in merged declaration bar must be all exported or all local.
|
||||
|
||||
module {
|
||||
~
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
==== tests/cases/compiler/duplicateSymbolsExportMatching.ts (8 errors) ====
|
||||
==== tests/cases/compiler/duplicateSymbolsExportMatching.ts (18 errors) ====
|
||||
module M {
|
||||
export interface E { }
|
||||
interface I { }
|
||||
@@ -23,23 +23,29 @@
|
||||
|
||||
module N2 {
|
||||
interface I { }
|
||||
~
|
||||
!!! Individual declarations in merged declaration I must be all exported or all local.
|
||||
export interface I { } // error
|
||||
~
|
||||
!!! Duplicate identifier 'I'.
|
||||
!!! Individual declarations in merged declaration I must be all exported or all local.
|
||||
export interface E { }
|
||||
~
|
||||
!!! Individual declarations in merged declaration E must be all exported or all local.
|
||||
interface E { } // error
|
||||
~
|
||||
!!! Duplicate identifier 'E'.
|
||||
!!! Individual declarations in merged declaration E must be all exported or all local.
|
||||
}
|
||||
|
||||
// Should report error only once for instantiated module
|
||||
module M {
|
||||
module inst {
|
||||
~~~~
|
||||
!!! Individual declarations in merged declaration inst must be all exported or all local.
|
||||
var t;
|
||||
}
|
||||
export module inst { // one error
|
||||
~~~~
|
||||
!!! Duplicate identifier 'inst'.
|
||||
!!! Individual declarations in merged declaration inst must be all exported or all local.
|
||||
var t;
|
||||
}
|
||||
}
|
||||
@@ -47,36 +53,50 @@
|
||||
// Variables of the same / different type
|
||||
module M2 {
|
||||
var v: string;
|
||||
~
|
||||
!!! Individual declarations in merged declaration v must be all exported or all local.
|
||||
export var v: string; // one error (visibility)
|
||||
~
|
||||
!!! Duplicate identifier 'v'.
|
||||
!!! Individual declarations in merged declaration v must be all exported or all local.
|
||||
var w: number;
|
||||
~
|
||||
!!! Individual declarations in merged declaration w must be all exported or all local.
|
||||
export var w: string; // two errors (visibility and type mismatch)
|
||||
~
|
||||
!!! Duplicate identifier 'w'.
|
||||
!!! Individual declarations in merged declaration w must be all exported or all local.
|
||||
}
|
||||
|
||||
module M {
|
||||
module F {
|
||||
~
|
||||
!!! A module declaration cannot be located prior to a class or function with which it is merged
|
||||
~
|
||||
!!! Individual declarations in merged declaration F must be all exported or all local.
|
||||
var t;
|
||||
}
|
||||
export function F() { } // Only one error for duplicate identifier (don't consider visibility)
|
||||
~
|
||||
!!! Duplicate identifier 'F'.
|
||||
!!! Individual declarations in merged declaration F must be all exported or all local.
|
||||
}
|
||||
|
||||
module M {
|
||||
class C { }
|
||||
~
|
||||
!!! Individual declarations in merged declaration C must be all exported or all local.
|
||||
module C { }
|
||||
~
|
||||
!!! Individual declarations in merged declaration C must be all exported or all local.
|
||||
export module C { // Two visibility errors (one for the clodule symbol, and one for the merged container symbol)
|
||||
~
|
||||
!!! Duplicate identifier 'C'.
|
||||
!!! Individual declarations in merged declaration C must be all exported or all local.
|
||||
var t;
|
||||
}
|
||||
}
|
||||
|
||||
// Top level
|
||||
interface D { }
|
||||
~
|
||||
!!! Individual declarations in merged declaration D must be all exported or all local.
|
||||
export interface D { }
|
||||
~
|
||||
!!! Duplicate identifier 'D'.
|
||||
!!! Individual declarations in merged declaration D must be all exported or all local.
|
||||
@@ -1,4 +1,4 @@
|
||||
==== tests/cases/conformance/functions/functionOverloadErrors.ts (19 errors) ====
|
||||
==== tests/cases/conformance/functions/functionOverloadErrors.ts (15 errors) ====
|
||||
//Function overload signature with initializer
|
||||
function fn1(x = 3);
|
||||
~~~~~
|
||||
@@ -88,24 +88,16 @@
|
||||
export function fn1();
|
||||
~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! Function implementation expected.
|
||||
~~~
|
||||
!!! Overload signatures must all be exported or not exported.
|
||||
function fn1(n: string);
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! Function implementation expected.
|
||||
~~~
|
||||
!!! Duplicate identifier 'fn1'.
|
||||
function fn1() { }
|
||||
~~~
|
||||
!!! Duplicate identifier 'fn1'.
|
||||
|
||||
function fn2(n: string);
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! Function implementation expected.
|
||||
~~~
|
||||
!!! Overload signatures must all be exported or not exported.
|
||||
export function fn2();
|
||||
~~~
|
||||
!!! Duplicate identifier 'fn2'.
|
||||
export function fn2() { }
|
||||
~~~
|
||||
!!! Duplicate identifier 'fn2'.
|
||||
}
|
||||
|
||||
//Function overloads with differing ambience
|
||||
|
||||
19
tests/baselines/reference/mixedExports.js
Normal file
19
tests/baselines/reference/mixedExports.js
Normal file
@@ -0,0 +1,19 @@
|
||||
//// [mixedExports.ts]
|
||||
declare module M {
|
||||
function foo();
|
||||
export function foo();
|
||||
function foo();
|
||||
}
|
||||
|
||||
declare module M1 {
|
||||
export interface Foo {}
|
||||
interface Foo {}
|
||||
}
|
||||
|
||||
module A {
|
||||
interface X {x}
|
||||
export module X {}
|
||||
interface X {y}
|
||||
}
|
||||
|
||||
//// [mixedExports.js]
|
||||
@@ -1,10 +1,12 @@
|
||||
==== tests/cases/compiler/multivar.ts (1 errors) ====
|
||||
==== tests/cases/compiler/multivar.ts (2 errors) ====
|
||||
var a,b,c;
|
||||
var x=1,y=2,z=3;
|
||||
|
||||
module m2 {
|
||||
|
||||
export var a, b2: number = 10, b;
|
||||
~~
|
||||
!!! Individual declarations in merged declaration b2 must be all exported or all local.
|
||||
var m1;
|
||||
var a2, b22: number = 10, b222;
|
||||
var m3;
|
||||
@@ -22,7 +24,7 @@
|
||||
declare var d1, d2;
|
||||
var b2;
|
||||
~~
|
||||
!!! Duplicate identifier 'b2'.
|
||||
!!! Individual declarations in merged declaration b2 must be all exported or all local.
|
||||
|
||||
declare var v1;
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! Function implementation expected.
|
||||
~~~
|
||||
!!! Duplicate identifier 'bar'.
|
||||
!!! Overload signatures must all be exported or not exported.
|
||||
function bar(s?: string) { }
|
||||
|
||||
interface I {
|
||||
|
||||
16
tests/cases/compiler/mixedExports.ts
Normal file
16
tests/cases/compiler/mixedExports.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
declare module M {
|
||||
function foo();
|
||||
export function foo();
|
||||
function foo();
|
||||
}
|
||||
|
||||
declare module M1 {
|
||||
export interface Foo {}
|
||||
interface Foo {}
|
||||
}
|
||||
|
||||
module A {
|
||||
interface X {x}
|
||||
export module X {}
|
||||
interface X {y}
|
||||
}
|
||||
Reference in New Issue
Block a user