mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-11 01:34:55 -06:00
get name for index info
This commit is contained in:
parent
965d43c6a5
commit
93cd1dc1ea
@ -59,7 +59,7 @@ namespace ts.codefix {
|
||||
/*decorators*/ undefined
|
||||
, /*modifiers*/ undefined
|
||||
, /*dotDotDotToken*/ undefined
|
||||
, "name"
|
||||
, "x"
|
||||
, /*questionToken*/ undefined
|
||||
, stringTypeNode);
|
||||
const indexSignature = createIndexSignatureDeclaration([indexingParameter], typeNode);
|
||||
|
||||
@ -54,13 +54,12 @@ namespace ts.codefix {
|
||||
return undefined;
|
||||
}
|
||||
const typeNode = checker.createTypeNode(indexInfoOfKind.type);
|
||||
let name: string;
|
||||
const newIndexSignatureDeclaration = createIndexSignatureDeclaration(
|
||||
[createParameter(
|
||||
/*decorators*/undefined
|
||||
, /*modifiers*/ undefined
|
||||
, /*dotDotDotToken*/ undefined
|
||||
, name
|
||||
, getNameFromIndexInfo(indexInfoOfKind)
|
||||
, /*questionToken*/ undefined
|
||||
, kind === IndexKind.String ? createKeywordTypeNode(SyntaxKind.StringKeyword) : createKeywordTypeNode(SyntaxKind.NumberKeyword))]
|
||||
, typeNode);
|
||||
|
||||
@ -234,4 +234,8 @@ namespace ts.codefix {
|
||||
, parameterTypeNode);
|
||||
return parameterNode;
|
||||
}
|
||||
|
||||
export function getNameFromIndexInfo(info: IndexInfo) {
|
||||
return info.declaration ? declarationNameToString(info.declaration.parameters[0].name) : "x"
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user