From a39f9ef1a7ef92a3198c2f7524b31fd64c899f67 Mon Sep 17 00:00:00 2001 From: Kanchalai Tanglertsampan Date: Thu, 19 Jan 2017 09:46:15 -0800 Subject: [PATCH] Update calling to getSpreadType and using set function when adding value to map --- src/compiler/checker.ts | 16 ++++++++-------- src/harness/harness.ts | 10 +++++----- src/services/services.ts | 2 +- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 42cb4a1be3f..4152aad0c84 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -11903,13 +11903,13 @@ namespace ts { } attributeSymbol.type = exprType; attributeSymbol.target = member; - attributesTable[attributeSymbol.name] = attributeSymbol; + attributesTable.set(attributeSymbol.name, attributeSymbol); attributesArray.push(attributeSymbol); } else { Debug.assert(attributeDecl.kind === SyntaxKind.JsxSpreadAttribute); if (attributesArray.length > 0) { - spread = getSpreadType(spread, createJsxAttributesType(attributes.symbol, attributesTable), /*isFromObjectLiteral*/ true); + spread = getSpreadType(spread, createJsxAttributesType(attributes.symbol, attributesTable)); attributesArray = []; attributesTable = createMap(); } @@ -11922,13 +11922,13 @@ namespace ts { if (isTypeAny(widenExprType)) { return undefined; } - spread = getSpreadType(spread, exprType, /*isFromObjectLiteral*/ false); + spread = getSpreadType(spread, exprType); } } if (spread !== emptyObjectType) { if (attributesArray.length > 0) { - spread = getSpreadType(spread, createJsxAttributesType(attributes.symbol, attributesTable), /*isFromObjectLiteral*/ true); + spread = getSpreadType(spread, createJsxAttributesType(attributes.symbol, attributesTable)); attributesArray = []; attributesTable = createMap(); } @@ -11962,7 +11962,7 @@ namespace ts { if (symbolArray) { const symbolTable = createMap(); forEach(symbolArray, (attr) => { - symbolTable[attr.name] = attr; + symbolTable.set(attr.name, attr); }); argAttributesType = createJsxAttributesType(node.symbol, symbolTable); } @@ -11986,7 +11986,7 @@ namespace ts { } const symbolArray = getJsxAttributesSymbolArrayFromAttributesProperty(openingLikeElement); - // sourceAttributesType is a type of an attributes properties. + // sourceAttributesType is a type of attributes properties. // i.e
// attr1 and attr2 are treated as JSXAttributes attached in the JsxOpeningLikeElement as "attributes". They resolved to be sourceAttributesType. let sourceAttributesType = anyType as Type; @@ -11996,7 +11996,7 @@ namespace ts { const symbolTable = createMap(); forEach(symbolArray, (attr) => { if (isUnhyphenatedJsxName(attr.name) || getPropertyOfType(targetAttributesType, attr.name)) { - symbolTable[attr.name] = attr; + symbolTable.set(attr.name, attr); isSourceAttributesTypeEmpty = false; } }); @@ -12450,7 +12450,7 @@ namespace ts { } } - checkJSXAttributesAssignableToTagnameAttributes(openingLikeElement); + checkJSXAttributesAssignableToTagnameAttributes(node); } function checkJsxExpression(node: JsxExpression) { diff --git a/src/harness/harness.ts b/src/harness/harness.ts index ee7a1ccccce..8935da642d4 100644 --- a/src/harness/harness.ts +++ b/src/harness/harness.ts @@ -1011,13 +1011,13 @@ namespace Harness { const libFileName = "tests/lib/" + fileName; if (scriptTarget <= ts.ScriptTarget.ES5) { - if (!testLibFileNameSourceFileMap[libFileName]) { - testLibFileNameSourceFileMap[libFileName] = createSourceFileAndAssertInvariants(libFileName, IO.readFile(libFileName), scriptTarget); + if (!testLibFileNameSourceFileMap.get(libFileName)) { + testLibFileNameSourceFileMap.set(libFileName, createSourceFileAndAssertInvariants(libFileName, IO.readFile(libFileName), scriptTarget)); } } else { - if (!es6TestLibFileNameSourceFileMap[libFileName]) { - es6TestLibFileNameSourceFileMap[libFileName] = createSourceFileAndAssertInvariants(libFileName, IO.readFile(libFileName), scriptTarget); + if (!es6TestLibFileNameSourceFileMap.get(libFileName)) { + es6TestLibFileNameSourceFileMap.set(libFileName, createSourceFileAndAssertInvariants(libFileName, IO.readFile(libFileName), scriptTarget)) } } } @@ -1035,7 +1035,7 @@ namespace Harness { return fourslashSourceFile; } else if (ts.startsWith(fileName, "tests/lib/")) { - return scriptTarget <= ts.ScriptTarget.ES5 ? testLibFileNameSourceFileMap[fileName] : es6TestLibFileNameSourceFileMap[fileName]; + return scriptTarget <= ts.ScriptTarget.ES5 ? testLibFileNameSourceFileMap.get(fileName) : es6TestLibFileNameSourceFileMap.get(fileName); } else { // Don't throw here -- the compiler might be looking for a test that actually doesn't exist as part of the TC diff --git a/src/services/services.ts b/src/services/services.ts index e43a5356a7b..227e9a33edb 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -2007,7 +2007,7 @@ namespace ts { if (node.name.kind === SyntaxKind.ComputedPropertyName) { const nameExpression = (node.name).expression; // treat computed property names where expression is string/numeric literal as just string/numeric literal - if (isStringOrNumericLiteral(nameExpression.kind)) { + if (isStringOrNumericLiteral(nameExpression)) { return (nameExpression).text; } return undefined;