0

Let's say I have those three files:

moduleA.ts:

export const foo = 42;

moduleB.ts:

module TestModules {
  export const bar = 43;
} 

moduleC.ts:

import './moduleA';

module TestModules {
  console.log(TestModules.bar);
}

When I try to compile, I get a moduleC.ts(4,29): error TS2339: Property 'bar' does not exist on type 'typeof TestModules'. error.

Why?

I know mixing namespaces and modules ain't great but what if I have an old-style TypeScript project of a considerable size and I want to start using ES6-style modules?

1 Answer 1

1

OK, it's explained in this issue: https://github.com/Microsoft/TypeScript/issues/909 .

TL;DR: Don't mix internal and external modules. It doesn't work.

Which sucks bad for older projects: they're pretty much stuck with internal modules or else - good luck refactoring.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.