小编Khu*_*rob的帖子

如何在启用isolatedModules = true选项的情况下创建包?

在一个文件中,我在以下行中导出包的所有类:

export {default as BoundList, IBoundListOption, TBoundListFilterFn} from './list/BoundList';
Run Code Online (Sandbox Code Playgroud)

生成表格错误:

TS1205: Cannot re-export a type when the '--isolatedModules' flag is provided.
Run Code Online (Sandbox Code Playgroud)

我现在如何导出课程?

在CRA2.1中发生此问题。不得不强制执行isolatedModules = true。我正在CRA2.1上制作组件库

typescript reactjs babeljs create-react-app

8
推荐指数
2
解决办法
2009
查看次数

打字稿错误TS2394:重载签名与函数实现不兼容

这是Typecript编译器诅咒的代码:

use(path: PathParams, ...handlers: RequestHandler[]): this
use(path: PathParams, ...handlers: RequestHandlerParams[]): this
use(...handlers: RequestHandler[]): this
use(...handlers: RequestHandlerParams[]): this {
    // ...
    return this;
}
Run Code Online (Sandbox Code Playgroud)

错误TS2394:重载签名与功能实现不兼容。

我不明白如何正确执行过载。你能告诉挖掘的方向吗?

typescript

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

如何在Ajv中添加关键字Nullable(或allowNull)?

我写了下面的代码。

var ajv = new require('ajv');

ajv.addKeyword('allowNull', {
    type: 'null',
    metaSchema: {
        type: 'boolean'
    },
    compile: function(allowNullEnable, parentSchema) {
        return function(data, dataPath, parentData) {
            if (allowNullEnable) {
                return true;
            } else {
                if (parentSchema.type == 'null') {
                    return true;
                } else {
                    return data === null ? false : true;
                }
            }
        }
    }
});

var schema = {
  type: "object",
  properties: {
    file: {
      type: "string",
      allowNull: true
    }
  }
};

var data = {
   file: null
};

console.log(ajv.validate(schema, …
Run Code Online (Sandbox Code Playgroud)

node.js ajv

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

组合数组类型时出错?错误:无法调用类型缺少调用签名的表达式

此代码导致错误,其文本如下:

function getHandler(handlers: number[] | string[]): any {
    return handlers.map(handler => handler);
}
Run Code Online (Sandbox Code Playgroud)

错误文本:

错误 TS2349:无法调用类型缺少调用签名的表达式。类型 '{ (this: [string, string, string, string, string], callbackfn: (value: string, index: number, ...' 没有兼容的调用签名。

typescript

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

标签 统计

typescript ×3

ajv ×1

babeljs ×1

create-react-app ×1

node.js ×1

reactjs ×1