Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8666637
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T17:46:44+00:00 2026-06-12T17:46:44+00:00

I have spent some time reading the Typescript language specification and am somewhat confused

  • 0

I have spent some time reading the Typescript language specification and am somewhat confused about the difference between internal and external modules. Here is the description taken directly from the specification:

Internal modules (section 9.2.2) are local or exported members of other modules (including the global module and external modules). Internal modules are declared using ModuleDeclarations that specify their name and body. A name path with more than one identifier is equivalent to a series of nested internal module declarations.

External modules (section 9.4) are separately loaded bodies of code referenced using external module names. An external module is written as a separate source file that contains at least one import or export declaration. In addition, external modules can be declared using AmbientModuleDeclarations in the global module that directly specify the external module names as string literals. This is described further in section 0.

From what I’ve understood I think that external modules correspond to typescript files without enclosing module definitions that simply export a set of types and/or variables. From another typescript file I can simple import an external module in foo.ts with import foo = module("foo");

Can somebody explain to me the destinction between external and internal modules?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T17:46:46+00:00Added an answer on June 12, 2026 at 5:46 pm

    Sections 9.3 and 9.4 of the specification explain this more clearly. I’ll reproduce here some of the examples given in those sections.

    External modules

    Suppose the following code is in main.ts.

    import log = module("log");
    log.message("hello");
    

    This file references an external module log, defined by whatever log.ts exports.

    export function message(s: string) { 
      console.log(s); 
    }
    

    Notice that log.ts doesn’t use the module keyword anywhere. It just exports things with export.

    Internal modules

    This file has two internal modules, X.Y.Z.

    module A.B.C { 
      import XYZ = X.Y.Z; 
      export function ping(x: number) { 
        if (x > 0) XYZ.pong(x – 1); 
      }
    } 
    module X.Y.Z { 
      import ABC = A.B.C; 
      export function pong(x: number) { 
        if (x > 0) ABC.ping(x – 1); 
      } 
    }
    

    These behave (mostly) like external modules, but they are contained in one file and you don’t have to reference any outside files to use them. They have to be contained inside of a module block when they are defined.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have spent a lot of time reading questions and answers about Big-Oh on
I have spent a lot of time recently reading the HTTP 1.1 specification and
I have spent some time now to solve a problem for which i have
Have spend quite some time to learn Sencha touch, just like an evaluation about
I have spent quite some time making a function and the last 15-20 minutes
So I've spent some time checking out CocoaDev, reading the Cocoa docs on NSMenuItems,
So i am using varnish for the first time. i have spent quite some
I am having trouble getting the JSF annotations to work. I have spent some
I have spent several days now researching Hibernate and have several small questions about
I have spent about half a day searching for an answer to this question

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.