折叠TypeScript中的嵌套键?
假设我在TypeScript中有两种类型:折叠TypeScript中的嵌套键?,typescript,typescript-typings,Typescript,Typescript Typings,假设我在TypeScript中有两种类型: interface Foo { bar: string; } interface Baz { foo: Foo; } TypeScript中是否有方法将Baz(例如type FlatBaz=Flat)展平,使签名看起来像这样 interface FlatBaz { "foo.bar": string; } 好了,没有这样的事情。没有。目前没有办法用Typescript连接字符串文字类型: 我很想知道你想要实现什么目标。因为您的Flat
interface Foo {
bar: string;
}
interface Baz {
foo: Foo;
}
TypeScript中是否有方法将Baz
(例如type FlatBaz=Flat
)展平,使签名看起来像这样
interface FlatBaz {
"foo.bar": string;
}
好了,没有这样的事情。没有。目前没有办法用Typescript连接字符串文字类型:
我很想知道你想要实现什么目标。因为您的
FlatBaz
类型看起来像是从某个函数返回的类型的结构可能与@DamianGreen重复是-它将从函数返回。我正在将对象映射到查询参数,并希望更强烈地键入行为。