禁止将“any”类型的值赋值给变量和属性。
该规则仅支持对.ts文件进行检查。
let [x] = ['1']; [x] = ['1'] as [string]; console.info([x].toString()); // generic position examples export const a1: Set<string> = new Set<string>(); export const a2: Map<string, string> = new Map<string, string>(); export const a3: Set<string[]> = new Set<string[]>(); export const a4: Set<Set<Set<string>>> = new Set<Set<Set<string>>>();
let [x] = ['1']; [x] = ['1'] as [any]; [x] = '1' as any; console.info([x].toString()); // generic position examples export const a1: Set<string> = new Set<any>(); export const a2: Map<string, string> = new Map<any, string>(); export const a3: Set<string[]> = new Set<any[]>(); export const a4: Set<Set<Set<string>>> = new Set<Set<Set<any>>>();
plugin:@typescript-eslint/recommended plugin:@typescript-eslint/all
Code Linter代码检查规则的配置指导请参考Code Linter代码检查。