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

  • SEARCH
  • Home
  • 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 9192201
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T20:51:56+00:00 2026-06-17T20:51:56+00:00

Is it possible within TypeScript to import a module or reference a definition file

  • 0

Is it possible within TypeScript to import a module or reference a definition file from a uri?

We are using RequireJS for our application and would like to serve some of our definition files and TypeScript (or generated JavaScript) files from a CDN rather than including them all directly in our projects.

Referencing Definition Files
In TypeScript we can reference a definition file like this:

/// <reference path="jquery-1.8.3.d.ts" />

However, what we would like to do is this:

/// <reference path="https://github.com/borisyankov/DefinitelyTyped/raw/master/jquery/jquery-1.8.d.ts" />

export class UsesSomethingFromJQuery {

    TestMethod(element: JQuery) {
        // Do something with the supplied element
    }

}

NOTE: I’m not planning to use Boris’ github link as the CDN. I used the link to demonstrate the concept.

Importing TypeScript Files
We would also like to import modules from a common website, like this:

import OtherModule = module('http://some-internal-site/ts/other');

export class UsesSomethingFromOther {

    TestMethod(c: OtherModule.TestClass) {

    }

}

However, I get the error ‘Invalid import path’ when providing a uri for the module.

What We’re Trying to Solve
We have a library of TypeScript files that generate JavaScript for our controls, some REST service wrappers, and other utilities. We’d like to use these common controls in other web applications.

When we have a TypeScript file that is specific to one of our web sites (hence not part of the common core) that relies upon classes defined within the common core, we would like to reference the dependency using a uri. Hence the question above.

If these were simply JavaScript source files we would host them on an internal CDN and reference from there but with the TypeScript compilation step we run into a problem. Are we approaching this in the wrong way? Is there a better way?

  • 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-17T20:51:58+00:00Added an answer on June 17, 2026 at 8:51 pm

    I think it is a fine idea to server your JavaScript output from a CDN, which would impact either your module-loader or your script tags, but the .d.ts files aren’t required at runtime.

    You could adjust this example of RequireJS and jQuery in TypeScript to load files remotely like this…

    1. Local definitions files (.d.ts)
    2. Remote runtime files, using require.config.

    app.ts

    ///<reference path="require.d.ts" />
    ///<reference path="jquery.d.ts" />
    
    require.config({
      paths: {
        'jquery' : 'https://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min'
      }
    });
    
    require(['jquery'], function (jquery) {
        jquery(document).ready(() => {
            alert('Your code executes after jQuery has been loaded.');
        });
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: How to use include within a function? i have two file inc.php
Possible Duplicate: How to change appearance of URL from within a PHP script I
Is it possible from within a rake task to get a list of tasks
I have a need to measure a room (if possible) from within an iPhone
is it possible to call a method of a plugin from within TypoScript? I
Is it possible within Flex 4 to change the background color of an <s:Application>
Is it possible to within a Handlebars.js helper to create elements using jQuery and
It's possible within a Flex application, to declare elements, for example a HTTPService elements,
I would like to double sort my user list. Is this possible within one
Is it possible within a PHP script to start a trace log and activate

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.