小编And*_*nes的帖子

找不到命名空间错误

我有以下设置:

// enums.ts
export enum DocumentType {
  Email = 0,
  Unknown = 1
}
Run Code Online (Sandbox Code Playgroud)

-

// remote.ts
/// <reference path="./remote.d.ts" />
import enums = require('./enums');

class Remote implements test.IRemote {
  public docType: enums.DocumentType;

  constructor() {
    this.docType = enums.DocumentType.Unknown;
  }
}

export = Remote;
Run Code Online (Sandbox Code Playgroud)

-

// remote.d.ts
import * as enums from './enums';


declare module test {
  export interface IRemote { 
    docType: enums.DocumentType;
  } 
}
Run Code Online (Sandbox Code Playgroud)

但是当我运行tsc时,我Cannot find namespace 'test'从remotes.ts 获得.我错过了什么?

其他可能有用的信息:我最近从Typescript 1.5升级到了Typescript 1.8,并在示例中将const枚举替换为普通枚举.

typescript

9
推荐指数
1
解决办法
2万
查看次数

绑定函数通过嵌套指令与孤立范围在Angular 1.4中失败

在嵌套指令中绑定函数时,1.4更新似乎引入了一个问题.我有一个示例plunker:http://plnkr.co/edit/fQLY0N8BTNs38VC8ikll

码:

var app = angular.module('myApp', []);

app.controller('myCtrl', function(){
  this.searchFunction = function(term) {
    console.log('you searched for ' + term);
  }
 });

 app.directive('outerDirective', function(){
   return {
    restrict: 'E',
    scope: {
      outer: '&'
    },
    template: '<inner-directive inner="cx.outer(term)"></inner-directive>',
    controller: function(){

    },
    controllerAs: 'cx',
    bindToController: true
  };
});

app.directive('innerDirective', function(){
  return {
    restrict: 'E',
    scope: {
      inner: '&'
    },
    template: '<a ng-click="cx.execute()">Click</a>',
    controller: function(){
      this.execute = function(){
        this.inner('fred');
      }
    },
    controllerAs: 'cx',
    bindToController: true
  };
});
Run Code Online (Sandbox Code Playgroud)

这是在1.3中工作,但在1.4中我应该采用一些新方法吗?

单击该链接,您将在控制台中看到以下错误:

TypeError:不能使用'in'运算符在fn中搜索fred中的'cx'(eval at(https://code.angularjs.org/1.4.0/angular.js:13036:15),:2:54)在目的地.(匿名函数)[内部]( …

angularjs angular-directive

4
推荐指数
1
解决办法
7579
查看次数

使用 jsdom 和 Jest

我正在尝试使用 Jest 对角度应用程序进行单元测试。为了测试角度绑定,我尝试使用 jsdom (注意,我使用 v3.1.2,因为我使用节点而不是 IO)。当我需要加载带有 html 的脚本时,测试似乎在加载脚本之前完成。

我已经简化了我的测试用例以使用 jsdom 中的示例:

it('updates the view without error', function(){
    var jsdom = require('../../../../node_modules/jsdom/lib/jsdom');

    jsdom.env(
      '<p><a class="the-link" href="https://github.com/tmpvar/jsdom">jsdom!</a></p>',
      ["http://code.jquery.com/jquery.js"],
      function (errors, window) {
        //console.log("contents of a.the-link:", window.$("a.the-link").text());
        console.log("Completed");
        expect(errors).toBeNull();
      }
    );

    console.log('exiting...');
});
Run Code Online (Sandbox Code Playgroud)

如果我运行此测试,测试将通过,但不会打印“已完成”日志消息,我还可以用明显失败的内容替换期望,例如expect(false).toBeTruthy(),并且测试仍将“经过”。如果我删除 jquery 的注入,那么一切都会按预期工作。

我应该如何确保在退出测试之前加载脚本?更一般地说,在 Jest 中显式使用 jsdom 感觉有点不对劲。有没有更好的办法?

javascript jsdom angularjs jestjs

2
推荐指数
1
解决办法
5698
查看次数

在IBM i-Series上为std :: map使用自定义比较器

我正在尝试使用std :: map,其中键是c风格的字符串而不是std :: strings但是在编译IBM iSeries目标v7r1m0时遇到问题

我想使用c风格的字符串,因为使用性能资源管理器(PEX),为了地图查找而创建大量临时字符串似乎非常昂贵.

为此,我使用了自定义比较器,但在iSeries上进行编译时出现错误:

"/QIBM/include/t/xtree.t",第457.30行:CZP0218(30)该调用
与"const mycompany :: myapp :: cmp_str :: operator()"的任何参数列表都不匹配.
"/QIBM/include/t/xtree.t",第457.21行:CZP1289(0)
类型为"mycompany :: myapp :: cmp_str&" 的隐式对象参数无法使用类型为"const mycompany ::"的隐含参数进行初始化MYAPP :: cmp_str".

我的比较器定义为:

struct cmp_str 
{
    bool operator()(char const *a, char const *b)
    {
        return std::strcmp(a, b) < 0;
    }
};
Run Code Online (Sandbox Code Playgroud)

并在地图中使用:

class LocalSchema : public RecordSchema
{
    public:
        int Operation;
        //map<string, int> FieldLookup;
        map<char *, int, cmp_str> FieldLookup;
};
Run Code Online (Sandbox Code Playgroud)

我做了些蠢事吗?

编辑:改为

std::map<char const*, int, cmp_str>
Run Code Online (Sandbox Code Playgroud)

给出了同样的错误.进一步查看作业日志,我看到在处理以下函数时产生了此错误:

inline int VxSubfile::IndexOfFieldInSchema(char * columnName)
{
    std::map<char …
Run Code Online (Sandbox Code Playgroud)

c++ ibm-midrange

1
推荐指数
1
解决办法
82
查看次数