将 js 模块导入打字稿文件 (normalizr)

Import js module to typescript file (normalizr)

我正在尝试为我的打字稿项目使用 normalizr 库。所以我定义了以下实体模式(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";

导致错误:

module ./schemas was resolved as "schemas.js" but "allowJs" parameter is not set

如果我在 tsconfig.json 中设置 allowJs = true 那么会发生错误:

Cannot write file ".../schemas.js" because it would overwrite input file

我也用过

//schemas.ts
import * as normalizr from 'normalizr';
export const user = new normalizr.Schema.Entity("users");

但是又出现错误:

Property Schema does not exist on type 'typeof' .../normalizr/index

我该如何解决?

Visual Studio 2017, ts v.2.2.2

查看 normalizr 的类型定义,Entity class 在 schema 命名空间内(小写 s):

import * as normalizr from 'normalizr';
export const user = new normalizr.schema.Entity("users");