mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-06 02:13:31 -06:00
fix(44701): allow renaming string literal in rhs/lhs of equality (#44708)
This commit is contained in:
parent
193b7494d0
commit
ba2e2600c8
@ -802,6 +802,11 @@ namespace ts {
|
||||
return contextualType;
|
||||
}
|
||||
|
||||
const parent = node.parent;
|
||||
if (parent && isBinaryExpression(parent) && isEqualityOperatorKind(parent.operatorToken.kind)) {
|
||||
return checker.getTypeAtLocation(node === parent.left ? parent.right : parent.left);
|
||||
}
|
||||
|
||||
const ancestorTypeNode = getAncestorTypeNode(node);
|
||||
return ancestorTypeNode && checker.getTypeAtLocation(ancestorTypeNode);
|
||||
}
|
||||
|
||||
@ -9,10 +9,3 @@
|
||||
//// ff.f = '[|foo|]'
|
||||
|
||||
verify.rangesWithSameTextAreRenameLocations("foo");
|
||||
|
||||
interface Foo {
|
||||
f: 'foo' | 'bar'
|
||||
}
|
||||
const d: 'foo' = 'foo'
|
||||
declare const f: Foo
|
||||
f.f = 'foo'
|
||||
22
tests/cases/fourslash/renameStringLiteralTypes2.ts
Normal file
22
tests/cases/fourslash/renameStringLiteralTypes2.ts
Normal file
@ -0,0 +1,22 @@
|
||||
/// <reference path='fourslash.ts' />
|
||||
|
||||
////type Foo = "[|a|]" | "b";
|
||||
////
|
||||
////class C {
|
||||
//// p: Foo = "[|a|]";
|
||||
//// m() {
|
||||
//// if (this.p === "[|a|]") {}
|
||||
//// if ("[|a|]" === this.p) {}
|
||||
////
|
||||
//// if (this.p !== "[|a|]") {}
|
||||
//// if ("[|a|]" !== this.p) {}
|
||||
////
|
||||
//// if (this.p == "[|a|]") {}
|
||||
//// if ("[|a|]" == this.p) {}
|
||||
////
|
||||
//// if (this.p != "[|a|]") {}
|
||||
//// if ("[|a|]" != this.p) {}
|
||||
//// }
|
||||
////}
|
||||
|
||||
verify.rangesWithSameTextAreRenameLocations("a");
|
||||
Loading…
x
Reference in New Issue
Block a user