Skip to content

Commit ea220c1

Browse files
committed
Adding tests and changed property checking
1 parent e59fdd5 commit ea220c1

7 files changed

Lines changed: 52 additions & 16 deletions

src/services/findAllReferences.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2478,7 +2478,7 @@ export namespace Core {
24782478
cancellationToken.throwIfCancellationRequested();
24792479
return mapDefined(getPossibleSymbolReferenceNodes(sourceFile, node.text), ref => {
24802480
if (isStringLiteralLike(ref) && ref.text === node.text) {
2481-
if (type) {
2481+
if (type && !isStringLiteralPropertyReference(node, checker)) {
24822482
const refType = getContextualTypeFromParentOrAncestorTypeNode(ref, checker);
24832483
if (type !== checker.getStringType() && (type === refType || isStringLiteralPropertyReference(ref, checker))) {
24842484
return nodeEntry(ref, EntryKind.StringLiteral);
Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
// === findRenameLocations ===
22
// === /tests/cases/fourslash/renameStringLiteralTypes5.ts ===
3-
// declare const Att_1: "[|Att 2RENAME|]"/*RENAME*/
4-
//
5-
// interface Case_1 {
6-
// [Att_1]: string
3+
// type T = {
4+
// <|"[|Prop 1RENAME|]": string;|>
75
// }
86
//
9-
// declare const fnc_1: <K extends keyof Case_1>(p: K) => void
7+
// declare const fn: <K extends keyof T>(p: K) => void
108
//
11-
// fnc_1("[|Att 2RENAME|]")
9+
// fn("[|Prop 1RENAME|]"/*RENAME*/)
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// === findRenameLocations ===
2+
// === /tests/cases/fourslash/renameStringLiteralTypes7.ts ===
3+
// declare const Att_1: "[|Att 2RENAME|]"/*RENAME*/
4+
//
5+
// interface Case_1 {
6+
// [Att_1]: string
7+
// }
8+
//
9+
// declare const fnc_1: <K extends keyof Case_1>(p: K) => void
10+
//
11+
// fnc_1("[|Att 2RENAME|]")
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// === findRenameLocations ===
2+
// === /tests/cases/fourslash/renameStringLiteralTypes8.ts ===
3+
// type T = {
4+
// <|"[|Prop 1RENAME|]"/*RENAME*/: string;|>
5+
// }
6+
//
7+
// declare const fn: <K extends keyof T>(p: K) => void
8+
//
9+
// fn("[|Prop 1RENAME|]")
Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
11
/// <reference path="fourslash.ts" />
2-
3-
////declare const Att_1: "Att 2"/**/
4-
////
5-
////interface Case_1 {
6-
//// [Att_1]: string
2+
////type T = {
3+
//// "Prop 1": string;
74
////}
85
////
9-
////declare const fnc_1: <K extends keyof Case_1>(p: K) => void
6+
////declare const fn: <K extends keyof T>(p: K) => void
107
////
11-
////fnc_1("Att 2")
12-
13-
verify.baselineRename("", {});
8+
////fn("Prop 1"/**/)
9+
verify.baselineRename("", {});
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/// <reference path="fourslash.ts" />
2+
3+
////declare const Att_1: "Att 2"/**/
4+
////
5+
////interface Case_1 {
6+
//// [Att_1]: string
7+
////}
8+
////
9+
////declare const fnc_1: <K extends keyof Case_1>(p: K) => void
10+
////
11+
////fnc_1("Att 2")
12+
13+
verify.baselineRename("", {});
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
/// <reference path="fourslash.ts" />
2+
////type T = {
3+
//// "Prop 1"/**/: string;
4+
////}
5+
////
6+
////declare const fn: <K extends keyof T>(p: K) => void
7+
////
8+
////fn("Prop 1")
9+
verify.baselineRename("", {});

0 commit comments

Comments
 (0)