Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit ab64809

Browse files
armano2JamesHenry
authored andcommitted
fix(typescript-estree): update type annotation in index signature (typescript-eslint#74)
1 parent f8187ac commit ab64809

File tree

4 files changed

+9
-8
lines changed

4 files changed

+9
-8
lines changed

packages/typescript-eslint-parser/src/visitor-keys.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ export const visitorKeys = eslintVisitorKeys.unionWith({
7676
TSLiteralType: ['literal'],
7777
TSIntersectionType: ['types'],
7878
TSIndexedAccessType: ['indexType', 'objectType'],
79-
TSIndexSignature: ['typeAnnotation', 'parameters'],
79+
TSIndexSignature: ['parameters', 'typeAnnotation'],
8080
TSInterfaceBody: ['body'],
8181
TSInterfaceDeclaration: ['id', 'typeParameters', 'extends', 'body'],
8282
TSInterfaceHeritage: ['expression', 'typeParameters'],

packages/typescript-eslint-parser/tests/lib/__snapshots__/typescript.ts.snap

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110090,7 +110090,6 @@ Object {
110090110090
27,
110091110091
],
110092110092
"type": "TSIndexSignature",
110093-
"typeAnnotation": null,
110094110093
},
110095110094
],
110096110095
"range": Array [

packages/typescript-estree/src/convert.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ export default function convert(config: ConvertConfig): ESTreeNode | null {
282282
return [];
283283
}
284284
return parameters.map(param => {
285-
const convertedParam = convertChild(param) as ESTreeNode;
285+
const convertedParam = convertChild(param)!;
286286
if (!param.decorators || !param.decorators.length) {
287287
return convertedParam;
288288
}
@@ -1881,8 +1881,8 @@ export default function convert(config: ConvertConfig): ESTreeNode | null {
18811881
case SyntaxKind.JsxFragment:
18821882
Object.assign(result, {
18831883
type: AST_NODE_TYPES.JSXFragment,
1884-
openingFragment: convertChild((node as ts.JsxFragment).openingFragment),
1885-
closingFragment: convertChild((node as ts.JsxFragment).closingFragment),
1884+
openingFragment: convertChild(node.openingFragment),
1885+
closingFragment: convertChild(node.closingFragment),
18861886
children: node.children.map(convertChild)
18871887
});
18881888
break;
@@ -2248,10 +2248,13 @@ export default function convert(config: ConvertConfig): ESTreeNode | null {
22482248
case SyntaxKind.IndexSignature: {
22492249
Object.assign(result, {
22502250
type: AST_NODE_TYPES.TSIndexSignature,
2251-
parameters: node.parameters.map(convertChild),
2252-
typeAnnotation: node.type ? convertTypeAnnotation(node.type) : null
2251+
parameters: node.parameters.map(convertChild)
22532252
});
22542253

2254+
if (node.type) {
2255+
result.typeAnnotation = convertTypeAnnotation(node.type);
2256+
}
2257+
22552258
if (hasModifier(SyntaxKind.ReadonlyKeyword, node)) {
22562259
result.readonly = true;
22572260
}

packages/typescript-estree/tests/lib/__snapshots__/typescript.ts.snap

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109676,7 +109676,6 @@ Object {
109676109676
27,
109677109677
],
109678109678
"type": "TSIndexSignature",
109679-
"typeAnnotation": null,
109680109679
},
109681109680
],
109682109681
"range": Array [

0 commit comments

Comments
 (0)