打字稿-重复的标识符错误-const x:({y:string,z:string})=> string;

下面的代码为什么在参数blog_list = Blog.objects.filter(is_published=True).distinct('author').order_by('-published_date','author') 中标记string,错误Duplicate identifier 'string'.(2300)

const append: ({ first: string,second: string }) => string = ({ first,second }) => first + second;

console.log(append({ first: "a",second: "b" }));

它可以编译并正确运行。

复制

wangjihong0407 回答:打字稿-重复的标识符错误-const x:({y:string,z:string})=> string;

您想要的类型定义不正确

const append: (input: { first: string,second: string }) => string = ({ first,second }) => first + second;

在更明确的条目中,该内容与:

interface Input {
    first: string;
    second: string;
}

interface Append {
    (input: Input): string;
}

const append: Append = ({first,second}) => {
    return first + second;
}
本文链接:https://www.f2er.com/2821744.html

大家都在问