Skip to content

Commit

Permalink
fix(check-param-names, require-param): handle TSIndexSignature earl…
Browse files Browse the repository at this point in the history
…y to avoid throwing; fixes #570

Also updating devDeps.
  • Loading branch information
brettz9 committed Jun 8, 2020
1 parent 634839e commit 5b814fc
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 6 deletions.
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2180,6 +2180,17 @@ class CSS {
setCssObject(propertyObject: {[key: string]: string | number}): void {
}
}

/**
* Logs a string.
*
* @param input - String to output.
*/
export default function (input: {
[foo: string]: { a: string; b: string };
}): void {
input;
}
````


Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@
"@babel/plugin-transform-flow-strip-types": "^7.10.1",
"@babel/preset-env": "^7.10.2",
"@babel/register": "^7.10.1",
"@typescript-eslint/parser": "^3.1.0",
"@typescript-eslint/parser": "^3.2.0",
"babel-eslint": "^10.1.0",
"babel-plugin-add-module-exports": "^1.0.2",
"babel-plugin-istanbul": "^6.0.0",
"chai": "^4.2.0",
"cross-env": "^7.0.2",
"eslint": "7.1.0",
"eslint": "7.2.0",
"eslint-config-canonical": "^20.0.5",
"gitdown": "^3.1.3",
"glob": "^7.1.6",
Expand All @@ -36,7 +36,7 @@
"nyc": "^15.1.0",
"rimraf": "^3.0.2",
"semantic-release": "^17.0.8",
"typescript": "^3.9.3"
"typescript": "^3.9.5"
},
"engines": {
"node": ">=8"
Expand Down
6 changes: 3 additions & 3 deletions src/jsdocUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,14 @@ const flattenRoots = (params, root = '') => {

type T = string | [?string, T];
const getPropertiesFromPropertySignature = (propSignature): T => {
if (propSignature.type === 'TSIndexSignature') {
return undefined;
}
if (propSignature.typeAnnotation && propSignature.typeAnnotation.typeAnnotation.type === 'TSTypeLiteral') {
return [propSignature.key.name, propSignature.typeAnnotation.typeAnnotation.members.map((member) => {
return getPropertiesFromPropertySignature(member);
})];
}
if (propSignature.type === 'TSIndexSignature') {
return undefined;
}

return propSignature.key.name;
};
Expand Down
15 changes: 15 additions & 0 deletions test/rules/assertions/checkParamNames.js
Original file line number Diff line number Diff line change
Expand Up @@ -1085,5 +1085,20 @@ export default {
`,
parser: require.resolve('@typescript-eslint/parser'),
},
{
code: `
/**
* Logs a string.
*
* @param input - String to output.
*/
export default function (input: {
[foo: string]: { a: string; b: string };
}): void {
input;
}
`,
parser: require.resolve('@typescript-eslint/parser'),
},
],
};

0 comments on commit 5b814fc

Please sign in to comment.