2017-05-22 8 views
0

내 typescript 프로젝트에 normalizr 라이브러리를 사용하려고합니다.js 모듈을 typescript 파일 (normalizr)로 가져 오기

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

을 내가 설정 한 경우 : 그래서 오류 다음 개체 스키마 (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"; 

리드를 파일을 사용하려는 시도를 정의 tsconfig.json에서 allowJs = true이면 오류가 발생합니다.

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

또한 나는 this approach 사용 :

//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

어떻게 그것을 해결할 수 있습니까?

비주얼 스튜디오 2017, TS v.2.2.2

답변

1

normalizr의 유형 정의에서 보면, Entity 클래스 (소문자의 사용) schema 네임 스페이스 내부 :

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