I'm trying use normalizr library for my typescript project. So I have defined the following entity schema (js format)
//schema.js
import { Schema, Entity } from "normalizr";
export const user = new Schema.Entity("users", options = { idAttribute: "userId" });
and an attempt to use this in .ts file
//app.ts
import { user } from "./schemas";
leads to error:
module ./schemas was resolved as "schemas.js" but "allowJs" parameter is not set
If I set allowJs = true in tsconfig.json then the error occurs:
Cannot write file ".../schemas.js" because it would overwrite input file
Also I used this approach:
//schemas.ts
import * as normalizr from 'normalizr';
export const user = new normalizr.Schema.Entity("users");
But there is the error again:
Property Schema does not exist on type 'typeof' .../normalizr/index
How can I resolve it?
Visual Studio 2017, ts v.2.2.2
Looking at the type definitions of normalizr, the Entity
class is inside the schema
namespace (with lowercase s):
import * as normalizr from 'normalizr';
export const user = new normalizr.schema.Entity("users");