library을 쓰고있어 타이프립트로 이식하려고합니다.속성이있는 함수를 선언하는 Typescript
const is = value => {
... do some returns here
}
is.number = x => typeof x === 'number'
is.bla = x => typeof x === 'bla'
하는 index.js 등 :
현재는 그 같은 모양.
const is = value => {
... do some returns here
}
is.number = x => typeof x === 'number'
is.bla = x => typeof x === 'bla'
나는 is
및 모든 메소드를 설명하는 인터페이스를 작성했습니다.
type TypeQueryMethod = (val: any) => boolean;
interface Is {
(val: any): string;
undefined: TypeQueryMethod;
null: TypeQueryMethod;
...
}
나는 유형과 is
을 표시 할 때 : const is: Is = value => ...
그것은 오류가 발생합니다 :
개체의 선언이 분할이기 때문에 의미가Type '(value: any) => string' is not assignable to type 'Is'.
Property 'undefined' is missing in type '(value: any) => string'.
.
메소드와 메소드가 모두 같은 객체를 어떻게 구성합니까?
'Object.assign()'을 사용하여 형식 어설 션없이 'Is'를 생성 할 수 있어야합니다. – jcalz