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

Simplify JavaScript AMD module import workflow #1908

Closed
v3nom opened this issue Feb 3, 2015 · 0 comments
Closed

Simplify JavaScript AMD module import workflow #1908

v3nom opened this issue Feb 3, 2015 · 0 comments
Labels
Fixed A PR has been merged for this issue Suggestion An idea for TypeScript

Comments

@v3nom
Copy link
Contributor

v3nom commented Feb 3, 2015

We are using AMD modules in our JavaScript application. Application code base is growing and we have made a decision to move to TS for more type safety recently.

Problem

Consuming AMD modules written in JavaScript is too cumbersome.
/// <amd-dependency path="x" /> works for expressing the dependency, but in order to consume the dependecy from TS requires all kinds of trickery, which should not be the case for a common case of using TS and JS interchangeably.

Solution

Introduce name parameter to amd-dependecy comment.
/// <amd-dependency path="x" name="variableName" />

With this simple enhancement we can write much cleaner TS code:

/// <amd-dependency path="legacy/moduleA" name="moduleA"/>
declare var moduleA:MyType
moduleA.callStuff()

Generated JS code:

define(["require", "exports", "legacy/moduleA"], function (require, exports, moduleA) {
    moduleA.callStuff()
});

Extra benefits

@danquirk danquirk added the Suggestion An idea for TypeScript label Feb 4, 2015
@mhegazy mhegazy added the Fixed A PR has been merged for this issue label Feb 12, 2015
@mhegazy mhegazy added this to the TypeScript 1.5 milestone Feb 12, 2015
@mhegazy mhegazy closed this as completed Feb 12, 2015
@microsoft microsoft locked and limited conversation to collaborators Jun 18, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Fixed A PR has been merged for this issue Suggestion An idea for TypeScript
Projects
None yet
Development

No branches or pull requests

3 participants