declare关键字的含义是什么?

type Callback = (err: Error | String, data: Array<CalledBackData>) => void;

vs.

declare type Callback = (err: Error | String, data:Array<CalledBackData>) => void;

在TS中找不到解释declare关键字目的的文档。Qué signa ?

Record<K, T>在Typescript中是什么意思?

Typescript 2.1引入了Record类型,在一个例子中描述了它:

//对于每一个T类型的属性K,将其转换为U 函数mapObject<K扩展字符串,T, U>(obj:记录<K, T>, f: (x: T) => U):记录<K, U>

参见Typescript 2.1

高级类型页面在映射类型标题下提到了Record,与Readonly, Partial和Pick并列,这似乎是它的定义:

type记录<K扩展字符串,T> = { [P in K]: T; }

Readonly、Partial和Pick是同态的,而Record不是。Record不是同态的一个线索是,它不需要输入类型来复制属性: type ThreeStringProps =记录<'prop1' | 'prop2' | 'prop3',字符串>

就是这样。除了上面的引用,typescriptlang.org上没有提到Record。

问题

Can someone give a simple definition of what Record is? Is Record<K,T> merely a way of saying "all properties on this object will have type T"? Probably not all properties, since K has some purpose... Does the K generic forbid additional keys on the object that are not K, or does it allow them and just indicate that their properties are not transformed to T? With the given example: type ThreeStringProps = Record<'prop1' | 'prop2' | 'prop3', string> Is it exactly the same as this?: type ThreeStringProps = {prop1: string, prop2: string, prop3: string}

我有一个非常简单的功能组件如下:

import * as React from 'react';

export interface AuxProps  { 
    children: React.ReactNode
 }


const aux = (props: AuxProps) => props.children;

export default aux;

另一个组成部分:

import * as React from "react";

export interface LayoutProps  { 
   children: React.ReactNode
}

const layout = (props: LayoutProps) => (
    <Aux>
        <div>Toolbar, SideDrawer, Backdrop</div>
        <main>
            {props.children}
        </main>
    <Aux/>
);

export default layout;

我一直得到以下错误:

(ts) JSX元素类型“ReactNode”不是JSX元素的构造函数。 类型'undefined'不能赋值给类型'ElementClass'。[2605]

我如何正确地输入这个?