mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-15 03:23:08 -06:00
Merge branch 'master' into new-jsdoc-parser
This commit is contained in:
commit
9e8e5ea337
@ -5378,7 +5378,7 @@ namespace ts {
|
||||
while (i > 0) {
|
||||
i--;
|
||||
if (isSubtypeOfAny(types[i], types)) {
|
||||
types.splice(i, 1);
|
||||
orderedRemoveItemAt(types, i);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -8759,7 +8759,7 @@ namespace ts {
|
||||
// The location isn't a reference to the given symbol, meaning we're being asked
|
||||
// a hypothetical question of what type the symbol would have if there was a reference
|
||||
// to it at the given location. Since we have no control flow information for the
|
||||
// hypotherical reference (control flow information is created and attached by the
|
||||
// hypothetical reference (control flow information is created and attached by the
|
||||
// binder), we simply return the declared type of the symbol.
|
||||
return getTypeOfSymbol(symbol);
|
||||
}
|
||||
|
||||
@ -566,6 +566,21 @@ namespace ts {
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the value to an array of values associated with the key, and returns the array.
|
||||
* Creates the array if it does not already exist.
|
||||
*/
|
||||
export function multiMapAdd<V>(map: Map<V[]>, key: string, value: V): V[] {
|
||||
const values = map[key];
|
||||
if (values) {
|
||||
values.push(value);
|
||||
return values;
|
||||
}
|
||||
else {
|
||||
return map[key] = [value];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests whether a value is an array.
|
||||
*/
|
||||
@ -1500,20 +1515,39 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
export function copyListRemovingItem<T>(item: T, list: T[]) {
|
||||
const copiedList: T[] = [];
|
||||
for (const e of list) {
|
||||
if (e !== item) {
|
||||
copiedList.push(e);
|
||||
}
|
||||
/** Remove an item from an array, moving everything to its right one space left. */
|
||||
export function orderedRemoveItemAt<T>(array: T[], index: number): void {
|
||||
// This seems to be faster than either `array.splice(i, 1)` or `array.copyWithin(i, i+ 1)`.
|
||||
for (let i = index; i < array.length - 1; i++) {
|
||||
array[i] = array[i + 1];
|
||||
}
|
||||
return copiedList;
|
||||
array.pop();
|
||||
}
|
||||
|
||||
export function createGetCanonicalFileName(useCaseSensitivefileNames: boolean): (fileName: string) => string {
|
||||
return useCaseSensitivefileNames
|
||||
export function unorderedRemoveItemAt<T>(array: T[], index: number): void {
|
||||
// Fill in the "hole" left at `index`.
|
||||
array[index] = array[array.length - 1];
|
||||
array.pop();
|
||||
}
|
||||
|
||||
/** Remove the *first* occurrence of `item` from the array. */
|
||||
export function unorderedRemoveItem<T>(array: T[], item: T): void {
|
||||
unorderedRemoveFirstItemWhere(array, element => element === item);
|
||||
}
|
||||
|
||||
/** Remove the *first* element satisfying `predicate`. */
|
||||
function unorderedRemoveFirstItemWhere<T>(array: T[], predicate: (element: T) => boolean): void {
|
||||
for (let i = 0; i < array.length; i++) {
|
||||
if (predicate(array[i])) {
|
||||
unorderedRemoveItemAt(array, i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export function createGetCanonicalFileName(useCaseSensitiveFileNames: boolean): (fileName: string) => string {
|
||||
return useCaseSensitiveFileNames
|
||||
? ((fileName) => fileName)
|
||||
: ((fileName) => fileName.toLowerCase());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -6851,7 +6851,7 @@ const _super = (function (geti, seti) {
|
||||
// export { x, y }
|
||||
for (const specifier of (<ExportDeclaration>node).exportClause.elements) {
|
||||
const name = (specifier.propertyName || specifier.name).text;
|
||||
(exportSpecifiers[name] || (exportSpecifiers[name] = [])).push(specifier);
|
||||
multiMapAdd(exportSpecifiers, name, specifier);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
@ -267,7 +267,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
function addFileWatcherCallback(filePath: string, callback: FileWatcherCallback): void {
|
||||
(fileWatcherCallbacks[filePath] || (fileWatcherCallbacks[filePath] = [])).push(callback);
|
||||
multiMapAdd(fileWatcherCallbacks, filePath, callback);
|
||||
}
|
||||
|
||||
function addFile(fileName: string, callback: FileWatcherCallback): WatchedFile {
|
||||
@ -285,13 +285,10 @@ namespace ts {
|
||||
function removeFileWatcherCallback(filePath: string, callback: FileWatcherCallback) {
|
||||
const callbacks = fileWatcherCallbacks[filePath];
|
||||
if (callbacks) {
|
||||
const newCallbacks = copyListRemovingItem(callback, callbacks);
|
||||
if (newCallbacks.length === 0) {
|
||||
unorderedRemoveItem(callbacks, callback);
|
||||
if (callbacks.length === 0) {
|
||||
delete fileWatcherCallbacks[filePath];
|
||||
}
|
||||
else {
|
||||
fileWatcherCallbacks[filePath] = newCallbacks;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -489,10 +489,7 @@ namespace ts {
|
||||
sourceFile.fileWatcher.close();
|
||||
sourceFile.fileWatcher = undefined;
|
||||
if (removed) {
|
||||
const index = rootFileNames.indexOf(sourceFile.fileName);
|
||||
if (index >= 0) {
|
||||
rootFileNames.splice(index, 1);
|
||||
}
|
||||
unorderedRemoveItem(rootFileNames, sourceFile.fileName);
|
||||
}
|
||||
startTimerForRecompilation();
|
||||
}
|
||||
|
||||
@ -1035,6 +1035,18 @@ namespace ts {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
export function isCallLikeExpression(node: Node): node is CallLikeExpression {
|
||||
switch (node.kind) {
|
||||
case SyntaxKind.CallExpression:
|
||||
case SyntaxKind.NewExpression:
|
||||
case SyntaxKind.TaggedTemplateExpression:
|
||||
case SyntaxKind.Decorator:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
export function getInvokedExpression(node: CallLikeExpression): Expression {
|
||||
if (node.kind === SyntaxKind.TaggedTemplateExpression) {
|
||||
return (<TaggedTemplateExpression>node).tag;
|
||||
@ -2739,10 +2751,17 @@ namespace ts {
|
||||
return token >= SyntaxKind.FirstAssignment && token <= SyntaxKind.LastAssignment;
|
||||
}
|
||||
|
||||
export function isExpressionWithTypeArgumentsInClassExtendsClause(node: Node): boolean {
|
||||
return node.kind === SyntaxKind.ExpressionWithTypeArguments &&
|
||||
/** Get `C` given `N` if `N` is in the position `class C extends N` where `N` is an ExpressionWithTypeArguments. */
|
||||
export function tryGetClassExtendingExpressionWithTypeArguments(node: Node): ClassLikeDeclaration | undefined {
|
||||
if (node.kind === SyntaxKind.ExpressionWithTypeArguments &&
|
||||
(<HeritageClause>node.parent).token === SyntaxKind.ExtendsKeyword &&
|
||||
isClassLike(node.parent.parent);
|
||||
isClassLike(node.parent.parent)) {
|
||||
return node.parent.parent;
|
||||
}
|
||||
}
|
||||
|
||||
export function isExpressionWithTypeArgumentsInClassExtendsClause(node: Node): boolean {
|
||||
return tryGetClassExtendingExpressionWithTypeArguments(node) !== undefined;
|
||||
}
|
||||
|
||||
export function isEntityNameExpression(node: Expression): node is EntityNameExpression {
|
||||
|
||||
@ -1564,7 +1564,7 @@ namespace FourSlash {
|
||||
public goToDefinition(definitionIndex: number) {
|
||||
const definitions = this.languageService.getDefinitionAtPosition(this.activeFile.fileName, this.currentCaretPosition);
|
||||
if (!definitions || !definitions.length) {
|
||||
this.raiseError("goToDefinition failed - expected to at least one definition location but got 0");
|
||||
this.raiseError("goToDefinition failed - expected to find at least one definition location but got 0");
|
||||
}
|
||||
|
||||
if (definitionIndex >= definitions.length) {
|
||||
@ -1579,7 +1579,7 @@ namespace FourSlash {
|
||||
public goToTypeDefinition(definitionIndex: number) {
|
||||
const definitions = this.languageService.getTypeDefinitionAtPosition(this.activeFile.fileName, this.currentCaretPosition);
|
||||
if (!definitions || !definitions.length) {
|
||||
this.raiseError("goToTypeDefinition failed - expected to at least one definition location but got 0");
|
||||
this.raiseError("goToTypeDefinition failed - expected to find at least one definition location but got 0");
|
||||
}
|
||||
|
||||
if (definitionIndex >= definitions.length) {
|
||||
@ -1600,7 +1600,7 @@ namespace FourSlash {
|
||||
this.raiseError(`goToDefinition - expected to 0 definition locations but got ${definitions.length}`);
|
||||
}
|
||||
else if (!foundDefinitions && !negative) {
|
||||
this.raiseError("goToDefinition - expected to at least one definition location but got 0");
|
||||
this.raiseError("goToDefinition - expected to find at least one definition location but got 0");
|
||||
}
|
||||
}
|
||||
|
||||
@ -1649,8 +1649,7 @@ namespace FourSlash {
|
||||
const result = ts.createMap<Range[]>();
|
||||
for (const range of this.getRanges()) {
|
||||
const text = this.rangeText(range);
|
||||
const ranges = result[text] || (result[text] = []);
|
||||
ranges.push(range);
|
||||
ts.multiMapAdd(result, text, range);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -1785,7 +1785,7 @@ namespace Harness {
|
||||
tsConfig.options.configFilePath = data.name;
|
||||
|
||||
// delete entry from the list
|
||||
testUnitData.splice(i, 1);
|
||||
ts.orderedRemoveItemAt(testUnitData, i);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
@ -1,79 +0,0 @@
|
||||
class a {
|
||||
constructor ( n : number ) ;
|
||||
constructor ( s : string ) ;
|
||||
constructor ( ns : any ) {
|
||||
|
||||
}
|
||||
|
||||
public pgF ( ) { } ;
|
||||
|
||||
public pv ;
|
||||
public get d ( ) {
|
||||
return 30 ;
|
||||
}
|
||||
public set d ( ) {
|
||||
}
|
||||
|
||||
public static get p2 ( ) {
|
||||
return { x : 30 , y : 40 } ;
|
||||
}
|
||||
|
||||
private static d2 ( ) {
|
||||
}
|
||||
private static get p3 ( ) {
|
||||
return "string" ;
|
||||
}
|
||||
private pv3 ;
|
||||
|
||||
private foo ( n : number ) : string ;
|
||||
private foo ( s : string ) : string ;
|
||||
private foo ( ns : any ) {
|
||||
return ns.toString ( ) ;
|
||||
}
|
||||
}
|
||||
|
||||
class b extends a {
|
||||
}
|
||||
|
||||
class m1b {
|
||||
|
||||
}
|
||||
|
||||
interface m1ib {
|
||||
|
||||
}
|
||||
class c extends m1b {
|
||||
}
|
||||
|
||||
class ib2 implements m1ib {
|
||||
}
|
||||
|
||||
declare class aAmbient {
|
||||
constructor ( n : number ) ;
|
||||
constructor ( s : string ) ;
|
||||
public pgF ( ) : void ;
|
||||
public pv ;
|
||||
public d : number ;
|
||||
static p2 : { x : number ; y : number ; } ;
|
||||
static d2 ( ) ;
|
||||
static p3 ;
|
||||
private pv3 ;
|
||||
private foo ( s ) ;
|
||||
}
|
||||
|
||||
class d {
|
||||
private foo ( n : number ) : string ;
|
||||
private foo ( ns : any ) {
|
||||
return ns.toString ( ) ;
|
||||
}
|
||||
private foo ( s : string ) : string ;
|
||||
}
|
||||
|
||||
class e {
|
||||
private foo ( ns : any ) {
|
||||
return ns.toString ( ) ;
|
||||
}
|
||||
private foo ( s : string ) : string ;
|
||||
private foo ( n : number ) : string ;
|
||||
}
|
||||
|
||||
@ -1,79 +0,0 @@
|
||||
class a {
|
||||
constructor(n: number);
|
||||
constructor(s: string);
|
||||
constructor(ns: any) {
|
||||
|
||||
}
|
||||
|
||||
public pgF() { };
|
||||
|
||||
public pv;
|
||||
public get d() {
|
||||
return 30;
|
||||
}
|
||||
public set d() {
|
||||
}
|
||||
|
||||
public static get p2() {
|
||||
return { x: 30, y: 40 };
|
||||
}
|
||||
|
||||
private static d2() {
|
||||
}
|
||||
private static get p3() {
|
||||
return "string";
|
||||
}
|
||||
private pv3;
|
||||
|
||||
private foo(n: number): string;
|
||||
private foo(s: string): string;
|
||||
private foo(ns: any) {
|
||||
return ns.toString();
|
||||
}
|
||||
}
|
||||
|
||||
class b extends a {
|
||||
}
|
||||
|
||||
class m1b {
|
||||
|
||||
}
|
||||
|
||||
interface m1ib {
|
||||
|
||||
}
|
||||
class c extends m1b {
|
||||
}
|
||||
|
||||
class ib2 implements m1ib {
|
||||
}
|
||||
|
||||
declare class aAmbient {
|
||||
constructor(n: number);
|
||||
constructor(s: string);
|
||||
public pgF(): void;
|
||||
public pv;
|
||||
public d: number;
|
||||
static p2: { x: number; y: number; };
|
||||
static d2();
|
||||
static p3;
|
||||
private pv3;
|
||||
private foo(s);
|
||||
}
|
||||
|
||||
class d {
|
||||
private foo(n: number): string;
|
||||
private foo(ns: any) {
|
||||
return ns.toString();
|
||||
}
|
||||
private foo(s: string): string;
|
||||
}
|
||||
|
||||
class e {
|
||||
private foo(ns: any) {
|
||||
return ns.toString();
|
||||
}
|
||||
private foo(s: string): string;
|
||||
private foo(n: number): string;
|
||||
}
|
||||
|
||||
@ -1,4 +0,0 @@
|
||||
class foo {
|
||||
constructor (n?: number, m? = 5, o?: string = "") { }
|
||||
x:number = 1?2:3;
|
||||
}
|
||||
@ -1,4 +0,0 @@
|
||||
class foo {
|
||||
constructor(n?: number, m? = 5, o?: string = "") { }
|
||||
x: number = 1 ? 2 : 3;
|
||||
}
|
||||
@ -1,3 +0,0 @@
|
||||
$ ( document ) . ready ( function ( ) {
|
||||
alert ( 'i am ready' ) ;
|
||||
} );
|
||||
@ -1,3 +0,0 @@
|
||||
$(document).ready(function() {
|
||||
alert('i am ready');
|
||||
});
|
||||
@ -1 +0,0 @@
|
||||
{}
|
||||
@ -1 +0,0 @@
|
||||
{ }
|
||||
@ -1,10 +0,0 @@
|
||||
function foo ( x : { } ) { }
|
||||
|
||||
foo ( { } ) ;
|
||||
|
||||
|
||||
|
||||
interface bar {
|
||||
x : { } ;
|
||||
y : ( ) => { } ;
|
||||
}
|
||||
@ -1,10 +0,0 @@
|
||||
function foo(x: {}) { }
|
||||
|
||||
foo({});
|
||||
|
||||
|
||||
|
||||
interface bar {
|
||||
x: {};
|
||||
y: () => {};
|
||||
}
|
||||
@ -1,112 +0,0 @@
|
||||
// valid
|
||||
( ) => 1 ;
|
||||
( arg ) => 2 ;
|
||||
arg => 2 ;
|
||||
( arg = 1 ) => 3 ;
|
||||
( arg ? ) => 4 ;
|
||||
( arg : number ) => 5 ;
|
||||
( arg : number = 0 ) => 6 ;
|
||||
( arg ? : number ) => 7 ;
|
||||
( ... arg : number [ ] ) => 8 ;
|
||||
( arg1 , arg2 ) => 12 ;
|
||||
( arg1 = 1 , arg2 =3 ) => 13 ;
|
||||
( arg1 ? , arg2 ? ) => 14 ;
|
||||
( arg1 : number , arg2 : number ) => 15 ;
|
||||
( arg1 : number = 0 , arg2 : number = 1 ) => 16 ;
|
||||
( arg1 ? : number , arg2 ? : number ) => 17 ;
|
||||
( arg1 , ... arg2 : number [ ] ) => 18 ;
|
||||
( arg1 , arg2 ? : number ) => 19 ;
|
||||
|
||||
// in paren
|
||||
( ( ) => 21 ) ;
|
||||
( ( arg ) => 22 ) ;
|
||||
( ( arg = 1 ) => 23 ) ;
|
||||
( ( arg ? ) => 24 ) ;
|
||||
( ( arg : number ) => 25 ) ;
|
||||
( ( arg : number = 0 ) => 26 ) ;
|
||||
( ( arg ? : number ) => 27 ) ;
|
||||
( ( ... arg : number [ ] ) => 28 ) ;
|
||||
|
||||
// in multiple paren
|
||||
( ( ( ( ( arg ) => { return 32 ; } ) ) ) ) ;
|
||||
|
||||
// in ternary exression
|
||||
false ? ( ) => 41 : null ;
|
||||
false ? ( arg ) => 42 : null ;
|
||||
false ? ( arg = 1 ) => 43 : null ;
|
||||
false ? ( arg ? ) => 44 : null ;
|
||||
false ? ( arg : number ) => 45 : null ;
|
||||
false ? ( arg ? : number ) => 46 : null ;
|
||||
false ? ( arg ? : number = 0 ) => 47 : null ;
|
||||
false ? ( ... arg : number [ ] ) => 48 : null ;
|
||||
|
||||
// in ternary exression within paren
|
||||
false ? ( ( ) => 51 ) : null ;
|
||||
false ? ( ( arg ) => 52 ) : null ;
|
||||
false ? ( ( arg = 1 ) => 53 ) : null ;
|
||||
false ? ( ( arg ? ) => 54 ) : null ;
|
||||
false ? ( ( arg : number ) => 55 ) : null ;
|
||||
false ? ( ( arg ? : number ) => 56 ) : null ;
|
||||
false ? ( ( arg ? : number = 0 ) => 57 ) : null ;
|
||||
false ? ( ( ... arg : number [ ] ) => 58 ) : null ;
|
||||
|
||||
// ternary exression's else clause
|
||||
false ? null : ( ) => 61 ;
|
||||
false ? null : ( arg ) => 62 ;
|
||||
false ? null : ( arg = 1 ) => 63 ;
|
||||
false ? null : ( arg ? ) => 64 ;
|
||||
false ? null : ( arg : number ) => 65 ;
|
||||
false ? null : ( arg ? : number ) => 66 ;
|
||||
false ? null : ( arg ? : number = 0 ) => 67 ;
|
||||
false ? null : ( ... arg : number [ ] ) => 68 ;
|
||||
|
||||
|
||||
// nested ternary expressions
|
||||
( a ? ) => { return a ; } ? ( b ? ) => { return b ; } : ( c ? ) => { return c ; } ;
|
||||
|
||||
//multiple levels
|
||||
( a ? ) => { return a ; } ? ( b ) => ( c ) => 81 : ( c ) => ( d ) => 82 ;
|
||||
|
||||
|
||||
// In Expressions
|
||||
( ( arg ) => 90 ) instanceof Function ;
|
||||
( ( arg = 1 ) => 91 ) instanceof Function ;
|
||||
( ( arg ? ) => 92 ) instanceof Function ;
|
||||
( ( arg : number ) => 93 ) instanceof Function ;
|
||||
( ( arg : number = 1 ) => 94 ) instanceof Function ;
|
||||
( ( arg ? : number ) => 95 ) instanceof Function ;
|
||||
( ( ... arg : number [ ] ) => 96 ) instanceof Function ;
|
||||
|
||||
'' + ( arg ) => 100 ;
|
||||
( ( arg ) => 0 ) + '' + ( arg ) => 101 ;
|
||||
( ( arg = 1 ) => 0 ) + '' + ( arg = 2 ) => 102 ;
|
||||
( ( arg ? ) => 0 ) + '' + ( arg ? ) => 103 ;
|
||||
( ( arg : number ) => 0 ) + '' + ( arg : number ) => 104 ;
|
||||
( ( arg : number = 1 ) => 0 ) + '' + ( arg : number = 2 ) => 105 ;
|
||||
( ( arg ? : number = 1 ) => 0 ) + '' + ( arg ? : number = 2 ) => 106 ;
|
||||
( ( ... arg : number [ ] ) => 0 ) + '' + ( ... arg : number [ ] ) => 107 ;
|
||||
( ( arg1 , arg2 ? ) => 0 ) + '' + ( arg1 , arg2 ? ) => 108 ;
|
||||
( ( arg1 , ... arg2 : number [ ] ) => 0 ) + '' + ( arg1 , ... arg2 : number [ ] ) => 108 ;
|
||||
|
||||
|
||||
// Function Parameters
|
||||
function foo ( ... arg : any [ ] ) { }
|
||||
|
||||
foo (
|
||||
( a ) => 110 ,
|
||||
( ( a ) => 111 ) ,
|
||||
( a ) => {
|
||||
return 112 ;
|
||||
} ,
|
||||
( a ? ) => 113 ,
|
||||
( a , b ? ) => 114 ,
|
||||
( a : number ) => 115 ,
|
||||
( a : number = 0 ) => 116 ,
|
||||
( a = 0 ) => 117 ,
|
||||
( a ? : number = 0 ) => 118 ,
|
||||
( a ? , b ? : number = 0 ) => 118 ,
|
||||
( ... a : number [ ] ) => 119 ,
|
||||
( a , b ? = 0 , ... c : number [ ] ) => 120 ,
|
||||
( a ) => ( b ) => ( c ) => 121 ,
|
||||
false ? ( a ) => 0 : ( b ) => 122
|
||||
) ;
|
||||
@ -1,112 +0,0 @@
|
||||
// valid
|
||||
() => 1;
|
||||
(arg) => 2;
|
||||
arg => 2;
|
||||
(arg = 1) => 3;
|
||||
(arg?) => 4;
|
||||
(arg: number) => 5;
|
||||
(arg: number = 0) => 6;
|
||||
(arg?: number) => 7;
|
||||
(...arg: number[]) => 8;
|
||||
(arg1, arg2) => 12;
|
||||
(arg1 = 1, arg2 = 3) => 13;
|
||||
(arg1?, arg2?) => 14;
|
||||
(arg1: number, arg2: number) => 15;
|
||||
(arg1: number = 0, arg2: number = 1) => 16;
|
||||
(arg1?: number, arg2?: number) => 17;
|
||||
(arg1, ...arg2: number[]) => 18;
|
||||
(arg1, arg2?: number) => 19;
|
||||
|
||||
// in paren
|
||||
(() => 21);
|
||||
((arg) => 22);
|
||||
((arg = 1) => 23);
|
||||
((arg?) => 24);
|
||||
((arg: number) => 25);
|
||||
((arg: number = 0) => 26);
|
||||
((arg?: number) => 27);
|
||||
((...arg: number[]) => 28);
|
||||
|
||||
// in multiple paren
|
||||
(((((arg) => { return 32; }))));
|
||||
|
||||
// in ternary exression
|
||||
false ? () => 41 : null;
|
||||
false ? (arg) => 42 : null;
|
||||
false ? (arg = 1) => 43 : null;
|
||||
false ? (arg?) => 44 : null;
|
||||
false ? (arg: number) => 45 : null;
|
||||
false ? (arg?: number) => 46 : null;
|
||||
false ? (arg?: number = 0) => 47 : null;
|
||||
false ? (...arg: number[]) => 48 : null;
|
||||
|
||||
// in ternary exression within paren
|
||||
false ? (() => 51) : null;
|
||||
false ? ((arg) => 52) : null;
|
||||
false ? ((arg = 1) => 53) : null;
|
||||
false ? ((arg?) => 54) : null;
|
||||
false ? ((arg: number) => 55) : null;
|
||||
false ? ((arg?: number) => 56) : null;
|
||||
false ? ((arg?: number = 0) => 57) : null;
|
||||
false ? ((...arg: number[]) => 58) : null;
|
||||
|
||||
// ternary exression's else clause
|
||||
false ? null : () => 61;
|
||||
false ? null : (arg) => 62;
|
||||
false ? null : (arg = 1) => 63;
|
||||
false ? null : (arg?) => 64;
|
||||
false ? null : (arg: number) => 65;
|
||||
false ? null : (arg?: number) => 66;
|
||||
false ? null : (arg?: number = 0) => 67;
|
||||
false ? null : (...arg: number[]) => 68;
|
||||
|
||||
|
||||
// nested ternary expressions
|
||||
(a?) => { return a; } ? (b?) => { return b; } : (c?) => { return c; };
|
||||
|
||||
//multiple levels
|
||||
(a?) => { return a; } ? (b) => (c) => 81 : (c) => (d) => 82;
|
||||
|
||||
|
||||
// In Expressions
|
||||
((arg) => 90) instanceof Function;
|
||||
((arg = 1) => 91) instanceof Function;
|
||||
((arg?) => 92) instanceof Function;
|
||||
((arg: number) => 93) instanceof Function;
|
||||
((arg: number = 1) => 94) instanceof Function;
|
||||
((arg?: number) => 95) instanceof Function;
|
||||
((...arg: number[]) => 96) instanceof Function;
|
||||
|
||||
'' + (arg) => 100;
|
||||
((arg) => 0) + '' + (arg) => 101;
|
||||
((arg = 1) => 0) + '' + (arg = 2) => 102;
|
||||
((arg?) => 0) + '' + (arg?) => 103;
|
||||
((arg: number) => 0) + '' + (arg: number) => 104;
|
||||
((arg: number = 1) => 0) + '' + (arg: number = 2) => 105;
|
||||
((arg?: number = 1) => 0) + '' + (arg?: number = 2) => 106;
|
||||
((...arg: number[]) => 0) + '' + (...arg: number[]) => 107;
|
||||
((arg1, arg2?) => 0) + '' + (arg1, arg2?) => 108;
|
||||
((arg1, ...arg2: number[]) => 0) + '' + (arg1, ...arg2: number[]) => 108;
|
||||
|
||||
|
||||
// Function Parameters
|
||||
function foo(...arg: any[]) { }
|
||||
|
||||
foo(
|
||||
(a) => 110,
|
||||
((a) => 111),
|
||||
(a) => {
|
||||
return 112;
|
||||
},
|
||||
(a?) => 113,
|
||||
(a, b?) => 114,
|
||||
(a: number) => 115,
|
||||
(a: number = 0) => 116,
|
||||
(a = 0) => 117,
|
||||
(a?: number = 0) => 118,
|
||||
(a?, b?: number = 0) => 118,
|
||||
(...a: number[]) => 119,
|
||||
(a, b? = 0, ...c: number[]) => 120,
|
||||
(a) => (b) => (c) => 121,
|
||||
false ? (a) => 0 : (b) => 122
|
||||
);
|
||||
@ -1,2 +0,0 @@
|
||||
if(false){debugger;}
|
||||
if ( false ) { debugger ; }
|
||||
@ -1,2 +0,0 @@
|
||||
if (false) { debugger; }
|
||||
if (false) { debugger; }
|
||||
@ -1,13 +0,0 @@
|
||||
var fun1 = function ( ) {
|
||||
var x = 'foo' ,
|
||||
z = 'bar' ;
|
||||
return x ;
|
||||
},
|
||||
|
||||
fun2 = ( function ( f ) {
|
||||
var fun = function ( ) {
|
||||
console . log ( f ( ) ) ;
|
||||
},
|
||||
x = 'Foo' ;
|
||||
return fun ;
|
||||
} ( fun1 ) ) ;
|
||||
@ -1,13 +0,0 @@
|
||||
var fun1 = function() {
|
||||
var x = 'foo',
|
||||
z = 'bar';
|
||||
return x;
|
||||
},
|
||||
|
||||
fun2 = (function(f) {
|
||||
var fun = function() {
|
||||
console.log(f());
|
||||
},
|
||||
x = 'Foo';
|
||||
return fun;
|
||||
} (fun1));
|
||||
@ -1,3 +0,0 @@
|
||||
export class A {
|
||||
|
||||
}
|
||||
@ -1,3 +0,0 @@
|
||||
export class A {
|
||||
|
||||
}
|
||||
@ -1,6 +0,0 @@
|
||||
module Foo {
|
||||
}
|
||||
|
||||
import bar = Foo;
|
||||
|
||||
import bar2=Foo;
|
||||
@ -1,6 +0,0 @@
|
||||
module Foo {
|
||||
}
|
||||
|
||||
import bar = Foo;
|
||||
|
||||
import bar2 = Foo;
|
||||
@ -1,95 +0,0 @@
|
||||
|
||||
var a;var c , b;var $d
|
||||
var $e
|
||||
var f
|
||||
a++;b++;
|
||||
|
||||
function f ( ) {
|
||||
for (i = 0; i < 10; i++) {
|
||||
k = abc + 123 ^ d;
|
||||
a = XYZ[m (a[b[c][d]])];
|
||||
break;
|
||||
|
||||
switch ( variable){
|
||||
case 1: abc += 425;
|
||||
break;
|
||||
case 404 : a [x--/2]%=3 ;
|
||||
break ;
|
||||
case vari : v[--x ] *=++y*( m + n / k[z]);
|
||||
for (a in b){
|
||||
for (a = 0; a < 10; ++a) {
|
||||
a++;--a;
|
||||
if (a == b) {
|
||||
a++;b--;
|
||||
}
|
||||
else
|
||||
if (a == c){
|
||||
++a;
|
||||
(--c)+=d;
|
||||
$c = $a + --$b;
|
||||
}
|
||||
if (a == b)
|
||||
if (a != b) {
|
||||
if (a !== b)
|
||||
if (a === b)
|
||||
--a;
|
||||
else
|
||||
--a;
|
||||
else {
|
||||
a--;++b;
|
||||
a++
|
||||
}
|
||||
}
|
||||
}
|
||||
for (x in y) {
|
||||
m-=m;
|
||||
k=1+2+3+4;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
var a ={b:function(){}};
|
||||
return {a:1,b:2}
|
||||
}
|
||||
|
||||
var z = 1;
|
||||
for (i = 0; i < 10; i++)
|
||||
for (j = 0; j < 10; j++)
|
||||
for (k = 0; k < 10; ++k) {
|
||||
z++;
|
||||
}
|
||||
|
||||
for (k = 0; k < 10; k += 2) {
|
||||
z++;
|
||||
}
|
||||
|
||||
$(document).ready ();
|
||||
|
||||
|
||||
function pageLoad() {
|
||||
$('#TextBox1' ) . unbind ( ) ;
|
||||
$('#TextBox1' ) . datepicker ( ) ;
|
||||
}
|
||||
|
||||
function pageLoad ( ) {
|
||||
var webclass=[
|
||||
{ 'student' :
|
||||
{ 'id': '1', 'name': 'Linda Jones', 'legacySkill': 'Access, VB 5.0' }
|
||||
} ,
|
||||
{ 'student':
|
||||
{'id':'2','name':'Adam Davidson','legacySkill':'Cobol,MainFrame'}
|
||||
} ,
|
||||
{ 'student':
|
||||
{ 'id':'3','name':'Charles Boyer' ,'legacySkill':'HTML, XML'}
|
||||
}
|
||||
];
|
||||
|
||||
$create(Sys.UI.DataView,{data:webclass},null,null,$get('SList'));
|
||||
|
||||
}
|
||||
|
||||
$( document ).ready(function(){
|
||||
alert('hello');
|
||||
} ) ;
|
||||
@ -1,98 +0,0 @@
|
||||
|
||||
var a; var c, b; var $d
|
||||
var $e
|
||||
var f
|
||||
a++; b++;
|
||||
|
||||
function f() {
|
||||
for (i = 0; i < 10; i++) {
|
||||
k = abc + 123 ^ d;
|
||||
a = XYZ[m(a[b[c][d]])];
|
||||
break;
|
||||
|
||||
switch (variable) {
|
||||
case 1: abc += 425;
|
||||
break;
|
||||
case 404: a[x-- / 2] %= 3;
|
||||
break;
|
||||
case vari: v[--x] *= ++y * (m + n / k[z]);
|
||||
for (a in b) {
|
||||
for (a = 0; a < 10; ++a) {
|
||||
a++; --a;
|
||||
if (a == b) {
|
||||
a++; b--;
|
||||
}
|
||||
else
|
||||
if (a == c) {
|
||||
++a;
|
||||
(--c) += d;
|
||||
$c = $a + --$b;
|
||||
}
|
||||
if (a == b)
|
||||
if (a != b) {
|
||||
if (a !== b)
|
||||
if (a === b)
|
||||
--a;
|
||||
else
|
||||
--a;
|
||||
else {
|
||||
a--; ++b;
|
||||
a++
|
||||
}
|
||||
}
|
||||
}
|
||||
for (x in y) {
|
||||
m -= m;
|
||||
k = 1 + 2 + 3 + 4;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
var a = { b: function() { } };
|
||||
return { a: 1, b: 2 }
|
||||
}
|
||||
|
||||
var z = 1;
|
||||
for (i = 0; i < 10; i++)
|
||||
for (j = 0; j < 10; j++)
|
||||
for (k = 0; k < 10; ++k) {
|
||||
z++;
|
||||
}
|
||||
|
||||
for (k = 0; k < 10; k += 2) {
|
||||
z++;
|
||||
}
|
||||
|
||||
$(document).ready();
|
||||
|
||||
|
||||
function pageLoad() {
|
||||
$('#TextBox1').unbind();
|
||||
$('#TextBox1').datepicker();
|
||||
}
|
||||
|
||||
function pageLoad() {
|
||||
var webclass = [
|
||||
{
|
||||
'student':
|
||||
{ 'id': '1', 'name': 'Linda Jones', 'legacySkill': 'Access, VB 5.0' }
|
||||
},
|
||||
{
|
||||
'student':
|
||||
{ 'id': '2', 'name': 'Adam Davidson', 'legacySkill': 'Cobol,MainFrame' }
|
||||
},
|
||||
{
|
||||
'student':
|
||||
{ 'id': '3', 'name': 'Charles Boyer', 'legacySkill': 'HTML, XML' }
|
||||
}
|
||||
];
|
||||
|
||||
$create(Sys.UI.DataView, { data: webclass }, null, null, $get('SList'));
|
||||
|
||||
}
|
||||
|
||||
$(document).ready(function() {
|
||||
alert('hello');
|
||||
});
|
||||
@ -1,3 +0,0 @@
|
||||
module Foo {
|
||||
export module A . B . C { }
|
||||
}
|
||||
@ -1,3 +0,0 @@
|
||||
module Foo {
|
||||
export module A.B.C { }
|
||||
}
|
||||
@ -1,76 +0,0 @@
|
||||
module mod1 {
|
||||
export class b {
|
||||
}
|
||||
class d {
|
||||
}
|
||||
|
||||
|
||||
export interface ib {
|
||||
}
|
||||
}
|
||||
|
||||
module m2 {
|
||||
|
||||
export module m3 {
|
||||
export class c extends mod1.b {
|
||||
}
|
||||
export class ib2 implements mod1.ib {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class c extends mod1.b {
|
||||
}
|
||||
|
||||
class ib2 implements mod1.ib {
|
||||
}
|
||||
|
||||
declare export module "m4" {
|
||||
export class d {
|
||||
} ;
|
||||
var x : d ;
|
||||
export function foo ( ) : d ;
|
||||
}
|
||||
|
||||
import m4 = module ( "m4" ) ;
|
||||
export var x4 = m4.x ;
|
||||
export var d4 = m4.d ;
|
||||
export var f4 = m4.foo ( ) ;
|
||||
|
||||
export module m1 {
|
||||
declare export module "m2" {
|
||||
export class d {
|
||||
} ;
|
||||
var x: d ;
|
||||
export function foo ( ) : d ;
|
||||
}
|
||||
import m2 = module ( "m2" ) ;
|
||||
import m3 = module ( "m4" ) ;
|
||||
|
||||
export var x2 = m2.x ;
|
||||
export var d2 = m2.d ;
|
||||
export var f2 = m2.foo ( ) ;
|
||||
|
||||
export var x3 = m3.x ;
|
||||
export var d3 = m3.d ;
|
||||
export var f3 = m3.foo ( ) ;
|
||||
}
|
||||
|
||||
export var x2 = m1.m2.x ;
|
||||
export var d2 = m1.m2.d ;
|
||||
export var f2 = m1.m2.foo ( ) ;
|
||||
|
||||
export var x3 = m1.m3.x ;
|
||||
export var d3 = m1.m3.d ;
|
||||
export var f3 = m1.m3.foo ( ) ;
|
||||
|
||||
export module m5 {
|
||||
export var x2 = m1.m2.x ;
|
||||
export var d2 = m1.m2.d ;
|
||||
export var f2 = m1.m2.foo ( ) ;
|
||||
|
||||
export var x3 = m1.m3.x ;
|
||||
export var d3 = m1.m3.d ;
|
||||
export var f3 = m1.m3.foo ( ) ;
|
||||
}
|
||||
|
||||
@ -1,76 +0,0 @@
|
||||
module mod1 {
|
||||
export class b {
|
||||
}
|
||||
class d {
|
||||
}
|
||||
|
||||
|
||||
export interface ib {
|
||||
}
|
||||
}
|
||||
|
||||
module m2 {
|
||||
|
||||
export module m3 {
|
||||
export class c extends mod1.b {
|
||||
}
|
||||
export class ib2 implements mod1.ib {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class c extends mod1.b {
|
||||
}
|
||||
|
||||
class ib2 implements mod1.ib {
|
||||
}
|
||||
|
||||
declare export module "m4" {
|
||||
export class d {
|
||||
};
|
||||
var x: d;
|
||||
export function foo(): d;
|
||||
}
|
||||
|
||||
import m4 = module("m4");
|
||||
export var x4 = m4.x;
|
||||
export var d4 = m4.d;
|
||||
export var f4 = m4.foo();
|
||||
|
||||
export module m1 {
|
||||
declare export module "m2" {
|
||||
export class d {
|
||||
};
|
||||
var x: d;
|
||||
export function foo(): d;
|
||||
}
|
||||
import m2 = module("m2");
|
||||
import m3 = module("m4");
|
||||
|
||||
export var x2 = m2.x;
|
||||
export var d2 = m2.d;
|
||||
export var f2 = m2.foo();
|
||||
|
||||
export var x3 = m3.x;
|
||||
export var d3 = m3.d;
|
||||
export var f3 = m3.foo();
|
||||
}
|
||||
|
||||
export var x2 = m1.m2.x;
|
||||
export var d2 = m1.m2.d;
|
||||
export var f2 = m1.m2.foo();
|
||||
|
||||
export var x3 = m1.m3.x;
|
||||
export var d3 = m1.m3.d;
|
||||
export var f3 = m1.m3.foo();
|
||||
|
||||
export module m5 {
|
||||
export var x2 = m1.m2.x;
|
||||
export var d2 = m1.m2.d;
|
||||
export var f2 = m1.m2.foo();
|
||||
|
||||
export var x3 = m1.m3.x;
|
||||
export var d3 = m1.m3.d;
|
||||
export var f3 = m1.m3.foo();
|
||||
}
|
||||
|
||||
@ -1,27 +0,0 @@
|
||||
var x = {foo: 1,
|
||||
bar: "tt",
|
||||
boo: 1 + 5};
|
||||
|
||||
var x2 = {foo: 1,
|
||||
bar: "tt",boo:1+5};
|
||||
|
||||
function Foo() {
|
||||
var typeICalc = {
|
||||
clear: {
|
||||
"()": [1, 2, 3]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Rule for object literal members for the "value" of the memebr to follow the indent
|
||||
// of the member, i.e. the relative position of the value is maintained when the member
|
||||
// is indented.
|
||||
var x2 = {
|
||||
foo:
|
||||
3,
|
||||
'bar':
|
||||
{ a: 1, b : 2}
|
||||
};
|
||||
|
||||
var x={ };
|
||||
var y = {};
|
||||
@ -1,31 +0,0 @@
|
||||
var x = {
|
||||
foo: 1,
|
||||
bar: "tt",
|
||||
boo: 1 + 5
|
||||
};
|
||||
|
||||
var x2 = {
|
||||
foo: 1,
|
||||
bar: "tt", boo: 1 + 5
|
||||
};
|
||||
|
||||
function Foo() {
|
||||
var typeICalc = {
|
||||
clear: {
|
||||
"()": [1, 2, 3]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Rule for object literal members for the "value" of the memebr to follow the indent
|
||||
// of the member, i.e. the relative position of the value is maintained when the member
|
||||
// is indented.
|
||||
var x2 = {
|
||||
foo:
|
||||
3,
|
||||
'bar':
|
||||
{ a: 1, b: 2 }
|
||||
};
|
||||
|
||||
var x = {};
|
||||
var y = {};
|
||||
@ -1,32 +0,0 @@
|
||||
function f( ) {
|
||||
var x = 3;
|
||||
var z = 2 ;
|
||||
a = z ++ - 2 * x ;
|
||||
for ( ; ; ) {
|
||||
a+=(g +g)*a%t;
|
||||
b -- ;
|
||||
}
|
||||
|
||||
switch ( a )
|
||||
{
|
||||
case 1 : {
|
||||
a ++ ;
|
||||
b--;
|
||||
if(a===a)
|
||||
return;
|
||||
else
|
||||
{
|
||||
for(a in b)
|
||||
if(a!=a)
|
||||
{
|
||||
for(a in b)
|
||||
{
|
||||
a++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -1,28 +0,0 @@
|
||||
function f() {
|
||||
var x = 3;
|
||||
var z = 2;
|
||||
a = z++ - 2 * x;
|
||||
for (; ;) {
|
||||
a += (g + g) * a % t;
|
||||
b--;
|
||||
}
|
||||
|
||||
switch (a) {
|
||||
case 1: {
|
||||
a++;
|
||||
b--;
|
||||
if (a === a)
|
||||
return;
|
||||
else {
|
||||
for (a in b)
|
||||
if (a != a) {
|
||||
for (a in b) {
|
||||
a++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -1 +0,0 @@
|
||||
var a=b+c^d-e*++f;
|
||||
@ -1 +0,0 @@
|
||||
var a = b + c ^ d - e * ++f;
|
||||
@ -1 +0,0 @@
|
||||
class test { constructor () { } }
|
||||
@ -1 +0,0 @@
|
||||
class test { constructor() { } }
|
||||
@ -1,10 +0,0 @@
|
||||
module Tools {
|
||||
export enum NodeType {
|
||||
Error,
|
||||
Comment,
|
||||
}
|
||||
export enum foob
|
||||
{
|
||||
Blah=1, Bleah=2
|
||||
}
|
||||
}
|
||||
@ -1,9 +0,0 @@
|
||||
module Tools {
|
||||
export enum NodeType {
|
||||
Error,
|
||||
Comment,
|
||||
}
|
||||
export enum foob {
|
||||
Blah = 1, Bleah = 2
|
||||
}
|
||||
}
|
||||
@ -1,65 +0,0 @@
|
||||
module MyModule
|
||||
{
|
||||
module A.B.C {
|
||||
module F {
|
||||
}
|
||||
}
|
||||
interface Blah
|
||||
{
|
||||
boo: string;
|
||||
}
|
||||
|
||||
class Foo
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
class Foo2 {
|
||||
public foo():number {
|
||||
return 5 * 6;
|
||||
}
|
||||
public foo2() {
|
||||
if (1 === 2)
|
||||
|
||||
|
||||
{
|
||||
var y : number= 76;
|
||||
return y;
|
||||
}
|
||||
|
||||
while (2 == 3) {
|
||||
if ( y == null ) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public foo3() {
|
||||
if (1 === 2)
|
||||
|
||||
//comment preventing line merging
|
||||
{
|
||||
var y = 76;
|
||||
return y;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function foo(a:number, b:number):number
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
function bar(a:number, b:number) :number[] {
|
||||
return [];
|
||||
}
|
||||
|
||||
module BugFix3 {
|
||||
declare var f: {
|
||||
(): any;
|
||||
(x: number): string;
|
||||
foo: number;
|
||||
};
|
||||
}
|
||||
@ -1,58 +0,0 @@
|
||||
module MyModule {
|
||||
module A.B.C {
|
||||
module F {
|
||||
}
|
||||
}
|
||||
interface Blah {
|
||||
boo: string;
|
||||
}
|
||||
|
||||
class Foo {
|
||||
|
||||
}
|
||||
|
||||
class Foo2 {
|
||||
public foo(): number {
|
||||
return 5 * 6;
|
||||
}
|
||||
public foo2() {
|
||||
if (1 === 2) {
|
||||
var y: number = 76;
|
||||
return y;
|
||||
}
|
||||
|
||||
while (2 == 3) {
|
||||
if (y == null) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public foo3() {
|
||||
if (1 === 2)
|
||||
|
||||
//comment preventing line merging
|
||||
{
|
||||
var y = 76;
|
||||
return y;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function foo(a: number, b: number): number {
|
||||
return 0;
|
||||
}
|
||||
|
||||
function bar(a: number, b: number): number[] {
|
||||
return [];
|
||||
}
|
||||
|
||||
module BugFix3 {
|
||||
declare var f: {
|
||||
(): any;
|
||||
(x: number): string;
|
||||
foo: number;
|
||||
};
|
||||
}
|
||||
@ -1,17 +0,0 @@
|
||||
function f(a,b,c,d){
|
||||
for(var i=0;i<10;i++){
|
||||
var a=0;
|
||||
var b=a+a+a*a%a/2-1;
|
||||
b+=a;
|
||||
++b;
|
||||
f(a,b,c,d);
|
||||
if(1===1){
|
||||
var m=function(e,f){
|
||||
return e^f;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (var i = 0 ; i < this.foo(); i++) {
|
||||
}
|
||||
@ -1,17 +0,0 @@
|
||||
function f(a, b, c, d) {
|
||||
for (var i = 0; i < 10; i++) {
|
||||
var a = 0;
|
||||
var b = a + a + a * a % a / 2 - 1;
|
||||
b += a;
|
||||
++b;
|
||||
f(a, b, c, d);
|
||||
if (1 === 1) {
|
||||
var m = function(e, f) {
|
||||
return e ^ f;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (var i = 0 ; i < this.foo(); i++) {
|
||||
}
|
||||
@ -1,9 +0,0 @@
|
||||
with (foo.bar)
|
||||
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
with (bar.blah)
|
||||
{
|
||||
}
|
||||
@ -1,6 +0,0 @@
|
||||
with (foo.bar) {
|
||||
|
||||
}
|
||||
|
||||
with (bar.blah) {
|
||||
}
|
||||
@ -198,18 +198,13 @@ namespace ts {
|
||||
|
||||
watchDirectory(directoryName: string, callback: DirectoryWatcherCallback, recursive: boolean): DirectoryWatcher {
|
||||
const path = this.toPath(directoryName);
|
||||
const callbacks = this.watchedDirectories[path] || (this.watchedDirectories[path] = []);
|
||||
callbacks.push({ cb: callback, recursive });
|
||||
const cbWithRecursive = { cb: callback, recursive };
|
||||
const callbacks = multiMapAdd(this.watchedDirectories, path, cbWithRecursive);
|
||||
return {
|
||||
referenceCount: 0,
|
||||
directoryName,
|
||||
close: () => {
|
||||
for (let i = 0; i < callbacks.length; i++) {
|
||||
if (callbacks[i].cb === callback) {
|
||||
callbacks.splice(i, 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
unorderedRemoveItem(callbacks, cbWithRecursive);
|
||||
if (!callbacks.length) {
|
||||
delete this.watchedDirectories[path];
|
||||
}
|
||||
@ -239,12 +234,10 @@ namespace ts {
|
||||
|
||||
watchFile(fileName: string, callback: FileWatcherCallback) {
|
||||
const path = this.toPath(fileName);
|
||||
const callbacks = this.watchedFiles[path] || (this.watchedFiles[path] = []);
|
||||
callbacks.push(callback);
|
||||
const callbacks = multiMapAdd(this.watchedFiles, path, callback);
|
||||
return {
|
||||
close: () => {
|
||||
const i = callbacks.indexOf(callback);
|
||||
callbacks.splice(i, 1);
|
||||
unorderedRemoveItem(callbacks, callback);
|
||||
if (!callbacks.length) {
|
||||
delete this.watchedFiles[path];
|
||||
}
|
||||
@ -259,7 +252,7 @@ namespace ts {
|
||||
};
|
||||
readonly clearTimeout = (timeoutId: any): void => {
|
||||
if (typeof timeoutId === "number") {
|
||||
this.callbackQueue.splice(timeoutId, 1);
|
||||
orderedRemoveItemAt(this.callbackQueue, timeoutId);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@ -275,7 +275,7 @@ namespace ts.server {
|
||||
removeRoot(info: ScriptInfo) {
|
||||
if (this.filenameToScript.contains(info.path)) {
|
||||
this.filenameToScript.remove(info.path);
|
||||
this.roots = copyListRemovingItem(info, this.roots);
|
||||
unorderedRemoveItem(this.roots, info);
|
||||
this.resolvedModuleNames.remove(info.path);
|
||||
this.resolvedTypeReferenceDirectives.remove(info.path);
|
||||
}
|
||||
@ -585,16 +585,6 @@ namespace ts.server {
|
||||
project?: Project;
|
||||
}
|
||||
|
||||
function copyListRemovingItem<T>(item: T, list: T[]) {
|
||||
const copiedList: T[] = [];
|
||||
for (let i = 0, len = list.length; i < len; i++) {
|
||||
if (list[i] != item) {
|
||||
copiedList.push(list[i]);
|
||||
}
|
||||
}
|
||||
return copiedList;
|
||||
}
|
||||
|
||||
/**
|
||||
* This helper funciton processes a list of projects and return the concatenated, sortd and deduplicated output of processing each project.
|
||||
*/
|
||||
@ -880,7 +870,7 @@ namespace ts.server {
|
||||
project.directoryWatcher.close();
|
||||
forEachProperty(project.directoriesWatchedForWildcards, watcher => { watcher.close(); });
|
||||
delete project.directoriesWatchedForWildcards;
|
||||
this.configuredProjects = copyListRemovingItem(project, this.configuredProjects);
|
||||
unorderedRemoveItem(this.configuredProjects, project);
|
||||
}
|
||||
else {
|
||||
for (const directory of project.directoriesWatchedForTsconfig) {
|
||||
@ -892,7 +882,7 @@ namespace ts.server {
|
||||
delete project.projectService.directoryWatchersForTsconfig[directory];
|
||||
}
|
||||
}
|
||||
this.inferredProjects = copyListRemovingItem(project, this.inferredProjects);
|
||||
unorderedRemoveItem(this.inferredProjects, project);
|
||||
}
|
||||
|
||||
const fileNames = project.getFileNames();
|
||||
@ -1017,7 +1007,7 @@ namespace ts.server {
|
||||
}
|
||||
}
|
||||
else {
|
||||
this.openFilesReferenced = copyListRemovingItem(info, this.openFilesReferenced);
|
||||
unorderedRemoveItem(this.openFilesReferenced, info);
|
||||
}
|
||||
info.close();
|
||||
}
|
||||
@ -1524,13 +1514,13 @@ namespace ts.server {
|
||||
// openFileRoots or openFileReferenced.
|
||||
if (info.isOpen) {
|
||||
if (this.openFileRoots.indexOf(info) >= 0) {
|
||||
this.openFileRoots = copyListRemovingItem(info, this.openFileRoots);
|
||||
unorderedRemoveItem(this.openFileRoots, info);
|
||||
if (info.defaultProject && !info.defaultProject.isConfiguredProject()) {
|
||||
this.removeProject(info.defaultProject);
|
||||
}
|
||||
}
|
||||
if (this.openFilesReferenced.indexOf(info) >= 0) {
|
||||
this.openFilesReferenced = copyListRemovingItem(info, this.openFilesReferenced);
|
||||
unorderedRemoveItem(this.openFilesReferenced, info);
|
||||
}
|
||||
this.openFileRootsConfigured.push(info);
|
||||
info.defaultProject = project;
|
||||
|
||||
@ -204,7 +204,7 @@ namespace ts.server {
|
||||
// average async stat takes about 30 microseconds
|
||||
// set chunk size to do 30 files in < 1 millisecond
|
||||
function createPollingWatchedFileSet(interval = 2500, chunkSize = 30) {
|
||||
let watchedFiles: WatchedFile[] = [];
|
||||
const watchedFiles: WatchedFile[] = [];
|
||||
let nextFileToCheck = 0;
|
||||
let watchTimer: any;
|
||||
|
||||
@ -267,7 +267,7 @@ namespace ts.server {
|
||||
}
|
||||
|
||||
function removeFile(file: WatchedFile) {
|
||||
watchedFiles = copyListRemovingItem(file, watchedFiles);
|
||||
unorderedRemoveItem(watchedFiles, file);
|
||||
}
|
||||
|
||||
return {
|
||||
|
||||
@ -466,6 +466,7 @@ namespace ts.NavigationBar {
|
||||
case SyntaxKind.MethodDeclaration:
|
||||
case SyntaxKind.GetAccessor:
|
||||
case SyntaxKind.SetAccessor:
|
||||
case SyntaxKind.VariableDeclaration:
|
||||
return hasSomeImportantChild(item);
|
||||
|
||||
case SyntaxKind.ArrowFunction:
|
||||
|
||||
@ -686,8 +686,7 @@ namespace ts {
|
||||
function addDeclaration(declaration: Declaration) {
|
||||
const name = getDeclarationName(declaration);
|
||||
if (name) {
|
||||
const declarations = getDeclarations(name);
|
||||
declarations.push(declaration);
|
||||
multiMapAdd(result, name, declaration);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2491,18 +2490,42 @@ namespace ts {
|
||||
return node && node.parent && node.parent.kind === SyntaxKind.PropertyAccessExpression && (<PropertyAccessExpression>node.parent).name === node;
|
||||
}
|
||||
|
||||
function climbPastPropertyAccess(node: Node) {
|
||||
return isRightSideOfPropertyAccess(node) ? node.parent : node;
|
||||
}
|
||||
|
||||
/** Get `C` given `N` if `N` is in the position `class C extends N` or `class C extends foo.N` where `N` is an identifier. */
|
||||
function tryGetClassByExtendingIdentifier(node: Node): ClassLikeDeclaration | undefined {
|
||||
return tryGetClassExtendingExpressionWithTypeArguments(climbPastPropertyAccess(node).parent);
|
||||
}
|
||||
|
||||
function isCallExpressionTarget(node: Node): boolean {
|
||||
if (isRightSideOfPropertyAccess(node)) {
|
||||
node = node.parent;
|
||||
}
|
||||
return node && node.parent && node.parent.kind === SyntaxKind.CallExpression && (<CallExpression>node.parent).expression === node;
|
||||
return isCallOrNewExpressionTarget(node, SyntaxKind.CallExpression);
|
||||
}
|
||||
|
||||
function isNewExpressionTarget(node: Node): boolean {
|
||||
if (isRightSideOfPropertyAccess(node)) {
|
||||
node = node.parent;
|
||||
}
|
||||
return node && node.parent && node.parent.kind === SyntaxKind.NewExpression && (<CallExpression>node.parent).expression === node;
|
||||
return isCallOrNewExpressionTarget(node, SyntaxKind.NewExpression);
|
||||
}
|
||||
|
||||
function isCallOrNewExpressionTarget(node: Node, kind: SyntaxKind) {
|
||||
const target = climbPastPropertyAccess(node);
|
||||
return target && target.parent && target.parent.kind === kind && (<CallExpression>target.parent).expression === target;
|
||||
}
|
||||
|
||||
function climbPastManyPropertyAccesses(node: Node): Node {
|
||||
return isRightSideOfPropertyAccess(node) ? climbPastManyPropertyAccesses(node.parent) : node;
|
||||
}
|
||||
|
||||
/** Returns a CallLikeExpression where `node` is the target being invoked. */
|
||||
function getAncestorCallLikeExpression(node: Node): CallLikeExpression | undefined {
|
||||
const target = climbPastManyPropertyAccesses(node);
|
||||
const callLike = target.parent;
|
||||
return callLike && isCallLikeExpression(callLike) && getInvokedExpression(callLike) === target && callLike;
|
||||
}
|
||||
|
||||
function tryGetSignatureDeclaration(typeChecker: TypeChecker, node: Node): SignatureDeclaration | undefined {
|
||||
const callLike = getAncestorCallLikeExpression(node);
|
||||
return callLike && typeChecker.getResolvedSignature(callLike).declaration;
|
||||
}
|
||||
|
||||
function isNameOfModuleDeclaration(node: Node) {
|
||||
@ -4308,7 +4331,7 @@ namespace ts {
|
||||
const symbolFlags = symbol.flags;
|
||||
let symbolKind = getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar(symbol, symbolFlags, location);
|
||||
let hasAddedSymbolInfo: boolean;
|
||||
const isThisExpression: boolean = location.kind === SyntaxKind.ThisKeyword && isExpression(location);
|
||||
const isThisExpression = location.kind === SyntaxKind.ThisKeyword && isExpression(location);
|
||||
let type: Type;
|
||||
|
||||
// Class at constructor site need to be shown as constructor apart from property,method, vars
|
||||
@ -4771,14 +4794,25 @@ namespace ts {
|
||||
};
|
||||
}
|
||||
|
||||
function getSymbolInfo(typeChecker: TypeChecker, symbol: Symbol, node: Node) {
|
||||
return {
|
||||
symbolName: typeChecker.symbolToString(symbol), // Do not get scoped name, just the name of the symbol
|
||||
symbolKind: getSymbolKind(symbol, node),
|
||||
containerName: symbol.parent ? typeChecker.symbolToString(symbol.parent, node) : ""
|
||||
};
|
||||
}
|
||||
|
||||
function createDefinitionFromSignatureDeclaration(decl: SignatureDeclaration): DefinitionInfo {
|
||||
const typeChecker = program.getTypeChecker();
|
||||
const { symbolName, symbolKind, containerName } = getSymbolInfo(typeChecker, decl.symbol, decl);
|
||||
return createDefinitionInfo(decl, symbolKind, symbolName, containerName);
|
||||
}
|
||||
|
||||
function getDefinitionFromSymbol(symbol: Symbol, node: Node): DefinitionInfo[] {
|
||||
const typeChecker = program.getTypeChecker();
|
||||
const result: DefinitionInfo[] = [];
|
||||
const declarations = symbol.getDeclarations();
|
||||
const symbolName = typeChecker.symbolToString(symbol); // Do not get scoped name, just the name of the symbol
|
||||
const symbolKind = getSymbolKind(symbol, node);
|
||||
const containerSymbol = symbol.parent;
|
||||
const containerName = containerSymbol ? typeChecker.symbolToString(containerSymbol, node) : "";
|
||||
const { symbolName, symbolKind, containerName } = getSymbolInfo(typeChecker, symbol, node);
|
||||
|
||||
if (!tryAddConstructSignature(symbol, node, symbolKind, symbolName, containerName, result) &&
|
||||
!tryAddCallSignature(symbol, node, symbolKind, symbolName, containerName, result)) {
|
||||
@ -4904,6 +4938,12 @@ namespace ts {
|
||||
}
|
||||
|
||||
const typeChecker = program.getTypeChecker();
|
||||
|
||||
const calledDeclaration = tryGetSignatureDeclaration(typeChecker, node);
|
||||
if (calledDeclaration) {
|
||||
return [createDefinitionFromSignatureDeclaration(calledDeclaration)];
|
||||
}
|
||||
|
||||
let symbol = typeChecker.getSymbolAtLocation(node);
|
||||
|
||||
// Could not find a symbol e.g. node is string or number keyword,
|
||||
@ -5711,6 +5751,7 @@ namespace ts {
|
||||
case SyntaxKind.Identifier:
|
||||
case SyntaxKind.ThisKeyword:
|
||||
// case SyntaxKind.SuperKeyword: TODO:GH#9268
|
||||
case SyntaxKind.ConstructorKeyword:
|
||||
case SyntaxKind.StringLiteral:
|
||||
return getReferencedSymbolsForNode(node, program.getSourceFiles(), findInStrings, findInComments);
|
||||
}
|
||||
@ -5755,6 +5796,8 @@ namespace ts {
|
||||
return getReferencesForSuperKeyword(node);
|
||||
}
|
||||
|
||||
// `getSymbolAtLocation` normally returns the symbol of the class when given the constructor keyword,
|
||||
// so we have to specify that we want the constructor symbol.
|
||||
const symbol = typeChecker.getSymbolAtLocation(node);
|
||||
|
||||
if (!symbol && node.kind === SyntaxKind.StringLiteral) {
|
||||
@ -5829,7 +5872,7 @@ namespace ts {
|
||||
};
|
||||
}
|
||||
|
||||
function getAliasSymbolForPropertyNameSymbol(symbol: Symbol, location: Node): Symbol {
|
||||
function getAliasSymbolForPropertyNameSymbol(symbol: Symbol, location: Node): Symbol | undefined {
|
||||
if (symbol.flags & SymbolFlags.Alias) {
|
||||
// Default import get alias
|
||||
const defaultImport = getDeclarationOfKind(symbol, SyntaxKind.ImportClause);
|
||||
@ -5855,6 +5898,10 @@ namespace ts {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
function followAliasIfNecessary(symbol: Symbol, location: Node): Symbol {
|
||||
return getAliasSymbolForPropertyNameSymbol(symbol, location) || symbol;
|
||||
}
|
||||
|
||||
function getPropertySymbolOfDestructuringAssignment(location: Node) {
|
||||
return isArrayLiteralOrObjectLiteralDestructuringPattern(location.parent.parent) &&
|
||||
typeChecker.getPropertySymbolOfDestructuringAssignment(<Identifier>location);
|
||||
@ -6119,7 +6166,8 @@ namespace ts {
|
||||
if (referenceSymbol) {
|
||||
const referenceSymbolDeclaration = referenceSymbol.valueDeclaration;
|
||||
const shorthandValueSymbol = typeChecker.getShorthandAssignmentValueSymbol(referenceSymbolDeclaration);
|
||||
const relatedSymbol = getRelatedSymbol(searchSymbols, referenceSymbol, referenceLocation);
|
||||
const relatedSymbol = getRelatedSymbol(searchSymbols, referenceSymbol, referenceLocation,
|
||||
/*searchLocationIsConstructor*/ searchLocation.kind === SyntaxKind.ConstructorKeyword);
|
||||
|
||||
if (relatedSymbol) {
|
||||
const referencedSymbol = getReferencedSymbol(relatedSymbol);
|
||||
@ -6135,12 +6183,94 @@ namespace ts {
|
||||
const referencedSymbol = getReferencedSymbol(shorthandValueSymbol);
|
||||
referencedSymbol.references.push(getReferenceEntryFromNode(referenceSymbolDeclaration.name));
|
||||
}
|
||||
else if (searchLocation.kind === SyntaxKind.ConstructorKeyword) {
|
||||
findAdditionalConstructorReferences(referenceSymbol, referenceLocation);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return;
|
||||
|
||||
/** Adds references when a constructor is used with `new this()` in its own class and `super()` calls in subclasses. */
|
||||
function findAdditionalConstructorReferences(referenceSymbol: Symbol, referenceLocation: Node): void {
|
||||
Debug.assert(isClassLike(searchSymbol.valueDeclaration));
|
||||
|
||||
const referenceClass = referenceLocation.parent;
|
||||
if (referenceSymbol === searchSymbol && isClassLike(referenceClass)) {
|
||||
Debug.assert(referenceClass.name === referenceLocation);
|
||||
// This is the class declaration containing the constructor.
|
||||
addReferences(findOwnConstructorCalls(searchSymbol));
|
||||
}
|
||||
else {
|
||||
// If this class appears in `extends C`, then the extending class' "super" calls are references.
|
||||
const classExtending = tryGetClassByExtendingIdentifier(referenceLocation);
|
||||
if (classExtending && isClassLike(classExtending) && followAliasIfNecessary(referenceSymbol, referenceLocation) === searchSymbol) {
|
||||
addReferences(superConstructorAccesses(classExtending));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function addReferences(references: Node[]): void {
|
||||
if (references.length) {
|
||||
const referencedSymbol = getReferencedSymbol(searchSymbol);
|
||||
addRange(referencedSymbol.references, map(references, getReferenceEntryFromNode));
|
||||
}
|
||||
}
|
||||
|
||||
/** `classSymbol` is the class where the constructor was defined.
|
||||
* Reference the constructor and all calls to `new this()`.
|
||||
*/
|
||||
function findOwnConstructorCalls(classSymbol: Symbol): Node[] {
|
||||
const result: Node[] = [];
|
||||
|
||||
for (const decl of classSymbol.members["__constructor"].declarations) {
|
||||
Debug.assert(decl.kind === SyntaxKind.Constructor);
|
||||
const ctrKeyword = decl.getChildAt(0);
|
||||
Debug.assert(ctrKeyword.kind === SyntaxKind.ConstructorKeyword);
|
||||
result.push(ctrKeyword);
|
||||
}
|
||||
|
||||
forEachProperty(classSymbol.exports, member => {
|
||||
const decl = member.valueDeclaration;
|
||||
if (decl && decl.kind === SyntaxKind.MethodDeclaration) {
|
||||
const body = (<MethodDeclaration>decl).body;
|
||||
if (body) {
|
||||
forEachDescendantOfKind(body, SyntaxKind.ThisKeyword, thisKeyword => {
|
||||
if (isNewExpressionTarget(thisKeyword)) {
|
||||
result.push(thisKeyword);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/** Find references to `super` in the constructor of an extending class. */
|
||||
function superConstructorAccesses(cls: ClassLikeDeclaration): Node[] {
|
||||
const symbol = cls.symbol;
|
||||
const ctr = symbol.members["__constructor"];
|
||||
if (!ctr) {
|
||||
return [];
|
||||
}
|
||||
|
||||
const result: Node[] = [];
|
||||
for (const decl of ctr.declarations) {
|
||||
Debug.assert(decl.kind === SyntaxKind.Constructor);
|
||||
const body = (<ConstructorDeclaration>decl).body;
|
||||
if (body) {
|
||||
forEachDescendantOfKind(body, SyntaxKind.SuperKeyword, node => {
|
||||
if (isCallExpressionTarget(node)) {
|
||||
result.push(node);
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
return result;
|
||||
}
|
||||
|
||||
function getReferencedSymbol(symbol: Symbol): ReferencedSymbol {
|
||||
const symbolId = getSymbolId(symbol);
|
||||
let index = symbolToIndex[symbolId];
|
||||
@ -6521,16 +6651,17 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
function getRelatedSymbol(searchSymbols: Symbol[], referenceSymbol: Symbol, referenceLocation: Node): Symbol {
|
||||
if (searchSymbols.indexOf(referenceSymbol) >= 0) {
|
||||
return referenceSymbol;
|
||||
function getRelatedSymbol(searchSymbols: Symbol[], referenceSymbol: Symbol, referenceLocation: Node, searchLocationIsConstructor: boolean): Symbol | undefined {
|
||||
if (contains(searchSymbols, referenceSymbol)) {
|
||||
// If we are searching for constructor uses, they must be 'new' expressions.
|
||||
return (!searchLocationIsConstructor || isNewExpressionTarget(referenceLocation)) && referenceSymbol;
|
||||
}
|
||||
|
||||
// If the reference symbol is an alias, check if what it is aliasing is one of the search
|
||||
// symbols but by looking up for related symbol of this alias so it can handle multiple level of indirectness.
|
||||
const aliasSymbol = getAliasSymbolForPropertyNameSymbol(referenceSymbol, referenceLocation);
|
||||
if (aliasSymbol) {
|
||||
return getRelatedSymbol(searchSymbols, aliasSymbol, referenceLocation);
|
||||
return getRelatedSymbol(searchSymbols, aliasSymbol, referenceLocation, searchLocationIsConstructor);
|
||||
}
|
||||
|
||||
// If the reference location is in an object literal, try to get the contextual type for the
|
||||
@ -8055,6 +8186,15 @@ namespace ts {
|
||||
};
|
||||
}
|
||||
|
||||
function forEachDescendantOfKind(node: Node, kind: SyntaxKind, action: (node: Node) => void) {
|
||||
forEachChild(node, child => {
|
||||
if (child.kind === kind) {
|
||||
action(child);
|
||||
}
|
||||
forEachDescendantOfKind(child, kind, action);
|
||||
});
|
||||
}
|
||||
|
||||
/* @internal */
|
||||
export function getNameTable(sourceFile: SourceFile): Map<number> {
|
||||
if (!sourceFile.nameTable) {
|
||||
|
||||
46
tests/cases/fourslash/findAllReferencesOfConstructor.ts
Normal file
46
tests/cases/fourslash/findAllReferencesOfConstructor.ts
Normal file
@ -0,0 +1,46 @@
|
||||
/// <reference path="fourslash.ts" />
|
||||
|
||||
// @Filename: a.ts
|
||||
////export class C {
|
||||
//// [|constructor|](n: number);
|
||||
//// [|constructor|]();
|
||||
//// [|constructor|](n?: number){}
|
||||
//// static f() {
|
||||
//// this.f();
|
||||
//// new [|this|]();
|
||||
//// }
|
||||
////}
|
||||
////new [|C|]();
|
||||
// Does not handle alias.
|
||||
////const D = C;
|
||||
////new D();
|
||||
|
||||
// @Filename: b.ts
|
||||
////import { C } from "./a";
|
||||
////new [|C|]();
|
||||
|
||||
// @Filename: c.ts
|
||||
////import { C } from "./a";
|
||||
////class D extends C {
|
||||
//// constructor() {
|
||||
//// [|super|]();
|
||||
//// super.method();
|
||||
//// }
|
||||
//// method() { super(); }
|
||||
////}
|
||||
// Does not find 'super()' calls for a class that merely implements 'C',
|
||||
// since those must be calling a different constructor.
|
||||
////class E implements C {
|
||||
//// constructor() { super(); }
|
||||
////}
|
||||
|
||||
// Works with qualified names too
|
||||
// @Filename: d.ts
|
||||
////import * as a from "./a";
|
||||
////new a.[|C|]();
|
||||
////class d extends a.C { constructor() { [|super|](); }
|
||||
|
||||
const ranges = test.ranges();
|
||||
for (const ctr of ranges.slice(0, 3)) {
|
||||
verify.referencesOf(ctr, ranges);
|
||||
}
|
||||
@ -0,0 +1,8 @@
|
||||
/// <reference path="fourslash.ts" />
|
||||
|
||||
////class C {
|
||||
//// [|constructor|](n: number);
|
||||
//// [|constructor|](){}
|
||||
////}
|
||||
|
||||
verify.rangesReferenceEachOther();
|
||||
22
tests/cases/fourslash/goToDeclarationDecoratorOverloads.ts
Normal file
22
tests/cases/fourslash/goToDeclarationDecoratorOverloads.ts
Normal file
@ -0,0 +1,22 @@
|
||||
// @Target: ES6
|
||||
// @experimentaldecorators: true
|
||||
|
||||
////async function f() {}
|
||||
////
|
||||
/////*defDecString*/function dec(target: any, propertyKey: string): void;
|
||||
/////*defDecSymbol*/function dec(target: any, propertyKey: symbol): void;
|
||||
////function dec(target: any, propertyKey: string | symbol) {}
|
||||
////
|
||||
////declare const s: symbol;
|
||||
////class C {
|
||||
//// @/*useDecString*/dec f() {}
|
||||
//// @/*useDecSymbol*/dec [s]() {}
|
||||
////}
|
||||
|
||||
goTo.marker("useDecString");
|
||||
goTo.definition();
|
||||
verify.caretAtMarker("defDecString");
|
||||
|
||||
goTo.marker("useDecSymbol");
|
||||
goTo.definition();
|
||||
verify.caretAtMarker("defDecSymbol");
|
||||
@ -11,11 +11,11 @@
|
||||
|
||||
goTo.marker('constructorOverloadReference1');
|
||||
goTo.definition();
|
||||
verify.caretAtMarker('constructorDefinition');
|
||||
verify.caretAtMarker('constructorOverload1');
|
||||
|
||||
goTo.marker('constructorOverloadReference2');
|
||||
goTo.definition();
|
||||
verify.caretAtMarker('constructorDefinition');
|
||||
verify.caretAtMarker('constructorOverload2');
|
||||
|
||||
goTo.marker('constructorOverload1');
|
||||
goTo.definition();
|
||||
|
||||
@ -1,19 +1,24 @@
|
||||
/// <reference path='fourslash.ts' />
|
||||
|
||||
/////*functionOverload1*/function /*functionOverload*/functionOverload();
|
||||
/////*functionOverload1*/function /*functionOverload*/functionOverload(value: number);
|
||||
/////*functionOverload2*/function functionOverload(value: string);
|
||||
/////*functionOverloadDefinition*/function functionOverload() {}
|
||||
////
|
||||
/////*functionOverloadReference1*/functionOverload();
|
||||
/////*functionOverloadReference1*/functionOverload(123);
|
||||
/////*functionOverloadReference2*/functionOverload("123");
|
||||
/////*brokenOverload*/functionOverload({});
|
||||
|
||||
goTo.marker('functionOverloadReference1');
|
||||
goTo.definition();
|
||||
verify.caretAtMarker('functionOverloadDefinition');
|
||||
verify.caretAtMarker('functionOverload1');
|
||||
|
||||
goTo.marker('functionOverloadReference2');
|
||||
goTo.definition();
|
||||
verify.caretAtMarker('functionOverloadDefinition');
|
||||
verify.caretAtMarker('functionOverload2');
|
||||
|
||||
goTo.marker('brokenOverload');
|
||||
goTo.definition();
|
||||
verify.caretAtMarker('functionOverload1');
|
||||
|
||||
goTo.marker('functionOverload');
|
||||
goTo.definition();
|
||||
|
||||
@ -1,11 +1,11 @@
|
||||
/// <reference path='fourslash.ts' />
|
||||
|
||||
////class MethodOverload {
|
||||
//// static me/*staticMethodOverload1*/thod();
|
||||
//// static me/*staticMethodOverload2*/thod(foo: string);
|
||||
/////*staticMethodDefinition*/static method(foo?: any) { }
|
||||
//// public met/*instanceMethodOverload1*/hod(): any;
|
||||
//// public met/*instanceMethodOverload2*/hod(foo: string);
|
||||
//// /*staticMethodOverload1*/static /*staticMethodOverload1Name*/method();
|
||||
//// /*staticMethodOverload2*/static method(foo: string);
|
||||
//// /*staticMethodDefinition*/static method(foo?: any) { }
|
||||
//// /*instanceMethodOverload1*/public /*instanceMethodOverload1Name*/method(): any;
|
||||
//// /*instanceMethodOverload2*/public method(foo: string);
|
||||
/////*instanceMethodDefinition*/public method(foo?: any) { return "foo" }
|
||||
////}
|
||||
|
||||
@ -20,25 +20,25 @@
|
||||
|
||||
goTo.marker('staticMethodReference1');
|
||||
goTo.definition();
|
||||
verify.caretAtMarker('staticMethodDefinition');
|
||||
verify.caretAtMarker('staticMethodOverload1');
|
||||
|
||||
goTo.marker('staticMethodReference2');
|
||||
goTo.definition();
|
||||
verify.caretAtMarker('staticMethodDefinition');
|
||||
verify.caretAtMarker('staticMethodOverload2');
|
||||
|
||||
goTo.marker('instanceMethodReference1');
|
||||
goTo.definition();
|
||||
verify.caretAtMarker('instanceMethodDefinition');
|
||||
verify.caretAtMarker('instanceMethodOverload1');
|
||||
|
||||
goTo.marker('instanceMethodReference2');
|
||||
goTo.definition();
|
||||
verify.caretAtMarker('instanceMethodDefinition');
|
||||
verify.caretAtMarker('instanceMethodOverload2');
|
||||
|
||||
goTo.marker('staticMethodOverload1');
|
||||
goTo.marker('staticMethodOverload1Name');
|
||||
goTo.definition();
|
||||
verify.caretAtMarker('staticMethodDefinition');
|
||||
|
||||
goTo.marker('instanceMethodOverload1');
|
||||
goTo.marker('instanceMethodOverload1Name');
|
||||
goTo.definition();
|
||||
verify.caretAtMarker('instanceMethodDefinition');
|
||||
|
||||
|
||||
@ -0,0 +1,16 @@
|
||||
/// <reference path='fourslash.ts' />
|
||||
|
||||
// Test that we can climb past more than one property access to reach a call expression.
|
||||
|
||||
////namespace A {
|
||||
//// export namespace B {
|
||||
//// export function f(value: number): void;
|
||||
//// /*1*/export function f(value: string): void;
|
||||
//// export function f(value: number | string) {}
|
||||
//// }
|
||||
////}
|
||||
////A.B./*2*/f("");
|
||||
|
||||
goTo.marker("2");
|
||||
goTo.definition();
|
||||
verify.caretAtMarker("1");
|
||||
@ -0,0 +1,16 @@
|
||||
/// <reference path='fourslash.ts' />
|
||||
|
||||
/////*defFNumber*/function f(strs: TemplateStringsArray, x: number): void;
|
||||
/////*defFBool*/function f(strs: TemplateStringsArray, x: boolean): void;
|
||||
////function f(strs: TemplateStringsArray, x: number | boolean) {}
|
||||
////
|
||||
/////*useFNumber*/f`${0}`;
|
||||
/////*useFBool*/f`${false}`;
|
||||
|
||||
goTo.marker("useFNumber");
|
||||
goTo.definition();
|
||||
verify.caretAtMarker("defFNumber");
|
||||
|
||||
goTo.marker("useFBool");
|
||||
goTo.definition();
|
||||
verify.caretAtMarker("defFBool");
|
||||
33
tests/cases/fourslash/goToDefinition_super.ts
Normal file
33
tests/cases/fourslash/goToDefinition_super.ts
Normal file
@ -0,0 +1,33 @@
|
||||
///<reference path="fourslash.ts"/>
|
||||
|
||||
////class A {
|
||||
//// /*ctr*/constructor() {}
|
||||
//// x() {}
|
||||
////}
|
||||
/////*B*/class B extends A {}
|
||||
////class C extends B {
|
||||
//// constructor() {
|
||||
//// /*super*/super();
|
||||
//// }
|
||||
//// method() {
|
||||
//// /*superExpression*/super.x();
|
||||
//// }
|
||||
////}
|
||||
////class D {
|
||||
//// constructor() {
|
||||
//// /*superBroken*/super();
|
||||
//// }
|
||||
////}
|
||||
|
||||
// Super in call position goes to constructor.
|
||||
goTo.marker("super");
|
||||
goTo.definition();
|
||||
verify.caretAtMarker("ctr");
|
||||
|
||||
// Super in any other position goes to the superclass.
|
||||
goTo.marker("superExpression");
|
||||
goTo.definition();
|
||||
verify.caretAtMarker("B");
|
||||
|
||||
goTo.marker("superBroken");
|
||||
verify.definitionCountIs(0);
|
||||
@ -90,6 +90,17 @@ verify.navigationBar([
|
||||
],
|
||||
"indent": 2
|
||||
},
|
||||
{
|
||||
"text": "y",
|
||||
"kind": "const",
|
||||
"childItems": [
|
||||
{
|
||||
"text": "foo",
|
||||
"kind": "function"
|
||||
}
|
||||
],
|
||||
"indent": 2
|
||||
},
|
||||
{
|
||||
"text": "<function>",
|
||||
"kind": "function",
|
||||
|
||||
@ -0,0 +1,46 @@
|
||||
/// <reference path="fourslash.ts"/>
|
||||
|
||||
////var a = {
|
||||
//// propA: function() {}
|
||||
////};
|
||||
////var b;
|
||||
////b = {
|
||||
//// propB: function() {}
|
||||
////};
|
||||
|
||||
verify.navigationBar([
|
||||
{
|
||||
"text": "<global>",
|
||||
"kind": "script",
|
||||
"childItems": [
|
||||
{
|
||||
"text": "a",
|
||||
"kind": "var"
|
||||
},
|
||||
{
|
||||
"text": "b",
|
||||
"kind": "var"
|
||||
},
|
||||
{
|
||||
"text": "propB",
|
||||
"kind": "function"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"text": "a",
|
||||
"kind": "var",
|
||||
"childItems": [
|
||||
{
|
||||
"text": "propA",
|
||||
"kind": "function"
|
||||
}
|
||||
],
|
||||
"indent": 1
|
||||
},
|
||||
{
|
||||
"text": "propB",
|
||||
"kind": "function",
|
||||
"indent": 1
|
||||
}
|
||||
]);
|
||||
Loading…
x
Reference in New Issue
Block a user