TypeScript接口允许的名称

TypeScript接口允许的名称,typescript,Typescript,考虑这段代码,它编译得很好: interface Whatever { name: string; } var x : Whatever = { name: "Whatever" }; 将“Whatever”更改为“Map”,您将获得以下代码: interface Map { name: string; } var x : Map = { name: "Whatever" }; 当我使用tsc(在最新的Ubuntu上从npm安装)编译时,我得到了这个看起来

考虑这段代码,它编译得很好:

interface Whatever {
    name: string;
}

var x : Whatever = {
    name: "Whatever"
};
将“Whatever”更改为“Map”,您将获得以下代码:

interface Map {
    name: string;
}

var x : Map = {
    name: "Whatever"
};
当我使用
tsc
(在最新的Ubuntu上从npm安装)编译时,我得到了这个看起来很糟糕的输出:

test.ts(1,11): error TS2234: All declarations of an interface must have identical type parameters.
test.ts(5,5): error TS2012: Cannot convert '{ name: string; }' to 'Map<any, any>':
    Type '{ name: string; }' is missing property 'clear' from type 'Map<any, any>'.
test.ts(5,9): error TS2173: Generic type references must include all type arguments.
test.ts(1,11):错误TS2234:接口的所有声明必须具有相同的类型参数。
test.ts(5,5):错误TS2012:无法将“{name:string;}”转换为“Map”:
类型“{name:string;}”缺少类型“Map”中的属性“clear”。
ts(5,9):错误TS2173:泛型类型引用必须包含所有类型参数。

我对TypeScript完全不熟悉,所以我不确定这意味着什么。我猜某个东西已经被默认命名为
Map
,也许吧?有人知道发生了什么吗?对于我可以命名的接口,是否有一些明确的限制列表?

您遇到的是,有一些接口是为许多ECMAScript 6功能预定义的,包括
Map
(对
Map
规范的解释):


旁注:这是我用打字机写的第一个界面,我花了太长时间把头撞在墙上,才意识到如果我把名字从“地图”改成其他东西,一切都会好起来:)
// lib.t.ts
//
/////////////////////////////
/// IE11 ECMAScript Extensions
/////////////////////////////
interface Map<K, V> {
    clear(): void;
    delete(key: K): boolean;
    forEach(callbackfn: (value: V, index: K, map: Map<K, V>) => void, thisArg?: any): void;
    get(key: K): V;
    has(key: K): boolean;
    set(key: K, value: V): Map<K, V>;
    size: number;
}
declare var Map: {
    new <K, V>(): Map<K, V>;
}
module Special {
    export interface Map {
        name: string;
    }
}