2016-10-04 3 views
0

RouteProps 인터페이스에 이름 속성을 추가하고 싶습니다. 그게 없으면 내가 얻을 :TypeScript 2.0 및 Route.d.ts에 선언 된 반응 라우터 인터페이스 병합

오류 TS2339 : 부동산의 '이름'형식에 존재하지 않는 'IntrinsicAttributes &> IntrinsicClassAttributes> & RouteProp ...'

내가 외부 경로에 name?: string;를 추가하는 경우. d.ts 파일 오류가 사라집니다.

모듈을 여러 가지 방법으로 병합하려고했지만 성공하지 못했습니다.

외부 Route.d.ts 선언이처럼 시작합니다

declare const self: self.Route; 
type self = self.Route; 
export default self; 

declare namespace self { 

    interface RouteProps extends React.Props<Route> {... 

내가 타이프 라이터 2

답변

0

을 사용하고 내가 같은 질문을 하바 내가 "모듈 확대 술"을 사용하여 : https://www.typescriptlang.org/docs/handbook/declaration-merging.html#module-augmentation

당신은 코드를 새 파일 맞춤 route.d.ts를 추가 쓸 수

declare module "react-router/lib/Route" { 
    interface RouteProps { 
     name?: String; 
    } 
} 

내 질문은 내게 볼 수 있습니다 Typescript custom @types package for @types/react-router

+0

제공된 링크에서 필수적인 부분을 추가하십시오./링크 전용 답변을 환영하지 않습니다. :) – gofr1