Skip to content
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

Automatic resolution of internal Typescript modules in separate files? #220

Closed
gravidThoughts opened this issue Jun 18, 2015 · 6 comments
Closed

Comments

@gravidThoughts
Copy link

I have a ASP.net project that uses TS with internal modules and has a file per class. As long as the module name is the same in the file, all exported members can be seen in all files automatically without needing to use the old ///<reference..../> convention.

This does not seem work when using a nodejs application template.

I am trying to confirm that this does not work, and I am not doing something wrong.

@NoelAbrahams
Copy link

@gravidThoughts,

With NodeJS one needs to use CommonJS, not internal modules. Does that make sense?

@gravidThoughts
Copy link
Author

@NoelAbrahams

Yes.

I guess my issue is at this point in time there is poor support for the concept of a single external module split across multiple files.

How do I implement private/internal classes that help a module do its job?

@NoelAbrahams
Copy link

I guess my issue is at this point in time there is poor support for the concept of a single external module split across multiple files.

Yes, that's right. See microsoft/TypeScript#17

How do I implement private/internal classes that help a module do its job?

The only option for a truly private class is to have it in the same file. We don't normally do this, preferring instead to defining "internal" type classes externally and importing them into the main class.

@gravidThoughts
Copy link
Author

I appreciate your responses Noel.

Do we have to wait for ECMA6 before we have a robust modular pattern for TS, or does ECMA5 have the necessary semantics?

@NoelAbrahams
Copy link

TS already supports ES6 modules (as of 1.5). It's an improvement on the old module system, but I don't think there's anything in the pipeline for solving multi-file external modules.

Probably the best bet is to close this issue and raise a question on the TS forum.

@NoelAbrahams
Copy link

Or better still on typescript gitter: https://gitter.im/Microsoft/TypeScript

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants