【问题标题】:Typescript requirejs web essentials 2.9Typescript requirejs 网络要领 2.9
【发布时间】:2013-08-06 17:25:53
【问题描述】:

我只是将 Web Essentials 和 Typescript 更新到新版本。

结果我的项目不再工作了。

这是我的打字稿代码:

/// <reference path="DefinitelyTyped/jqueryui.d.ts" />
/// <reference path="DefinitelyTyped/jquery-datatable.d.ts" />

import Common = module("Common");
import GMap = module("GMap");

declare var $: JQueryStatic;

export class Polygon extends GMap.Polygon {

在更新我生成的代码(有效)之前:

var __extends = this.__extends || function (d, b) {
    function __() { this.constructor = d; }
    __.prototype = b.prototype;
    d.prototype = new __();
};
define(["require", "exports", "GMap", "Common"], function(require, exports, __GMap__,          __Common__) {
var GMap = __GMap__;

var Common = __Common__;

var Polygon = (function (_super) {
    __extends(Polygon, _super);
    function Polygon() {
        _super.apply(this, arguments);

    }

现在看起来像:

var __extends = this.__extends || function (d, b) {
    for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
    function __() { this.constructor = d; }
    __.prototype = b.prototype;
    d.prototype = new __();
};
var Common = require("./Common");
var GMap = require("./GMap");

var Polygon = (function (_super) {
    __extends(Polygon, _super);

在我的控制台中出现此错误:

未捕获的错误:尚未为上下文加载模块名称“Common”:_。使用 require([])

我尝试在配置中添加 Common。但是在更新之前它工作正常。

任何人都可以帮助我,也许需要对我的代码进行一些更改才能使我的项目恢复正常。

谢谢,

杰罗姆

更新

我只是看到这是由于 Web Essentials 2.9,我没有为 amd 模块指定编译器选项的选项。

我只是删除扩展并重新安装 2.7 版:

http://vswebessentials.com/nightly/webessentials2012-2.7.vsix

【问题讨论】:

    标签: import requirejs typescript web-essentials


    【解决方案1】:

    您需要使用 amd 选项进行编译。即

    tsc yourfile.ts --module "amd" 
    

    它默认为“commonjs”,这是您目前看到的输出。

    【讨论】:

      【解决方案2】:

      我只想补充一点,Web Essentials 在 2.8 版中确实支持 AMD 模块,但在 2.9 版中该选项已丢失 - check out the comments on the download page

      您将在...中找到设置(2.8 或更低版本)

      Tools &gt; Options &gt; Web Essentials &gt; TypeScript &gt; "Use the AMD module"

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2019-04-19
        • 1970-01-01
        • 2013-10-10
        • 2019-10-22
        • 2019-11-18
        • 2018-11-16
        相关资源
        最近更新 更多