Answer the question
In order to leave comments, you need to log in
How to define interface in typescript?
Let's say there is such a proxy
let test = new Proxy(new String('test'), {
get: (str, method, r) => (...args: any[]) => new Promise(resolve => {
resolve(str[method](...args))
})
})
let p = test.indexOf('st')
p.then(n => console.log(n)) // 2
test.toUpperCase().then(s => console.log(s)) // TEST
interface PromiseOfString {
// define
}
let test: PromiseOfString = new Proxy(new String('test'), {
get: (str, method, r) => (...args: any[]) => new Promise(resolve => {
resolve(str[method](...args))
})
})
let p = test.indexOf('est')
p
must have a type. Promise<number>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question