mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-15 12:51:30 -05:00
Respond to CR
This commit is contained in:
@@ -186,20 +186,21 @@ namespace ts.codefix {
|
||||
}
|
||||
// we only care about identifiers that are parameters and declarations (don't care about other uses)
|
||||
else if (node.parent && (isParameter(node.parent) || isVariableDeclaration(node.parent))) {
|
||||
const originalName = node.text;
|
||||
|
||||
// if the identifier name conflicts with a different identifier that we've already seen
|
||||
if (allVarNames.some(ident => ident.originalName === node.text && ident.symbol !== symbol)) {
|
||||
const newName = getNewNameIfConflict(node, allVarNames);
|
||||
identsToRenameMap.set(symbolIdString, newName.identifier);
|
||||
synthNamesMap.set(symbolIdString, newName);
|
||||
allVarNames.push({ identifier: newName.identifier, symbol, originalName: node.text });
|
||||
allVarNames.push({ identifier: newName.identifier, symbol, originalName });
|
||||
}
|
||||
else {
|
||||
const identifier = getSynthesizedDeepClone(node);
|
||||
identsToRenameMap.set(symbolIdString, identifier);
|
||||
synthNamesMap.set(symbolIdString, { identifier, types: [], numberOfAssignmentsOriginal: allVarNames.filter(elem => elem.identifier.text === node.text).length/*, numberOfAssignmentsSynthesized: 0*/ });
|
||||
if ((isParameter(node.parent) && isExpressionOrCallOnTypePromise(node.parent.parent)) || isVariableDeclaration(node.parent)) {
|
||||
allVarNames.push({ identifier, symbol, originalName: node.text });
|
||||
allVarNames.push({ identifier, symbol, originalName });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1654,11 +1654,10 @@ namespace ts {
|
||||
return clone;
|
||||
}
|
||||
|
||||
export function getSynthesizedDeepCloneWithRenames<T extends Node | undefined>(node: T, includeTrivia = true, renameMap?: Map<Identifier>, checker?: TypeChecker, callback?: (originalNode: Node, clone: Node) => any): T {
|
||||
|
||||
export function getSynthesizedDeepCloneWithRenames<T extends Node>(node: T, includeTrivia = true, renameMap?: Map<Identifier>, checker?: TypeChecker, callback?: (originalNode: Node, clone: Node) => any): T {
|
||||
let clone;
|
||||
if (node && isIdentifier(node!) && renameMap && checker) {
|
||||
const symbol = checker.getSymbolAtLocation(node!);
|
||||
if (isIdentifier(node) && renameMap && checker) {
|
||||
const symbol = checker.getSymbolAtLocation(node);
|
||||
const renameInfo = symbol && renameMap.get(String(getSymbolId(symbol)));
|
||||
|
||||
if (renameInfo) {
|
||||
@@ -1667,11 +1666,11 @@ namespace ts {
|
||||
}
|
||||
|
||||
if (!clone) {
|
||||
clone = node && getSynthesizedDeepCloneWorker(node as NonNullable<T>, renameMap, checker, callback);
|
||||
clone = getSynthesizedDeepCloneWorker(node as NonNullable<T>, renameMap, checker, callback);
|
||||
}
|
||||
|
||||
if (clone && !includeTrivia) suppressLeadingAndTrailingTrivia(clone);
|
||||
if (callback && node && clone) callback(node!, clone);
|
||||
if (callback && clone) callback(node, clone);
|
||||
|
||||
return clone as T;
|
||||
}
|
||||
|
||||
@@ -823,7 +823,7 @@ function [#|f|](): Promise<void> {
|
||||
}
|
||||
return x.then(resp => {
|
||||
var blob = resp.blob().then(blob => blob.byteOffset).catch(err => 'Error');
|
||||
return fetch("https://micorosft.com").then(res => console.log("Another one!"));
|
||||
return fetch("https://microsoft.com").then(res => console.log("Another one!"));
|
||||
});
|
||||
}
|
||||
`
|
||||
@@ -1201,7 +1201,7 @@ function [#|f|]() {
|
||||
`);
|
||||
|
||||
_testConvertToAsyncFunction("convertToAsyncFunction_bindingPattern", `
|
||||
function [#|f|]():Promise<void> {
|
||||
function [#|f|]() {
|
||||
return fetch('https://typescriptlang.org').then(res);
|
||||
}
|
||||
function res({ status, trailer }){
|
||||
@@ -1210,7 +1210,7 @@ function res({ status, trailer }){
|
||||
`);
|
||||
|
||||
_testConvertToAsyncFunction("convertToAsyncFunction_bindingPatternNameCollision", `
|
||||
function [#|f|]():Promise<void> {
|
||||
function [#|f|]() {
|
||||
const result = 'https://typescriptlang.org';
|
||||
return fetch(result).then(res);
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ function /*[#|*/f/*|]*/(): Promise<void> {
|
||||
}
|
||||
return x.then(resp => {
|
||||
var blob = resp.blob().then(blob => blob.byteOffset).catch(err => 'Error');
|
||||
return fetch("https://micorosft.com").then(res => console.log("Another one!"));
|
||||
return fetch("https://microsoft.com").then(res => console.log("Another one!"));
|
||||
});
|
||||
}
|
||||
|
||||
@@ -21,6 +21,6 @@ async function f(): Promise<void> {
|
||||
}
|
||||
const resp = await x;
|
||||
var blob = resp.blob().then(blob_1 => blob_1.byteOffset).catch(err => 'Error');
|
||||
const res_2 = await fetch("https://micorosft.com");
|
||||
const res_2 = await fetch("https://microsoft.com");
|
||||
return console.log("Another one!");
|
||||
}
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
// ==ORIGINAL==
|
||||
|
||||
function /*[#|*/f/*|]*/() {
|
||||
return fetch('https://typescriptlang.org').then(res);
|
||||
}
|
||||
function res({ status, trailer }){
|
||||
console.log(status);
|
||||
}
|
||||
|
||||
// ==ASYNC FUNCTION::Convert to async function==
|
||||
|
||||
async function f() {
|
||||
const result = await fetch('https://typescriptlang.org');
|
||||
return res(result);
|
||||
}
|
||||
function res({ status, trailer }){
|
||||
console.log(status);
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
// ==ORIGINAL==
|
||||
|
||||
function /*[#|*/f/*|]*/():Promise<void> {
|
||||
function /*[#|*/f/*|]*/() {
|
||||
return fetch('https://typescriptlang.org').then(res);
|
||||
}
|
||||
function res({ status, trailer }){
|
||||
@@ -9,7 +9,7 @@ function res({ status, trailer }){
|
||||
|
||||
// ==ASYNC FUNCTION::Convert to async function==
|
||||
|
||||
async function f():Promise<void> {
|
||||
async function f() {
|
||||
const result = await fetch('https://typescriptlang.org');
|
||||
return res(result);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
// ==ORIGINAL==
|
||||
|
||||
function /*[#|*/f/*|]*/() {
|
||||
const result = 'https://typescriptlang.org';
|
||||
return fetch(result).then(res);
|
||||
}
|
||||
function res({ status, trailer }){
|
||||
console.log(status);
|
||||
}
|
||||
|
||||
// ==ASYNC FUNCTION::Convert to async function==
|
||||
|
||||
async function f() {
|
||||
const result = 'https://typescriptlang.org';
|
||||
const result_1 = await fetch(result);
|
||||
return res(result_1);
|
||||
}
|
||||
function res({ status, trailer }){
|
||||
console.log(status);
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
// ==ORIGINAL==
|
||||
|
||||
function /*[#|*/f/*|]*/():Promise<void> {
|
||||
function /*[#|*/f/*|]*/() {
|
||||
const result = 'https://typescriptlang.org';
|
||||
return fetch(result).then(res);
|
||||
}
|
||||
@@ -10,7 +10,7 @@ function res({ status, trailer }){
|
||||
|
||||
// ==ASYNC FUNCTION::Convert to async function==
|
||||
|
||||
async function f():Promise<void> {
|
||||
async function f() {
|
||||
const result = 'https://typescriptlang.org';
|
||||
const result_1 = await fetch(result);
|
||||
return res(result_1);
|
||||
|
||||
Reference in New Issue
Block a user