@@ -215,6 +215,11 @@ impl Rule for ArrayType {
215215 ctx,
216216 ) ;
217217 }
218+ AstKind :: TSTypeParameterInstantiation ( ts_type_param_instantiation) => {
219+ for param in & ts_type_param_instantiation. params {
220+ check ( param, default_config, readonly_config, ctx) ;
221+ }
222+ }
218223 _ => { }
219224 }
220225 }
@@ -1256,6 +1261,36 @@ fn test() {
12561261 ( "type x = Array<number>[]" , None ) ,
12571262 ( "const arr: Array<Array<number>>[] = [];" , None ) ,
12581263 ( "export function fn4(arr: Array<number>[]) { return arr; }" , None ) ,
1264+ (
1265+ "function testFn<T>(param: T) { return param; }
1266+ export const test2 = testFn<{name: string}[]>([]);" ,
1267+ Some ( serde_json:: json!( [ { "default" : "array-simple" } ] ) ) ,
1268+ ) ,
1269+ (
1270+ "function testFn<T>(param: T) { return param; }
1271+ export const test2 = testFn<Array<{name: string}>>([]);" ,
1272+ Some ( serde_json:: json!( [ { "default" : "array" } ] ) ) ,
1273+ ) ,
1274+ (
1275+ "function testFn<T>(param: T) { return param; }
1276+ export const test2 = testFn<string[]>([]);" ,
1277+ Some ( serde_json:: json!( [ { "default" : "generic" } ] ) ) ,
1278+ ) ,
1279+ (
1280+ "function testFn<T>(param: T) { return param; }
1281+ export const test2 = testFn<(string | number)[]>([]);" ,
1282+ Some ( serde_json:: json!( [ { "default" : "generic" } ] ) ) ,
1283+ ) ,
1284+ (
1285+ "function testFn<T>(param: T) { return param; }
1286+ export const test2 = testFn<readonly string[]>([]);" ,
1287+ Some ( serde_json:: json!( [ { "default" : "generic" } ] ) ) ,
1288+ ) ,
1289+ (
1290+ "function testFn<T>(param: T) { return param; }
1291+ export const test2 = testFn<ReadonlyArray<string>>([]);" ,
1292+ Some ( serde_json:: json!( [ { "default" : "array" } ] ) ) ,
1293+ ) ,
12591294 ] ;
12601295
12611296 let fix: Vec < ( & str , & str , Option < serde_json:: Value > ) > = vec ! [
@@ -1788,6 +1823,48 @@ fn test() {
17881823 "let a: Promise<Array<string>> = Promise.resolve([]);" ,
17891824 Some ( serde_json:: json!( [ { "default" : "generic" } ] ) ) ,
17901825 ) ,
1826+ (
1827+ "function testFn<T>(param: T) { return param; }
1828+ export const test2 = testFn<{name: string}[]>([]);" ,
1829+ "function testFn<T>(param: T) { return param; }
1830+ export const test2 = testFn<Array<{name: string}>>([]);" ,
1831+ Some ( serde_json:: json!( [ { "default" : "array-simple" } ] ) ) ,
1832+ ) ,
1833+ (
1834+ "function testFn<T>(param: T) { return param; }
1835+ export const test2 = testFn<Array<{name: string}>>([]);" ,
1836+ "function testFn<T>(param: T) { return param; }
1837+ export const test2 = testFn<{name: string}[]>([]);" ,
1838+ Some ( serde_json:: json!( [ { "default" : "array" } ] ) ) ,
1839+ ) ,
1840+ (
1841+ "function testFn<T>(param: T) { return param; }
1842+ export const test2 = testFn<string[]>([]);" ,
1843+ "function testFn<T>(param: T) { return param; }
1844+ export const test2 = testFn<Array<string>>([]);" ,
1845+ Some ( serde_json:: json!( [ { "default" : "generic" } ] ) ) ,
1846+ ) ,
1847+ (
1848+ "function testFn<T>(param: T) { return param; }
1849+ export const test2 = testFn<(string | number)[]>([]);" ,
1850+ "function testFn<T>(param: T) { return param; }
1851+ export const test2 = testFn<Array<string | number>>([]);" ,
1852+ Some ( serde_json:: json!( [ { "default" : "generic" } ] ) ) ,
1853+ ) ,
1854+ (
1855+ "function testFn<T>(param: T) { return param; }
1856+ export const test2 = testFn<readonly string[]>([]);" ,
1857+ "function testFn<T>(param: T) { return param; }
1858+ export const test2 = testFn<ReadonlyArray<string>>([]);" ,
1859+ Some ( serde_json:: json!( [ { "default" : "generic" } ] ) ) ,
1860+ ) ,
1861+ (
1862+ "function testFn<T>(param: T) { return param; }
1863+ export const test2 = testFn<ReadonlyArray<string>>([]);" ,
1864+ "function testFn<T>(param: T) { return param; }
1865+ export const test2 = testFn<readonly string[]>([]);" ,
1866+ Some ( serde_json:: json!( [ { "default" : "array" } ] ) ) ,
1867+ ) ,
17911868 ] ;
17921869
17931870 Tester :: new ( ArrayType :: NAME , ArrayType :: PLUGIN , pass, fail)
0 commit comments