TypeScript 类型文字中的计算属性名称必须直接引用内置符号 [英] TypeScript A computed property name in a type literal must directly refer to a built-in symbol

查看:51
本文介绍了TypeScript 类型文字中的计算属性名称必须直接引用内置符号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

ERROR in ...component.ts (..,..): 类型中的计算属性名称文字必须直接引用内置符号....: 找不到命名为任何".

ERROR in ...component.ts (..,..): A computed property name in a type literal must directly refer to a built- in symbol. ...: Cannot find name 'any'.

我期待一个包含具有其他字符串的字符串的对象,即:

I'm looking forward an object which contains strings which have other string, i.e:

{ abc: 'xyz' }

我做了什么:

foo: { [string]: string };

推荐答案

计算值需要一个识别名称:

An identifying name on the computed value is required:

foo: { [bar: string]: string };

这篇关于TypeScript 类型文字中的计算属性名称必须直接引用内置符号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆