Improve 'isWriteAccess' for findAllReferences (#26889)
This commit is contained in:
parent
ddba6d8a70
commit
8c22770ea8
|
@ -739,6 +739,7 @@ namespace ts {
|
|||
}
|
||||
|
||||
export interface ComputedPropertyName extends Node {
|
||||
parent: Declaration;
|
||||
kind: SyntaxKind.ComputedPropertyName;
|
||||
expression: Expression;
|
||||
}
|
||||
|
|
|
@ -2384,29 +2384,33 @@ namespace ts {
|
|||
}
|
||||
|
||||
// See GH#16030
|
||||
export function isAnyDeclarationName(name: Node): boolean {
|
||||
export function getDeclarationFromName(name: Node): Declaration | undefined {
|
||||
const parent = name.parent;
|
||||
switch (name.kind) {
|
||||
case SyntaxKind.Identifier:
|
||||
case SyntaxKind.StringLiteral:
|
||||
case SyntaxKind.NumericLiteral: {
|
||||
const parent = name.parent;
|
||||
case SyntaxKind.NumericLiteral:
|
||||
if (isComputedPropertyName(parent)) return parent.parent;
|
||||
// falls through
|
||||
|
||||
case SyntaxKind.Identifier:
|
||||
if (isDeclaration(parent)) {
|
||||
return parent.name === name;
|
||||
return parent.name === name ? parent : undefined;
|
||||
}
|
||||
else if (isQualifiedName(name.parent)) {
|
||||
const tag = name.parent.parent;
|
||||
return isJSDocParameterTag(tag) && tag.name === name.parent;
|
||||
else if (isQualifiedName(parent)) {
|
||||
const tag = parent.parent;
|
||||
return isJSDocParameterTag(tag) && tag.name === parent ? tag : undefined;
|
||||
}
|
||||
else {
|
||||
const binExp = name.parent.parent;
|
||||
const binExp = parent.parent;
|
||||
return isBinaryExpression(binExp) &&
|
||||
getSpecialPropertyAssignmentKind(binExp) !== SpecialPropertyAssignmentKind.None &&
|
||||
(binExp.left.symbol || binExp.symbol) &&
|
||||
getNameOfDeclaration(binExp) === name;
|
||||
getNameOfDeclaration(binExp) === name
|
||||
? binExp
|
||||
: undefined;
|
||||
}
|
||||
}
|
||||
default:
|
||||
return false;
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -154,7 +154,7 @@ namespace ts.FindAllReferences {
|
|||
textSpan: getTextSpan(node, sourceFile),
|
||||
isWriteAccess: isWriteAccessForReference(node),
|
||||
isDefinition: node.kind === SyntaxKind.DefaultKeyword
|
||||
|| isAnyDeclarationName(node)
|
||||
|| !!getDeclarationFromName(node)
|
||||
|| isLiteralComputedPropertyDeclarationName(node),
|
||||
isInString,
|
||||
};
|
||||
|
@ -223,7 +223,65 @@ namespace ts.FindAllReferences {
|
|||
|
||||
/** A node is considered a writeAccess iff it is a name of a declaration or a target of an assignment */
|
||||
function isWriteAccessForReference(node: Node): boolean {
|
||||
return node.kind === SyntaxKind.DefaultKeyword || isAnyDeclarationName(node) || isWriteAccess(node);
|
||||
const decl = getDeclarationFromName(node);
|
||||
return !!decl && declarationIsWriteAccess(decl) || node.kind === SyntaxKind.DefaultKeyword || isWriteAccess(node);
|
||||
}
|
||||
|
||||
/**
|
||||
* True if 'decl' provides a value, as in `function f() {}`;
|
||||
* false if 'decl' is just a location for a future write, as in 'let x;'
|
||||
*/
|
||||
function declarationIsWriteAccess(decl: Declaration): boolean {
|
||||
// Consider anything in an ambient declaration to be a write access since it may be coming from JS.
|
||||
if (!!(decl.flags & NodeFlags.Ambient)) return true;
|
||||
|
||||
switch (decl.kind) {
|
||||
case SyntaxKind.BinaryExpression:
|
||||
case SyntaxKind.BindingElement:
|
||||
case SyntaxKind.ClassDeclaration:
|
||||
case SyntaxKind.ClassExpression:
|
||||
case SyntaxKind.DefaultKeyword:
|
||||
case SyntaxKind.EnumDeclaration:
|
||||
case SyntaxKind.EnumMember:
|
||||
case SyntaxKind.ExportSpecifier:
|
||||
case SyntaxKind.ImportClause: // default import
|
||||
case SyntaxKind.ImportEqualsDeclaration:
|
||||
case SyntaxKind.ImportSpecifier:
|
||||
case SyntaxKind.InterfaceDeclaration:
|
||||
case SyntaxKind.JSDocCallbackTag:
|
||||
case SyntaxKind.JSDocTypedefTag:
|
||||
case SyntaxKind.JsxAttribute:
|
||||
case SyntaxKind.ModuleDeclaration:
|
||||
case SyntaxKind.NamespaceExportDeclaration:
|
||||
case SyntaxKind.NamespaceImport:
|
||||
case SyntaxKind.Parameter:
|
||||
case SyntaxKind.PropertyAssignment:
|
||||
case SyntaxKind.ShorthandPropertyAssignment:
|
||||
case SyntaxKind.TypeAliasDeclaration:
|
||||
case SyntaxKind.TypeParameter:
|
||||
return true;
|
||||
|
||||
case SyntaxKind.FunctionDeclaration:
|
||||
case SyntaxKind.FunctionExpression:
|
||||
case SyntaxKind.Constructor:
|
||||
case SyntaxKind.MethodDeclaration:
|
||||
case SyntaxKind.GetAccessor:
|
||||
case SyntaxKind.SetAccessor:
|
||||
return !!(decl as FunctionDeclaration | FunctionExpression | ConstructorDeclaration | MethodDeclaration | GetAccessorDeclaration | SetAccessorDeclaration).body;
|
||||
|
||||
case SyntaxKind.VariableDeclaration:
|
||||
case SyntaxKind.PropertyDeclaration:
|
||||
return !!(decl as VariableDeclaration | PropertyDeclaration).initializer || isCatchClause(decl.parent);
|
||||
|
||||
case SyntaxKind.MethodSignature:
|
||||
case SyntaxKind.PropertySignature:
|
||||
case SyntaxKind.JSDocPropertyTag:
|
||||
case SyntaxKind.JSDocParameterTag:
|
||||
return false;
|
||||
|
||||
default:
|
||||
return Debug.failBadSyntaxKind(decl);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -536,6 +536,7 @@ declare namespace ts {
|
|||
name?: Identifier | StringLiteral | NumericLiteral;
|
||||
}
|
||||
interface ComputedPropertyName extends Node {
|
||||
parent: Declaration;
|
||||
kind: SyntaxKind.ComputedPropertyName;
|
||||
expression: Expression;
|
||||
}
|
||||
|
|
|
@ -536,6 +536,7 @@ declare namespace ts {
|
|||
name?: Identifier | StringLiteral | NumericLiteral;
|
||||
}
|
||||
interface ComputedPropertyName extends Node {
|
||||
parent: Declaration;
|
||||
kind: SyntaxKind.ComputedPropertyName;
|
||||
expression: Expression;
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
//// * @param {string} o.x - a thing, its ok
|
||||
//// * @param {number} o.y - another thing
|
||||
//// * @param {Object} o.nested - very nested
|
||||
//// * @param {boolean} o.nested.[|{| "isWriteAccess": true, "isDefinition": true |}great|] - much greatness
|
||||
//// * @param {boolean} o.nested.[|{| "isDefinition": true |}great|] - much greatness
|
||||
//// * @param {number} o.nested.times - twice? probably!??
|
||||
//// */
|
||||
//// function f(o) { return o.nested.[|great|]; }
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/// <reference path='fourslash.ts' />
|
||||
|
||||
////interface I<T> {
|
||||
//// [|{| "isWriteAccess": true, "isDefinition": true |}x|]: boolean;
|
||||
//// [|{| "isDefinition": true |}x|]: boolean;
|
||||
////}
|
||||
////declare const i: I<number>;
|
||||
////const { [|{| "isWriteAccess": true, "isDefinition": true |}x|] } = i;
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
////}
|
||||
////
|
||||
////var x: I = {
|
||||
//// ["[|{| "isDefinition": true |}prop1|]"]: function () { },
|
||||
//// ["[|{| "isWriteAccess": true, "isDefinition": true |}prop1|]"]: function () { },
|
||||
////}
|
||||
|
||||
const ranges = test.ranges();
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
////}
|
||||
////
|
||||
////var x: I = {
|
||||
//// ["[|{| "isDefinition": true |}42|]"]: function () { }
|
||||
//// ["[|{| "isWriteAccess": true, "isDefinition": true |}42|]"]: function () { }
|
||||
////}
|
||||
|
||||
const ranges = test.ranges();
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/// <reference path='fourslash.ts'/>
|
||||
|
||||
////interface T { [|{| "isWriteAccess": true, "isDefinition": true |}a|]: number };
|
||||
////interface T { [|{| "isDefinition": true |}a|]: number };
|
||||
////type U = { [K in keyof T]: string };
|
||||
////type V = { [K in keyof U]: boolean };
|
||||
////const u: U = { [|{| "isWriteAccess": true, "isDefinition": true |}a|]: "" }
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/// <reference path='fourslash.ts'/>
|
||||
|
||||
////interface A1 { readonly [|{| "isWriteAccess": true, "isDefinition": true |}a|]: string };
|
||||
////interface A2 { [|{| "isWriteAccess": true, "isDefinition": true |}a|]?: number };
|
||||
////interface A1 { readonly [|{| "isDefinition": true |}a|]: string };
|
||||
////interface A2 { [|{| "isDefinition": true |}a|]?: number };
|
||||
////let a1: A1;
|
||||
////let a2: A2;
|
||||
////let a12 = { ...a1, ...a2 };
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/// <reference path='fourslash.ts'/>
|
||||
////interface Gen {
|
||||
//// x: number
|
||||
//// [|{| "isWriteAccess": true, "isDefinition": true |}parent|]: Gen;
|
||||
//// [|{| "isDefinition": true |}parent|]: Gen;
|
||||
//// millenial: string;
|
||||
////}
|
||||
////let t: Gen;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/// <reference path='fourslash.ts'/>
|
||||
|
||||
////interface I { [|{| "isWriteAccess": true, "isDefinition": true |}boom|](): void; }
|
||||
////interface I { [|{| "isDefinition": true |}boom|](): void; }
|
||||
////new class C implements I {
|
||||
//// [|{| "isWriteAccess": true, "isDefinition": true |}boom|](){}
|
||||
////}
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
/// <reference path='fourslash.ts' />
|
||||
|
||||
////interface I {
|
||||
//// [|{| "isDefinition": true, "isWriteAccess": true |}0|]: number;
|
||||
//// [|{| "isDefinition": true, "isWriteAccess": true |}s|]: string;
|
||||
//// [|{| "isDefinition": true |}0|]: number;
|
||||
//// [|{| "isDefinition": true |}s|]: string;
|
||||
////}
|
||||
////interface J {
|
||||
//// a: I[[|0|]],
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
//// class class1 extends class1 {
|
||||
//// [|{| "isWriteAccess": true, "isDefinition": true |}doStuff|]() { }
|
||||
//// [|{| "isWriteAccess": true, "isDefinition": true |}propName|]: string;
|
||||
//// [|{| "isDefinition": true |}propName|]: string;
|
||||
//// }
|
||||
////
|
||||
//// var v: class1;
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
/// <reference path='fourslash.ts'/>
|
||||
|
||||
//// interface interface1 extends interface1 {
|
||||
//// [|{| "isWriteAccess": true, "isDefinition": true |}doStuff|](): void; // r0
|
||||
//// [|{| "isWriteAccess": true, "isDefinition": true |}propName|]: string; // r1
|
||||
//// [|{| "isDefinition": true |}doStuff|](): void; // r0
|
||||
//// [|{| "isDefinition": true |}propName|]: string; // r1
|
||||
//// }
|
||||
////
|
||||
//// var v: interface1;
|
||||
|
|
|
@ -2,15 +2,15 @@
|
|||
|
||||
//// class class1 extends class1 {
|
||||
//// [|{| "isWriteAccess": true, "isDefinition": true |}doStuff|]() { } // r0
|
||||
//// [|{| "isWriteAccess": true, "isDefinition": true |}propName|]: string; // r1
|
||||
//// [|{| "isDefinition": true |}propName|]: string; // r1
|
||||
//// }
|
||||
//// interface interface1 extends interface1 {
|
||||
//// [|{| "isWriteAccess": true, "isDefinition": true |}doStuff|](): void; // r2
|
||||
//// [|{| "isWriteAccess": true, "isDefinition": true |}propName|]: string; // r3
|
||||
//// [|{| "isDefinition": true |}doStuff|](): void; // r2
|
||||
//// [|{| "isDefinition": true |}propName|]: string; // r3
|
||||
//// }
|
||||
//// class class2 extends class1 implements interface1 {
|
||||
//// [|{| "isWriteAccess": true, "isDefinition": true |}doStuff|]() { } // r4
|
||||
//// [|{| "isWriteAccess": true, "isDefinition": true |}propName|]: string; // r5
|
||||
//// [|{| "isDefinition": true |}propName|]: string; // r5
|
||||
//// }
|
||||
////
|
||||
//// var v: class2;
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
/// <reference path='fourslash.ts'/>
|
||||
|
||||
//// interface C extends D {
|
||||
//// [|{| "isWriteAccess": true, "isDefinition": true |}prop0|]: string; // r0
|
||||
//// [|{| "isWriteAccess": true, "isDefinition": true |}prop1|]: number; // r1
|
||||
//// [|{| "isDefinition": true |}prop0|]: string; // r0
|
||||
//// [|{| "isDefinition": true |}prop1|]: number; // r1
|
||||
//// }
|
||||
////
|
||||
//// interface D extends C {
|
||||
//// [|{| "isWriteAccess": true, "isDefinition": true |}prop0|]: string; // r2
|
||||
//// [|{| "isDefinition": true |}prop0|]: string; // r2
|
||||
//// }
|
||||
////
|
||||
//// var d: D;
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
/// <reference path='fourslash.ts'/>
|
||||
|
||||
//// class C extends D {
|
||||
//// [|{| "isWriteAccess": true, "isDefinition": true |}prop0|]: string; // r0
|
||||
//// [|{| "isWriteAccess": true, "isDefinition": true |}prop1|]: number; // r1
|
||||
//// [|{| "isDefinition": true |}prop0|]: string; // r0
|
||||
//// [|{| "isDefinition": true |}prop1|]: number; // r1
|
||||
//// }
|
||||
////
|
||||
//// class D extends C {
|
||||
//// [|{| "isWriteAccess": true, "isDefinition": true |}prop0|]: string; // r2
|
||||
//// [|{| "isDefinition": true |}prop0|]: string; // r2
|
||||
//// }
|
||||
////
|
||||
//// var d: D;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/// <reference path='fourslash.ts'/>
|
||||
|
||||
////interface T { [|{| "isWriteAccess": true, "isDefinition": true |}a|]: number; }
|
||||
////interface T { [|{| "isDefinition": true |}a|]: number; }
|
||||
////type U = { readonly [K in keyof T]?: string };
|
||||
////declare const t: T;
|
||||
////t.[|a|];
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/// <reference path='fourslash.ts'/>
|
||||
|
||||
////interface I {
|
||||
//// [|{| "isWriteAccess": true, "isDefinition": true |}property1|]: number;
|
||||
//// [|{| "isDefinition": true |}property1|]: number;
|
||||
//// property2: string;
|
||||
////}
|
||||
////
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/// <reference path='fourslash.ts'/>
|
||||
|
||||
////interface I {
|
||||
//// [|{| "isWriteAccess": true, "isDefinition": true |}property1|]: number;
|
||||
//// [|{| "isDefinition": true |}property1|]: number;
|
||||
//// property2: string;
|
||||
////}
|
||||
////
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/// <reference path='fourslash.ts'/>
|
||||
|
||||
////interface I {
|
||||
//// [|{| "isWriteAccess": true, "isDefinition": true |}property1|]: number;
|
||||
//// [|{| "isDefinition": true |}property1|]: number;
|
||||
//// property2: string;
|
||||
////}
|
||||
////
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/// <reference path='fourslash.ts'/>
|
||||
|
||||
////interface I {
|
||||
//// [|{| "isWriteAccess": true, "isDefinition": true |}property1|]: number;
|
||||
//// [|{| "isDefinition": true |}property1|]: number;
|
||||
//// property2: string;
|
||||
////}
|
||||
////
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/// <reference path='fourslash.ts'/>
|
||||
|
||||
////interface I {
|
||||
//// [|{| "isWriteAccess": true, "isDefinition": true |}property1|]: number;
|
||||
//// [|{| "isDefinition": true |}property1|]: number;
|
||||
//// property2: string;
|
||||
////}
|
||||
////
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/// <reference path='fourslash.ts'/>
|
||||
|
||||
////interface Recursive {
|
||||
//// [|{| "isWriteAccess": true, "isDefinition": true |}next|]?: Recursive;
|
||||
//// [|{| "isDefinition": true |}next|]?: Recursive;
|
||||
//// value: any;
|
||||
////}
|
||||
////
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/// <reference path="./fourslash.ts" />
|
||||
|
||||
////interface IFoo {
|
||||
//// [|{| "isWriteAccess": true, "isDefinition": true |}a|]: string;
|
||||
//// [|{| "isDefinition": true |}a|]: string;
|
||||
////}
|
||||
////class C<T extends IFoo> {
|
||||
//// method() {
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
// @noLib: true
|
||||
|
||||
// @Filename: /a.ts
|
||||
////var [|{| "isWriteAccess": true, "isDefinition": true |}x|];
|
||||
////var [|{| "isDefinition": true |}x|];
|
||||
////export { [|{| "isWriteAccess": true, "isDefinition": true |}x|] };
|
||||
////export { [|x|] as [|{| "isWriteAccess": true, "isDefinition": true |}y|] };
|
||||
|
||||
|
|
|
@ -3,10 +3,10 @@
|
|||
// @noLib: true
|
||||
|
||||
////interface A {
|
||||
//// readonly [|{| "isWriteAccess": true, "isDefinition": true |}x|]: number | string;
|
||||
//// readonly [|{| "isDefinition": true |}x|]: number | string;
|
||||
////}
|
||||
////interface B extends A {
|
||||
//// readonly [|{| "isWriteAccess": true, "isDefinition": true |}x|]: number;
|
||||
//// readonly [|{| "isDefinition": true |}x|]: number;
|
||||
////}
|
||||
////const a: A = { [|{| "isWriteAccess": true, "isDefinition": true |}x|]: 0 };
|
||||
////const b: B = { [|{| "isWriteAccess": true, "isDefinition": true |}x|]: 0 };
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/// <reference path="fourslash.ts" />
|
||||
|
||||
////interface I { [|{| "isWriteAccess": true, "isDefinition": true |}x|]: {}; }
|
||||
////interface J { [|{| "isWriteAccess": true, "isDefinition": true |}x|]: {}; }
|
||||
////interface I { [|{| "isDefinition": true |}x|]: {}; }
|
||||
////interface J { [|{| "isDefinition": true |}x|]: {}; }
|
||||
////declare const o: (I | J) & { [|{| "isWriteAccess": true, "isDefinition": true |}x|]: string };
|
||||
////o.[|x|];
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
// @Filename: /a.js
|
||||
/////**
|
||||
//// * @typedef I {Object}
|
||||
//// * @prop [|{| "isWriteAccess": true, "isDefinition": true |}p|] {number}
|
||||
//// * @prop [|{| "isDefinition": true |}p|] {number}
|
||||
//// */
|
||||
////
|
||||
/////** @type {I} */
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
/// <reference path='fourslash.ts'/>
|
||||
|
||||
////type T =
|
||||
//// | { [|{| "isWriteAccess": true, "isDefinition": true |}type|]: "a", [|{| "isWriteAccess": true, "isDefinition": true |}prop|]: number }
|
||||
//// | { [|{| "isWriteAccess": true, "isDefinition": true |}type|]: "b", [|{| "isWriteAccess": true, "isDefinition": true |}prop|]: string };
|
||||
//// | { [|{| "isDefinition": true |}type|]: "a", [|{| "isDefinition": true |}prop|]: number }
|
||||
//// | { [|{| "isDefinition": true |}type|]: "b", [|{| "isDefinition": true |}prop|]: string };
|
||||
////const tt: T = {
|
||||
//// [|{| "isWriteAccess": true, "isDefinition": true |}type|]: "a",
|
||||
//// [|{| "isWriteAccess": true, "isDefinition": true |}prop|]: 0,
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
////class Foo {
|
||||
//// public _bar;
|
||||
//// public __bar;
|
||||
//// public [|{| "isWriteAccess": true, "isDefinition": true |}___bar|];
|
||||
//// public [|{| "isDefinition": true |}___bar|];
|
||||
//// public ____bar;
|
||||
////}
|
||||
////
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
////class Foo {
|
||||
//// public _bar;
|
||||
//// public [|{| "isWriteAccess": true, "isDefinition": true |}__bar|];
|
||||
//// public [|{| "isDefinition": true |}__bar|];
|
||||
//// public ___bar;
|
||||
//// public ____bar;
|
||||
////}
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
//// var [|{| "isWriteAccess": true, "isDefinition": true |}dx|] = "Foo";
|
||||
////
|
||||
//// module M { export var [|{| "isWriteAccess": true, "isDefinition": true |}dx|]; }
|
||||
//// module M { export var [|{| "isDefinition": true |}dx|]; }
|
||||
//// module M {
|
||||
//// var z = 100;
|
||||
//// export var y = { [|{| "isWriteAccess": true, "isDefinition": true |}dx|], z };
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/// <reference path="fourslash.ts" />
|
||||
|
||||
//@Filename: a.ts
|
||||
////var [|{| "isWriteAccess": true, "isDefinition": true |}x|]: number;
|
||||
////var [|{| "isDefinition": true |}x|]: number;
|
||||
|
||||
//@Filename: b.ts
|
||||
/////// <reference path="a.ts" />
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
// @Filename: a.ts
|
||||
////interface A {
|
||||
//// [|{| "isWriteAccess": true, "isDefinition": true |}foo|]: string;
|
||||
//// [|{| "isDefinition": true |}foo|]: string;
|
||||
////}
|
||||
|
||||
// @Filename: b.ts
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
////namespace JSX {
|
||||
//// export interface Element { }
|
||||
//// export interface IntrinsicElements {
|
||||
//// [|{| "isWriteAccess": true, "isDefinition": true |}div|]: any;
|
||||
//// [|{| "isDefinition": true |}div|]: any;
|
||||
//// }
|
||||
////}
|
||||
////
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/// <reference path='fourslash.ts' />
|
||||
////let o = { ["[|{| "isDefinition": true |}foo|]"]: 12 };
|
||||
////let o = { ["[|{| "isWriteAccess": true, "isDefinition": true |}foo|]"]: 12 };
|
||||
////let y = o.[|foo|];
|
||||
////let z = o['[|foo|]'];
|
||||
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
/// <reference path='fourslash.ts'/>
|
||||
|
||||
////class Base {
|
||||
//// [|{| "isWriteAccess": true, "isDefinition": true |}a|]: number;
|
||||
//// [|{| "isDefinition": true |}a|]: number;
|
||||
//// [|{| "isWriteAccess": true, "isDefinition": true |}method|](): void { }
|
||||
////}
|
||||
////class MyClass extends Base {
|
||||
//// [|{| "isWriteAccess": true, "isDefinition": true |}a|];
|
||||
//// [|{| "isDefinition": true |}a|];
|
||||
//// [|{| "isWriteAccess": true, "isDefinition": true |}method|]() { }
|
||||
////}
|
||||
////
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
/// <reference path='fourslash.ts'/>
|
||||
|
||||
////abstract class Base {
|
||||
//// abstract [|{| "isWriteAccess": true, "isDefinition": true |}a|]: number;
|
||||
//// abstract [|{| "isWriteAccess": true, "isDefinition": true |}method|](): void;
|
||||
//// abstract [|{| "isDefinition": true |}a|]: number;
|
||||
//// abstract [|{| "isDefinition": true |}method|](): void;
|
||||
////}
|
||||
////class MyClass extends Base {
|
||||
//// [|{| "isWriteAccess": true, "isDefinition": true |}a|];
|
||||
//// [|{| "isDefinition": true |}a|];
|
||||
//// [|{| "isWriteAccess": true, "isDefinition": true |}method|]() { }
|
||||
////}
|
||||
////
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
/// <reference path='fourslash.ts'/>
|
||||
|
||||
////class Base<T> {
|
||||
//// [|{| "isWriteAccess": true, "isDefinition": true |}a|]: this;
|
||||
//// [|{| "isDefinition": true |}a|]: this;
|
||||
//// [|{| "isWriteAccess": true, "isDefinition": true |}method|]<U>(a?:T, b?:U): this { }
|
||||
////}
|
||||
////class MyClass extends Base<number> {
|
||||
//// [|{| "isWriteAccess": true, "isDefinition": true |}a|];
|
||||
//// [|{| "isDefinition": true |}a|];
|
||||
//// [|{| "isWriteAccess": true, "isDefinition": true |}method|]() { }
|
||||
////}
|
||||
////
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/// <reference path='fourslash.ts'/>
|
||||
|
||||
////interface IFoo { [|{| "isWriteAccess": true, "isDefinition": true |}xy|]: number; }
|
||||
////interface IFoo { [|{| "isDefinition": true |}xy|]: number; }
|
||||
////
|
||||
////// Assignment
|
||||
////var a1: IFoo = { [|{| "isWriteAccess": true, "isDefinition": true |}xy|]: 0 };
|
||||
|
|
|
@ -2,12 +2,12 @@
|
|||
|
||||
////interface A {
|
||||
//// a: number;
|
||||
//// [|{| "isWriteAccess": true, "isDefinition": true |}common|]: string;
|
||||
//// [|{| "isDefinition": true |}common|]: string;
|
||||
////}
|
||||
////
|
||||
////interface B {
|
||||
//// b: number;
|
||||
//// [|{| "isWriteAccess": true, "isDefinition": true |}common|]: number;
|
||||
//// [|{| "isDefinition": true |}common|]: number;
|
||||
////}
|
||||
////
|
||||
////// Assignment
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
////}
|
||||
////
|
||||
////interface B {
|
||||
//// [|{| "isWriteAccess": true, "isDefinition": true |}b|]: number;
|
||||
//// [|{| "isDefinition": true |}b|]: number;
|
||||
//// common: number;
|
||||
////}
|
||||
////
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
// Function overloads should be highlighted together.
|
||||
|
||||
////function [|{| "isWriteAccess": true, "isDefinition": true |}foo|](x: string);
|
||||
////function [|{| "isDefinition": true |}foo|](x: string);
|
||||
////function [|{| "isWriteAccess": true, "isDefinition": true |}foo|](x: string, y: number) {
|
||||
//// [|foo|]('', 43);
|
||||
////}
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
// References a class property using string index access
|
||||
|
||||
////class Foo {
|
||||
//// [|{| "isWriteAccess": true, "isDefinition": true |}property|]: number;
|
||||
//// [|{| "isDefinition": true |}property|]: number;
|
||||
//// [|{| "isWriteAccess": true, "isDefinition": true |}method|](): void { }
|
||||
////}
|
||||
////
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
// References to a property of the apparent type using string indexer
|
||||
|
||||
////interface Object {
|
||||
//// [|{| "isWriteAccess": true, "isDefinition": true |}toMyString|]();
|
||||
//// [|{| "isDefinition": true |}toMyString|]();
|
||||
////}
|
||||
////
|
||||
////var y: Object;
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
/// <reference path='fourslash.ts'/>
|
||||
|
||||
////interface interface1 {
|
||||
//// [|{| "isWriteAccess": true, "isDefinition": true |}doStuff|](): void;
|
||||
//// [|{| "isDefinition": true |}doStuff|](): void;
|
||||
////}
|
||||
////
|
||||
////interface interface2 extends interface1{
|
||||
//// [|{| "isWriteAccess": true, "isDefinition": true |}doStuff|](): void;
|
||||
//// [|{| "isDefinition": true |}doStuff|](): void;
|
||||
////}
|
||||
////
|
||||
////class class1 implements interface2 {
|
||||
|
|
|
@ -3,11 +3,11 @@
|
|||
// extends statement in a diffrent declaration
|
||||
|
||||
////interface interface1 {
|
||||
//// [|{| "isWriteAccess": true, "isDefinition": true |}doStuff|](): void;
|
||||
//// [|{| "isDefinition": true |}doStuff|](): void;
|
||||
////}
|
||||
////
|
||||
////interface interface2 {
|
||||
//// [|{| "isWriteAccess": true, "isDefinition": true |}doStuff|](): void;
|
||||
//// [|{| "isDefinition": true |}doStuff|](): void;
|
||||
////}
|
||||
////
|
||||
////interface interface2 extends interface1 {
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
/// <reference path='fourslash.ts'/>
|
||||
|
||||
//// interface interface1 extends interface1 {
|
||||
//// [|{| "isWriteAccess": true, "isDefinition": true |}doStuff|](): void;
|
||||
//// [|{| "isWriteAccess": true, "isDefinition": true |}propName|]: string;
|
||||
//// [|{| "isDefinition": true |}doStuff|](): void;
|
||||
//// [|{| "isDefinition": true |}propName|]: string;
|
||||
//// }
|
||||
////
|
||||
//// var v: interface1;
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
//// class class1 extends class1 {
|
||||
//// [|{| "isWriteAccess": true, "isDefinition": true |}doStuff|]() { }
|
||||
//// [|{| "isWriteAccess": true, "isDefinition": true |}propName|]: string;
|
||||
//// [|{| "isDefinition": true |}propName|]: string;
|
||||
//// }
|
||||
////
|
||||
//// var c: class1;
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
/// <reference path='fourslash.ts'/>
|
||||
|
||||
//// interface interface1 extends interface1 {
|
||||
//// [|{| "isWriteAccess": true, "isDefinition": true |}doStuff|](): void;
|
||||
//// [|{| "isWriteAccess": true, "isDefinition": true |}propName|]: string;
|
||||
//// [|{| "isDefinition": true |}doStuff|](): void;
|
||||
//// [|{| "isDefinition": true |}propName|]: string;
|
||||
//// }
|
||||
//// interface interface2 extends interface1 {
|
||||
//// [|{| "isWriteAccess": true, "isDefinition": true |}doStuff|](): void;
|
||||
//// [|{| "isWriteAccess": true, "isDefinition": true |}propName|]: string;
|
||||
//// [|{| "isDefinition": true |}doStuff|](): void;
|
||||
//// [|{| "isDefinition": true |}propName|]: string;
|
||||
//// }
|
||||
////
|
||||
//// var v: interface1;
|
||||
|
|
|
@ -2,15 +2,15 @@
|
|||
|
||||
//// class class1 extends class1 {
|
||||
//// [|{| "isWriteAccess": true, "isDefinition": true |}doStuff|]() { }
|
||||
//// [|{| "isWriteAccess": true, "isDefinition": true |}propName|]: string;
|
||||
//// [|{| "isDefinition": true |}propName|]: string;
|
||||
//// }
|
||||
//// interface interface1 extends interface1 {
|
||||
//// [|{| "isWriteAccess": true, "isDefinition": true |}doStuff|](): void;
|
||||
//// [|{| "isWriteAccess": true, "isDefinition": true |}propName|]: string;
|
||||
//// [|{| "isDefinition": true |}doStuff|](): void;
|
||||
//// [|{| "isDefinition": true |}propName|]: string;
|
||||
//// }
|
||||
//// class class2 extends class1 implements interface1 {
|
||||
//// [|{| "isWriteAccess": true, "isDefinition": true |}doStuff|]() { }
|
||||
//// [|{| "isWriteAccess": true, "isDefinition": true |}propName|]: string;
|
||||
//// [|{| "isDefinition": true |}propName|]: string;
|
||||
//// }
|
||||
////
|
||||
//// var v: class2;
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
/// <reference path='fourslash.ts'/>
|
||||
|
||||
//// interface C extends D {
|
||||
//// [|{| "isWriteAccess": true, "isDefinition": true |}propD|]: number;
|
||||
//// [|{| "isDefinition": true |}propD|]: number;
|
||||
//// }
|
||||
//// interface D extends C {
|
||||
//// [|{| "isWriteAccess": true, "isDefinition": true |}propD|]: string;
|
||||
//// [|{| "isWriteAccess": true, "isDefinition": true |}propC|]: number;
|
||||
//// [|{| "isDefinition": true |}propD|]: string;
|
||||
//// [|{| "isDefinition": true |}propC|]: number;
|
||||
//// }
|
||||
//// var d: D;
|
||||
//// d.[|propD|];
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
/// <reference path='fourslash.ts'/>
|
||||
|
||||
//// class D extends C {
|
||||
//// [|{| "isWriteAccess": true, "isDefinition": true |}prop1|]: string;
|
||||
//// [|{| "isDefinition": true |}prop1|]: string;
|
||||
//// }
|
||||
////
|
||||
//// class C extends D {
|
||||
//// [|{| "isWriteAccess": true, "isDefinition": true |}prop1|]: string;
|
||||
//// [|{| "isDefinition": true |}prop1|]: string;
|
||||
//// }
|
||||
////
|
||||
//// var c: C;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/// <reference path='fourslash.ts'/>
|
||||
|
||||
////class Foo {
|
||||
//// public [|{| "isWriteAccess": true, "isDefinition": true |}12|]: any;
|
||||
//// public [|{| "isDefinition": true |}12|]: any;
|
||||
////}
|
||||
////
|
||||
////var x: Foo;
|
||||
|
|
|
@ -14,16 +14,16 @@
|
|||
////
|
||||
//// module SimpleInterfaceTest {
|
||||
//// export interface IFoo {
|
||||
//// [|{| "isWriteAccess": true, "isDefinition": true |}ifoo|](): void;
|
||||
//// [|{| "isDefinition": true |}ifoo|](): void;
|
||||
//// }
|
||||
//// export interface IBar extends IFoo {
|
||||
//// [|{| "isWriteAccess": true, "isDefinition": true |}ifoo|](): void;
|
||||
//// [|{| "isDefinition": true |}ifoo|](): void;
|
||||
//// }
|
||||
//// }
|
||||
////
|
||||
//// module SimpleClassInterfaceTest {
|
||||
//// export interface IFoo {
|
||||
//// [|{| "isWriteAccess": true, "isDefinition": true |}icfoo|](): void;
|
||||
//// [|{| "isDefinition": true |}icfoo|](): void;
|
||||
//// }
|
||||
//// export class Bar implements IFoo {
|
||||
//// public [|{| "isWriteAccess": true, "isDefinition": true |}icfoo|](): void {
|
||||
|
@ -33,29 +33,29 @@
|
|||
////
|
||||
//// module Test {
|
||||
//// export interface IBase {
|
||||
//// [|{| "isWriteAccess": true, "isDefinition": true |}field|]: string;
|
||||
//// [|{| "isWriteAccess": true, "isDefinition": true |}method|](): void;
|
||||
//// [|{| "isDefinition": true |}field|]: string;
|
||||
//// [|{| "isDefinition": true |}method|](): void;
|
||||
//// }
|
||||
////
|
||||
//// export interface IBlah extends IBase {
|
||||
//// [|{| "isWriteAccess": true, "isDefinition": true |}field|]: string;
|
||||
//// [|{| "isDefinition": true |}field|]: string;
|
||||
//// }
|
||||
////
|
||||
//// export interface IBlah2 extends IBlah {
|
||||
//// [|{| "isWriteAccess": true, "isDefinition": true |}field|]: string;
|
||||
//// [|{| "isDefinition": true |}field|]: string;
|
||||
//// }
|
||||
////
|
||||
//// export interface IDerived extends IBlah2 {
|
||||
//// [|{| "isWriteAccess": true, "isDefinition": true |}method|](): void;
|
||||
//// [|{| "isDefinition": true |}method|](): void;
|
||||
//// }
|
||||
////
|
||||
//// export class Bar implements IDerived {
|
||||
//// public [|{| "isWriteAccess": true, "isDefinition": true |}field|]: string;
|
||||
//// public [|{| "isDefinition": true |}field|]: string;
|
||||
//// public [|{| "isWriteAccess": true, "isDefinition": true |}method|](): void { }
|
||||
//// }
|
||||
////
|
||||
//// export class BarBlah extends Bar {
|
||||
//// public [|{| "isWriteAccess": true, "isDefinition": true |}field|]: string;
|
||||
//// public [|{| "isDefinition": true |}field|]: string;
|
||||
//// }
|
||||
//// }
|
||||
////
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/// <reference path='fourslash.ts'/>
|
||||
|
||||
////interface IFoo<T> {
|
||||
//// [|{| "isWriteAccess": true, "isDefinition": true |}doSomething|](v: T): T;
|
||||
//// [|{| "isDefinition": true |}doSomething|](v: T): T;
|
||||
////}
|
||||
////
|
||||
////var x: IFoo<string>;
|
||||
|
|
|
@ -3,8 +3,8 @@
|
|||
////module FindRef4 {
|
||||
//// module MixedStaticsClassTest {
|
||||
//// export class Foo {
|
||||
//// [|{| "isWriteAccess": true, "isDefinition": true |}bar|]: Foo;
|
||||
//// static [|{| "isWriteAccess": true, "isDefinition": true |}bar|]: Foo;
|
||||
//// [|{| "isDefinition": true |}bar|]: Foo;
|
||||
//// static [|{| "isDefinition": true |}bar|]: Foo;
|
||||
////
|
||||
//// public [|{| "isWriteAccess": true, "isDefinition": true |}foo|](): void {
|
||||
//// }
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/// <reference path='fourslash.ts'/>
|
||||
|
||||
////class Foo {
|
||||
//// public "[|{| "isWriteAccess": true, "isDefinition": true |}ss|]": any;
|
||||
//// public "[|{| "isDefinition": true |}ss|]": any;
|
||||
////}
|
||||
////
|
||||
////var x: Foo;
|
||||
|
|
|
@ -1,16 +1,16 @@
|
|||
/// <reference path='fourslash.ts'/>
|
||||
|
||||
////interface One {
|
||||
//// common: { [|{| "isWriteAccess": true, "isDefinition": true |}a|]: number; };
|
||||
//// common: { [|{| "isDefinition": true |}a|]: number; };
|
||||
////}
|
||||
////
|
||||
////interface Base {
|
||||
//// [|{| "isWriteAccess": true, "isDefinition": true |}a|]: string;
|
||||
//// [|{| "isDefinition": true |}a|]: string;
|
||||
//// b: string;
|
||||
////}
|
||||
////
|
||||
////interface HasAOrB extends Base {
|
||||
//// [|{| "isWriteAccess": true, "isDefinition": true |}a|]: string;
|
||||
//// [|{| "isDefinition": true |}a|]: string;
|
||||
//// b: string;
|
||||
////}
|
||||
////
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/// <reference path='fourslash.ts' />
|
||||
|
||||
// @Filename: a.ts
|
||||
////export var [|{| "isWriteAccess": true, "isDefinition": true |}a|];
|
||||
////export var [|{| "isDefinition": true |}a|];
|
||||
|
||||
// @Filename: b.ts
|
||||
////import { [|{| "isWriteAccess": true, "isDefinition": true |}a|] } from './a';
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
//// className?: string;
|
||||
//// }
|
||||
//// interface ButtonProps extends ClickableProps {
|
||||
//// [|{| "isWriteAccess": true, "isDefinition": true |}onClick|](event?: React.MouseEvent<HTMLButtonElement>): void;
|
||||
//// [|{| "isDefinition": true |}onClick|](event?: React.MouseEvent<HTMLButtonElement>): void;
|
||||
//// }
|
||||
//// interface LinkProps extends ClickableProps {
|
||||
//// goTo: string;
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
//// }
|
||||
//// class MyClass {
|
||||
//// props: {
|
||||
//// [|{| "isWriteAccess": true, "isDefinition": true |}name|]?: string;
|
||||
//// [|{| "isDefinition": true |}name|]?: string;
|
||||
//// size?: number;
|
||||
//// }
|
||||
////
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
//// interface ElementAttributesProperty { props; }
|
||||
//// }
|
||||
//// interface OptionPropBag {
|
||||
//// [|{| "isWriteAccess": true, "isDefinition": true |}propx|]: number
|
||||
//// [|{| "isDefinition": true |}propx|]: number
|
||||
//// propString: string
|
||||
//// optional?: boolean
|
||||
//// }
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
//// onClick(event?: React.MouseEvent<HTMLButtonElement>): void;
|
||||
//// }
|
||||
//// interface LinkProps extends ClickableProps {
|
||||
//// [|{| "isWriteAccess": true, "isDefinition": true |}goTo|]: string;
|
||||
//// [|{| "isDefinition": true |}goTo|]: string;
|
||||
//// }
|
||||
//// declare function MainButton(buttonProps: ButtonProps): JSX.Element;
|
||||
//// declare function MainButton(linkProps: LinkProps): JSX.Element;
|
||||
|
|
Loading…
Reference in a new issue