Skip to content

Compiler errors for module augmentation with export= #7130

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
yortus opened this issue Feb 18, 2016 · 2 comments
Closed

Compiler errors for module augmentation with export= #7130

yortus opened this issue Feb 18, 2016 · 2 comments

Comments

@yortus
Copy link
Contributor

yortus commented Feb 18, 2016

TypeScript Version:

nightly (1.9.0-dev.20160217)

Problem Description:

I've copied the following code verbatim from a baseline test file for #6742. My understanding is that this code should compile without errors, but I get two errors, which I've indicated with comments. The output .js files are exactly as expected.

Code

//// [file1.ts]
function foo() {}
namespace foo {
    export var v = 1;
}
export = foo;


//// [file2.ts]
import x = require("./file1"); 
x.b = 1;                // OK

declare module "./file1" {
    interface A { a }   // ERROR: Module augmentation cannot introduce new names in the top level scope
    let b: number;      // ERROR: Module augmentation cannot introduce new names in the top level scope
}


//// [file3.ts]
import * as x from "./file1";
import "./file2";
let a: x.A;     // OK, a's type is interface A
let b = x.b;    // OK, b's type is number


//// [tsconfig.json]
{
    "compilerOptions": {
        "target": "es6",
        "module": "amd"
    }
}

Expected behavior:

No compiler errors.

Actual behavior:

Two compiler errors, as indicated in the code comments.

Additional info:

I also copied and compiled the express.d.ts baseline test, and that does compile for me with no errors.

@yortus
Copy link
Contributor Author

yortus commented Feb 18, 2016

ping @vladima

@yortus
Copy link
Contributor Author

yortus commented Feb 19, 2016

Closing.

My misunderstanding - I see now the two compiler errors I'm getting are expected, as per https://github.com/Microsoft/TypeScript/blob/master/tests/baselines/reference/augmentExportEquals3.errors.txt

@yortus yortus closed this as completed Feb 19, 2016
@microsoft microsoft locked and limited conversation to collaborators Jun 19, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant