Today, when adding attributes to objects, tslint reported an error: object access through string text is not allowed (no string text)
const init = {
id: 'aaa',
name: 'bbb'
};
init['sex'] = 'ccc';
There are three solutions.
1: It is not allowed to pass strings. You can use variables
const name = 'sex';
const init = {
id: 'aaa',
name: 'bbb'
};
init[name] = 'ccc';
2: Let this line of code disable the tslint rule
const init = {
id: 'aaa',
name: 'bbb'
};
// tslint:disable-next-line:no-string-literal
init['sex'] = 'ccc';
3: Change tslint.json , disable this rule completely, add the following
"no-string-literal": false,
Read More:
- A repeated string is composed of two identical strings. For example, abcabc is a repeated string with length of 6, while abcba does not have a duplicate string. Given any string, please help Xiaoqiang find the longest repeated substring.
- Illegal escape character in string literal
- Unity short string intercepts long string
- In Java, int is converted to string, and zero is added before the number of bits is insufficient
- Converting string object into datetime type in pandas
- Split keyword in ABAP when the separator is at the beginning and end of the string
- error: ‘to_string’ is not a member of ‘std’
- Mybatis error,There is no getter for property named ‘xx’ in ‘class java.lang.String The solution
- C++ string substr()
- The Vue mobile terminal cannot use string.replaceall, and the error message is blank
- Parsing error: Decorators cannot be used to decorate object literal properties
- invalid connection string format, a valid format is host:ip:port
- When MATLAB uses audioread, an error is reported: Error using which Must be a string scalar or character vector.
- Conversion between list and string array
- The differences between the equals method in the string class and the equals method in the object class
- Finding the longest connection path of a string
- TypeError: int() can’t convert non-string with explicit base
- Solve the problem of error: cannot pass objects of non trivially copyable type ‘STD:: String’ in C / C + +
- Java String.split () special character processing
- C++ foundation — clear/erase/pop of string class_back