我正在尝试在我的打字本项目中使用归一化库。因此,我定义了以下实体模式(js格式)
//schema.js
import { Schema, Entity } from "normalizr";
export const user = new Schema.Entity("users", options = { idAttribute: "userId" });并试图在.ts文件中使用此方法。
//app.ts
import { user } from "./schemas";导致错误:
模块./schema被解析为"schemas.js“,但是没有设置"allowJs”参数。
如果我在tsconfig.json中设置了allowJs = true,那么就会发生错误:
无法写入文件“./schemas.js”,因为它将覆盖输入文件
我还使用了这种方法:
//schemas.ts
import * as normalizr from 'normalizr';
export const user = new normalizr.Schema.Entity("users");但还是有一个错误:
属性模式在‘type on’./normalizr/index类型上不存在
我该怎么解决呢?
Visual Studio 2017,ts v.2.2.2
发布于 2017-05-22 14:27:20
查看normalizr的类型定义,Entity类位于schema命名空间内(小写s):
import * as normalizr from 'normalizr';
export const user = new normalizr.schema.Entity("users");https://stackoverflow.com/questions/44114769
复制相似问题