Merge branch 'master' into cleanupDiagnostics

This commit is contained in:
Anders Hejlsberg
2015-03-13 15:06:14 -07:00
266 changed files with 29703 additions and 11192 deletions
+9 -3
View File
@@ -179,19 +179,19 @@ interface ObjectConstructor {
* Prevents the modification of attributes of existing properties, and prevents the addition of new properties.
* @param o Object on which to lock the attributes.
*/
seal(o: any): any;
seal<T>(o: T): T;
/**
* Prevents the modification of existing property attributes and values, and prevents the addition of new properties.
* @param o Object on which to lock the attributes.
*/
freeze(o: any): any;
freeze<T>(o: T): T;
/**
* Prevents the addition of new properties to an object.
* @param o Object to make non-extensible.
*/
preventExtensions(o: any): any;
preventExtensions<T>(o: T): T;
/**
* Returns true if existing property attributes cannot be modified in an object and new properties cannot be added to the object.
@@ -425,6 +425,9 @@ interface String {
*/
substr(from: number, length?: number): string;
/** Returns the primitive value of the specified object. */
valueOf(): string;
[index: number]: string;
}
@@ -477,6 +480,9 @@ interface Number {
* @param precision Number of significant digits. Must be in the range 1 - 21, inclusive.
*/
toPrecision(precision?: number): string;
/** Returns the primitive value of the specified object. */
valueOf(): number;
}
interface NumberConstructor {
+9 -3
View File
@@ -179,19 +179,19 @@ interface ObjectConstructor {
* Prevents the modification of attributes of existing properties, and prevents the addition of new properties.
* @param o Object on which to lock the attributes.
*/
seal(o: any): any;
seal<T>(o: T): T;
/**
* Prevents the modification of existing property attributes and values, and prevents the addition of new properties.
* @param o Object on which to lock the attributes.
*/
freeze(o: any): any;
freeze<T>(o: T): T;
/**
* Prevents the addition of new properties to an object.
* @param o Object to make non-extensible.
*/
preventExtensions(o: any): any;
preventExtensions<T>(o: T): T;
/**
* Returns true if existing property attributes cannot be modified in an object and new properties cannot be added to the object.
@@ -425,6 +425,9 @@ interface String {
*/
substr(from: number, length?: number): string;
/** Returns the primitive value of the specified object. */
valueOf(): string;
[index: number]: string;
}
@@ -477,6 +480,9 @@ interface Number {
* @param precision Number of significant digits. Must be in the range 1 - 21, inclusive.
*/
toPrecision(precision?: number): string;
/** Returns the primitive value of the specified object. */
valueOf(): number;
}
interface NumberConstructor {
+9 -3
View File
@@ -179,19 +179,19 @@ interface ObjectConstructor {
* Prevents the modification of attributes of existing properties, and prevents the addition of new properties.
* @param o Object on which to lock the attributes.
*/
seal(o: any): any;
seal<T>(o: T): T;
/**
* Prevents the modification of existing property attributes and values, and prevents the addition of new properties.
* @param o Object on which to lock the attributes.
*/
freeze(o: any): any;
freeze<T>(o: T): T;
/**
* Prevents the addition of new properties to an object.
* @param o Object to make non-extensible.
*/
preventExtensions(o: any): any;
preventExtensions<T>(o: T): T;
/**
* Returns true if existing property attributes cannot be modified in an object and new properties cannot be added to the object.
@@ -425,6 +425,9 @@ interface String {
*/
substr(from: number, length?: number): string;
/** Returns the primitive value of the specified object. */
valueOf(): string;
[index: number]: string;
}
@@ -477,6 +480,9 @@ interface Number {
* @param precision Number of significant digits. Must be in the range 1 - 21, inclusive.
*/
toPrecision(precision?: number): string;
/** Returns the primitive value of the specified object. */
valueOf(): number;
}
interface NumberConstructor {
+9 -3
View File
@@ -179,19 +179,19 @@ interface ObjectConstructor {
* Prevents the modification of attributes of existing properties, and prevents the addition of new properties.
* @param o Object on which to lock the attributes.
*/
seal(o: any): any;
seal<T>(o: T): T;
/**
* Prevents the modification of existing property attributes and values, and prevents the addition of new properties.
* @param o Object on which to lock the attributes.
*/
freeze(o: any): any;
freeze<T>(o: T): T;
/**
* Prevents the addition of new properties to an object.
* @param o Object to make non-extensible.
*/
preventExtensions(o: any): any;
preventExtensions<T>(o: T): T;
/**
* Returns true if existing property attributes cannot be modified in an object and new properties cannot be added to the object.
@@ -425,6 +425,9 @@ interface String {
*/
substr(from: number, length?: number): string;
/** Returns the primitive value of the specified object. */
valueOf(): string;
[index: number]: string;
}
@@ -477,6 +480,9 @@ interface Number {
* @param precision Number of significant digits. Must be in the range 1 - 21, inclusive.
*/
toPrecision(precision?: number): string;
/** Returns the primitive value of the specified object. */
valueOf(): number;
}
interface NumberConstructor {
+573 -382
View File
File diff suppressed because it is too large Load Diff
+7600 -2490
View File
File diff suppressed because one or more lines are too long
+29 -21
View File
@@ -224,27 +224,28 @@ declare module "typescript" {
EnumDeclaration = 199,
ModuleDeclaration = 200,
ModuleBlock = 201,
ImportEqualsDeclaration = 202,
ImportDeclaration = 203,
ImportClause = 204,
NamespaceImport = 205,
NamedImports = 206,
ImportSpecifier = 207,
ExportAssignment = 208,
ExportDeclaration = 209,
NamedExports = 210,
ExportSpecifier = 211,
ExternalModuleReference = 212,
CaseClause = 213,
DefaultClause = 214,
HeritageClause = 215,
CatchClause = 216,
PropertyAssignment = 217,
ShorthandPropertyAssignment = 218,
EnumMember = 219,
SourceFile = 220,
SyntaxList = 221,
Count = 222,
CaseBlock = 202,
ImportEqualsDeclaration = 203,
ImportDeclaration = 204,
ImportClause = 205,
NamespaceImport = 206,
NamedImports = 207,
ImportSpecifier = 208,
ExportAssignment = 209,
ExportDeclaration = 210,
NamedExports = 211,
ExportSpecifier = 212,
ExternalModuleReference = 213,
CaseClause = 214,
DefaultClause = 215,
HeritageClause = 216,
CatchClause = 217,
PropertyAssignment = 218,
ShorthandPropertyAssignment = 219,
EnumMember = 220,
SourceFile = 221,
SyntaxList = 222,
Count = 223,
FirstAssignment = 52,
LastAssignment = 63,
FirstReservedWord = 65,
@@ -619,6 +620,9 @@ declare module "typescript" {
}
interface SwitchStatement extends Statement {
expression: Expression;
caseBlock: CaseBlock;
}
interface CaseBlock extends Node {
clauses: NodeArray<CaseOrDefaultClause>;
}
interface CaseClause extends Node {
@@ -1197,6 +1201,7 @@ declare module "typescript" {
version?: boolean;
watch?: boolean;
stripInternal?: boolean;
preserveNewLines?: boolean;
[option: string]: string | number | boolean;
}
const enum ModuleKind {
@@ -1437,12 +1442,15 @@ declare module "typescript" {
function createTypeChecker(host: TypeCheckerHost, produceDiagnostics: boolean): TypeChecker;
}
declare module "typescript" {
/** The version of the TypeScript compiler release */
var version: string;
function createCompilerHost(options: CompilerOptions): CompilerHost;
function getPreEmitDiagnostics(program: Program): Diagnostic[];
function flattenDiagnosticMessageText(messageText: string | DiagnosticMessageChain, newLine: string): string;
function createProgram(rootNames: string[], options: CompilerOptions, host?: CompilerHost): Program;
}
declare module "typescript" {
/** The version of the language service API */
var servicesVersion: string;
interface Node {
getSourceFile(): SourceFile;
+7264 -2344
View File
File diff suppressed because one or more lines are too long
+29 -21
View File
@@ -224,27 +224,28 @@ declare module ts {
EnumDeclaration = 199,
ModuleDeclaration = 200,
ModuleBlock = 201,
ImportEqualsDeclaration = 202,
ImportDeclaration = 203,
ImportClause = 204,
NamespaceImport = 205,
NamedImports = 206,
ImportSpecifier = 207,
ExportAssignment = 208,
ExportDeclaration = 209,
NamedExports = 210,
ExportSpecifier = 211,
ExternalModuleReference = 212,
CaseClause = 213,
DefaultClause = 214,
HeritageClause = 215,
CatchClause = 216,
PropertyAssignment = 217,
ShorthandPropertyAssignment = 218,
EnumMember = 219,
SourceFile = 220,
SyntaxList = 221,
Count = 222,
CaseBlock = 202,
ImportEqualsDeclaration = 203,
ImportDeclaration = 204,
ImportClause = 205,
NamespaceImport = 206,
NamedImports = 207,
ImportSpecifier = 208,
ExportAssignment = 209,
ExportDeclaration = 210,
NamedExports = 211,
ExportSpecifier = 212,
ExternalModuleReference = 213,
CaseClause = 214,
DefaultClause = 215,
HeritageClause = 216,
CatchClause = 217,
PropertyAssignment = 218,
ShorthandPropertyAssignment = 219,
EnumMember = 220,
SourceFile = 221,
SyntaxList = 222,
Count = 223,
FirstAssignment = 52,
LastAssignment = 63,
FirstReservedWord = 65,
@@ -619,6 +620,9 @@ declare module ts {
}
interface SwitchStatement extends Statement {
expression: Expression;
caseBlock: CaseBlock;
}
interface CaseBlock extends Node {
clauses: NodeArray<CaseOrDefaultClause>;
}
interface CaseClause extends Node {
@@ -1197,6 +1201,7 @@ declare module ts {
version?: boolean;
watch?: boolean;
stripInternal?: boolean;
preserveNewLines?: boolean;
[option: string]: string | number | boolean;
}
const enum ModuleKind {
@@ -1437,12 +1442,15 @@ declare module ts {
function createTypeChecker(host: TypeCheckerHost, produceDiagnostics: boolean): TypeChecker;
}
declare module ts {
/** The version of the TypeScript compiler release */
var version: string;
function createCompilerHost(options: CompilerOptions): CompilerHost;
function getPreEmitDiagnostics(program: Program): Diagnostic[];
function flattenDiagnosticMessageText(messageText: string | DiagnosticMessageChain, newLine: string): string;
function createProgram(rootNames: string[], options: CompilerOptions, host?: CompilerHost): Program;
}
declare module ts {
/** The version of the language service API */
var servicesVersion: string;
interface Node {
getSourceFile(): SourceFile;
+7264 -2344
View File
File diff suppressed because one or more lines are too long
+1 -1
View File
@@ -171,6 +171,7 @@ declare module ts {
function unescapeIdentifier(identifier: string): string;
function makeIdentifierFromModuleName(moduleName: string): string;
function isBlockOrCatchScoped(declaration: Declaration): boolean;
function getEnclosingBlockScopeContainer(node: Node): Node;
function isCatchClauseVariableDeclaration(declaration: Declaration): boolean;
function declarationNameToString(name: DeclarationName): string;
function createDiagnosticForNode(node: Node, message: DiagnosticMessage, arg0?: any, arg1?: any, arg2?: any): Diagnostic;
@@ -270,7 +271,6 @@ declare module ts {
function nodeIsSynthesized(node: Node): boolean;
function createSynthesizedNode(kind: SyntaxKind, startsOnNewLine?: boolean): Node;
function generateUniqueName(baseName: string, isExistingName: (name: string) => boolean): string;
function createDiagnosticCollection(): DiagnosticCollection;
/**
* Based heavily on the abstract 'Quote'/'QuoteJSONString' operation from ECMA-262 (24.3.2.2),
* but augmented for a few select characters (e.g. lineSeparator, paragraphSeparator, nextLine)
+1 -1
View File
@@ -171,6 +171,7 @@ declare module "typescript" {
function unescapeIdentifier(identifier: string): string;
function makeIdentifierFromModuleName(moduleName: string): string;
function isBlockOrCatchScoped(declaration: Declaration): boolean;
function getEnclosingBlockScopeContainer(node: Node): Node;
function isCatchClauseVariableDeclaration(declaration: Declaration): boolean;
function declarationNameToString(name: DeclarationName): string;
function createDiagnosticForNode(node: Node, message: DiagnosticMessage, arg0?: any, arg1?: any, arg2?: any): Diagnostic;
@@ -270,7 +271,6 @@ declare module "typescript" {
function nodeIsSynthesized(node: Node): boolean;
function createSynthesizedNode(kind: SyntaxKind, startsOnNewLine?: boolean): Node;
function generateUniqueName(baseName: string, isExistingName: (name: string) => boolean): string;
function createDiagnosticCollection(): DiagnosticCollection;
/**
* Based heavily on the abstract 'Quote'/'QuoteJSONString' operation from ECMA-262 (24.3.2.2),
* but augmented for a few select characters (e.g. lineSeparator, paragraphSeparator, nextLine)
+29 -28
View File
@@ -1,7 +1,7 @@
/// <reference path="parser.ts"/>
module ts {
/* @internal */ export var bindTime = 0;
/* @internal */ export let bindTime = 0;
export const enum ModuleInstanceState {
NonInstantiated = 0,
@@ -25,7 +25,7 @@ module ts {
}
// 4. other uninstantiated module declarations.
else if (node.kind === SyntaxKind.ModuleBlock) {
var state = ModuleInstanceState.NonInstantiated;
let state = ModuleInstanceState.NonInstantiated;
forEachChild(node, n => {
switch (getModuleInstanceState(n)) {
case ModuleInstanceState.NonInstantiated:
@@ -52,18 +52,18 @@ module ts {
}
export function bindSourceFile(file: SourceFile): void {
var start = new Date().getTime();
let start = new Date().getTime();
bindSourceFileWorker(file);
bindTime += new Date().getTime() - start;
}
function bindSourceFileWorker(file: SourceFile): void {
var parent: Node;
var container: Node;
var blockScopeContainer: Node;
var lastContainer: Node;
var symbolCount = 0;
var Symbol = objectAllocator.getSymbolConstructor();
let container: Node;
let blockScopeContainer: Node;
let lastContainer: Node;
let symbolCount = 0;
let Symbol = objectAllocator.getSymbolConstructor();
if (!file.locals) {
file.locals = {};
@@ -103,7 +103,7 @@ module ts {
return '"' + (<LiteralExpression>node.name).text + '"';
}
if (node.name.kind === SyntaxKind.ComputedPropertyName) {
var nameExpression = (<ComputedPropertyName>node.name).expression;
let nameExpression = (<ComputedPropertyName>node.name).expression;
Debug.assert(isWellKnownSymbolSyntactically(nameExpression));
return getPropertyNameForKnownSymbolName((<PropertyAccessExpression>nameExpression).name.text);
}
@@ -138,10 +138,11 @@ module ts {
Debug.assert(!hasDynamicName(node));
// The exported symbol for an export default function/class node is always named "default"
var name = node.flags & NodeFlags.Default && parent ? "default" : getDeclarationName(node);
let name = node.flags & NodeFlags.Default && parent ? "default" : getDeclarationName(node);
let symbol: Symbol;
if (name !== undefined) {
var symbol = hasProperty(symbols, name) ? symbols[name] : (symbols[name] = createSymbol(0, name));
symbol = hasProperty(symbols, name) ? symbols[name] : (symbols[name] = createSymbol(0, name));
if (symbol.flags & excludes) {
if (node.name) {
node.name.parent = node;
@@ -149,7 +150,7 @@ module ts {
// Report errors every position with duplicate declaration
// Report errors on previous encountered declarations
var message = symbol.flags & SymbolFlags.BlockScopedVariable
let message = symbol.flags & SymbolFlags.BlockScopedVariable
? Diagnostics.Cannot_redeclare_block_scoped_variable_0
: Diagnostics.Duplicate_identifier_0;
@@ -172,7 +173,7 @@ module ts {
// Every class automatically contains a static property member named 'prototype',
// the type of which is an instantiation of the class type with type Any supplied as a type argument for each type parameter.
// It is an error to explicitly declare a static property member with the name 'prototype'.
var prototypeSymbol = createSymbol(SymbolFlags.Property | SymbolFlags.Prototype, "prototype");
let prototypeSymbol = createSymbol(SymbolFlags.Property | SymbolFlags.Prototype, "prototype");
if (hasProperty(symbol.exports, prototypeSymbol.name)) {
if (node.name) {
node.name.parent = node;
@@ -196,7 +197,7 @@ module ts {
}
function declareModuleMember(node: Declaration, symbolKind: SymbolFlags, symbolExcludes: SymbolFlags) {
var hasExportModifier = getCombinedNodeFlags(node) & NodeFlags.Export;
let hasExportModifier = getCombinedNodeFlags(node) & NodeFlags.Export;
if (symbolKind & SymbolFlags.Alias) {
if (node.kind === SyntaxKind.ExportSpecifier || (node.kind === SyntaxKind.ImportEqualsDeclaration && hasExportModifier)) {
declareSymbol(container.symbol.exports, container.symbol, node, symbolKind, symbolExcludes);
@@ -218,10 +219,10 @@ module ts {
// but return the export symbol (by calling getExportSymbolOfValueSymbolIfExported). That way
// when the emitter comes back to it, it knows not to qualify the name if it was found in a containing scope.
if (hasExportModifier || isAmbientContext(container)) {
var exportKind = (symbolKind & SymbolFlags.Value ? SymbolFlags.ExportValue : 0) |
let exportKind = (symbolKind & SymbolFlags.Value ? SymbolFlags.ExportValue : 0) |
(symbolKind & SymbolFlags.Type ? SymbolFlags.ExportType : 0) |
(symbolKind & SymbolFlags.Namespace ? SymbolFlags.ExportNamespace : 0);
var local = declareSymbol(container.locals, undefined, node, exportKind, symbolExcludes);
let local = declareSymbol(container.locals, undefined, node, exportKind, symbolExcludes);
local.exportSymbol = declareSymbol(container.symbol.exports, container.symbol, node, symbolKind, symbolExcludes);
node.localSymbol = local;
}
@@ -238,9 +239,9 @@ module ts {
node.locals = {};
}
var saveParent = parent;
var saveContainer = container;
var savedBlockScopeContainer = blockScopeContainer;
let saveParent = parent;
let saveContainer = container;
let savedBlockScopeContainer = blockScopeContainer;
parent = node;
if (symbolKind & SymbolFlags.IsContainer) {
container = node;
@@ -315,7 +316,7 @@ module ts {
bindDeclaration(node, SymbolFlags.ValueModule, SymbolFlags.ValueModuleExcludes, /*isBlockScopeContainer*/ true);
}
else {
var state = getModuleInstanceState(node);
let state = getModuleInstanceState(node);
if (state === ModuleInstanceState.NonInstantiated) {
bindDeclaration(node, SymbolFlags.NamespaceModule, SymbolFlags.NamespaceModuleExcludes, /*isBlockScopeContainer*/ true);
}
@@ -341,18 +342,18 @@ module ts {
// symbol as its sole member. To the rest of the system, this symbol will be indistinguishable
// from an actual type literal symbol you would have gotten had you used the long form.
var symbol = createSymbol(SymbolFlags.Signature, getDeclarationName(node));
let symbol = createSymbol(SymbolFlags.Signature, getDeclarationName(node));
addDeclarationToSymbol(symbol, node, SymbolFlags.Signature);
bindChildren(node, SymbolFlags.Signature, /*isBlockScopeContainer:*/ false);
var typeLiteralSymbol = createSymbol(SymbolFlags.TypeLiteral, "__type");
let typeLiteralSymbol = createSymbol(SymbolFlags.TypeLiteral, "__type");
addDeclarationToSymbol(typeLiteralSymbol, node, SymbolFlags.TypeLiteral);
typeLiteralSymbol.members = {};
typeLiteralSymbol.members[node.kind === SyntaxKind.FunctionType ? "__call" : "__new"] = symbol
}
function bindAnonymousDeclaration(node: Declaration, symbolKind: SymbolFlags, name: string, isBlockScopeContainer: boolean) {
var symbol = createSymbol(symbolKind, name);
let symbol = createSymbol(symbolKind, name);
addDeclarationToSymbol(symbol, node, symbolKind);
bindChildren(node, symbolKind, isBlockScopeContainer);
}
@@ -525,20 +526,20 @@ module ts {
// Otherwise this won't be considered as redeclaration of a block scoped local:
// function foo() {
// let x;
// var x;
// let x;
// }
// 'var x' will be placed into the function locals and 'let x' - into the locals of the block
// 'let x' will be placed into the function locals and 'let x' - into the locals of the block
bindChildren(node, 0, /*isBlockScopeContainer*/ !isFunctionLike(node.parent));
break;
case SyntaxKind.CatchClause:
case SyntaxKind.ForStatement:
case SyntaxKind.ForInStatement:
case SyntaxKind.ForOfStatement:
case SyntaxKind.SwitchStatement:
case SyntaxKind.CaseBlock:
bindChildren(node, 0, /*isBlockScopeContainer*/ true);
break;
default:
var saveParent = parent;
let saveParent = parent;
parent = node;
forEachChild(node, bind);
parent = saveParent;
@@ -559,7 +560,7 @@ module ts {
node.parent.kind === SyntaxKind.Constructor &&
node.parent.parent.kind === SyntaxKind.ClassDeclaration) {
var classDeclaration = <ClassDeclaration>node.parent.parent;
let classDeclaration = <ClassDeclaration>node.parent.parent;
declareSymbol(classDeclaration.symbol.members, classDeclaration.symbol, node, SymbolFlags.Property, SymbolFlags.PropertyExcludes);
}
}
+1469 -1359
View File
File diff suppressed because it is too large Load Diff
+95 -90
View File
@@ -25,8 +25,8 @@ module ts {
export function forEach<T, U>(array: T[], callback: (element: T, index: number) => U): U {
if (array) {
for (var i = 0, len = array.length; i < len; i++) {
var result = callback(array[i], i);
for (let i = 0, len = array.length; i < len; i++) {
let result = callback(array[i], i);
if (result) {
return result;
}
@@ -37,8 +37,8 @@ module ts {
export function contains<T>(array: T[], value: T): boolean {
if (array) {
for (var i = 0, len = array.length; i < len; i++) {
if (array[i] === value) {
for (let v of array) {
if (v === value) {
return true;
}
}
@@ -48,7 +48,7 @@ module ts {
export function indexOf<T>(array: T[], value: T): number {
if (array) {
for (var i = 0, len = array.length; i < len; i++) {
for (let i = 0, len = array.length; i < len; i++) {
if (array[i] === value) {
return i;
}
@@ -58,10 +58,10 @@ module ts {
}
export function countWhere<T>(array: T[], predicate: (x: T) => boolean): number {
var count = 0;
let count = 0;
if (array) {
for (var i = 0, len = array.length; i < len; i++) {
if (predicate(array[i])) {
for (let v of array) {
if (predicate(v)) {
count++;
}
}
@@ -69,11 +69,11 @@ module ts {
return count;
}
export function filter<T>(array: T[], f: (x: T) => boolean): T[] {
export function filter<T>(array: T[], f: (x: T) => boolean): T[]{
let result: T[];
if (array) {
var result: T[] = [];
for (var i = 0, len = array.length; i < len; i++) {
var item = array[i];
result = [];
for (let item of array) {
if (f(item)) {
result.push(item);
}
@@ -82,11 +82,12 @@ module ts {
return result;
}
export function map<T, U>(array: T[], f: (x: T) => U): U[] {
export function map<T, U>(array: T[], f: (x: T) => U): U[]{
let result: U[];
if (array) {
var result: U[] = [];
for (var i = 0, len = array.length; i < len; i++) {
result.push(f(array[i]));
result = [];
for (let v of array) {
result.push(f(v));
}
}
return result;
@@ -99,28 +100,30 @@ module ts {
return array1.concat(array2);
}
export function deduplicate<T>(array: T[]): T[] {
export function deduplicate<T>(array: T[]): T[]{
let result: T[];
if (array) {
var result: T[] = [];
for (var i = 0, len = array.length; i < len; i++) {
var item = array[i];
if (!contains(result, item)) result.push(item);
result = [];
for (let item of array) {
if (!contains(result, item)) {
result.push(item);
}
}
}
return result;
}
export function sum(array: any[], prop: string): number {
var result = 0;
for (var i = 0; i < array.length; i++) {
result += array[i][prop];
let result = 0;
for (let v of array) {
result += v[prop];
}
return result;
}
export function addRange<T>(to: T[], from: T[]): void {
for (var i = 0, n = from.length; i < n; i++) {
to.push(from[i]);
for (let v of from) {
to.push(v);
}
}
@@ -136,12 +139,12 @@ module ts {
}
export function binarySearch(array: number[], value: number): number {
var low = 0;
var high = array.length - 1;
let low = 0;
let high = array.length - 1;
while (low <= high) {
var middle = low + ((high - low) >> 1);
var midValue = array[middle];
let middle = low + ((high - low) >> 1);
let midValue = array[middle];
if (midValue === value) {
return middle;
@@ -157,7 +160,7 @@ module ts {
return ~low;
}
var hasOwnProperty = Object.prototype.hasOwnProperty;
let hasOwnProperty = Object.prototype.hasOwnProperty;
export function hasProperty<T>(map: Map<T>, key: string): boolean {
return hasOwnProperty.call(map, key);
@@ -168,7 +171,7 @@ module ts {
}
export function isEmpty<T>(map: Map<T>) {
for (var id in map) {
for (let id in map) {
if (hasProperty(map, id)) {
return false;
}
@@ -177,19 +180,19 @@ module ts {
}
export function clone<T>(object: T): T {
var result: any = {};
for (var id in object) {
let result: any = {};
for (let id in object) {
result[id] = (<any>object)[id];
}
return <T>result;
}
export function extend<T>(first: Map<T>, second: Map<T>): Map<T> {
var result: Map<T> = {};
for (var id in first) {
let result: Map<T> = {};
for (let id in first) {
result[id] = first[id];
}
for (var id in second) {
for (let id in second) {
if (!hasProperty(result, id)) {
result[id] = second[id];
}
@@ -198,16 +201,16 @@ module ts {
}
export function forEachValue<T, U>(map: Map<T>, callback: (value: T) => U): U {
var result: U;
for (var id in map) {
let result: U;
for (let id in map) {
if (result = callback(map[id])) break;
}
return result;
}
export function forEachKey<T, U>(map: Map<T>, callback: (key: string) => U): U {
var result: U;
for (var id in map) {
let result: U;
for (let id in map) {
if (result = callback(id)) break;
}
return result;
@@ -218,9 +221,9 @@ module ts {
}
export function mapToArray<T>(map: Map<T>): T[] {
var result: T[] = [];
let result: T[] = [];
for (var id in map) {
for (let id in map) {
result.push(map[id]);
}
@@ -228,7 +231,7 @@ module ts {
}
export function copyMap<T>(source: Map<T>, target: Map<T>): void {
for (var p in source) {
for (let p in source) {
target[p] = source[p];
}
}
@@ -244,7 +247,7 @@ module ts {
* index in the array will be the one associated with the produced key.
*/
export function arrayToMap<T>(array: T[], makeKey: (value: T) => string): Map<T> {
var result: Map<T> = {};
let result: Map<T> = {};
forEach(array, value => {
result[makeKey(value)] = value;
@@ -259,7 +262,7 @@ module ts {
return text.replace(/{(\d+)}/g, (match, index?) => args[+index + baseIndex]);
}
export var localizedDiagnosticMessages: Map<string> = undefined;
export let localizedDiagnosticMessages: Map<string> = undefined;
export function getLocaleSpecificMessage(message: string) {
return localizedDiagnosticMessages && localizedDiagnosticMessages[message]
@@ -269,10 +272,14 @@ module ts {
export function createFileDiagnostic(file: SourceFile, start: number, length: number, message: DiagnosticMessage, ...args: any[]): Diagnostic;
export function createFileDiagnostic(file: SourceFile, start: number, length: number, message: DiagnosticMessage): Diagnostic {
let end = start + length;
Debug.assert(start >= 0, "start must be non-negative, is " + start);
Debug.assert(length >= 0, "length must be non-negative, is " + length);
Debug.assert(start <= file.text.length, `start must be within the bounds of the file. ${ start } > ${ file.text.length }`);
Debug.assert(end <= file.text.length, `end must be the bounds of the file. ${ end } > ${ file.text.length }`);
var text = getLocaleSpecificMessage(message.key);
let text = getLocaleSpecificMessage(message.key);
if (arguments.length > 4) {
text = formatStringFromArgs(text, arguments, 4);
@@ -291,7 +298,7 @@ module ts {
export function createCompilerDiagnostic(message: DiagnosticMessage, ...args: any[]): Diagnostic;
export function createCompilerDiagnostic(message: DiagnosticMessage): Diagnostic {
var text = getLocaleSpecificMessage(message.key);
let text = getLocaleSpecificMessage(message.key);
if (arguments.length > 1) {
text = formatStringFromArgs(text, arguments, 1);
@@ -310,7 +317,7 @@ module ts {
export function chainDiagnosticMessages(details: DiagnosticMessageChain, message: DiagnosticMessage, ...args: any[]): DiagnosticMessageChain;
export function chainDiagnosticMessages(details: DiagnosticMessageChain, message: DiagnosticMessage): DiagnosticMessageChain {
var text = getLocaleSpecificMessage(message.key);
let text = getLocaleSpecificMessage(message.key);
if (arguments.length > 2) {
text = formatStringFromArgs(text, arguments, 2);
@@ -354,10 +361,10 @@ module ts {
function compareMessageText(text1: string | DiagnosticMessageChain, text2: string | DiagnosticMessageChain): Comparison {
while (text1 && text2) {
// We still have both chains.
var string1 = typeof text1 === "string" ? text1 : text1.messageText;
var string2 = typeof text2 === "string" ? text2 : text2.messageText;
let string1 = typeof text1 === "string" ? text1 : text1.messageText;
let string2 = typeof text2 === "string" ? text2 : text2.messageText;
var res = compareValues(string1, string2);
let res = compareValues(string1, string2);
if (res) {
return res;
}
@@ -384,11 +391,11 @@ module ts {
return diagnostics;
}
var newDiagnostics = [diagnostics[0]];
var previousDiagnostic = diagnostics[0];
for (var i = 1; i < diagnostics.length; i++) {
var currentDiagnostic = diagnostics[i];
var isDupe = compareDiagnostics(currentDiagnostic, previousDiagnostic) === Comparison.EqualTo;
let newDiagnostics = [diagnostics[0]];
let previousDiagnostic = diagnostics[0];
for (let i = 1; i < diagnostics.length; i++) {
let currentDiagnostic = diagnostics[i];
let isDupe = compareDiagnostics(currentDiagnostic, previousDiagnostic) === Comparison.EqualTo;
if (!isDupe) {
newDiagnostics.push(currentDiagnostic);
previousDiagnostic = currentDiagnostic;
@@ -406,9 +413,9 @@ module ts {
export function getRootLength(path: string): number {
if (path.charCodeAt(0) === CharacterCodes.slash) {
if (path.charCodeAt(1) !== CharacterCodes.slash) return 1;
var p1 = path.indexOf("/", 2);
let p1 = path.indexOf("/", 2);
if (p1 < 0) return 2;
var p2 = path.indexOf("/", p1 + 1);
let p2 = path.indexOf("/", p1 + 1);
if (p2 < 0) return p1 + 1;
return p2 + 1;
}
@@ -419,12 +426,11 @@ module ts {
return 0;
}
export var directorySeparator = "/";
export let directorySeparator = "/";
function getNormalizedParts(normalizedSlashedPath: string, rootLength: number) {
var parts = normalizedSlashedPath.substr(rootLength).split(directorySeparator);
var normalized: string[] = [];
for (var i = 0; i < parts.length; i++) {
var part = parts[i];
let parts = normalizedSlashedPath.substr(rootLength).split(directorySeparator);
let normalized: string[] = [];
for (let part of parts) {
if (part !== ".") {
if (part === ".." && normalized.length > 0 && normalized[normalized.length - 1] !== "..") {
normalized.pop();
@@ -443,9 +449,9 @@ module ts {
}
export function normalizePath(path: string): string {
var path = normalizeSlashes(path);
var rootLength = getRootLength(path);
var normalized = getNormalizedParts(path, rootLength);
path = normalizeSlashes(path);
let rootLength = getRootLength(path);
let normalized = getNormalizedParts(path, rootLength);
return path.substr(0, rootLength) + normalized.join(directorySeparator);
}
@@ -462,13 +468,13 @@ module ts {
}
function normalizedPathComponents(path: string, rootLength: number) {
var normalizedParts = getNormalizedParts(path, rootLength);
let normalizedParts = getNormalizedParts(path, rootLength);
return [path.substr(0, rootLength)].concat(normalizedParts);
}
export function getNormalizedPathComponents(path: string, currentDirectory: string) {
var path = normalizeSlashes(path);
var rootLength = getRootLength(path);
path = normalizeSlashes(path);
let rootLength = getRootLength(path);
if (rootLength == 0) {
// If the path is not rooted it is relative to current directory
path = combinePaths(normalizeSlashes(currentDirectory), path);
@@ -493,9 +499,9 @@ module ts {
// In this example the root is: http://www.website.com/
// normalized path components should be ["http://www.website.com/", "folder1", "folder2"]
var urlLength = url.length;
let urlLength = url.length;
// Initial root length is http:// part
var rootLength = url.indexOf("://") + "://".length;
let rootLength = url.indexOf("://") + "://".length;
while (rootLength < urlLength) {
// Consume all immediate slashes in the protocol
// eg.initial rootlength is just file:// but it needs to consume another "/" in file:///
@@ -514,7 +520,7 @@ module ts {
}
// Find the index of "/" after website.com so the root can be http://www.website.com/ (from existing http://)
var indexOfNextSlash = url.indexOf(directorySeparator, rootLength);
let indexOfNextSlash = url.indexOf(directorySeparator, rootLength);
if (indexOfNextSlash !== -1) {
// Found the "/" after the website.com so the root is length of http://www.website.com/
// and get components afetr the root normally like any other folder components
@@ -540,8 +546,8 @@ module ts {
}
export function getRelativePathToDirectoryOrUrl(directoryPathOrUrl: string, relativeOrAbsolutePath: string, currentDirectory: string, getCanonicalFileName: (fileName: string) => string, isAbsolutePathAnUrl: boolean) {
var pathComponents = getNormalizedPathOrUrlComponents(relativeOrAbsolutePath, currentDirectory);
var directoryComponents = getNormalizedPathOrUrlComponents(directoryPathOrUrl, currentDirectory);
let pathComponents = getNormalizedPathOrUrlComponents(relativeOrAbsolutePath, currentDirectory);
let directoryComponents = getNormalizedPathOrUrlComponents(directoryPathOrUrl, currentDirectory);
if (directoryComponents.length > 1 && directoryComponents[directoryComponents.length - 1] === "") {
// If the directory path given was of type test/cases/ then we really need components of directory to be only till its name
// that is ["test", "cases", ""] needs to be actually ["test", "cases"]
@@ -557,8 +563,8 @@ module ts {
// Get the relative path
if (joinStartIndex) {
var relativePath = "";
var relativePathComponents = pathComponents.slice(joinStartIndex, pathComponents.length);
let relativePath = "";
let relativePathComponents = pathComponents.slice(joinStartIndex, pathComponents.length);
for (; joinStartIndex < directoryComponents.length; joinStartIndex++) {
if (directoryComponents[joinStartIndex] !== "") {
relativePath = relativePath + ".." + directorySeparator;
@@ -569,7 +575,7 @@ module ts {
}
// Cant find the relative path, get the absolute path
var absolutePath = getNormalizedPathFromPathComponents(pathComponents);
let absolutePath = getNormalizedPathFromPathComponents(pathComponents);
if (isAbsolutePathAnUrl && isRootedDiskPath(absolutePath)) {
absolutePath = "file:///" + absolutePath;
}
@@ -578,7 +584,7 @@ module ts {
}
export function getBaseFileName(path: string) {
var i = path.lastIndexOf(directorySeparator);
let i = path.lastIndexOf(directorySeparator);
return i < 0 ? path : path.substring(i + 1);
}
@@ -591,16 +597,15 @@ module ts {
}
export function fileExtensionIs(path: string, extension: string): boolean {
var pathLen = path.length;
var extLen = extension.length;
let pathLen = path.length;
let extLen = extension.length;
return pathLen > extLen && path.substr(pathLen - extLen, extLen) === extension;
}
var supportedExtensions = [".d.ts", ".ts", ".js"];
let supportedExtensions = [".d.ts", ".ts", ".js"];
export function removeFileExtension(path: string): string {
for (var i = 0; i < supportedExtensions.length; i++) {
var ext = supportedExtensions[i];
for (let ext of supportedExtensions) {
if (fileExtensionIs(path, ext)) {
return path.substr(0, path.length - ext.length);
@@ -610,9 +615,9 @@ module ts {
return path;
}
var backslashOrDoubleQuote = /[\"\\]/g;
var escapedCharsRegExp = /[\u0000-\u001f\t\v\f\b\r\n\u2028\u2029\u0085]/g;
var escapedCharsMap: Map<string> = {
let backslashOrDoubleQuote = /[\"\\]/g;
let escapedCharsRegExp = /[\u0000-\u001f\t\v\f\b\r\n\u2028\u2029\u0085]/g;
let escapedCharsMap: Map<string> = {
"\0": "\\0",
"\t": "\\t",
"\v": "\\v",
@@ -651,7 +656,7 @@ module ts {
function Signature(checker: TypeChecker) {
}
export var objectAllocator: ObjectAllocator = {
export let objectAllocator: ObjectAllocator = {
getNodeConstructor: kind => {
function Node() {
}
@@ -677,7 +682,7 @@ module ts {
}
export module Debug {
var currentAssertionLevel = AssertionLevel.None;
let currentAssertionLevel = AssertionLevel.None;
export function shouldAssert(level: AssertionLevel): boolean {
return currentAssertionLevel >= level;
@@ -685,7 +690,7 @@ module ts {
export function assert(expression: boolean, message?: string, verboseDebugInfo?: () => string): void {
if (!expression) {
var verboseDebugString = "";
let verboseDebugString = "";
if (verboseDebugInfo) {
verboseDebugString = "\r\nVerbose Debug Information: " + verboseDebugInfo();
}
@@ -327,7 +327,6 @@ module ts {
Property_0_does_not_exist_on_const_enum_1: { code: 2479, category: DiagnosticCategory.Error, key: "Property '{0}' does not exist on 'const' enum '{1}'." },
let_is_not_allowed_to_be_used_as_a_name_in_let_or_const_declarations: { code: 2480, category: DiagnosticCategory.Error, key: "'let' is not allowed to be used as a name in 'let' or 'const' declarations." },
Cannot_initialize_outer_scoped_variable_0_in_the_same_scope_as_block_scoped_declaration_1: { code: 2481, category: DiagnosticCategory.Error, key: "Cannot initialize outer scoped variable '{0}' in the same scope as block scoped declaration '{1}'." },
for_of_statements_are_only_available_when_targeting_ECMAScript_6_or_higher: { code: 2482, category: DiagnosticCategory.Error, key: "'for...of' statements are only available when targeting ECMAScript 6 or higher." },
The_left_hand_side_of_a_for_of_statement_cannot_use_a_type_annotation: { code: 2483, category: DiagnosticCategory.Error, key: "The left-hand side of a 'for...of' statement cannot use a type annotation." },
Export_declaration_conflicts_with_exported_declaration_of_0: { code: 2484, category: DiagnosticCategory.Error, key: "Export declaration conflicts with exported declaration of '{0}'" },
The_left_hand_side_of_a_for_of_statement_cannot_be_a_previously_defined_constant: { code: 2485, category: DiagnosticCategory.Error, key: "The left-hand side of a 'for...of' statement cannot be a previously defined constant." },
@@ -338,6 +337,9 @@ module ts {
The_type_returned_by_the_next_method_of_an_iterator_must_have_a_value_property: { code: 2490, category: DiagnosticCategory.Error, key: "The type returned by the 'next()' method of an iterator must have a 'value' property." },
The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern: { code: 2491, category: DiagnosticCategory.Error, key: "The left-hand side of a 'for...in' statement cannot be a destructuring pattern." },
Cannot_redeclare_identifier_0_in_catch_clause: { code: 2492, category: DiagnosticCategory.Error, key: "Cannot redeclare identifier '{0}' in catch clause" },
Tuple_type_0_with_length_1_cannot_be_assigned_to_tuple_with_length_2: { code: 2493, category: DiagnosticCategory.Error, key: "Tuple type '{0}' with length '{1}' cannot be assigned to tuple with length '{2}'." },
Using_a_string_in_a_for_of_statement_is_only_supported_in_ECMAScript_5_and_higher: { code: 2494, category: DiagnosticCategory.Error, key: "Using a string in a 'for...of' statement is only supported in ECMAScript 5 and higher." },
Type_0_is_not_an_array_type_or_a_string_type: { code: 2461, category: DiagnosticCategory.Error, key: "Type '{0}' is not an array type or a string type." },
Import_declaration_0_is_using_private_name_1: { code: 4000, category: DiagnosticCategory.Error, key: "Import declaration '{0}' is using private name '{1}'." },
Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: { code: 4002, category: DiagnosticCategory.Error, key: "Type parameter '{0}' of exported class has or is using private name '{1}'." },
Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1: { code: 4004, category: DiagnosticCategory.Error, key: "Type parameter '{0}' of exported interface has or is using private name '{1}'." },
+12 -4
View File
@@ -1299,10 +1299,6 @@
"category": "Error",
"code": 2481
},
"'for...of' statements are only available when targeting ECMAScript 6 or higher.": {
"category": "Error",
"code": 2482
},
"The left-hand side of a 'for...of' statement cannot use a type annotation.": {
"category": "Error",
"code": 2483
@@ -1343,6 +1339,18 @@
"category": "Error",
"code": 2492
},
"Tuple type '{0}' with length '{1}' cannot be assigned to tuple with length '{2}'.": {
"category": "Error",
"code": 2493
},
"Using a string in a 'for...of' statement is only supported in ECMAScript 5 and higher.": {
"category": "Error",
"code": 2494
},
"Type '{0}' is not an array type or a string type.": {
"category": "Error",
"code": 2461
},
"Import declaration '{0}' is using private name '{1}'.": {
"category": "Error",
+560 -402
View File
File diff suppressed because it is too large Load Diff
+312 -302
View File
File diff suppressed because it is too large Load Diff
+87 -87
View File
File diff suppressed because one or more lines are too long
+7 -8
View File
@@ -124,15 +124,14 @@ module ts {
function visitDirectory(path: string) {
var folder = fso.GetFolder(path || ".");
var files = getNames(folder.files);
for (var i = 0; i < files.length; i++) {
var name = files[i];
for (let name of files) {
if (!extension || fileExtensionIs(name, extension)) {
result.push(combinePaths(path, name));
}
}
var subfolders = getNames(folder.subfolders);
for (var i = 0; i < subfolders.length; i++) {
visitDirectory(combinePaths(path, subfolders[i]));
for (let current of subfolders) {
visitDirectory(combinePaths(path, current));
}
}
}
@@ -230,8 +229,8 @@ module ts {
function visitDirectory(path: string) {
var files = _fs.readdirSync(path || ".").sort();
var directories: string[] = [];
for (var i = 0; i < files.length; i++) {
var name = combinePaths(path, files[i]);
for (let current of files) {
var name = combinePaths(path, current);
var stat = _fs.lstatSync(name);
if (stat.isFile()) {
if (!extension || fileExtensionIs(name, extension)) {
@@ -242,8 +241,8 @@ module ts {
directories.push(name);
}
}
for (var i = 0; i < directories.length; i++) {
visitDirectory(directories[i]);
for (let current of directories) {
visitDirectory(current);
}
}
}
+5
View File
@@ -233,6 +233,7 @@ module ts {
EnumDeclaration,
ModuleDeclaration,
ModuleBlock,
CaseBlock,
ImportEqualsDeclaration,
ImportDeclaration,
ImportClause,
@@ -790,6 +791,10 @@ module ts {
export interface SwitchStatement extends Statement {
expression: Expression;
caseBlock: CaseBlock;
}
export interface CaseBlock extends Node {
clauses: NodeArray<CaseOrDefaultClause>;
}
+34 -6
View File
@@ -15,8 +15,7 @@ module ts {
export function getDeclarationOfKind(symbol: Symbol, kind: SyntaxKind): Declaration {
var declarations = symbol.declarations;
for (var i = 0; i < declarations.length; i++) {
var declaration = declarations[i];
for (let declaration of declarations) {
if (declaration.kind === kind) {
return declaration;
}
@@ -203,6 +202,33 @@ module ts {
isCatchClauseVariableDeclaration(declaration);
}
export function getEnclosingBlockScopeContainer(node: Node): Node {
var current = node;
while (current) {
if (isFunctionLike(current)) {
return current;
}
switch (current.kind) {
case SyntaxKind.SourceFile:
case SyntaxKind.CaseBlock:
case SyntaxKind.CatchClause:
case SyntaxKind.ModuleDeclaration:
case SyntaxKind.ForStatement:
case SyntaxKind.ForInStatement:
case SyntaxKind.ForOfStatement:
return current;
case SyntaxKind.Block:
// function block is not considered block-scope container
// see comment in binder.ts: bind(...), case for SyntaxKind.Block
if (!isFunctionLike(current.parent)) {
return current;
}
}
current = current.parent;
}
}
export function isCatchClauseVariableDeclaration(declaration: Declaration) {
return declaration &&
declaration.kind === SyntaxKind.VariableDeclaration &&
@@ -376,6 +402,7 @@ module ts {
switch (node.kind) {
case SyntaxKind.ReturnStatement:
return visitor(<ReturnStatement>node);
case SyntaxKind.CaseBlock:
case SyntaxKind.Block:
case SyntaxKind.IfStatement:
case SyntaxKind.DoStatement:
@@ -824,9 +851,9 @@ module ts {
export function getHeritageClause(clauses: NodeArray<HeritageClause>, kind: SyntaxKind) {
if (clauses) {
for (var i = 0, n = clauses.length; i < n; i++) {
if (clauses[i].token === kind) {
return clauses[i];
for (let clause of clauses) {
if (clause.token === kind) {
return clause;
}
}
}
@@ -1207,6 +1234,7 @@ module ts {
}
}
// @internal
export function createDiagnosticCollection(): DiagnosticCollection {
var nonFileDiagnostics: Diagnostic[] = [];
var fileDiagnostics: Map<Diagnostic[]> = {};
@@ -1336,4 +1364,4 @@ module ts {
s.replace(nonAsciiCharacters, c => get16BitUnicodeEscapeSequence(c.charCodeAt(0))) :
s;
}
}
}
+3 -3
View File
@@ -164,19 +164,19 @@ interface ObjectConstructor {
* Prevents the modification of attributes of existing properties, and prevents the addition of new properties.
* @param o Object on which to lock the attributes.
*/
seal(o: any): any;
seal<T>(o: T): T;
/**
* Prevents the modification of existing property attributes and values, and prevents the addition of new properties.
* @param o Object on which to lock the attributes.
*/
freeze(o: any): any;
freeze<T>(o: T): T;
/**
* Prevents the addition of new properties to an object.
* @param o Object to make non-extensible.
*/
preventExtensions(o: any): any;
preventExtensions<T>(o: T): T;
/**
* Returns true if existing property attributes cannot be modified in an object and new properties cannot be added to the object.
+22 -22
View File
@@ -13,13 +13,13 @@ module ts.BreakpointResolver {
return undefined;
}
var tokenAtLocation = getTokenAtPosition(sourceFile, position);
var lineOfPosition = sourceFile.getLineAndCharacterOfPosition(position).line;
let tokenAtLocation = getTokenAtPosition(sourceFile, position);
let lineOfPosition = sourceFile.getLineAndCharacterOfPosition(position).line;
if (sourceFile.getLineAndCharacterOfPosition(tokenAtLocation.getStart()).line > lineOfPosition) {
// Get previous token if the token is returned starts on new line
// eg: var x =10; |--- cursor is here
// var y = 10;
// token at position will return var keyword on second line as the token but we would like to use
// eg: let x =10; |--- cursor is here
// let y = 10;
// token at position will return let keyword on second line as the token but we would like to use
// token on same line if trailing trivia (comments or white spaces on same line) part of the last token on that line
tokenAtLocation = findPrecedingToken(tokenAtLocation.pos, sourceFile);
@@ -275,9 +275,9 @@ module ts.BreakpointResolver {
return spanInNode(variableDeclaration.parent.parent);
}
var isParentVariableStatement = variableDeclaration.parent.parent.kind === SyntaxKind.VariableStatement;
var isDeclarationOfForStatement = variableDeclaration.parent.parent.kind === SyntaxKind.ForStatement && contains((<VariableDeclarationList>(<ForStatement>variableDeclaration.parent.parent).initializer).declarations, variableDeclaration);
var declarations = isParentVariableStatement
let isParentVariableStatement = variableDeclaration.parent.parent.kind === SyntaxKind.VariableStatement;
let isDeclarationOfForStatement = variableDeclaration.parent.parent.kind === SyntaxKind.ForStatement && contains((<VariableDeclarationList>(<ForStatement>variableDeclaration.parent.parent).initializer).declarations, variableDeclaration);
let declarations = isParentVariableStatement
? (<VariableStatement>variableDeclaration.parent.parent).declarationList.declarations
: isDeclarationOfForStatement
? (<VariableDeclarationList>(<ForStatement>variableDeclaration.parent.parent).initializer).declarations
@@ -287,12 +287,12 @@ module ts.BreakpointResolver {
if (variableDeclaration.initializer || (variableDeclaration.flags & NodeFlags.Export)) {
if (declarations && declarations[0] === variableDeclaration) {
if (isParentVariableStatement) {
// First declaration - include var keyword
// First declaration - include let keyword
return textSpan(variableDeclaration.parent, variableDeclaration);
}
else {
Debug.assert(isDeclarationOfForStatement);
// Include var keyword from for statement declarations in the span
// Include let keyword from for statement declarations in the span
return textSpan(findPrecedingToken(variableDeclaration.pos, sourceFile, variableDeclaration.parent), variableDeclaration);
}
}
@@ -303,7 +303,7 @@ module ts.BreakpointResolver {
}
else if (declarations && declarations[0] !== variableDeclaration) {
// If we cant set breakpoint on this declaration, set it on previous one
var indexOfCurrentDeclaration = indexOf(declarations, variableDeclaration);
let indexOfCurrentDeclaration = indexOf(declarations, variableDeclaration);
return spanInVariableDeclaration(declarations[indexOfCurrentDeclaration - 1]);
}
}
@@ -319,8 +319,8 @@ module ts.BreakpointResolver {
return textSpan(parameter);
}
else {
var functionDeclaration = <FunctionLikeDeclaration>parameter.parent;
var indexOfParameter = indexOf(functionDeclaration.parameters, parameter);
let functionDeclaration = <FunctionLikeDeclaration>parameter.parent;
let indexOfParameter = indexOf(functionDeclaration.parameters, parameter);
if (indexOfParameter) {
// Not a first parameter, go to previous parameter
return spanInParameterDeclaration(functionDeclaration.parameters[indexOfParameter - 1]);
@@ -353,7 +353,7 @@ module ts.BreakpointResolver {
}
function spanInFunctionBlock(block: Block): TextSpan {
var nodeForSpanInBlock = block.statements.length ? block.statements[0] : block.getLastToken();
let nodeForSpanInBlock = block.statements.length ? block.statements[0] : block.getLastToken();
if (canFunctionHaveSpanInWholeDeclaration(<FunctionLikeDeclaration>block.parent)) {
return spanInNodeIfStartsOnSameLine(block.parent, nodeForSpanInBlock);
}
@@ -387,7 +387,7 @@ module ts.BreakpointResolver {
function spanInForStatement(forStatement: ForStatement): TextSpan {
if (forStatement.initializer) {
if (forStatement.initializer.kind === SyntaxKind.VariableDeclarationList) {
var variableDeclarationList = <VariableDeclarationList>forStatement.initializer;
let variableDeclarationList = <VariableDeclarationList>forStatement.initializer;
if (variableDeclarationList.declarations.length > 0) {
return spanInNode(variableDeclarationList.declarations[0]);
}
@@ -409,15 +409,15 @@ module ts.BreakpointResolver {
function spanInOpenBraceToken(node: Node): TextSpan {
switch (node.parent.kind) {
case SyntaxKind.EnumDeclaration:
var enumDeclaration = <EnumDeclaration>node.parent;
let enumDeclaration = <EnumDeclaration>node.parent;
return spanInNodeIfStartsOnSameLine(findPrecedingToken(node.pos, sourceFile, node.parent), enumDeclaration.members.length ? enumDeclaration.members[0] : enumDeclaration.getLastToken(sourceFile));
case SyntaxKind.ClassDeclaration:
var classDeclaration = <ClassDeclaration>node.parent;
let classDeclaration = <ClassDeclaration>node.parent;
return spanInNodeIfStartsOnSameLine(findPrecedingToken(node.pos, sourceFile, node.parent), classDeclaration.members.length ? classDeclaration.members[0] : classDeclaration.getLastToken(sourceFile));
case SyntaxKind.SwitchStatement:
return spanInNodeIfStartsOnSameLine(node.parent, (<SwitchStatement>node.parent).clauses[0]);
case SyntaxKind.CaseBlock:
return spanInNodeIfStartsOnSameLine(node.parent.parent, (<CaseBlock>node.parent).clauses[0]);
}
// Default to parent node
@@ -447,10 +447,10 @@ module ts.BreakpointResolver {
case SyntaxKind.CatchClause:
return spanInNode((<Block>node.parent).statements[(<Block>node.parent).statements.length - 1]);;
case SyntaxKind.SwitchStatement:
case SyntaxKind.CaseBlock:
// breakpoint in last statement of the last clause
var switchStatement = <SwitchStatement>node.parent;
var lastClause = switchStatement.clauses[switchStatement.clauses.length - 1];
let caseBlock = <CaseBlock>node.parent;
let lastClause = caseBlock.clauses[caseBlock.clauses.length - 1];
if (lastClause) {
return spanInNode(lastClause.statements[lastClause.statements.length - 1]);
}
+4 -6
View File
@@ -609,8 +609,8 @@ module ts.formatting {
}
var inheritedIndentation = Constants.Unknown;
for (var i = 0, len = nodes.length; i < len; ++i) {
inheritedIndentation = processChildNode(nodes[i], inheritedIndentation, node, listDynamicIndentation, startLine, /*isListElement*/ true)
for (let child of nodes) {
inheritedIndentation = processChildNode(child, inheritedIndentation, node, listDynamicIndentation, startLine, /*isListElement*/ true)
}
if (listEndToken !== SyntaxKind.Unknown) {
@@ -668,8 +668,7 @@ module ts.formatting {
if (indentToken) {
var indentNextTokenOrTrivia = true;
if (currentTokenInfo.leadingTrivia) {
for (var i = 0, len = currentTokenInfo.leadingTrivia.length; i < len; ++i) {
var triviaItem = currentTokenInfo.leadingTrivia[i];
for (let triviaItem of currentTokenInfo.leadingTrivia) {
if (!rangeContainsRange(originalRange, triviaItem)) {
continue;
}
@@ -709,8 +708,7 @@ module ts.formatting {
}
function processTrivia(trivia: TextRangeWithKind[], parent: Node, contextNode: Node, dynamicIndentation: DynamicIndentation): void {
for (var i = 0, len = trivia.length; i < len; ++i) {
var triviaItem = trivia[i];
for (let triviaItem of trivia) {
if (isComment(triviaItem.kind) && rangeContainsRange(originalRange, triviaItem)) {
var triviaItemStart = sourceFile.getLineAndCharacterOfPosition(triviaItem.pos);
processRange(triviaItem, triviaItemStart, parent, contextNode, dynamicIndentation);
@@ -36,8 +36,8 @@ module ts.formatting {
return true;
}
for (var i = 0, len = this.customContextChecks.length; i < len; i++) {
if (!this.customContextChecks[i](context)) {
for (let check of this.customContextChecks) {
if (!check(context)) {
return false;
}
}
+1 -1
View File
@@ -541,7 +541,7 @@ module ts.formatting {
switch (node.kind) {
case SyntaxKind.Block:
case SyntaxKind.SwitchStatement:
case SyntaxKind.CaseBlock:
case SyntaxKind.ObjectLiteralExpression:
case SyntaxKind.ModuleBlock:
return true;
+3 -3
View File
@@ -76,10 +76,10 @@ module ts.formatting {
var bucketIndex = this.GetRuleBucketIndex(context.currentTokenSpan.kind, context.nextTokenSpan.kind);
var bucket = this.map[bucketIndex];
if (bucket != null) {
for (var i = 0, len = bucket.Rules().length; i < len; i++) {
var rule = bucket.Rules()[i];
if (rule.Operation.Context.InContext(context))
for (let rule of bucket.Rules()) {
if (rule.Operation.Context.InContext(context)) {
return rule;
}
}
}
return null;
+8 -2
View File
@@ -357,7 +357,7 @@ module ts.formatting {
case SyntaxKind.ModuleBlock:
case SyntaxKind.ObjectLiteralExpression:
case SyntaxKind.TypeLiteral:
case SyntaxKind.SwitchStatement:
case SyntaxKind.CaseBlock:
case SyntaxKind.DefaultClause:
case SyntaxKind.CaseClause:
case SyntaxKind.ParenthesizedExpression:
@@ -431,7 +431,7 @@ module ts.formatting {
case SyntaxKind.ObjectLiteralExpression:
case SyntaxKind.Block:
case SyntaxKind.ModuleBlock:
case SyntaxKind.SwitchStatement:
case SyntaxKind.CaseBlock:
return nodeEndsWith(n, SyntaxKind.CloseBraceToken, sourceFile);
case SyntaxKind.CatchClause:
return isCompletedNode((<CatchClause>n).block, sourceFile);
@@ -461,6 +461,12 @@ module ts.formatting {
case SyntaxKind.DefaultClause:
// there is no such thing as terminator token for CaseClause\DefaultClause so for simplicitly always consider them non-completed
return false;
case SyntaxKind.ForStatement:
return isCompletedNode((<ForStatement>n).statement, sourceFile);
case SyntaxKind.ForInStatement:
return isCompletedNode((<ForInStatement>n).statement, sourceFile);
case SyntaxKind.ForOfStatement:
return isCompletedNode((<ForOfStatement>n).statement, sourceFile);
case SyntaxKind.WhileStatement:
return isCompletedNode((<WhileStatement>n).statement, sourceFile);
case SyntaxKind.DoStatement:
+23 -24
View File
@@ -2,22 +2,21 @@ module ts.NavigateTo {
type RawNavigateToItem = { name: string; fileName: string; matchKind: PatternMatchKind; isCaseSensitive: boolean; declaration: Declaration };
export function getNavigateToItems(program: Program, cancellationToken: CancellationTokenObject, searchValue: string, maxResultCount: number): NavigateToItem[] {
var patternMatcher = createPatternMatcher(searchValue);
var rawItems: RawNavigateToItem[] = [];
let patternMatcher = createPatternMatcher(searchValue);
let rawItems: RawNavigateToItem[] = [];
// Search the declarations in all files and output matched NavigateToItem into array of NavigateToItem[]
forEach(program.getSourceFiles(), sourceFile => {
cancellationToken.throwIfCancellationRequested();
var declarations = sourceFile.getNamedDeclarations();
for (var i = 0, n = declarations.length; i < n; i++) {
var declaration = declarations[i];
let declarations = sourceFile.getNamedDeclarations();
for (let declaration of declarations) {
var name = getDeclarationName(declaration);
if (name !== undefined) {
// First do a quick check to see if the name of the declaration matches the
// last portion of the (possibly) dotted name they're searching for.
var matches = patternMatcher.getMatchesForLastSegmentOfPattern(name);
let matches = patternMatcher.getMatchesForLastSegmentOfPattern(name);
if (!matches) {
continue;
@@ -26,7 +25,7 @@ module ts.NavigateTo {
// It was a match! If the pattern has dots in it, then also see if hte
// declaration container matches as well.
if (patternMatcher.patternContainsDots) {
var containers = getContainers(declaration);
let containers = getContainers(declaration);
if (!containers) {
return undefined;
}
@@ -38,8 +37,8 @@ module ts.NavigateTo {
}
}
var fileName = sourceFile.fileName;
var matchKind = bestMatchKind(matches);
let fileName = sourceFile.fileName;
let matchKind = bestMatchKind(matches);
rawItems.push({ name, fileName, matchKind, isCaseSensitive: allMatchesAreCaseSensitive(matches), declaration });
}
}
@@ -50,7 +49,7 @@ module ts.NavigateTo {
rawItems = rawItems.slice(0, maxResultCount);
}
var items = map(rawItems, createNavigateToItem);
let items = map(rawItems, createNavigateToItem);
return items;
@@ -58,8 +57,8 @@ module ts.NavigateTo {
Debug.assert(matches.length > 0);
// This is a case sensitive match, only if all the submatches were case sensitive.
for (var i = 0, n = matches.length; i < n; i++) {
if (!matches[i].isCaseSensitive) {
for (let match of matches) {
if (!match.isCaseSensitive) {
return false;
}
}
@@ -68,13 +67,13 @@ module ts.NavigateTo {
}
function getDeclarationName(declaration: Declaration): string {
var result = getTextOfIdentifierOrLiteral(declaration.name);
let result = getTextOfIdentifierOrLiteral(declaration.name);
if (result !== undefined) {
return result;
}
if (declaration.name.kind === SyntaxKind.ComputedPropertyName) {
var expr = (<ComputedPropertyName>declaration.name).expression;
let expr = (<ComputedPropertyName>declaration.name).expression;
if (expr.kind === SyntaxKind.PropertyAccessExpression) {
return (<PropertyAccessExpression>expr).name.text;
}
@@ -98,7 +97,7 @@ module ts.NavigateTo {
function tryAddSingleDeclarationName(declaration: Declaration, containers: string[]) {
if (declaration && declaration.name) {
var text = getTextOfIdentifierOrLiteral(declaration.name);
let text = getTextOfIdentifierOrLiteral(declaration.name);
if (text !== undefined) {
containers.unshift(text);
}
@@ -118,7 +117,7 @@ module ts.NavigateTo {
//
// [X.Y.Z]() { }
function tryAddComputedPropertyName(expression: Expression, containers: string[], includeLastPortion: boolean): boolean {
var text = getTextOfIdentifierOrLiteral(expression);
let text = getTextOfIdentifierOrLiteral(expression);
if (text !== undefined) {
if (includeLastPortion) {
containers.unshift(text);
@@ -127,7 +126,7 @@ module ts.NavigateTo {
}
if (expression.kind === SyntaxKind.PropertyAccessExpression) {
var propertyAccess = <PropertyAccessExpression>expression;
let propertyAccess = <PropertyAccessExpression>expression;
if (includeLastPortion) {
containers.unshift(propertyAccess.name.text);
}
@@ -139,7 +138,7 @@ module ts.NavigateTo {
}
function getContainers(declaration: Declaration) {
var containers: string[] = [];
let containers: string[] = [];
// First, if we started with a computed property name, then add all but the last
// portion into the container array.
@@ -165,10 +164,10 @@ module ts.NavigateTo {
function bestMatchKind(matches: PatternMatch[]) {
Debug.assert(matches.length > 0);
var bestMatchKind = PatternMatchKind.camelCase;
let bestMatchKind = PatternMatchKind.camelCase;
for (var i = 0, n = matches.length; i < n; i++) {
var kind = matches[i].kind;
for (let match of matches) {
let kind = match.kind;
if (kind < bestMatchKind) {
bestMatchKind = kind;
}
@@ -178,7 +177,7 @@ module ts.NavigateTo {
}
// This means "compare in a case insensitive manner."
var baseSensitivity: Intl.CollatorOptions = { sensitivity: "base" };
let baseSensitivity: Intl.CollatorOptions = { sensitivity: "base" };
function compareNavigateToItems(i1: RawNavigateToItem, i2: RawNavigateToItem) {
// TODO(cyrusn): get the gamut of comparisons that VS already uses here.
// Right now we just sort by kind first, and then by name of the item.
@@ -190,8 +189,8 @@ module ts.NavigateTo {
}
function createNavigateToItem(rawItem: RawNavigateToItem): NavigateToItem {
var declaration = rawItem.declaration;
var container = <Declaration>getContainerNode(declaration);
let declaration = rawItem.declaration;
let container = <Declaration>getContainerNode(declaration);
return {
name: rawItem.name,
kind: getNodeKind(declaration),
+33 -39
View File
@@ -4,16 +4,16 @@ module ts.NavigationBar {
export function getNavigationBarItems(sourceFile: SourceFile): ts.NavigationBarItem[] {
// If the source file has any child items, then it included in the tree
// and takes lexical ownership of all other top-level items.
var hasGlobalNode = false;
let hasGlobalNode = false;
return getItemsWorker(getTopLevelNodes(sourceFile), createTopLevelItem);
function getIndent(node: Node): number {
// If we have a global node in the tree,
// then it adds an extra layer of depth to all subnodes.
var indent = hasGlobalNode ? 1 : 0;
let indent = hasGlobalNode ? 1 : 0;
var current = node.parent;
let current = node.parent;
while (current) {
switch (current.kind) {
case SyntaxKind.ModuleDeclaration:
@@ -39,7 +39,7 @@ module ts.NavigationBar {
}
function getChildNodes(nodes: Node[]): Node[] {
var childNodes: Node[] = [];
let childNodes: Node[] = [];
function visit(node: Node) {
switch (node.kind) {
@@ -60,7 +60,7 @@ module ts.NavigationBar {
break;
case SyntaxKind.ImportDeclaration:
var importClause = (<ImportDeclaration>node).importClause;
let importClause = (<ImportDeclaration>node).importClause;
if (importClause) {
// Handle default import case e.g.:
// import d from "mod";
@@ -102,8 +102,8 @@ module ts.NavigationBar {
}
}
//for (var i = 0, n = nodes.length; i < n; i++) {
// var node = nodes[i];
//for (let i = 0, n = nodes.length; i < n; i++) {
// let node = nodes[i];
// if (node.kind === SyntaxKind.ClassDeclaration ||
// node.kind === SyntaxKind.EnumDeclaration ||
@@ -122,7 +122,7 @@ module ts.NavigationBar {
}
function getTopLevelNodes(node: SourceFile): Node[] {
var topLevelNodes: Node[] = [];
let topLevelNodes: Node[] = [];
topLevelNodes.push(node);
addTopLevelNodes(node.statements, topLevelNodes);
@@ -150,8 +150,7 @@ module ts.NavigationBar {
function addTopLevelNodes(nodes: Node[], topLevelNodes: Node[]): void {
nodes = sortNodes(nodes);
for (var i = 0, n = nodes.length; i < n; i++) {
var node = nodes[i];
for (let node of nodes) {
switch (node.kind) {
case SyntaxKind.ClassDeclaration:
case SyntaxKind.EnumDeclaration:
@@ -160,13 +159,13 @@ module ts.NavigationBar {
break;
case SyntaxKind.ModuleDeclaration:
var moduleDeclaration = <ModuleDeclaration>node;
let moduleDeclaration = <ModuleDeclaration>node;
topLevelNodes.push(node);
addTopLevelNodes((<Block>getInnermostModule(moduleDeclaration).body).statements, topLevelNodes);
break;
case SyntaxKind.FunctionDeclaration:
var functionDeclaration = <FunctionLikeDeclaration>node;
let functionDeclaration = <FunctionLikeDeclaration>node;
if (isTopLevelFunctionDeclaration(functionDeclaration)) {
topLevelNodes.push(node);
addTopLevelNodes((<Block>functionDeclaration.body).statements, topLevelNodes);
@@ -200,18 +199,17 @@ module ts.NavigationBar {
}
function getItemsWorker(nodes: Node[], createItem: (n: Node) => ts.NavigationBarItem): ts.NavigationBarItem[] {
var items: ts.NavigationBarItem[] = [];
let items: ts.NavigationBarItem[] = [];
var keyToItem: Map<NavigationBarItem> = {};
let keyToItem: Map<NavigationBarItem> = {};
for (var i = 0, n = nodes.length; i < n; i++) {
var child = nodes[i];
var item = createItem(child);
for (let child of nodes) {
let item = createItem(child);
if (item !== undefined) {
if (item.text.length > 0) {
var key = item.text + "-" + item.kind + "-" + item.indent;
let key = item.text + "-" + item.kind + "-" + item.indent;
var itemWithSameName = keyToItem[key];
let itemWithSameName = keyToItem[key];
if (itemWithSameName) {
// We had an item with the same name. Merge these items together.
merge(itemWithSameName, item);
@@ -238,12 +236,8 @@ module ts.NavigationBar {
// Next, recursively merge or add any children in the source as appropriate.
outer:
for (var i = 0, n = source.childItems.length; i < n; i++) {
var sourceChild = source.childItems[i];
for (var j = 0, m = target.childItems.length; j < m; j++) {
var targetChild = target.childItems[j];
for (let sourceChild of source.childItems) {
for (let targetChild of target.childItems) {
if (targetChild.text === sourceChild.text && targetChild.kind === sourceChild.kind) {
// Found a match. merge them.
merge(targetChild, sourceChild);
@@ -299,8 +293,8 @@ module ts.NavigationBar {
case SyntaxKind.VariableDeclaration:
case SyntaxKind.BindingElement:
var variableDeclarationNode: Node;
var name: Node;
let variableDeclarationNode: Node;
let name: Node;
if (node.kind === SyntaxKind.BindingElement) {
name = (<BindingElement>node).name;
@@ -397,7 +391,7 @@ module ts.NavigationBar {
}
// Otherwise, we need to aggregate each identifier to build up the qualified name.
var result: string[] = [];
let result: string[] = [];
result.push(moduleDeclaration.name.text);
@@ -411,9 +405,9 @@ module ts.NavigationBar {
}
function createModuleItem(node: ModuleDeclaration): NavigationBarItem {
var moduleName = getModuleName(node);
let moduleName = getModuleName(node);
var childItems = getItemsWorker(getChildNodes((<Block>getInnermostModule(node).body).statements), createChildItem);
let childItems = getItemsWorker(getChildNodes((<Block>getInnermostModule(node).body).statements), createChildItem);
return getNavigationBarItem(moduleName,
ts.ScriptElementKind.moduleElement,
@@ -425,7 +419,7 @@ module ts.NavigationBar {
function createFunctionItem(node: FunctionDeclaration) {
if (node.name && node.body && node.body.kind === SyntaxKind.Block) {
var childItems = getItemsWorker(sortNodes((<Block>node.body).statements), createChildItem);
let childItems = getItemsWorker(sortNodes((<Block>node.body).statements), createChildItem);
return getNavigationBarItem(node.name.text,
ts.ScriptElementKind.functionElement,
@@ -439,14 +433,14 @@ module ts.NavigationBar {
}
function createSourceFileItem(node: SourceFile): ts.NavigationBarItem {
var childItems = getItemsWorker(getChildNodes(node.statements), createChildItem);
let childItems = getItemsWorker(getChildNodes(node.statements), createChildItem);
if (childItems === undefined || childItems.length === 0) {
return undefined;
}
hasGlobalNode = true;
var rootName = isExternalModule(node)
let rootName = isExternalModule(node)
? "\"" + escapeString(getBaseFileName(removeFileExtension(normalizePath(node.fileName)))) + "\""
: "<global>"
@@ -463,22 +457,22 @@ module ts.NavigationBar {
return undefined;
}
var childItems: NavigationBarItem[];
let childItems: NavigationBarItem[];
if (node.members) {
var constructor = <ConstructorDeclaration>forEach(node.members, member => {
let constructor = <ConstructorDeclaration>forEach(node.members, member => {
return member.kind === SyntaxKind.Constructor && member;
});
// Add the constructor parameters in as children of the class (for property parameters).
// Note that *all non-binding pattern named* parameters will be added to the nodes array, but parameters that
// are not properties will be filtered out later by createChildItem.
var nodes: Node[] = removeDynamicallyNamedProperties(node);
let nodes: Node[] = removeDynamicallyNamedProperties(node);
if (constructor) {
nodes.push.apply(nodes, filter(constructor.parameters, p => !isBindingPattern(p.name)));
}
var childItems = getItemsWorker(sortNodes(nodes), createChildItem);
childItems = getItemsWorker(sortNodes(nodes), createChildItem);
}
return getNavigationBarItem(
@@ -491,7 +485,7 @@ module ts.NavigationBar {
}
function createEnumItem(node: EnumDeclaration): ts.NavigationBarItem {
var childItems = getItemsWorker(sortNodes(removeComputedProperties(node)), createChildItem);
let childItems = getItemsWorker(sortNodes(removeComputedProperties(node)), createChildItem);
return getNavigationBarItem(
node.name.text,
ts.ScriptElementKind.enumElement,
@@ -502,7 +496,7 @@ module ts.NavigationBar {
}
function createIterfaceItem(node: InterfaceDeclaration): ts.NavigationBarItem {
var childItems = getItemsWorker(sortNodes(removeDynamicallyNamedProperties(node)), createChildItem);
let childItems = getItemsWorker(sortNodes(removeDynamicallyNamedProperties(node)), createChildItem);
return getNavigationBarItem(
node.name.text,
ts.ScriptElementKind.interfaceElement,
+21 -19
View File
@@ -16,12 +16,12 @@
module ts {
export module OutliningElementsCollector {
export function collectElements(sourceFile: SourceFile): OutliningSpan[] {
var elements: OutliningSpan[] = [];
var collapseText = "...";
let elements: OutliningSpan[] = [];
let collapseText = "...";
function addOutliningSpan(hintSpanNode: Node, startElement: Node, endElement: Node, autoCollapse: boolean) {
if (hintSpanNode && startElement && endElement) {
var span: OutliningSpan = {
let span: OutliningSpan = {
textSpan: createTextSpanFromBounds(startElement.pos, endElement.end),
hintSpan: createTextSpanFromBounds(hintSpanNode.getStart(), hintSpanNode.end),
bannerText: collapseText,
@@ -35,8 +35,8 @@ module ts {
return isFunctionBlock(node) && node.parent.kind !== SyntaxKind.ArrowFunction;
}
var depth = 0;
var maxDepth = 20;
let depth = 0;
let maxDepth = 20;
function walk(n: Node): void {
if (depth > maxDepth) {
return;
@@ -44,9 +44,9 @@ module ts {
switch (n.kind) {
case SyntaxKind.Block:
if (!isFunctionBlock(n)) {
var parent = n.parent;
var openBrace = findChildOfKind(n, SyntaxKind.OpenBraceToken, sourceFile);
var closeBrace = findChildOfKind(n, SyntaxKind.CloseBraceToken, sourceFile);
let parent = n.parent;
let openBrace = findChildOfKind(n, SyntaxKind.OpenBraceToken, sourceFile);
let closeBrace = findChildOfKind(n, SyntaxKind.CloseBraceToken, sourceFile);
// Check if the block is standalone, or 'attached' to some parent statement.
// If the latter, we want to collaps the block, but consider its hint span
@@ -66,13 +66,13 @@ module ts {
if (parent.kind === SyntaxKind.TryStatement) {
// Could be the try-block, or the finally-block.
var tryStatement = <TryStatement>parent;
let tryStatement = <TryStatement>parent;
if (tryStatement.tryBlock === n) {
addOutliningSpan(parent, openBrace, closeBrace, autoCollapse(n));
break;
}
else if (tryStatement.finallyBlock === n) {
var finallyKeyword = findChildOfKind(tryStatement, SyntaxKind.FinallyKeyword, sourceFile);
let finallyKeyword = findChildOfKind(tryStatement, SyntaxKind.FinallyKeyword, sourceFile);
if (finallyKeyword) {
addOutliningSpan(finallyKeyword, openBrace, closeBrace, autoCollapse(n));
break;
@@ -84,7 +84,7 @@ module ts {
// Block was a standalone block. In this case we want to only collapse
// the span of the block, independent of any parent span.
var span = createTextSpanFromBounds(n.getStart(), n.end);
let span = createTextSpanFromBounds(n.getStart(), n.end);
elements.push({
textSpan: span,
hintSpan: span,
@@ -95,23 +95,25 @@ module ts {
}
// Fallthrough.
case SyntaxKind.ModuleBlock:
var openBrace = findChildOfKind(n, SyntaxKind.OpenBraceToken, sourceFile);
var closeBrace = findChildOfKind(n, SyntaxKind.CloseBraceToken, sourceFile);
case SyntaxKind.ModuleBlock: {
let openBrace = findChildOfKind(n, SyntaxKind.OpenBraceToken, sourceFile);
let closeBrace = findChildOfKind(n, SyntaxKind.CloseBraceToken, sourceFile);
addOutliningSpan(n.parent, openBrace, closeBrace, autoCollapse(n));
break;
}
case SyntaxKind.ClassDeclaration:
case SyntaxKind.InterfaceDeclaration:
case SyntaxKind.EnumDeclaration:
case SyntaxKind.ObjectLiteralExpression:
case SyntaxKind.SwitchStatement:
var openBrace = findChildOfKind(n, SyntaxKind.OpenBraceToken, sourceFile);
var closeBrace = findChildOfKind(n, SyntaxKind.CloseBraceToken, sourceFile);
case SyntaxKind.CaseBlock: {
let openBrace = findChildOfKind(n, SyntaxKind.OpenBraceToken, sourceFile);
let closeBrace = findChildOfKind(n, SyntaxKind.CloseBraceToken, sourceFile);
addOutliningSpan(n, openBrace, closeBrace, autoCollapse(n));
break;
}
case SyntaxKind.ArrayLiteralExpression:
var openBracket = findChildOfKind(n, SyntaxKind.OpenBracketToken, sourceFile);
var closeBracket = findChildOfKind(n, SyntaxKind.CloseBracketToken, sourceFile);
let openBracket = findChildOfKind(n, SyntaxKind.OpenBracketToken, sourceFile);
let closeBracket = findChildOfKind(n, SyntaxKind.CloseBracketToken, sourceFile);
addOutliningSpan(n, openBracket, closeBracket, autoCollapse(n));
break;
}
+69 -72
View File
@@ -112,13 +112,13 @@ module ts {
// we see the name of a module that is used everywhere, or the name of an overload). As
// such, we cache the information we compute about the candidate for the life of this
// pattern matcher so we don't have to compute it multiple times.
var stringToWordSpans: Map<TextSpan[]> = {};
let stringToWordSpans: Map<TextSpan[]> = {};
pattern = pattern.trim();
var fullPatternSegment = createSegment(pattern);
var dotSeparatedSegments = pattern.split(".").map(p => createSegment(p.trim()));
var invalidPattern = dotSeparatedSegments.length === 0 || forEach(dotSeparatedSegments, segmentIsInvalid);
let fullPatternSegment = createSegment(pattern);
let dotSeparatedSegments = pattern.split(".").map(p => createSegment(p.trim()));
let invalidPattern = dotSeparatedSegments.length === 0 || forEach(dotSeparatedSegments, segmentIsInvalid);
return {
getMatches,
@@ -147,7 +147,7 @@ module ts {
// First, check that the last part of the dot separated pattern matches the name of the
// candidate. If not, then there's no point in proceeding and doing the more
// expensive work.
var candidateMatch = matchSegment(candidate, lastOrUndefined(dotSeparatedSegments));
let candidateMatch = matchSegment(candidate, lastOrUndefined(dotSeparatedSegments));
if (!candidateMatch) {
return undefined;
}
@@ -164,16 +164,16 @@ module ts {
// So far so good. Now break up the container for the candidate and check if all
// the dotted parts match up correctly.
var totalMatch = candidateMatch;
let totalMatch = candidateMatch;
for (var i = dotSeparatedSegments.length - 2, j = candidateContainers.length - 1;
for (let i = dotSeparatedSegments.length - 2, j = candidateContainers.length - 1;
i >= 0;
i--, j--) {
var segment = dotSeparatedSegments[i];
var containerName = candidateContainers[j];
let segment = dotSeparatedSegments[i];
let containerName = candidateContainers[j];
var containerMatch = matchSegment(containerName, segment);
let containerMatch = matchSegment(containerName, segment);
if (!containerMatch) {
// This container didn't match the pattern piece. So there's no match at all.
return undefined;
@@ -196,7 +196,7 @@ module ts {
}
function matchTextChunk(candidate: string, chunk: TextChunk, punctuationStripped: boolean): PatternMatch {
var index = indexOfIgnoringCase(candidate, chunk.textLowerCase);
let index = indexOfIgnoringCase(candidate, chunk.textLowerCase);
if (index === 0) {
if (chunk.text.length === candidate.length) {
// a) Check if the part matches the candidate entirely, in an case insensitive or
@@ -210,7 +210,7 @@ module ts {
}
}
var isLowercase = chunk.isLowerCase;
let isLowercase = chunk.isLowerCase;
if (isLowercase) {
if (index > 0) {
// c) If the part is entirely lowercase, then check if it is contained anywhere in the
@@ -220,9 +220,8 @@ module ts {
// Note: We only have a substring match if the lowercase part is prefix match of some
// word part. That way we don't match something like 'Class' when the user types 'a'.
// But we would match 'FooAttribute' (since 'Attribute' starts with 'a').
var wordSpans = getWordSpans(candidate);
for (var i = 0, n = wordSpans.length; i < n; i++) {
var span = wordSpans[i]
let wordSpans = getWordSpans(candidate);
for (let span of wordSpans) {
if (partStartsWith(candidate, span, chunk.text, /*ignoreCase:*/ true)) {
return createPatternMatch(PatternMatchKind.substring, punctuationStripped,
/*isCaseSensitive:*/ partStartsWith(candidate, span, chunk.text, /*ignoreCase:*/ false));
@@ -242,8 +241,8 @@ module ts {
if (!isLowercase) {
// e) If the part was not entirely lowercase, then attempt a camel cased match as well.
if (chunk.characterSpans.length > 0) {
var candidateParts = getWordSpans(candidate);
var camelCaseWeight = tryCamelCaseMatch(candidate, candidateParts, chunk, /*ignoreCase:*/ false);
let candidateParts = getWordSpans(candidate);
let camelCaseWeight = tryCamelCaseMatch(candidate, candidateParts, chunk, /*ignoreCase:*/ false);
if (camelCaseWeight !== undefined) {
return createPatternMatch(PatternMatchKind.camelCase, punctuationStripped, /*isCaseSensitive:*/ true, /*camelCaseWeight:*/ camelCaseWeight);
}
@@ -274,8 +273,8 @@ module ts {
}
function containsSpaceOrAsterisk(text: string): boolean {
for (var i = 0; i < text.length; i++) {
var ch = text.charCodeAt(i);
for (let i = 0; i < text.length; i++) {
let ch = text.charCodeAt(i);
if (ch === CharacterCodes.space || ch === CharacterCodes.asterisk) {
return true;
}
@@ -293,7 +292,7 @@ module ts {
// Note: if the segment contains a space or an asterisk then we must assume that it's a
// multi-word segment.
if (!containsSpaceOrAsterisk(segment.totalTextChunk.text)) {
var match = matchTextChunk(candidate, segment.totalTextChunk, /*punctuationStripped:*/ false);
let match = matchTextChunk(candidate, segment.totalTextChunk, /*punctuationStripped:*/ false);
if (match) {
return [match];
}
@@ -336,14 +335,12 @@ module ts {
//
// Only if all words have some sort of match is the pattern considered matched.
var subWordTextChunks = segment.subWordTextChunks;
var matches: PatternMatch[] = undefined;
for (var i = 0, n = subWordTextChunks.length; i < n; i++) {
var subWordTextChunk = subWordTextChunks[i];
let subWordTextChunks = segment.subWordTextChunks;
let matches: PatternMatch[] = undefined;
for (let subWordTextChunk of subWordTextChunks) {
// Try to match the candidate with this word
var result = matchTextChunk(candidate, subWordTextChunk, /*punctuationStripped:*/ true);
let result = matchTextChunk(candidate, subWordTextChunk, /*punctuationStripped:*/ true);
if (!result) {
return undefined;
}
@@ -356,8 +353,8 @@ module ts {
}
function partStartsWith(candidate: string, candidateSpan: TextSpan, pattern: string, ignoreCase: boolean, patternSpan?: TextSpan): boolean {
var patternPartStart = patternSpan ? patternSpan.start : 0;
var patternPartLength = patternSpan ? patternSpan.length : pattern.length;
let patternPartStart = patternSpan ? patternSpan.start : 0;
let patternPartLength = patternSpan ? patternSpan.length : pattern.length;
if (patternPartLength > candidateSpan.length) {
// Pattern part is longer than the candidate part. There can never be a match.
@@ -365,18 +362,18 @@ module ts {
}
if (ignoreCase) {
for (var i = 0; i < patternPartLength; i++) {
var ch1 = pattern.charCodeAt(patternPartStart + i);
var ch2 = candidate.charCodeAt(candidateSpan.start + i);
for (let i = 0; i < patternPartLength; i++) {
let ch1 = pattern.charCodeAt(patternPartStart + i);
let ch2 = candidate.charCodeAt(candidateSpan.start + i);
if (toLowerCase(ch1) !== toLowerCase(ch2)) {
return false;
}
}
}
else {
for (var i = 0; i < patternPartLength; i++) {
var ch1 = pattern.charCodeAt(patternPartStart + i);
var ch2 = candidate.charCodeAt(candidateSpan.start + i);
for (let i = 0; i < patternPartLength; i++) {
let ch1 = pattern.charCodeAt(patternPartStart + i);
let ch2 = candidate.charCodeAt(candidateSpan.start + i);
if (ch1 !== ch2) {
return false;
}
@@ -387,23 +384,23 @@ module ts {
}
function tryCamelCaseMatch(candidate: string, candidateParts: TextSpan[], chunk: TextChunk, ignoreCase: boolean): number {
var chunkCharacterSpans = chunk.characterSpans;
let chunkCharacterSpans = chunk.characterSpans;
// Note: we may have more pattern parts than candidate parts. This is because multiple
// pattern parts may match a candidate part. For example "SiUI" against "SimpleUI".
// We'll have 3 pattern parts Si/U/I against two candidate parts Simple/UI. However, U
// and I will both match in UI.
var currentCandidate = 0;
var currentChunkSpan = 0;
var firstMatch: number = undefined;
var contiguous: boolean = undefined;
let currentCandidate = 0;
let currentChunkSpan = 0;
let firstMatch: number = undefined;
let contiguous: boolean = undefined;
while (true) {
// Let's consider our termination cases
if (currentChunkSpan === chunkCharacterSpans.length) {
// We did match! We shall assign a weight to this
var weight = 0;
let weight = 0;
// Was this contiguous?
if (contiguous) {
@@ -422,15 +419,15 @@ module ts {
return undefined;
}
var candidatePart = candidateParts[currentCandidate];
var gotOneMatchThisCandidate = false;
let candidatePart = candidateParts[currentCandidate];
let gotOneMatchThisCandidate = false;
// Consider the case of matching SiUI against SimpleUIElement. The candidate parts
// will be Simple/UI/Element, and the pattern parts will be Si/U/I. We'll match 'Si'
// against 'Simple' first. Then we'll match 'U' against 'UI'. However, we want to
// still keep matching pattern parts against that candidate part.
for (; currentChunkSpan < chunkCharacterSpans.length; currentChunkSpan++) {
var chunkCharacterSpan = chunkCharacterSpans[currentChunkSpan];
let chunkCharacterSpan = chunkCharacterSpans[currentChunkSpan];
if (gotOneMatchThisCandidate) {
// We've already gotten one pattern part match in this candidate. We will
@@ -540,7 +537,7 @@ module ts {
// TODO: find a way to determine this for any unicode characters in a
// non-allocating manner.
var str = String.fromCharCode(ch);
let str = String.fromCharCode(ch);
return str === str.toUpperCase();
}
@@ -557,12 +554,12 @@ module ts {
// TODO: find a way to determine this for any unicode characters in a
// non-allocating manner.
var str = String.fromCharCode(ch);
let str = String.fromCharCode(ch);
return str === str.toLowerCase();
}
function containsUpperCaseLetter(string: string): boolean {
for (var i = 0, n = string.length; i < n; i++) {
for (let i = 0, n = string.length; i < n; i++) {
if (isUpperCaseLetter(string.charCodeAt(i))) {
return true;
}
@@ -572,7 +569,7 @@ module ts {
}
function startsWith(string: string, search: string) {
for (var i = 0, n = search.length; i < n; i++) {
for (let i = 0, n = search.length; i < n; i++) {
if (string.charCodeAt(i) !== search.charCodeAt(i)) {
return false;
}
@@ -583,7 +580,7 @@ module ts {
// Assumes 'value' is already lowercase.
function indexOfIgnoringCase(string: string, value: string): number {
for (var i = 0, n = string.length - value.length; i <= n; i++) {
for (let i = 0, n = string.length - value.length; i <= n; i++) {
if (startsWithIgnoringCase(string, value, i)) {
return i;
}
@@ -594,9 +591,9 @@ module ts {
// Assumes 'value' is already lowercase.
function startsWithIgnoringCase(string: string, value: string, start: number): boolean {
for (var i = 0, n = value.length; i < n; i++) {
var ch1 = toLowerCase(string.charCodeAt(i + start));
var ch2 = value.charCodeAt(i);
for (let i = 0, n = value.length; i < n; i++) {
let ch1 = toLowerCase(string.charCodeAt(i + start));
let ch2 = value.charCodeAt(i);
if (ch1 !== ch2) {
return false;
@@ -631,12 +628,12 @@ module ts {
}
function breakPatternIntoTextChunks(pattern: string): TextChunk[] {
var result: TextChunk[] = [];
var wordStart = 0;
var wordLength = 0;
let result: TextChunk[] = [];
let wordStart = 0;
let wordLength = 0;
for (var i = 0; i < pattern.length; i++) {
var ch = pattern.charCodeAt(i);
for (let i = 0; i < pattern.length; i++) {
let ch = pattern.charCodeAt(i);
if (isWordChar(ch)) {
if (wordLength++ === 0) {
wordStart = i;
@@ -658,7 +655,7 @@ module ts {
}
function createTextChunk(text: string): TextChunk {
var textLowerCase = text.toLowerCase();
let textLowerCase = text.toLowerCase();
return {
text,
textLowerCase,
@@ -676,15 +673,15 @@ module ts {
}
function breakIntoSpans(identifier: string, word: boolean): TextSpan[] {
var result: TextSpan[] = [];
let result: TextSpan[] = [];
var wordStart = 0;
for (var i = 1, n = identifier.length; i < n; i++) {
var lastIsDigit = isDigit(identifier.charCodeAt(i - 1));
var currentIsDigit = isDigit(identifier.charCodeAt(i));
let wordStart = 0;
for (let i = 1, n = identifier.length; i < n; i++) {
let lastIsDigit = isDigit(identifier.charCodeAt(i - 1));
let currentIsDigit = isDigit(identifier.charCodeAt(i));
var hasTransitionFromLowerToUpper = transitionFromLowerToUpper(identifier, word, i);
var hasTransitionFromUpperToLower = transitionFromUpperToLower(identifier, word, i, wordStart);
let hasTransitionFromLowerToUpper = transitionFromLowerToUpper(identifier, word, i);
let hasTransitionFromUpperToLower = transitionFromUpperToLower(identifier, word, i, wordStart);
if (charIsPunctuation(identifier.charCodeAt(i - 1)) ||
charIsPunctuation(identifier.charCodeAt(i)) ||
@@ -739,8 +736,8 @@ module ts {
}
function isAllPunctuation(identifier: string, start: number, end: number): boolean {
for (var i = start; i < end; i++) {
var ch = identifier.charCodeAt(i);
for (let i = start; i < end; i++) {
let ch = identifier.charCodeAt(i);
// We don't consider _ or $ as punctuation as there may be things with that name.
if (!charIsPunctuation(ch) || ch === CharacterCodes._ || ch === CharacterCodes.$) {
@@ -761,8 +758,8 @@ module ts {
// etc.
if (index != wordStart &&
index + 1 < identifier.length) {
var currentIsUpper = isUpperCaseLetter(identifier.charCodeAt(index));
var nextIsLower = isLowerCaseLetter(identifier.charCodeAt(index + 1));
let currentIsUpper = isUpperCaseLetter(identifier.charCodeAt(index));
let nextIsLower = isLowerCaseLetter(identifier.charCodeAt(index + 1));
if (currentIsUpper && nextIsLower) {
// We have a transition from an upper to a lower letter here. But we only
@@ -773,7 +770,7 @@ module ts {
// that follows. Note: this will make the following not split properly:
// "HELLOthere". However, these sorts of names do not show up in .Net
// programs.
for (var i = wordStart; i < index; i++) {
for (let i = wordStart; i < index; i++) {
if (!isUpperCaseLetter(identifier.charCodeAt(i))) {
return false;
}
@@ -788,8 +785,8 @@ module ts {
}
function transitionFromLowerToUpper(identifier: string, word: boolean, index: number): boolean {
var lastIsUpper = isUpperCaseLetter(identifier.charCodeAt(index - 1));
var currentIsUpper = isUpperCaseLetter(identifier.charCodeAt(index));
let lastIsUpper = isUpperCaseLetter(identifier.charCodeAt(index - 1));
let currentIsUpper = isUpperCaseLetter(identifier.charCodeAt(index));
// See if the casing indicates we're starting a new word. Note: if we're breaking on
// words, then just seeing an upper case character isn't enough. Instead, it has to
@@ -804,7 +801,7 @@ module ts {
// on characters would be: A M
//
// We break the search string on characters. But we break the symbol name on words.
var transition = word
let transition = word
? (currentIsUpper && !lastIsUpper)
: currentIsUpper;
return transition;
+473 -472
View File
File diff suppressed because it is too large Load Diff
+113 -82
View File
@@ -8,15 +8,15 @@ module ts.SignatureHelp {
// will return the generic identifier that started the expression (e.g. "foo" in "foo<any, |"). It is then up to the caller to ensure that this is a valid generic expression through
// looking up the type. The method will also keep track of the parameter index inside the expression.
//public static isInPartiallyWrittenTypeArgumentList(syntaxTree: TypeScript.SyntaxTree, position: number): any {
// var token = Syntax.findTokenOnLeft(syntaxTree.sourceUnit(), position, /*includeSkippedTokens*/ true);
// let token = Syntax.findTokenOnLeft(syntaxTree.sourceUnit(), position, /*includeSkippedTokens*/ true);
// if (token && TypeScript.Syntax.hasAncestorOfKind(token, TypeScript.SyntaxKind.TypeParameterList)) {
// // We are in the wrong generic list. bail out
// return null;
// }
// var stack = 0;
// var argumentIndex = 0;
// let stack = 0;
// let argumentIndex = 0;
// whileLoop:
// while (token) {
@@ -24,7 +24,7 @@ module ts.SignatureHelp {
// case TypeScript.SyntaxKind.LessThanToken:
// if (stack === 0) {
// // Found the beginning of the generic argument expression
// var lessThanToken = token;
// let lessThanToken = token;
// token = previousToken(token, /*includeSkippedTokens*/ true);
// if (!token || token.kind() !== TypeScript.SyntaxKind.IdentifierName) {
// break whileLoop;
@@ -64,7 +64,7 @@ module ts.SignatureHelp {
// case TypeScript.SyntaxKind.CloseBraceToken:
// // This can be object type, skip untill we find the matching open brace token
// var unmatchedOpenBraceTokens = 0;
// let unmatchedOpenBraceTokens = 0;
// // Skip untill the matching open brace token
// token = SignatureInfoHelpers.moveBackUpTillMatchingTokenKind(token, TypeScript.SyntaxKind.CloseBraceToken, TypeScript.SyntaxKind.OpenBraceToken);
@@ -135,7 +135,7 @@ module ts.SignatureHelp {
// // Skip the current token
// token = previousToken(token, /*includeSkippedTokens*/ true);
// var stack = 0;
// let stack = 0;
// while (token) {
// if (token.kind() === matchingTokenKind) {
@@ -162,7 +162,7 @@ module ts.SignatureHelp {
// // Did not find matching token
// return null;
//}
var emptyArray: any[] = [];
let emptyArray: any[] = [];
const enum ArgumentListKind {
TypeArguments,
@@ -180,13 +180,13 @@ module ts.SignatureHelp {
export function getSignatureHelpItems(sourceFile: SourceFile, position: number, typeInfoResolver: TypeChecker, cancellationToken: CancellationTokenObject): SignatureHelpItems {
// Decide whether to show signature help
var startingToken = findTokenOnLeftOfPosition(sourceFile, position);
let startingToken = findTokenOnLeftOfPosition(sourceFile, position);
if (!startingToken) {
// We are at the beginning of the file
return undefined;
}
var argumentInfo = getContainingArgumentInfo(startingToken);
let argumentInfo = getContainingArgumentInfo(startingToken);
cancellationToken.throwIfCancellationRequested();
// Semantic filtering of signature help
@@ -194,9 +194,9 @@ module ts.SignatureHelp {
return undefined;
}
var call = argumentInfo.invocation;
var candidates = <Signature[]>[];
var resolvedSignature = typeInfoResolver.getResolvedSignature(call, candidates);
let call = argumentInfo.invocation;
let candidates = <Signature[]>[];
let resolvedSignature = typeInfoResolver.getResolvedSignature(call, candidates);
cancellationToken.throwIfCancellationRequested();
if (!candidates.length) {
@@ -211,7 +211,7 @@ module ts.SignatureHelp {
*/
function getImmediatelyContainingArgumentInfo(node: Node): ArgumentListInfo {
if (node.parent.kind === SyntaxKind.CallExpression || node.parent.kind === SyntaxKind.NewExpression) {
var callExpression = <CallExpression>node.parent;
let callExpression = <CallExpression>node.parent;
// There are 3 cases to handle:
// 1. The token introduces a list, and should begin a sig help session
// 2. The token is either not associated with a list, or ends a list, so the session should end
@@ -230,15 +230,15 @@ module ts.SignatureHelp {
node.kind === SyntaxKind.OpenParenToken) {
// Find the list that starts right *after* the < or ( token.
// If the user has just opened a list, consider this item 0.
var list = getChildListThatStartsWithOpenerToken(callExpression, node, sourceFile);
var isTypeArgList = callExpression.typeArguments && callExpression.typeArguments.pos === list.pos;
let list = getChildListThatStartsWithOpenerToken(callExpression, node, sourceFile);
let isTypeArgList = callExpression.typeArguments && callExpression.typeArguments.pos === list.pos;
Debug.assert(list !== undefined);
return {
kind: isTypeArgList ? ArgumentListKind.TypeArguments : ArgumentListKind.CallArguments,
invocation: callExpression,
argumentsSpan: getApplicableSpanForArguments(list),
argumentIndex: 0,
argumentCount: getCommaBasedArgCount(list)
argumentCount: getArgumentCount(list)
};
}
@@ -248,25 +248,16 @@ module ts.SignatureHelp {
// - Between the type arguments and the arguments (greater than token)
// - On the target of the call (parent.func)
// - On the 'new' keyword in a 'new' expression
var listItemInfo = findListItemInfo(node);
let listItemInfo = findListItemInfo(node);
if (listItemInfo) {
var list = listItemInfo.list;
var isTypeArgList = callExpression.typeArguments && callExpression.typeArguments.pos === list.pos;
let list = listItemInfo.list;
let isTypeArgList = callExpression.typeArguments && callExpression.typeArguments.pos === list.pos;
// The listItemIndex we got back includes commas. Our goal is to return the index of the proper
// item (not including commas). Here are some examples:
// 1. foo(a, b, c #) -> the listItemIndex is 4, we want to return 2
// 2. foo(a, b, # c) -> listItemIndex is 3, we want to return 2
// 3. foo(#a) -> listItemIndex is 0, we want to return 0
//
// In general, we want to subtract the number of commas before the current index.
// But if we are on a comma, we also want to pretend we are on the argument *following*
// the comma. That amounts to taking the ceiling of half the index.
var argumentIndex = (listItemInfo.listItemIndex + 1) >> 1;
let argumentIndex = getArgumentIndex(list, node);
let argumentCount = getArgumentCount(list);
var argumentCount = getCommaBasedArgCount(list);
Debug.assert(argumentIndex === 0 || argumentIndex < argumentCount, `argumentCount < argumentIndex, ${argumentCount} < ${argumentIndex}`);
Debug.assert(argumentIndex === 0 || argumentIndex < argumentCount,
`argumentCount < argumentIndex, ${argumentCount} < ${argumentIndex}`);
return {
kind: isTypeArgList ? ArgumentListKind.TypeArguments : ArgumentListKind.CallArguments,
@@ -285,18 +276,18 @@ module ts.SignatureHelp {
}
}
else if (node.kind === SyntaxKind.TemplateHead && node.parent.parent.kind === SyntaxKind.TaggedTemplateExpression) {
var templateExpression = <TemplateExpression>node.parent;
var tagExpression = <TaggedTemplateExpression>templateExpression.parent;
let templateExpression = <TemplateExpression>node.parent;
let tagExpression = <TaggedTemplateExpression>templateExpression.parent;
Debug.assert(templateExpression.kind === SyntaxKind.TemplateExpression);
var argumentIndex = isInsideTemplateLiteral(<LiteralExpression>node, position) ? 0 : 1;
let argumentIndex = isInsideTemplateLiteral(<LiteralExpression>node, position) ? 0 : 1;
return getArgumentListInfoForTemplate(tagExpression, argumentIndex);
}
else if (node.parent.kind === SyntaxKind.TemplateSpan && node.parent.parent.parent.kind === SyntaxKind.TaggedTemplateExpression) {
var templateSpan = <TemplateSpan>node.parent;
var templateExpression = <TemplateExpression>templateSpan.parent;
var tagExpression = <TaggedTemplateExpression>templateExpression.parent;
let templateSpan = <TemplateSpan>node.parent;
let templateExpression = <TemplateExpression>templateSpan.parent;
let tagExpression = <TaggedTemplateExpression>templateExpression.parent;
Debug.assert(templateExpression.kind === SyntaxKind.TemplateExpression);
// If we're just after a template tail, don't show signature help.
@@ -304,8 +295,8 @@ module ts.SignatureHelp {
return undefined;
}
var spanIndex = templateExpression.templateSpans.indexOf(templateSpan);
var argumentIndex = getArgumentIndexForTemplatePiece(spanIndex, node);
let spanIndex = templateExpression.templateSpans.indexOf(templateSpan);
let argumentIndex = getArgumentIndexForTemplatePiece(spanIndex, node);
return getArgumentListInfoForTemplate(tagExpression, argumentIndex);
}
@@ -313,12 +304,52 @@ module ts.SignatureHelp {
return undefined;
}
function getCommaBasedArgCount(argumentsList: Node) {
// The number of arguments is the number of commas plus one, unless the list
// is completely empty, in which case there are 0 arguments.
return argumentsList.getChildCount() === 0
? 0
: 1 + countWhere(argumentsList.getChildren(), arg => arg.kind === SyntaxKind.CommaToken);
function getArgumentIndex(argumentsList: Node, node: Node) {
// The list we got back can include commas. In the presence of errors it may
// also just have nodes without commas. For example "Foo(a b c)" will have 3
// args without commas. We want to find what index we're at. So we count
// forward until we hit ourselves, only incrementing the index if it isn't a
// comma.
//
// Note: the subtlety around trailing commas (in getArgumentCount) does not apply
// here. That's because we're only walking forward until we hit the node we're
// on. In that case, even if we're after the trailing comma, we'll still see
// that trailing comma in the list, and we'll have generated the appropriate
// arg index.
let argumentIndex = 0;
let listChildren = argumentsList.getChildren();
for (let child of listChildren) {
if (child === node) {
break;
}
if (child.kind !== SyntaxKind.CommaToken) {
argumentIndex++;
}
}
return argumentIndex;
}
function getArgumentCount(argumentsList: Node) {
// The argument count for a list is normally the number of non-comma children it has.
// For example, if you have "Foo(a,b)" then there will be three children of the arg
// list 'a' '<comma>' 'b'. So, in this case the arg count will be 2. However, there
// is a small subtlety. If you have "Foo(a,)", then the child list will just have
// 'a' '<comma>'. So, in the case where the last child is a comma, we increase the
// arg count by one to compensate.
//
// Note: this subtlety only applies to the last comma. If you had "Foo(a,," then
// we'll have: 'a' '<comma>' '<missing>'
// That will give us 2 non-commas. We then add one for the last comma, givin us an
// arg count of 3.
let listChildren = argumentsList.getChildren();
let argumentCount = countWhere(listChildren, arg => arg.kind !== SyntaxKind.CommaToken);
if (listChildren.length > 0 && lastOrUndefined(listChildren).kind === SyntaxKind.CommaToken) {
argumentCount++;
}
return argumentCount;
}
// spanIndex is either the index for a given template span.
@@ -347,7 +378,7 @@ module ts.SignatureHelp {
function getArgumentListInfoForTemplate(tagExpression: TaggedTemplateExpression, argumentIndex: number): ArgumentListInfo {
// argumentCount is either 1 or (numSpans + 1) to account for the template strings array argument.
var argumentCount = tagExpression.template.kind === SyntaxKind.NoSubstitutionTemplateLiteral
let argumentCount = tagExpression.template.kind === SyntaxKind.NoSubstitutionTemplateLiteral
? 1
: (<TemplateExpression>tagExpression.template).templateSpans.length + 1;
@@ -371,15 +402,15 @@ module ts.SignatureHelp {
//
// The applicable span is from the first bar to the second bar (inclusive,
// but not including parentheses)
var applicableSpanStart = argumentsList.getFullStart();
var applicableSpanEnd = skipTrivia(sourceFile.text, argumentsList.getEnd(), /*stopAfterLineBreak*/ false);
let applicableSpanStart = argumentsList.getFullStart();
let applicableSpanEnd = skipTrivia(sourceFile.text, argumentsList.getEnd(), /*stopAfterLineBreak*/ false);
return createTextSpan(applicableSpanStart, applicableSpanEnd - applicableSpanStart);
}
function getApplicableSpanForTaggedTemplate(taggedTemplate: TaggedTemplateExpression): TextSpan {
var template = taggedTemplate.template;
var applicableSpanStart = template.getStart();
var applicableSpanEnd = template.getEnd();
let template = taggedTemplate.template;
let applicableSpanStart = template.getStart();
let applicableSpanEnd = template.getEnd();
// We need to adjust the end position for the case where the template does not have a tail.
// Otherwise, we will not show signature help past the expression.
@@ -391,7 +422,7 @@ module ts.SignatureHelp {
// This is because a Missing node has no width. However, what we actually want is to include trivia
// leading up to the next token in case the user is about to type in a TemplateMiddle or TemplateTail.
if (template.kind === SyntaxKind.TemplateExpression) {
var lastSpan = lastOrUndefined((<TemplateExpression>template).templateSpans);
let lastSpan = lastOrUndefined((<TemplateExpression>template).templateSpans);
if (lastSpan.literal.getFullWidth() === 0) {
applicableSpanEnd = skipTrivia(sourceFile.text, applicableSpanEnd, /*stopAfterLineBreak*/ false);
}
@@ -401,7 +432,7 @@ module ts.SignatureHelp {
}
function getContainingArgumentInfo(node: Node): ArgumentListInfo {
for (var n = node; n.kind !== SyntaxKind.SourceFile; n = n.parent) {
for (let n = node; n.kind !== SyntaxKind.SourceFile; n = n.parent) {
if (isFunctionBlock(n)) {
return undefined;
}
@@ -412,7 +443,7 @@ module ts.SignatureHelp {
Debug.fail("Node of kind " + n.kind + " is not a subspan of its parent of kind " + n.parent.kind);
}
var argumentInfo = getImmediatelyContainingArgumentInfo(n);
let argumentInfo = getImmediatelyContainingArgumentInfo(n);
if (argumentInfo) {
return argumentInfo;
}
@@ -424,8 +455,8 @@ module ts.SignatureHelp {
}
function getChildListThatStartsWithOpenerToken(parent: Node, openerToken: Node, sourceFile: SourceFile): Node {
var children = parent.getChildren(sourceFile);
var indexOfOpenerToken = children.indexOf(openerToken);
let children = parent.getChildren(sourceFile);
let indexOfOpenerToken = children.indexOf(openerToken);
Debug.assert(indexOfOpenerToken >= 0 && children.length > indexOfOpenerToken + 1);
return children[indexOfOpenerToken + 1];
}
@@ -439,10 +470,10 @@ module ts.SignatureHelp {
* or the one with the most parameters.
*/
function selectBestInvalidOverloadIndex(candidates: Signature[], argumentCount: number): number {
var maxParamsSignatureIndex = -1;
var maxParams = -1;
for (var i = 0; i < candidates.length; i++) {
var candidate = candidates[i];
let maxParamsSignatureIndex = -1;
let maxParams = -1;
for (let i = 0; i < candidates.length; i++) {
let candidate = candidates[i];
if (candidate.hasRestParameter || candidate.parameters.length >= argumentCount) {
return i;
@@ -458,17 +489,17 @@ module ts.SignatureHelp {
}
function createSignatureHelpItems(candidates: Signature[], bestSignature: Signature, argumentListInfo: ArgumentListInfo): SignatureHelpItems {
var applicableSpan = argumentListInfo.argumentsSpan;
var isTypeParameterList = argumentListInfo.kind === ArgumentListKind.TypeArguments;
let applicableSpan = argumentListInfo.argumentsSpan;
let isTypeParameterList = argumentListInfo.kind === ArgumentListKind.TypeArguments;
var invocation = argumentListInfo.invocation;
var callTarget = getInvokedExpression(invocation)
var callTargetSymbol = typeInfoResolver.getSymbolAtLocation(callTarget);
var callTargetDisplayParts = callTargetSymbol && symbolToDisplayParts(typeInfoResolver, callTargetSymbol, /*enclosingDeclaration*/ undefined, /*meaning*/ undefined);
var items: SignatureHelpItem[] = map(candidates, candidateSignature => {
var signatureHelpParameters: SignatureHelpParameter[];
var prefixDisplayParts: SymbolDisplayPart[] = [];
var suffixDisplayParts: SymbolDisplayPart[] = [];
let invocation = argumentListInfo.invocation;
let callTarget = getInvokedExpression(invocation)
let callTargetSymbol = typeInfoResolver.getSymbolAtLocation(callTarget);
let callTargetDisplayParts = callTargetSymbol && symbolToDisplayParts(typeInfoResolver, callTargetSymbol, /*enclosingDeclaration*/ undefined, /*meaning*/ undefined);
let items: SignatureHelpItem[] = map(candidates, candidateSignature => {
let signatureHelpParameters: SignatureHelpParameter[];
let prefixDisplayParts: SymbolDisplayPart[] = [];
let suffixDisplayParts: SymbolDisplayPart[] = [];
if (callTargetDisplayParts) {
prefixDisplayParts.push.apply(prefixDisplayParts, callTargetDisplayParts);
@@ -476,25 +507,25 @@ module ts.SignatureHelp {
if (isTypeParameterList) {
prefixDisplayParts.push(punctuationPart(SyntaxKind.LessThanToken));
var typeParameters = candidateSignature.typeParameters;
let typeParameters = candidateSignature.typeParameters;
signatureHelpParameters = typeParameters && typeParameters.length > 0 ? map(typeParameters, createSignatureHelpParameterForTypeParameter) : emptyArray;
suffixDisplayParts.push(punctuationPart(SyntaxKind.GreaterThanToken));
var parameterParts = mapToDisplayParts(writer =>
let parameterParts = mapToDisplayParts(writer =>
typeInfoResolver.getSymbolDisplayBuilder().buildDisplayForParametersAndDelimiters(candidateSignature.parameters, writer, invocation));
suffixDisplayParts.push.apply(suffixDisplayParts, parameterParts);
}
else {
var typeParameterParts = mapToDisplayParts(writer =>
let typeParameterParts = mapToDisplayParts(writer =>
typeInfoResolver.getSymbolDisplayBuilder().buildDisplayForTypeParametersAndDelimiters(candidateSignature.typeParameters, writer, invocation));
prefixDisplayParts.push.apply(prefixDisplayParts, typeParameterParts);
prefixDisplayParts.push(punctuationPart(SyntaxKind.OpenParenToken));
var parameters = candidateSignature.parameters;
let parameters = candidateSignature.parameters;
signatureHelpParameters = parameters.length > 0 ? map(parameters, createSignatureHelpParameterForParameter) : emptyArray;
suffixDisplayParts.push(punctuationPart(SyntaxKind.CloseParenToken));
}
var returnTypeParts = mapToDisplayParts(writer =>
let returnTypeParts = mapToDisplayParts(writer =>
typeInfoResolver.getSymbolDisplayBuilder().buildReturnTypeDisplay(candidateSignature, writer, invocation));
suffixDisplayParts.push.apply(suffixDisplayParts, returnTypeParts);
@@ -508,12 +539,12 @@ module ts.SignatureHelp {
};
});
var argumentIndex = argumentListInfo.argumentIndex;
let argumentIndex = argumentListInfo.argumentIndex;
// argumentCount is the *apparent* number of arguments.
var argumentCount = argumentListInfo.argumentCount;
let argumentCount = argumentListInfo.argumentCount;
var selectedItemIndex = candidates.indexOf(bestSignature);
let selectedItemIndex = candidates.indexOf(bestSignature);
if (selectedItemIndex < 0) {
selectedItemIndex = selectBestInvalidOverloadIndex(candidates, argumentCount);
}
@@ -529,10 +560,10 @@ module ts.SignatureHelp {
};
function createSignatureHelpParameterForParameter(parameter: Symbol): SignatureHelpParameter {
var displayParts = mapToDisplayParts(writer =>
let displayParts = mapToDisplayParts(writer =>
typeInfoResolver.getSymbolDisplayBuilder().buildParameterDisplay(parameter, writer, invocation));
var isOptional = hasQuestionToken(parameter.valueDeclaration);
let isOptional = hasQuestionToken(parameter.valueDeclaration);
return {
name: parameter.name,
@@ -543,7 +574,7 @@ module ts.SignatureHelp {
}
function createSignatureHelpParameterForTypeParameter(typeParameter: TypeParameter): SignatureHelpParameter {
var displayParts = mapToDisplayParts(writer =>
let displayParts = mapToDisplayParts(writer =>
typeInfoResolver.getSymbolDisplayBuilder().buildTypeParameterDisplay(typeParameter, writer, invocation));
return {
+42 -41
View File
@@ -7,18 +7,18 @@ module ts {
export function getEndLinePosition(line: number, sourceFile: SourceFile): number {
Debug.assert(line >= 0);
var lineStarts = sourceFile.getLineStarts();
let lineStarts = sourceFile.getLineStarts();
var lineIndex = line;
let lineIndex = line;
if (lineIndex + 1 === lineStarts.length) {
// last line - return EOF
return sourceFile.text.length - 1;
}
else {
// current line start
var start = lineStarts[lineIndex];
let start = lineStarts[lineIndex];
// take the start position of the next line -1 = it should be some line break
var pos = lineStarts[lineIndex + 1] - 1;
let pos = lineStarts[lineIndex + 1] - 1;
Debug.assert(isLineBreak(sourceFile.text.charCodeAt(pos)));
// walk backwards skipping line breaks, stop the the beginning of current line.
// i.e:
@@ -32,8 +32,8 @@ module ts {
}
export function getLineStartPositionForPosition(position: number, sourceFile: SourceFile): number {
var lineStarts = sourceFile.getLineStarts();
var line = sourceFile.getLineAndCharacterOfPosition(position).line;
let lineStarts = sourceFile.getLineStarts();
let line = sourceFile.getLineAndCharacterOfPosition(position).line;
return lineStarts[line];
}
@@ -54,13 +54,13 @@ module ts {
}
export function startEndOverlapsWithStartEnd(start1: number, end1: number, start2: number, end2: number) {
var start = Math.max(start1, start2);
var end = Math.min(end1, end2);
let start = Math.max(start1, start2);
let end = Math.min(end1, end2);
return start < end;
}
export function findListItemInfo(node: Node): ListItemInfo {
var list = findContainingList(node);
let list = findContainingList(node);
// It is possible at this point for syntaxList to be undefined, either if
// node.parent had no list child, or if none of its list children contained
@@ -70,8 +70,8 @@ module ts {
return undefined;
}
var children = list.getChildren();
var listItemIndex = indexOf(children, node);
let children = list.getChildren();
let listItemIndex = indexOf(children, node);
return {
listItemIndex,
@@ -88,13 +88,15 @@ module ts {
// be parented by the container of the SyntaxList, not the SyntaxList itself.
// In order to find the list item index, we first need to locate SyntaxList itself and then search
// for the position of the relevant node (or comma).
var syntaxList = forEach(node.parent.getChildren(), c => {
let syntaxList = forEach(node.parent.getChildren(), c => {
// find syntax list that covers the span of the node
if (c.kind === SyntaxKind.SyntaxList && c.pos <= node.pos && c.end >= node.end) {
return c;
}
});
// Either we didn't find an appropriate list, or the list must contain us.
Debug.assert(!syntaxList || contains(syntaxList.getChildren(), node));
return syntaxList;
}
@@ -124,7 +126,7 @@ module ts {
/** Get the token whose text contains the position */
function getTokenAtPositionWorker(sourceFile: SourceFile, position: number, allowPositionInLeadingTrivia: boolean, includeItemAtEndPosition: (n: Node) => boolean): Node {
var current: Node = sourceFile;
let current: Node = sourceFile;
outer: while (true) {
if (isToken(current)) {
// exit early
@@ -132,17 +134,17 @@ module ts {
}
// find the child that contains 'position'
for (var i = 0, n = current.getChildCount(sourceFile); i < n; i++) {
var child = current.getChildAt(i);
var start = allowPositionInLeadingTrivia ? child.getFullStart() : child.getStart(sourceFile);
for (let i = 0, n = current.getChildCount(sourceFile); i < n; i++) {
let child = current.getChildAt(i);
let start = allowPositionInLeadingTrivia ? child.getFullStart() : child.getStart(sourceFile);
if (start <= position) {
var end = child.getEnd();
let end = child.getEnd();
if (position < end || (position === end && child.kind === SyntaxKind.EndOfFileToken)) {
current = child;
continue outer;
}
else if (includeItemAtEndPosition && end === position) {
var previousToken = findPrecedingToken(position, sourceFile, child);
let previousToken = findPrecedingToken(position, sourceFile, child);
if (previousToken && includeItemAtEndPosition(previousToken)) {
return previousToken;
}
@@ -164,7 +166,7 @@ module ts {
export function findTokenOnLeftOfPosition(file: SourceFile, position: number): Node {
// Ideally, getTokenAtPosition should return a token. However, it is currently
// broken, so we do a check to make sure the result was indeed a token.
var tokenAtPosition = getTokenAtPosition(file, position);
let tokenAtPosition = getTokenAtPosition(file, position);
if (isToken(tokenAtPosition) && position > tokenAtPosition.getStart(file) && position < tokenAtPosition.getEnd()) {
return tokenAtPosition;
}
@@ -181,10 +183,9 @@ module ts {
return n;
}
var children = n.getChildren();
for (var i = 0, len = children.length; i < len; ++i) {
var child = children[i];
var shouldDiveInChildNode =
let children = n.getChildren();
for (let child of children) {
let shouldDiveInChildNode =
// previous token is enclosed somewhere in the child
(child.pos <= previousToken.pos && child.end > previousToken.end) ||
// previous token ends exactly at the beginning of child
@@ -207,8 +208,8 @@ module ts {
return n;
}
var children = n.getChildren();
var candidate = findRightmostChildNodeWithTokens(children, /*exclusiveStartPosition*/ children.length);
let children = n.getChildren();
let candidate = findRightmostChildNodeWithTokens(children, /*exclusiveStartPosition*/ children.length);
return candidate && findRightmostToken(candidate);
}
@@ -218,14 +219,14 @@ module ts {
return n;
}
var children = n.getChildren();
for (var i = 0, len = children.length; i < len; ++i) {
var child = children[i];
let children = n.getChildren();
for (let i = 0, len = children.length; i < len; i++) {
let child = children[i];
if (nodeHasTokens(child)) {
if (position <= child.end) {
if (child.getStart(sourceFile) >= position) {
// actual start of the node is past the position - previous token should be at the end of previous child
var candidate = findRightmostChildNodeWithTokens(children, /*exclusiveStartPosition*/ i);
let candidate = findRightmostChildNodeWithTokens(children, /*exclusiveStartPosition*/ i);
return candidate && findRightmostToken(candidate)
}
else {
@@ -243,14 +244,14 @@ module ts {
// Try to find the rightmost token in the file without filtering.
// Namely we are skipping the check: 'position < node.end'
if (children.length) {
var candidate = findRightmostChildNodeWithTokens(children, /*exclusiveStartPosition*/ children.length);
let candidate = findRightmostChildNodeWithTokens(children, /*exclusiveStartPosition*/ children.length);
return candidate && findRightmostToken(candidate);
}
}
/// finds last node that is considered as candidate for search (isCandidate(node) === true) starting from 'exclusiveStartPosition'
function findRightmostChildNodeWithTokens(children: Node[], exclusiveStartPosition: number): Node {
for (var i = exclusiveStartPosition - 1; i >= 0; --i) {
for (let i = exclusiveStartPosition - 1; i >= 0; --i) {
if (nodeHasTokens(children[i])) {
return children[i];
}
@@ -265,8 +266,8 @@ module ts {
}
export function getNodeModifiers(node: Node): string {
var flags = getCombinedNodeFlags(node);
var result: string[] = [];
let flags = getCombinedNodeFlags(node);
let result: string[] = [];
if (flags & NodeFlags.Private) result.push(ScriptElementKindModifier.privateMemberModifier);
if (flags & NodeFlags.Protected) result.push(ScriptElementKindModifier.protectedMemberModifier);
@@ -316,7 +317,7 @@ module ts {
}
export function compareDataObjects(dst: any, src: any): boolean {
for (var e in dst) {
for (let e in dst) {
if (typeof dst[e] === "object") {
if (!compareDataObjects(dst[e], src[e])) {
return false;
@@ -338,11 +339,11 @@ module ts {
return symbol.declarations && symbol.declarations.length > 0 && symbol.declarations[0].kind === SyntaxKind.Parameter;
}
var displayPartWriter = getDisplayPartWriter();
let displayPartWriter = getDisplayPartWriter();
function getDisplayPartWriter(): DisplayPartsSymbolWriter {
var displayParts: SymbolDisplayPart[];
var lineStart: boolean;
var indent: number;
let displayParts: SymbolDisplayPart[];
let lineStart: boolean;
let indent: number;
resetWriter();
return {
@@ -363,7 +364,7 @@ module ts {
function writeIndent() {
if (lineStart) {
var indentString = getIndentString(indent);
let indentString = getIndentString(indent);
if (indentString) {
displayParts.push(displayPart(indentString, SymbolDisplayPartKind.space));
}
@@ -397,7 +398,7 @@ module ts {
return displayPart(text, displayPartKind(symbol), symbol);
function displayPartKind(symbol: Symbol): SymbolDisplayPartKind {
var flags = symbol.flags;
let flags = symbol.flags;
if (flags & SymbolFlags.Variable) {
return isFirstDeclarationOfSymbolParameter(symbol) ? SymbolDisplayPartKind.parameterName : SymbolDisplayPartKind.localName;
@@ -454,7 +455,7 @@ module ts {
export function mapToDisplayParts(writeDisplayParts: (writer: DisplayPartsSymbolWriter) => void): SymbolDisplayPart[] {
writeDisplayParts(displayPartWriter);
var result = displayPartWriter.displayParts();
let result = displayPartWriter.displayParts();
displayPartWriter.clear();
return result;
}
+27 -23
View File
@@ -261,27 +261,28 @@ declare module "typescript" {
EnumDeclaration = 199,
ModuleDeclaration = 200,
ModuleBlock = 201,
ImportEqualsDeclaration = 202,
ImportDeclaration = 203,
ImportClause = 204,
NamespaceImport = 205,
NamedImports = 206,
ImportSpecifier = 207,
ExportAssignment = 208,
ExportDeclaration = 209,
NamedExports = 210,
ExportSpecifier = 211,
ExternalModuleReference = 212,
CaseClause = 213,
DefaultClause = 214,
HeritageClause = 215,
CatchClause = 216,
PropertyAssignment = 217,
ShorthandPropertyAssignment = 218,
EnumMember = 219,
SourceFile = 220,
SyntaxList = 221,
Count = 222,
CaseBlock = 202,
ImportEqualsDeclaration = 203,
ImportDeclaration = 204,
ImportClause = 205,
NamespaceImport = 206,
NamedImports = 207,
ImportSpecifier = 208,
ExportAssignment = 209,
ExportDeclaration = 210,
NamedExports = 211,
ExportSpecifier = 212,
ExternalModuleReference = 213,
CaseClause = 214,
DefaultClause = 215,
HeritageClause = 216,
CatchClause = 217,
PropertyAssignment = 218,
ShorthandPropertyAssignment = 219,
EnumMember = 220,
SourceFile = 221,
SyntaxList = 222,
Count = 223,
FirstAssignment = 52,
LastAssignment = 63,
FirstReservedWord = 65,
@@ -656,6 +657,9 @@ declare module "typescript" {
}
interface SwitchStatement extends Statement {
expression: Expression;
caseBlock: CaseBlock;
}
interface CaseBlock extends Node {
clauses: NodeArray<CaseOrDefaultClause>;
}
interface CaseClause extends Node {
@@ -1484,7 +1488,7 @@ declare module "typescript" {
}
declare module "typescript" {
/** The version of the language service API */
var servicesVersion: string;
let servicesVersion: string;
interface Node {
getSourceFile(): SourceFile;
getChildCount(sourceFile?: SourceFile): number;
@@ -1971,7 +1975,7 @@ declare module "typescript" {
throwIfCancellationRequested(): void;
}
function createLanguageServiceSourceFile(fileName: string, scriptSnapshot: IScriptSnapshot, scriptTarget: ScriptTarget, version: string, setNodeParents: boolean): SourceFile;
var disableIncrementalParsing: boolean;
let disableIncrementalParsing: boolean;
function updateLanguageServiceSourceFile(sourceFile: SourceFile, scriptSnapshot: IScriptSnapshot, version: string, textChangeRange: TextChangeRange, aggressiveChecks?: boolean): SourceFile;
function createDocumentRegistry(): DocumentRegistry;
function preProcessFile(sourceText: string, readImportFiles?: boolean): PreProcessedFileInfo;
@@ -801,67 +801,70 @@ declare module "typescript" {
ModuleBlock = 201,
>ModuleBlock : SyntaxKind
ImportEqualsDeclaration = 202,
CaseBlock = 202,
>CaseBlock : SyntaxKind
ImportEqualsDeclaration = 203,
>ImportEqualsDeclaration : SyntaxKind
ImportDeclaration = 203,
ImportDeclaration = 204,
>ImportDeclaration : SyntaxKind
ImportClause = 204,
ImportClause = 205,
>ImportClause : SyntaxKind
NamespaceImport = 205,
NamespaceImport = 206,
>NamespaceImport : SyntaxKind
NamedImports = 206,
NamedImports = 207,
>NamedImports : SyntaxKind
ImportSpecifier = 207,
ImportSpecifier = 208,
>ImportSpecifier : SyntaxKind
ExportAssignment = 208,
ExportAssignment = 209,
>ExportAssignment : SyntaxKind
ExportDeclaration = 209,
ExportDeclaration = 210,
>ExportDeclaration : SyntaxKind
NamedExports = 210,
NamedExports = 211,
>NamedExports : SyntaxKind
ExportSpecifier = 211,
ExportSpecifier = 212,
>ExportSpecifier : SyntaxKind
ExternalModuleReference = 212,
ExternalModuleReference = 213,
>ExternalModuleReference : SyntaxKind
CaseClause = 213,
CaseClause = 214,
>CaseClause : SyntaxKind
DefaultClause = 214,
DefaultClause = 215,
>DefaultClause : SyntaxKind
HeritageClause = 215,
HeritageClause = 216,
>HeritageClause : SyntaxKind
CatchClause = 216,
CatchClause = 217,
>CatchClause : SyntaxKind
PropertyAssignment = 217,
PropertyAssignment = 218,
>PropertyAssignment : SyntaxKind
ShorthandPropertyAssignment = 218,
ShorthandPropertyAssignment = 219,
>ShorthandPropertyAssignment : SyntaxKind
EnumMember = 219,
EnumMember = 220,
>EnumMember : SyntaxKind
SourceFile = 220,
SourceFile = 221,
>SourceFile : SyntaxKind
SyntaxList = 221,
SyntaxList = 222,
>SyntaxList : SyntaxKind
Count = 222,
Count = 223,
>Count : SyntaxKind
FirstAssignment = 52,
@@ -1980,6 +1983,14 @@ declare module "typescript" {
>expression : Expression
>Expression : Expression
caseBlock: CaseBlock;
>caseBlock : CaseBlock
>CaseBlock : CaseBlock
}
interface CaseBlock extends Node {
>CaseBlock : CaseBlock
>Node : Node
clauses: NodeArray<CaseOrDefaultClause>;
>clauses : NodeArray<CaseClause | DefaultClause>
>NodeArray : NodeArray<T>
@@ -4757,7 +4768,7 @@ declare module "typescript" {
}
declare module "typescript" {
/** The version of the language service API */
var servicesVersion: string;
let servicesVersion: string;
>servicesVersion : string
interface Node {
@@ -6107,7 +6118,7 @@ declare module "typescript" {
>setNodeParents : boolean
>SourceFile : SourceFile
var disableIncrementalParsing: boolean;
let disableIncrementalParsing: boolean;
>disableIncrementalParsing : boolean
function updateLanguageServiceSourceFile(sourceFile: SourceFile, scriptSnapshot: IScriptSnapshot, version: string, textChangeRange: TextChangeRange, aggressiveChecks?: boolean): SourceFile;
+27 -23
View File
@@ -292,27 +292,28 @@ declare module "typescript" {
EnumDeclaration = 199,
ModuleDeclaration = 200,
ModuleBlock = 201,
ImportEqualsDeclaration = 202,
ImportDeclaration = 203,
ImportClause = 204,
NamespaceImport = 205,
NamedImports = 206,
ImportSpecifier = 207,
ExportAssignment = 208,
ExportDeclaration = 209,
NamedExports = 210,
ExportSpecifier = 211,
ExternalModuleReference = 212,
CaseClause = 213,
DefaultClause = 214,
HeritageClause = 215,
CatchClause = 216,
PropertyAssignment = 217,
ShorthandPropertyAssignment = 218,
EnumMember = 219,
SourceFile = 220,
SyntaxList = 221,
Count = 222,
CaseBlock = 202,
ImportEqualsDeclaration = 203,
ImportDeclaration = 204,
ImportClause = 205,
NamespaceImport = 206,
NamedImports = 207,
ImportSpecifier = 208,
ExportAssignment = 209,
ExportDeclaration = 210,
NamedExports = 211,
ExportSpecifier = 212,
ExternalModuleReference = 213,
CaseClause = 214,
DefaultClause = 215,
HeritageClause = 216,
CatchClause = 217,
PropertyAssignment = 218,
ShorthandPropertyAssignment = 219,
EnumMember = 220,
SourceFile = 221,
SyntaxList = 222,
Count = 223,
FirstAssignment = 52,
LastAssignment = 63,
FirstReservedWord = 65,
@@ -687,6 +688,9 @@ declare module "typescript" {
}
interface SwitchStatement extends Statement {
expression: Expression;
caseBlock: CaseBlock;
}
interface CaseBlock extends Node {
clauses: NodeArray<CaseOrDefaultClause>;
}
interface CaseClause extends Node {
@@ -1515,7 +1519,7 @@ declare module "typescript" {
}
declare module "typescript" {
/** The version of the language service API */
var servicesVersion: string;
let servicesVersion: string;
interface Node {
getSourceFile(): SourceFile;
getChildCount(sourceFile?: SourceFile): number;
@@ -2002,7 +2006,7 @@ declare module "typescript" {
throwIfCancellationRequested(): void;
}
function createLanguageServiceSourceFile(fileName: string, scriptSnapshot: IScriptSnapshot, scriptTarget: ScriptTarget, version: string, setNodeParents: boolean): SourceFile;
var disableIncrementalParsing: boolean;
let disableIncrementalParsing: boolean;
function updateLanguageServiceSourceFile(sourceFile: SourceFile, scriptSnapshot: IScriptSnapshot, version: string, textChangeRange: TextChangeRange, aggressiveChecks?: boolean): SourceFile;
function createDocumentRegistry(): DocumentRegistry;
function preProcessFile(sourceText: string, readImportFiles?: boolean): PreProcessedFileInfo;
@@ -947,67 +947,70 @@ declare module "typescript" {
ModuleBlock = 201,
>ModuleBlock : SyntaxKind
ImportEqualsDeclaration = 202,
CaseBlock = 202,
>CaseBlock : SyntaxKind
ImportEqualsDeclaration = 203,
>ImportEqualsDeclaration : SyntaxKind
ImportDeclaration = 203,
ImportDeclaration = 204,
>ImportDeclaration : SyntaxKind
ImportClause = 204,
ImportClause = 205,
>ImportClause : SyntaxKind
NamespaceImport = 205,
NamespaceImport = 206,
>NamespaceImport : SyntaxKind
NamedImports = 206,
NamedImports = 207,
>NamedImports : SyntaxKind
ImportSpecifier = 207,
ImportSpecifier = 208,
>ImportSpecifier : SyntaxKind
ExportAssignment = 208,
ExportAssignment = 209,
>ExportAssignment : SyntaxKind
ExportDeclaration = 209,
ExportDeclaration = 210,
>ExportDeclaration : SyntaxKind
NamedExports = 210,
NamedExports = 211,
>NamedExports : SyntaxKind
ExportSpecifier = 211,
ExportSpecifier = 212,
>ExportSpecifier : SyntaxKind
ExternalModuleReference = 212,
ExternalModuleReference = 213,
>ExternalModuleReference : SyntaxKind
CaseClause = 213,
CaseClause = 214,
>CaseClause : SyntaxKind
DefaultClause = 214,
DefaultClause = 215,
>DefaultClause : SyntaxKind
HeritageClause = 215,
HeritageClause = 216,
>HeritageClause : SyntaxKind
CatchClause = 216,
CatchClause = 217,
>CatchClause : SyntaxKind
PropertyAssignment = 217,
PropertyAssignment = 218,
>PropertyAssignment : SyntaxKind
ShorthandPropertyAssignment = 218,
ShorthandPropertyAssignment = 219,
>ShorthandPropertyAssignment : SyntaxKind
EnumMember = 219,
EnumMember = 220,
>EnumMember : SyntaxKind
SourceFile = 220,
SourceFile = 221,
>SourceFile : SyntaxKind
SyntaxList = 221,
SyntaxList = 222,
>SyntaxList : SyntaxKind
Count = 222,
Count = 223,
>Count : SyntaxKind
FirstAssignment = 52,
@@ -2126,6 +2129,14 @@ declare module "typescript" {
>expression : Expression
>Expression : Expression
caseBlock: CaseBlock;
>caseBlock : CaseBlock
>CaseBlock : CaseBlock
}
interface CaseBlock extends Node {
>CaseBlock : CaseBlock
>Node : Node
clauses: NodeArray<CaseOrDefaultClause>;
>clauses : NodeArray<CaseClause | DefaultClause>
>NodeArray : NodeArray<T>
@@ -4903,7 +4914,7 @@ declare module "typescript" {
}
declare module "typescript" {
/** The version of the language service API */
var servicesVersion: string;
let servicesVersion: string;
>servicesVersion : string
interface Node {
@@ -6253,7 +6264,7 @@ declare module "typescript" {
>setNodeParents : boolean
>SourceFile : SourceFile
var disableIncrementalParsing: boolean;
let disableIncrementalParsing: boolean;
>disableIncrementalParsing : boolean
function updateLanguageServiceSourceFile(sourceFile: SourceFile, scriptSnapshot: IScriptSnapshot, version: string, textChangeRange: TextChangeRange, aggressiveChecks?: boolean): SourceFile;
@@ -293,27 +293,28 @@ declare module "typescript" {
EnumDeclaration = 199,
ModuleDeclaration = 200,
ModuleBlock = 201,
ImportEqualsDeclaration = 202,
ImportDeclaration = 203,
ImportClause = 204,
NamespaceImport = 205,
NamedImports = 206,
ImportSpecifier = 207,
ExportAssignment = 208,
ExportDeclaration = 209,
NamedExports = 210,
ExportSpecifier = 211,
ExternalModuleReference = 212,
CaseClause = 213,
DefaultClause = 214,
HeritageClause = 215,
CatchClause = 216,
PropertyAssignment = 217,
ShorthandPropertyAssignment = 218,
EnumMember = 219,
SourceFile = 220,
SyntaxList = 221,
Count = 222,
CaseBlock = 202,
ImportEqualsDeclaration = 203,
ImportDeclaration = 204,
ImportClause = 205,
NamespaceImport = 206,
NamedImports = 207,
ImportSpecifier = 208,
ExportAssignment = 209,
ExportDeclaration = 210,
NamedExports = 211,
ExportSpecifier = 212,
ExternalModuleReference = 213,
CaseClause = 214,
DefaultClause = 215,
HeritageClause = 216,
CatchClause = 217,
PropertyAssignment = 218,
ShorthandPropertyAssignment = 219,
EnumMember = 220,
SourceFile = 221,
SyntaxList = 222,
Count = 223,
FirstAssignment = 52,
LastAssignment = 63,
FirstReservedWord = 65,
@@ -688,6 +689,9 @@ declare module "typescript" {
}
interface SwitchStatement extends Statement {
expression: Expression;
caseBlock: CaseBlock;
}
interface CaseBlock extends Node {
clauses: NodeArray<CaseOrDefaultClause>;
}
interface CaseClause extends Node {
@@ -1516,7 +1520,7 @@ declare module "typescript" {
}
declare module "typescript" {
/** The version of the language service API */
var servicesVersion: string;
let servicesVersion: string;
interface Node {
getSourceFile(): SourceFile;
getChildCount(sourceFile?: SourceFile): number;
@@ -2003,7 +2007,7 @@ declare module "typescript" {
throwIfCancellationRequested(): void;
}
function createLanguageServiceSourceFile(fileName: string, scriptSnapshot: IScriptSnapshot, scriptTarget: ScriptTarget, version: string, setNodeParents: boolean): SourceFile;
var disableIncrementalParsing: boolean;
let disableIncrementalParsing: boolean;
function updateLanguageServiceSourceFile(sourceFile: SourceFile, scriptSnapshot: IScriptSnapshot, version: string, textChangeRange: TextChangeRange, aggressiveChecks?: boolean): SourceFile;
function createDocumentRegistry(): DocumentRegistry;
function preProcessFile(sourceText: string, readImportFiles?: boolean): PreProcessedFileInfo;
@@ -897,67 +897,70 @@ declare module "typescript" {
ModuleBlock = 201,
>ModuleBlock : SyntaxKind
ImportEqualsDeclaration = 202,
CaseBlock = 202,
>CaseBlock : SyntaxKind
ImportEqualsDeclaration = 203,
>ImportEqualsDeclaration : SyntaxKind
ImportDeclaration = 203,
ImportDeclaration = 204,
>ImportDeclaration : SyntaxKind
ImportClause = 204,
ImportClause = 205,
>ImportClause : SyntaxKind
NamespaceImport = 205,
NamespaceImport = 206,
>NamespaceImport : SyntaxKind
NamedImports = 206,
NamedImports = 207,
>NamedImports : SyntaxKind
ImportSpecifier = 207,
ImportSpecifier = 208,
>ImportSpecifier : SyntaxKind
ExportAssignment = 208,
ExportAssignment = 209,
>ExportAssignment : SyntaxKind
ExportDeclaration = 209,
ExportDeclaration = 210,
>ExportDeclaration : SyntaxKind
NamedExports = 210,
NamedExports = 211,
>NamedExports : SyntaxKind
ExportSpecifier = 211,
ExportSpecifier = 212,
>ExportSpecifier : SyntaxKind
ExternalModuleReference = 212,
ExternalModuleReference = 213,
>ExternalModuleReference : SyntaxKind
CaseClause = 213,
CaseClause = 214,
>CaseClause : SyntaxKind
DefaultClause = 214,
DefaultClause = 215,
>DefaultClause : SyntaxKind
HeritageClause = 215,
HeritageClause = 216,
>HeritageClause : SyntaxKind
CatchClause = 216,
CatchClause = 217,
>CatchClause : SyntaxKind
PropertyAssignment = 217,
PropertyAssignment = 218,
>PropertyAssignment : SyntaxKind
ShorthandPropertyAssignment = 218,
ShorthandPropertyAssignment = 219,
>ShorthandPropertyAssignment : SyntaxKind
EnumMember = 219,
EnumMember = 220,
>EnumMember : SyntaxKind
SourceFile = 220,
SourceFile = 221,
>SourceFile : SyntaxKind
SyntaxList = 221,
SyntaxList = 222,
>SyntaxList : SyntaxKind
Count = 222,
Count = 223,
>Count : SyntaxKind
FirstAssignment = 52,
@@ -2076,6 +2079,14 @@ declare module "typescript" {
>expression : Expression
>Expression : Expression
caseBlock: CaseBlock;
>caseBlock : CaseBlock
>CaseBlock : CaseBlock
}
interface CaseBlock extends Node {
>CaseBlock : CaseBlock
>Node : Node
clauses: NodeArray<CaseOrDefaultClause>;
>clauses : NodeArray<CaseClause | DefaultClause>
>NodeArray : NodeArray<T>
@@ -4853,7 +4864,7 @@ declare module "typescript" {
}
declare module "typescript" {
/** The version of the language service API */
var servicesVersion: string;
let servicesVersion: string;
>servicesVersion : string
interface Node {
@@ -6203,7 +6214,7 @@ declare module "typescript" {
>setNodeParents : boolean
>SourceFile : SourceFile
var disableIncrementalParsing: boolean;
let disableIncrementalParsing: boolean;
>disableIncrementalParsing : boolean
function updateLanguageServiceSourceFile(sourceFile: SourceFile, scriptSnapshot: IScriptSnapshot, version: string, textChangeRange: TextChangeRange, aggressiveChecks?: boolean): SourceFile;
+27 -23
View File
@@ -330,27 +330,28 @@ declare module "typescript" {
EnumDeclaration = 199,
ModuleDeclaration = 200,
ModuleBlock = 201,
ImportEqualsDeclaration = 202,
ImportDeclaration = 203,
ImportClause = 204,
NamespaceImport = 205,
NamedImports = 206,
ImportSpecifier = 207,
ExportAssignment = 208,
ExportDeclaration = 209,
NamedExports = 210,
ExportSpecifier = 211,
ExternalModuleReference = 212,
CaseClause = 213,
DefaultClause = 214,
HeritageClause = 215,
CatchClause = 216,
PropertyAssignment = 217,
ShorthandPropertyAssignment = 218,
EnumMember = 219,
SourceFile = 220,
SyntaxList = 221,
Count = 222,
CaseBlock = 202,
ImportEqualsDeclaration = 203,
ImportDeclaration = 204,
ImportClause = 205,
NamespaceImport = 206,
NamedImports = 207,
ImportSpecifier = 208,
ExportAssignment = 209,
ExportDeclaration = 210,
NamedExports = 211,
ExportSpecifier = 212,
ExternalModuleReference = 213,
CaseClause = 214,
DefaultClause = 215,
HeritageClause = 216,
CatchClause = 217,
PropertyAssignment = 218,
ShorthandPropertyAssignment = 219,
EnumMember = 220,
SourceFile = 221,
SyntaxList = 222,
Count = 223,
FirstAssignment = 52,
LastAssignment = 63,
FirstReservedWord = 65,
@@ -725,6 +726,9 @@ declare module "typescript" {
}
interface SwitchStatement extends Statement {
expression: Expression;
caseBlock: CaseBlock;
}
interface CaseBlock extends Node {
clauses: NodeArray<CaseOrDefaultClause>;
}
interface CaseClause extends Node {
@@ -1553,7 +1557,7 @@ declare module "typescript" {
}
declare module "typescript" {
/** The version of the language service API */
var servicesVersion: string;
let servicesVersion: string;
interface Node {
getSourceFile(): SourceFile;
getChildCount(sourceFile?: SourceFile): number;
@@ -2040,7 +2044,7 @@ declare module "typescript" {
throwIfCancellationRequested(): void;
}
function createLanguageServiceSourceFile(fileName: string, scriptSnapshot: IScriptSnapshot, scriptTarget: ScriptTarget, version: string, setNodeParents: boolean): SourceFile;
var disableIncrementalParsing: boolean;
let disableIncrementalParsing: boolean;
function updateLanguageServiceSourceFile(sourceFile: SourceFile, scriptSnapshot: IScriptSnapshot, version: string, textChangeRange: TextChangeRange, aggressiveChecks?: boolean): SourceFile;
function createDocumentRegistry(): DocumentRegistry;
function preProcessFile(sourceText: string, readImportFiles?: boolean): PreProcessedFileInfo;
@@ -1070,67 +1070,70 @@ declare module "typescript" {
ModuleBlock = 201,
>ModuleBlock : SyntaxKind
ImportEqualsDeclaration = 202,
CaseBlock = 202,
>CaseBlock : SyntaxKind
ImportEqualsDeclaration = 203,
>ImportEqualsDeclaration : SyntaxKind
ImportDeclaration = 203,
ImportDeclaration = 204,
>ImportDeclaration : SyntaxKind
ImportClause = 204,
ImportClause = 205,
>ImportClause : SyntaxKind
NamespaceImport = 205,
NamespaceImport = 206,
>NamespaceImport : SyntaxKind
NamedImports = 206,
NamedImports = 207,
>NamedImports : SyntaxKind
ImportSpecifier = 207,
ImportSpecifier = 208,
>ImportSpecifier : SyntaxKind
ExportAssignment = 208,
ExportAssignment = 209,
>ExportAssignment : SyntaxKind
ExportDeclaration = 209,
ExportDeclaration = 210,
>ExportDeclaration : SyntaxKind
NamedExports = 210,
NamedExports = 211,
>NamedExports : SyntaxKind
ExportSpecifier = 211,
ExportSpecifier = 212,
>ExportSpecifier : SyntaxKind
ExternalModuleReference = 212,
ExternalModuleReference = 213,
>ExternalModuleReference : SyntaxKind
CaseClause = 213,
CaseClause = 214,
>CaseClause : SyntaxKind
DefaultClause = 214,
DefaultClause = 215,
>DefaultClause : SyntaxKind
HeritageClause = 215,
HeritageClause = 216,
>HeritageClause : SyntaxKind
CatchClause = 216,
CatchClause = 217,
>CatchClause : SyntaxKind
PropertyAssignment = 217,
PropertyAssignment = 218,
>PropertyAssignment : SyntaxKind
ShorthandPropertyAssignment = 218,
ShorthandPropertyAssignment = 219,
>ShorthandPropertyAssignment : SyntaxKind
EnumMember = 219,
EnumMember = 220,
>EnumMember : SyntaxKind
SourceFile = 220,
SourceFile = 221,
>SourceFile : SyntaxKind
SyntaxList = 221,
SyntaxList = 222,
>SyntaxList : SyntaxKind
Count = 222,
Count = 223,
>Count : SyntaxKind
FirstAssignment = 52,
@@ -2249,6 +2252,14 @@ declare module "typescript" {
>expression : Expression
>Expression : Expression
caseBlock: CaseBlock;
>caseBlock : CaseBlock
>CaseBlock : CaseBlock
}
interface CaseBlock extends Node {
>CaseBlock : CaseBlock
>Node : Node
clauses: NodeArray<CaseOrDefaultClause>;
>clauses : NodeArray<CaseClause | DefaultClause>
>NodeArray : NodeArray<T>
@@ -5026,7 +5037,7 @@ declare module "typescript" {
}
declare module "typescript" {
/** The version of the language service API */
var servicesVersion: string;
let servicesVersion: string;
>servicesVersion : string
interface Node {
@@ -6376,7 +6387,7 @@ declare module "typescript" {
>setNodeParents : boolean
>SourceFile : SourceFile
var disableIncrementalParsing: boolean;
let disableIncrementalParsing: boolean;
>disableIncrementalParsing : boolean
function updateLanguageServiceSourceFile(sourceFile: SourceFile, scriptSnapshot: IScriptSnapshot, version: string, textChangeRange: TextChangeRange, aggressiveChecks?: boolean): SourceFile;
@@ -0,0 +1,7 @@
tests/cases/conformance/statements/for-ofStatements/ES3For-ofTypeCheck1.ts(1,15): error TS2494: Using a string in a 'for...of' statement is only supported in ECMAScript 5 and higher.
==== tests/cases/conformance/statements/for-ofStatements/ES3For-ofTypeCheck1.ts (1 errors) ====
for (var v of "") { }
~~
!!! error TS2494: Using a string in a 'for...of' statement is only supported in ECMAScript 5 and higher.
@@ -0,0 +1,7 @@
//// [ES3For-ofTypeCheck1.ts]
for (var v of "") { }
//// [ES3For-ofTypeCheck1.js]
for (var _i = 0, _a = ""; _i < _a.length; _i++) {
var v = _a[_i];
}
@@ -0,0 +1,9 @@
//// [ES3For-ofTypeCheck2.ts]
for (var v of [true]) { }
//// [ES3For-ofTypeCheck2.js]
for (var _i = 0, _a = [
true
]; _i < _a.length; _i++) {
var v = _a[_i];
}
@@ -0,0 +1,5 @@
=== tests/cases/conformance/statements/for-ofStatements/ES3For-ofTypeCheck2.ts ===
for (var v of [true]) { }
>v : boolean
>[true] : boolean[]
@@ -0,0 +1,8 @@
tests/cases/conformance/statements/for-ofStatements/ES3For-ofTypeCheck4.ts(2,17): error TS2494: Using a string in a 'for...of' statement is only supported in ECMAScript 5 and higher.
==== tests/cases/conformance/statements/for-ofStatements/ES3For-ofTypeCheck4.ts (1 errors) ====
var union: string | string[];
for (const v of union) { }
~~~~~
!!! error TS2494: Using a string in a 'for...of' statement is only supported in ECMAScript 5 and higher.
@@ -0,0 +1,9 @@
//// [ES3For-ofTypeCheck4.ts]
var union: string | string[];
for (const v of union) { }
//// [ES3For-ofTypeCheck4.js]
var union;
for (var _i = 0; _i < union.length; _i++) {
var v = union[_i];
}
@@ -0,0 +1,9 @@
//// [ES3For-ofTypeCheck6.ts]
var union: string[] | number[];
for (var v of union) { }
//// [ES3For-ofTypeCheck6.js]
var union;
for (var _i = 0; _i < union.length; _i++) {
var v = union[_i];
}
@@ -0,0 +1,8 @@
=== tests/cases/conformance/statements/for-ofStatements/ES3For-ofTypeCheck6.ts ===
var union: string[] | number[];
>union : string[] | number[]
for (var v of union) { }
>v : string | number
>union : string[] | number[]
@@ -0,0 +1,9 @@
tests/cases/conformance/statements/for-ofStatements/ES5For-of1.ts(2,5): error TS2304: Cannot find name 'console'.
==== tests/cases/conformance/statements/for-ofStatements/ES5For-of1.ts (1 errors) ====
for (var v of ['a', 'b', 'c']) {
console.log(v);
~~~~~~~
!!! error TS2304: Cannot find name 'console'.
}
+15
View File
@@ -0,0 +1,15 @@
//// [ES5For-of1.ts]
for (var v of ['a', 'b', 'c']) {
console.log(v);
}
//// [ES5For-of1.js]
for (var _i = 0, _a = [
'a',
'b',
'c'
]; _i < _a.length; _i++) {
var v = _a[_i];
console.log(v);
}
//# sourceMappingURL=ES5For-of1.js.map
@@ -0,0 +1,2 @@
//// [ES5For-of1.js.map]
{"version":3,"file":"ES5For-of1.js","sourceRoot":"","sources":["ES5For-of1.ts"],"names":[],"mappings":"AAAA,GAAG,CAAC,CAAU,UAAe,EAAf;IAAC,GAAG;IAAE,GAAG;IAAE,GAAG;CAAC,EAAxB,cAAK,EAAL,IAAwB,CAAC;IAAzB,IAAI,CAAC,SAAA;IACN,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;CAClB"}
@@ -0,0 +1,127 @@
===================================================================
JsFile: ES5For-of1.js
mapUrl: ES5For-of1.js.map
sourceRoot:
sources: ES5For-of1.ts
===================================================================
-------------------------------------------------------------------
emittedFile:tests/cases/conformance/statements/for-ofStatements/ES5For-of1.js
sourceFile:ES5For-of1.ts
-------------------------------------------------------------------
>>>for (var _i = 0, _a = [
1 >
2 >^^^
3 > ^
4 > ^
5 > ^^^^^^^^^^
6 > ^^
1 >
2 >for
3 >
4 > (var v of
5 > ['a', 'b', 'c']
6 >
1 >Emitted(1, 1) Source(1, 1) + SourceIndex(0)
2 >Emitted(1, 4) Source(1, 4) + SourceIndex(0)
3 >Emitted(1, 5) Source(1, 5) + SourceIndex(0)
4 >Emitted(1, 6) Source(1, 15) + SourceIndex(0)
5 >Emitted(1, 16) Source(1, 30) + SourceIndex(0)
6 >Emitted(1, 18) Source(1, 15) + SourceIndex(0)
---
>>> 'a',
1 >^^^^
2 > ^^^
3 > ^^->
1 >[
2 > 'a'
1 >Emitted(2, 5) Source(1, 16) + SourceIndex(0)
2 >Emitted(2, 8) Source(1, 19) + SourceIndex(0)
---
>>> 'b',
1->^^^^
2 > ^^^
3 > ^->
1->,
2 > 'b'
1->Emitted(3, 5) Source(1, 21) + SourceIndex(0)
2 >Emitted(3, 8) Source(1, 24) + SourceIndex(0)
---
>>> 'c'
1->^^^^
2 > ^^^
3 > ^^^^^^^^^^^^^^^^^^^^->
1->,
2 > 'c'
1->Emitted(4, 5) Source(1, 26) + SourceIndex(0)
2 >Emitted(4, 8) Source(1, 29) + SourceIndex(0)
---
>>>]; _i < _a.length; _i++) {
1->^
2 > ^^
3 > ^^^^^^^^^^^^^^
4 > ^^
5 > ^^^^
6 > ^
1->]
2 >
3 > var v
4 >
5 > var v of ['a', 'b', 'c']
6 > )
1->Emitted(5, 2) Source(1, 30) + SourceIndex(0)
2 >Emitted(5, 4) Source(1, 6) + SourceIndex(0)
3 >Emitted(5, 18) Source(1, 11) + SourceIndex(0)
4 >Emitted(5, 20) Source(1, 6) + SourceIndex(0)
5 >Emitted(5, 24) Source(1, 30) + SourceIndex(0)
6 >Emitted(5, 25) Source(1, 31) + SourceIndex(0)
---
>>> var v = _a[_i];
1 >^^^^
2 > ^^^^
3 > ^
4 > ^^^^^^^^^
5 > ^^->
1 >
2 > var
3 > v
4 >
1 >Emitted(6, 5) Source(1, 6) + SourceIndex(0)
2 >Emitted(6, 9) Source(1, 10) + SourceIndex(0)
3 >Emitted(6, 10) Source(1, 11) + SourceIndex(0)
4 >Emitted(6, 19) Source(1, 11) + SourceIndex(0)
---
>>> console.log(v);
1->^^^^
2 > ^^^^^^^
3 > ^
4 > ^^^
5 > ^
6 > ^
7 > ^
8 > ^
1-> of ['a', 'b', 'c']) {
>
2 > console
3 > .
4 > log
5 > (
6 > v
7 > )
8 > ;
1->Emitted(7, 5) Source(2, 5) + SourceIndex(0)
2 >Emitted(7, 12) Source(2, 12) + SourceIndex(0)
3 >Emitted(7, 13) Source(2, 13) + SourceIndex(0)
4 >Emitted(7, 16) Source(2, 16) + SourceIndex(0)
5 >Emitted(7, 17) Source(2, 17) + SourceIndex(0)
6 >Emitted(7, 18) Source(2, 18) + SourceIndex(0)
7 >Emitted(7, 19) Source(2, 19) + SourceIndex(0)
8 >Emitted(7, 20) Source(2, 20) + SourceIndex(0)
---
>>>}
1 >^
2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^->
1 >
>}
1 >Emitted(8, 2) Source(3, 2) + SourceIndex(0)
---
>>>//# sourceMappingURL=ES5For-of1.js.map
+22
View File
@@ -0,0 +1,22 @@
//// [ES5For-of10.ts]
function foo() {
return { x: 0 };
}
for (foo().x of []) {
for (foo().x of [])
var p = foo().x;
}
//// [ES5For-of10.js]
function foo() {
return {
x: 0
};
}
for (var _i = 0, _a = []; _i < _a.length; _i++) {
foo().x = _a[_i];
for (var _b = 0, _c = []; _b < _c.length; _b++) {
foo().x = _c[_b];
var p = foo().x;
}
}
@@ -0,0 +1,29 @@
=== tests/cases/conformance/statements/for-ofStatements/ES5For-of10.ts ===
function foo() {
>foo : () => { x: number; }
return { x: 0 };
>{ x: 0 } : { x: number; }
>x : number
}
for (foo().x of []) {
>foo().x : number
>foo() : { x: number; }
>foo : () => { x: number; }
>x : number
>[] : undefined[]
for (foo().x of [])
>foo().x : number
>foo() : { x: number; }
>foo : () => { x: number; }
>x : number
>[] : undefined[]
var p = foo().x;
>p : number
>foo().x : number
>foo() : { x: number; }
>foo : () => { x: number; }
>x : number
}
+9
View File
@@ -0,0 +1,9 @@
//// [ES5For-of11.ts]
var v;
for (v of []) { }
//// [ES5For-of11.js]
var v;
for (var _i = 0, _a = []; _i < _a.length; _i++) {
v = _a[_i];
}
@@ -0,0 +1,8 @@
=== tests/cases/conformance/statements/for-ofStatements/ES5For-of11.ts ===
var v;
>v : any
for (v of []) { }
>v : any
>[] : undefined[]
@@ -0,0 +1,7 @@
tests/cases/conformance/statements/for-ofStatements/ES5For-of12.ts(1,7): error TS2364: Invalid left-hand side of assignment expression.
==== tests/cases/conformance/statements/for-ofStatements/ES5For-of12.ts (1 errors) ====
for ([""] of [[""]]) { }
~~
!!! error TS2364: Invalid left-hand side of assignment expression.
+11
View File
@@ -0,0 +1,11 @@
//// [ES5For-of12.ts]
for ([""] of [[""]]) { }
//// [ES5For-of12.js]
for (var _i = 0, _a = [
[
""
]
]; _i < _a.length; _i++) {
"" = _a[_i][0];
}
+15
View File
@@ -0,0 +1,15 @@
//// [ES5For-of13.ts]
for (let v of ['a', 'b', 'c']) {
var x = v;
}
//// [ES5For-of13.js]
for (var _i = 0, _a = [
'a',
'b',
'c'
]; _i < _a.length; _i++) {
var v = _a[_i];
var x = v;
}
//# sourceMappingURL=ES5For-of13.js.map
@@ -0,0 +1,2 @@
//// [ES5For-of13.js.map]
{"version":3,"file":"ES5For-of13.js","sourceRoot":"","sources":["ES5For-of13.ts"],"names":[],"mappings":"AAAA,GAAG,CAAC,CAAU,UAAe,EAAf;IAAC,GAAG;IAAE,GAAG;IAAE,GAAG;CAAC,EAAxB,cAAK,EAAL,IAAwB,CAAC;IAAzB,IAAI,CAAC,SAAA;IACN,IAAI,CAAC,GAAG,CAAC,CAAC;CACb"}
@@ -0,0 +1,120 @@
===================================================================
JsFile: ES5For-of13.js
mapUrl: ES5For-of13.js.map
sourceRoot:
sources: ES5For-of13.ts
===================================================================
-------------------------------------------------------------------
emittedFile:tests/cases/conformance/statements/for-ofStatements/ES5For-of13.js
sourceFile:ES5For-of13.ts
-------------------------------------------------------------------
>>>for (var _i = 0, _a = [
1 >
2 >^^^
3 > ^
4 > ^
5 > ^^^^^^^^^^
6 > ^^
1 >
2 >for
3 >
4 > (let v of
5 > ['a', 'b', 'c']
6 >
1 >Emitted(1, 1) Source(1, 1) + SourceIndex(0)
2 >Emitted(1, 4) Source(1, 4) + SourceIndex(0)
3 >Emitted(1, 5) Source(1, 5) + SourceIndex(0)
4 >Emitted(1, 6) Source(1, 15) + SourceIndex(0)
5 >Emitted(1, 16) Source(1, 30) + SourceIndex(0)
6 >Emitted(1, 18) Source(1, 15) + SourceIndex(0)
---
>>> 'a',
1 >^^^^
2 > ^^^
3 > ^^->
1 >[
2 > 'a'
1 >Emitted(2, 5) Source(1, 16) + SourceIndex(0)
2 >Emitted(2, 8) Source(1, 19) + SourceIndex(0)
---
>>> 'b',
1->^^^^
2 > ^^^
3 > ^->
1->,
2 > 'b'
1->Emitted(3, 5) Source(1, 21) + SourceIndex(0)
2 >Emitted(3, 8) Source(1, 24) + SourceIndex(0)
---
>>> 'c'
1->^^^^
2 > ^^^
3 > ^^^^^^^^^^^^^^^^^^^^->
1->,
2 > 'c'
1->Emitted(4, 5) Source(1, 26) + SourceIndex(0)
2 >Emitted(4, 8) Source(1, 29) + SourceIndex(0)
---
>>>]; _i < _a.length; _i++) {
1->^
2 > ^^
3 > ^^^^^^^^^^^^^^
4 > ^^
5 > ^^^^
6 > ^
1->]
2 >
3 > let v
4 >
5 > let v of ['a', 'b', 'c']
6 > )
1->Emitted(5, 2) Source(1, 30) + SourceIndex(0)
2 >Emitted(5, 4) Source(1, 6) + SourceIndex(0)
3 >Emitted(5, 18) Source(1, 11) + SourceIndex(0)
4 >Emitted(5, 20) Source(1, 6) + SourceIndex(0)
5 >Emitted(5, 24) Source(1, 30) + SourceIndex(0)
6 >Emitted(5, 25) Source(1, 31) + SourceIndex(0)
---
>>> var v = _a[_i];
1 >^^^^
2 > ^^^^
3 > ^
4 > ^^^^^^^^^
1 >
2 > let
3 > v
4 >
1 >Emitted(6, 5) Source(1, 6) + SourceIndex(0)
2 >Emitted(6, 9) Source(1, 10) + SourceIndex(0)
3 >Emitted(6, 10) Source(1, 11) + SourceIndex(0)
4 >Emitted(6, 19) Source(1, 11) + SourceIndex(0)
---
>>> var x = v;
1 >^^^^
2 > ^^^^
3 > ^
4 > ^^^
5 > ^
6 > ^
1 > of ['a', 'b', 'c']) {
>
2 > var
3 > x
4 > =
5 > v
6 > ;
1 >Emitted(7, 5) Source(2, 5) + SourceIndex(0)
2 >Emitted(7, 9) Source(2, 9) + SourceIndex(0)
3 >Emitted(7, 10) Source(2, 10) + SourceIndex(0)
4 >Emitted(7, 13) Source(2, 13) + SourceIndex(0)
5 >Emitted(7, 14) Source(2, 14) + SourceIndex(0)
6 >Emitted(7, 15) Source(2, 15) + SourceIndex(0)
---
>>>}
1 >^
2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^->
1 >
>}
1 >Emitted(8, 2) Source(3, 2) + SourceIndex(0)
---
>>>//# sourceMappingURL=ES5For-of13.js.map
@@ -0,0 +1,9 @@
=== tests/cases/conformance/statements/for-ofStatements/ES5For-of13.ts ===
for (let v of ['a', 'b', 'c']) {
>v : string
>['a', 'b', 'c'] : string[]
var x = v;
>x : string
>v : string
}
+10
View File
@@ -0,0 +1,10 @@
//// [ES5For-of14.ts]
for (const v of []) {
var x = v;
}
//// [ES5For-of14.js]
for (var _i = 0, _a = []; _i < _a.length; _i++) {
var v = _a[_i];
var x = v;
}
@@ -0,0 +1,9 @@
=== tests/cases/conformance/statements/for-ofStatements/ES5For-of14.ts ===
for (const v of []) {
>v : any
>[] : undefined[]
var x = v;
>x : any
>v : any
}
+17
View File
@@ -0,0 +1,17 @@
//// [ES5For-of15.ts]
for (let v of []) {
v;
for (const v of []) {
var x = v;
}
}
//// [ES5For-of15.js]
for (var _i = 0, _a = []; _i < _a.length; _i++) {
var v = _a[_i];
v;
for (var _b = 0, _c = []; _b < _c.length; _b++) {
var _v = _c[_b];
var x = _v;
}
}
@@ -0,0 +1,17 @@
=== tests/cases/conformance/statements/for-ofStatements/ES5For-of15.ts ===
for (let v of []) {
>v : any
>[] : undefined[]
v;
>v : any
for (const v of []) {
>v : any
>[] : undefined[]
var x = v;
>x : any
>v : any
}
}
+19
View File
@@ -0,0 +1,19 @@
//// [ES5For-of16.ts]
for (let v of []) {
v;
for (let v of []) {
var x = v;
v++;
}
}
//// [ES5For-of16.js]
for (var _i = 0, _a = []; _i < _a.length; _i++) {
var v = _a[_i];
v;
for (var _b = 0, _c = []; _b < _c.length; _b++) {
var _v = _c[_b];
var x = _v;
_v++;
}
}
@@ -0,0 +1,21 @@
=== tests/cases/conformance/statements/for-ofStatements/ES5For-of16.ts ===
for (let v of []) {
>v : any
>[] : undefined[]
v;
>v : any
for (let v of []) {
>v : any
>[] : undefined[]
var x = v;
>x : any
>v : any
v++;
>v++ : number
>v : any
}
}
@@ -0,0 +1,13 @@
tests/cases/conformance/statements/for-ofStatements/ES5For-of17.ts(3,20): error TS2448: Block-scoped variable 'v' used before its declaration.
==== tests/cases/conformance/statements/for-ofStatements/ES5For-of17.ts (1 errors) ====
for (let v of []) {
v;
for (let v of [v]) {
~
!!! error TS2448: Block-scoped variable 'v' used before its declaration.
var x = v;
v++;
}
}
+21
View File
@@ -0,0 +1,21 @@
//// [ES5For-of17.ts]
for (let v of []) {
v;
for (let v of [v]) {
var x = v;
v++;
}
}
//// [ES5For-of17.js]
for (var _i = 0, _a = []; _i < _a.length; _i++) {
var v = _a[_i];
v;
for (var _b = 0, _c = [
v
]; _b < _c.length; _b++) {
var _v = _c[_b];
var x = _v;
_v++;
}
}
+18
View File
@@ -0,0 +1,18 @@
//// [ES5For-of18.ts]
for (let v of []) {
v;
}
for (let v of []) {
v;
}
//// [ES5For-of18.js]
for (var _i = 0, _a = []; _i < _a.length; _i++) {
var v = _a[_i];
v;
}
for (var _b = 0, _c = []; _b < _c.length; _b++) {
var _v = _c[_b];
_v;
}
@@ -0,0 +1,16 @@
=== tests/cases/conformance/statements/for-ofStatements/ES5For-of18.ts ===
for (let v of []) {
>v : any
>[] : undefined[]
v;
>v : any
}
for (let v of []) {
>v : any
>[] : undefined[]
v;
>v : any
}
+22
View File
@@ -0,0 +1,22 @@
//// [ES5For-of19.ts]
for (let v of []) {
v;
function foo() {
for (const v of []) {
v;
}
}
}
//// [ES5For-of19.js]
for (var _i = 0, _a = []; _i < _a.length; _i++) {
var v = _a[_i];
v;
function foo() {
for (var _b = 0, _c = []; _b < _c.length; _b++) {
var _v = _c[_b];
_v;
}
}
}
@@ -0,0 +1,21 @@
=== tests/cases/conformance/statements/for-ofStatements/ES5For-of19.ts ===
for (let v of []) {
>v : any
>[] : undefined[]
v;
>v : any
function foo() {
>foo : () => void
for (const v of []) {
>v : any
>[] : undefined[]
v;
>v : any
}
}
}
+10
View File
@@ -0,0 +1,10 @@
//// [ES5For-of2.ts]
for (var v of []) {
var x = v;
}
//// [ES5For-of2.js]
for (var _i = 0, _a = []; _i < _a.length; _i++) {
var v = _a[_i];
var x = v;
}
@@ -0,0 +1,9 @@
=== tests/cases/conformance/statements/for-ofStatements/ES5For-of2.ts ===
for (var v of []) {
>v : any
>[] : undefined[]
var x = v;
>x : any
>v : any
}
@@ -0,0 +1,15 @@
tests/cases/conformance/statements/for-ofStatements/ES5For-of20.ts(3,20): error TS2448: Block-scoped variable 'v' used before its declaration.
tests/cases/conformance/statements/for-ofStatements/ES5For-of20.ts(4,15): error TS1155: 'const' declarations must be initialized
==== tests/cases/conformance/statements/for-ofStatements/ES5For-of20.ts (2 errors) ====
for (let v of []) {
let v;
for (let v of [v]) {
~
!!! error TS2448: Block-scoped variable 'v' used before its declaration.
const v;
~
!!! error TS1155: 'const' declarations must be initialized
}
}
+19
View File
@@ -0,0 +1,19 @@
//// [ES5For-of20.ts]
for (let v of []) {
let v;
for (let v of [v]) {
const v;
}
}
//// [ES5For-of20.js]
for (var _i = 0, _a = []; _i < _a.length; _i++) {
var v = _a[_i];
var _v;
for (var _b = 0, _c = [
v
]; _b < _c.length; _b++) {
var _v_1 = _c[_b];
var _v_2;
}
}
+12
View File
@@ -0,0 +1,12 @@
//// [ES5For-of21.ts]
for (let v of []) {
for (let _i of []) { }
}
//// [ES5For-of21.js]
for (var _i = 0, _a = []; _i < _a.length; _i++) {
var v = _a[_i];
for (var _b = 0, _c = []; _b < _c.length; _b++) {
var _i_1 = _c[_b];
}
}
@@ -0,0 +1,9 @@
=== tests/cases/conformance/statements/for-ofStatements/ES5For-of21.ts ===
for (let v of []) {
>v : any
>[] : undefined[]
for (let _i of []) { }
>_i : any
>[] : undefined[]
}
@@ -0,0 +1,10 @@
tests/cases/conformance/statements/for-ofStatements/ES5For-of22.ts(3,5): error TS2304: Cannot find name 'console'.
==== tests/cases/conformance/statements/for-ofStatements/ES5For-of22.ts (1 errors) ====
for (var x of [1, 2, 3]) {
let _a = 0;
console.log(x);
~~~~~~~
!!! error TS2304: Cannot find name 'console'.
}
+16
View File
@@ -0,0 +1,16 @@
//// [ES5For-of22.ts]
for (var x of [1, 2, 3]) {
let _a = 0;
console.log(x);
}
//// [ES5For-of22.js]
for (var _i = 0, _a = [
1,
2,
3
]; _i < _a.length; _i++) {
var x = _a[_i];
var _a_1 = 0;
console.log(x);
}
@@ -0,0 +1,10 @@
tests/cases/conformance/statements/for-ofStatements/ES5For-of23.ts(3,5): error TS2304: Cannot find name 'console'.
==== tests/cases/conformance/statements/for-ofStatements/ES5For-of23.ts (1 errors) ====
for (var x of [1, 2, 3]) {
var _a = 0;
console.log(x);
~~~~~~~
!!! error TS2304: Cannot find name 'console'.
}
+16
View File
@@ -0,0 +1,16 @@
//// [ES5For-of23.ts]
for (var x of [1, 2, 3]) {
var _a = 0;
console.log(x);
}
//// [ES5For-of23.js]
for (var _i = 0, _b = [
1,
2,
3
]; _i < _b.length; _i++) {
var x = _b[_i];
var _a = 0;
console.log(x);
}
+16
View File
@@ -0,0 +1,16 @@
//// [ES5For-of24.ts]
var a = [1, 2, 3];
for (var v of a) {
let a = 0;
}
//// [ES5For-of24.js]
var a = [
1,
2,
3
];
for (var _i = 0; _i < a.length; _i++) {
var v = a[_i];
var _a = 0;
}
@@ -0,0 +1,12 @@
=== tests/cases/conformance/statements/for-ofStatements/ES5For-of24.ts ===
var a = [1, 2, 3];
>a : number[]
>[1, 2, 3] : number[]
for (var v of a) {
>v : number
>a : number[]
let a = 0;
>a : number
}
+19
View File
@@ -0,0 +1,19 @@
//// [ES5For-of25.ts]
var a = [1, 2, 3];
for (var v of a) {
v;
a;
}
//// [ES5For-of25.js]
var a = [
1,
2,
3
];
for (var _i = 0; _i < a.length; _i++) {
var v = a[_i];
v;
a;
}
//# sourceMappingURL=ES5For-of25.js.map
@@ -0,0 +1,2 @@
//// [ES5For-of25.js.map]
{"version":3,"file":"ES5For-of25.js","sourceRoot":"","sources":["ES5For-of25.ts"],"names":[],"mappings":"AAAA,IAAI,CAAC,GAAG;IAAC,CAAC;IAAE,CAAC;IAAE,CAAC;CAAC,CAAC;AAClB,GAAG,CAAC,CAAU,UAAC,EAAV,aAAK,EAAL,IAAU,CAAC;IAAX,IAAI,CAAC,GAAI,CAAC,IAAL;IACN,CAAC,CAAC;IACF,CAAC,CAAC;CACL"}
@@ -0,0 +1,145 @@
===================================================================
JsFile: ES5For-of25.js
mapUrl: ES5For-of25.js.map
sourceRoot:
sources: ES5For-of25.ts
===================================================================
-------------------------------------------------------------------
emittedFile:tests/cases/conformance/statements/for-ofStatements/ES5For-of25.js
sourceFile:ES5For-of25.ts
-------------------------------------------------------------------
>>>var a = [
1 >
2 >^^^^
3 > ^
4 > ^^^
1 >
2 >var
3 > a
4 > =
1 >Emitted(1, 1) Source(1, 1) + SourceIndex(0)
2 >Emitted(1, 5) Source(1, 5) + SourceIndex(0)
3 >Emitted(1, 6) Source(1, 6) + SourceIndex(0)
4 >Emitted(1, 9) Source(1, 9) + SourceIndex(0)
---
>>> 1,
1 >^^^^
2 > ^
3 > ^^->
1 >[
2 > 1
1 >Emitted(2, 5) Source(1, 10) + SourceIndex(0)
2 >Emitted(2, 6) Source(1, 11) + SourceIndex(0)
---
>>> 2,
1->^^^^
2 > ^
3 > ^->
1->,
2 > 2
1->Emitted(3, 5) Source(1, 13) + SourceIndex(0)
2 >Emitted(3, 6) Source(1, 14) + SourceIndex(0)
---
>>> 3
1->^^^^
2 > ^
1->,
2 > 3
1->Emitted(4, 5) Source(1, 16) + SourceIndex(0)
2 >Emitted(4, 6) Source(1, 17) + SourceIndex(0)
---
>>>];
1 >^
2 > ^
3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^->
1 >]
2 > ;
1 >Emitted(5, 2) Source(1, 18) + SourceIndex(0)
2 >Emitted(5, 3) Source(1, 19) + SourceIndex(0)
---
>>>for (var _i = 0; _i < a.length; _i++) {
1->
2 >^^^
3 > ^
4 > ^
5 > ^^^^^^^^^^
6 > ^^
7 > ^^^^^^^^^^^^^
8 > ^^
9 > ^^^^
10> ^
1->
>
2 >for
3 >
4 > (var v of
5 > a
6 >
7 > var v
8 >
9 > var v of a
10> )
1->Emitted(6, 1) Source(2, 1) + SourceIndex(0)
2 >Emitted(6, 4) Source(2, 4) + SourceIndex(0)
3 >Emitted(6, 5) Source(2, 5) + SourceIndex(0)
4 >Emitted(6, 6) Source(2, 15) + SourceIndex(0)
5 >Emitted(6, 16) Source(2, 16) + SourceIndex(0)
6 >Emitted(6, 18) Source(2, 6) + SourceIndex(0)
7 >Emitted(6, 31) Source(2, 11) + SourceIndex(0)
8 >Emitted(6, 33) Source(2, 6) + SourceIndex(0)
9 >Emitted(6, 37) Source(2, 16) + SourceIndex(0)
10>Emitted(6, 38) Source(2, 17) + SourceIndex(0)
---
>>> var v = a[_i];
1 >^^^^
2 > ^^^^
3 > ^
4 > ^^^
5 > ^
6 > ^^^^
1 >
2 > var
3 > v
4 > of
5 > a
6 >
1 >Emitted(7, 5) Source(2, 6) + SourceIndex(0)
2 >Emitted(7, 9) Source(2, 10) + SourceIndex(0)
3 >Emitted(7, 10) Source(2, 11) + SourceIndex(0)
4 >Emitted(7, 13) Source(2, 15) + SourceIndex(0)
5 >Emitted(7, 14) Source(2, 16) + SourceIndex(0)
6 >Emitted(7, 18) Source(2, 11) + SourceIndex(0)
---
>>> v;
1 >^^^^
2 > ^
3 > ^
4 > ^->
1 > of a) {
>
2 > v
3 > ;
1 >Emitted(8, 5) Source(3, 5) + SourceIndex(0)
2 >Emitted(8, 6) Source(3, 6) + SourceIndex(0)
3 >Emitted(8, 7) Source(3, 7) + SourceIndex(0)
---
>>> a;
1->^^^^
2 > ^
3 > ^
1->
>
2 > a
3 > ;
1->Emitted(9, 5) Source(4, 5) + SourceIndex(0)
2 >Emitted(9, 6) Source(4, 6) + SourceIndex(0)
3 >Emitted(9, 7) Source(4, 7) + SourceIndex(0)
---
>>>}
1 >^
2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^->
1 >
>}
1 >Emitted(10, 2) Source(5, 2) + SourceIndex(0)
---
>>>//# sourceMappingURL=ES5For-of25.js.map
@@ -0,0 +1,15 @@
=== tests/cases/conformance/statements/for-ofStatements/ES5For-of25.ts ===
var a = [1, 2, 3];
>a : number[]
>[1, 2, 3] : number[]
for (var v of a) {
>v : number
>a : number[]
v;
>v : number
a;
>a : number[]
}
@@ -0,0 +1,10 @@
tests/cases/conformance/statements/for-ofStatements/ES5For-of26.ts(1,10): error TS2461: Type 'number' is not an array type.
==== tests/cases/conformance/statements/for-ofStatements/ES5For-of26.ts (1 errors) ====
for (var [a = 0, b = 1] of [2, 3]) {
~~~~~~~~~~~~~~
!!! error TS2461: Type 'number' is not an array type.
a;
b;
}
+16
View File
@@ -0,0 +1,16 @@
//// [ES5For-of26.ts]
for (var [a = 0, b = 1] of [2, 3]) {
a;
b;
}
//// [ES5For-of26.js]
for (var _i = 0, _a = [
2,
3
]; _i < _a.length; _i++) {
var _b = _a[_i], _c = _b[0], a = _c === void 0 ? 0 : _c, _d = _b[1], b = _d === void 0 ? 1 : _d;
a;
b;
}
//# sourceMappingURL=ES5For-of26.js.map
@@ -0,0 +1,2 @@
//// [ES5For-of26.js.map]
{"version":3,"file":"ES5For-of26.js","sourceRoot":"","sources":["ES5For-of26.ts"],"names":[],"mappings":"AAAA,GAAG,CAAC,CAAuB,UAAM,EAAN;IAAC,CAAC;IAAE,CAAC;CAAC,EAA5B,cAAkB,EAAlB,IAA4B,CAAC;IAA7B,6BAAK,CAAC,mBAAG,CAAC,mBAAE,CAAC,mBAAG,CAAC,KAAC;IACnB,CAAC,CAAC;IACF,CAAC,CAAC;CACL"}
@@ -0,0 +1,134 @@
===================================================================
JsFile: ES5For-of26.js
mapUrl: ES5For-of26.js.map
sourceRoot:
sources: ES5For-of26.ts
===================================================================
-------------------------------------------------------------------
emittedFile:tests/cases/conformance/statements/for-ofStatements/ES5For-of26.js
sourceFile:ES5For-of26.ts
-------------------------------------------------------------------
>>>for (var _i = 0, _a = [
1 >
2 >^^^
3 > ^
4 > ^
5 > ^^^^^^^^^^
6 > ^^
1 >
2 >for
3 >
4 > (var [a = 0, b = 1] of
5 > [2, 3]
6 >
1 >Emitted(1, 1) Source(1, 1) + SourceIndex(0)
2 >Emitted(1, 4) Source(1, 4) + SourceIndex(0)
3 >Emitted(1, 5) Source(1, 5) + SourceIndex(0)
4 >Emitted(1, 6) Source(1, 28) + SourceIndex(0)
5 >Emitted(1, 16) Source(1, 34) + SourceIndex(0)
6 >Emitted(1, 18) Source(1, 28) + SourceIndex(0)
---
>>> 2,
1 >^^^^
2 > ^
3 > ^->
1 >[
2 > 2
1 >Emitted(2, 5) Source(1, 29) + SourceIndex(0)
2 >Emitted(2, 6) Source(1, 30) + SourceIndex(0)
---
>>> 3
1->^^^^
2 > ^
3 > ^^^^^^^^^^^^^^^^^^^^^^->
1->,
2 > 3
1->Emitted(3, 5) Source(1, 32) + SourceIndex(0)
2 >Emitted(3, 6) Source(1, 33) + SourceIndex(0)
---
>>>]; _i < _a.length; _i++) {
1->^
2 > ^^
3 > ^^^^^^^^^^^^^^
4 > ^^
5 > ^^^^
6 > ^
7 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^->
1->]
2 >
3 > var [a = 0, b = 1]
4 >
5 > var [a = 0, b = 1] of [2, 3]
6 > )
1->Emitted(4, 2) Source(1, 34) + SourceIndex(0)
2 >Emitted(4, 4) Source(1, 6) + SourceIndex(0)
3 >Emitted(4, 18) Source(1, 24) + SourceIndex(0)
4 >Emitted(4, 20) Source(1, 6) + SourceIndex(0)
5 >Emitted(4, 24) Source(1, 34) + SourceIndex(0)
6 >Emitted(4, 25) Source(1, 35) + SourceIndex(0)
---
>>> var _b = _a[_i], _c = _b[0], a = _c === void 0 ? 0 : _c, _d = _b[1], b = _d === void 0 ? 1 : _d;
1->^^^^
2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
3 > ^
4 > ^^^^^^^^^^^^^^^^^^^
5 > ^
6 > ^^^^^^^^^^^^^^^^^^^
7 > ^
8 > ^^^^^^^^^^^^^^^^^^^
9 > ^
10> ^^^^^
1->
2 > var [
3 > a
4 > =
5 > 0
6 > ,
7 > b
8 > =
9 > 1
10> ]
1->Emitted(5, 5) Source(1, 6) + SourceIndex(0)
2 >Emitted(5, 34) Source(1, 11) + SourceIndex(0)
3 >Emitted(5, 35) Source(1, 12) + SourceIndex(0)
4 >Emitted(5, 54) Source(1, 15) + SourceIndex(0)
5 >Emitted(5, 55) Source(1, 16) + SourceIndex(0)
6 >Emitted(5, 74) Source(1, 18) + SourceIndex(0)
7 >Emitted(5, 75) Source(1, 19) + SourceIndex(0)
8 >Emitted(5, 94) Source(1, 22) + SourceIndex(0)
9 >Emitted(5, 95) Source(1, 23) + SourceIndex(0)
10>Emitted(5, 100) Source(1, 24) + SourceIndex(0)
---
>>> a;
1 >^^^^
2 > ^
3 > ^
4 > ^->
1 > of [2, 3]) {
>
2 > a
3 > ;
1 >Emitted(6, 5) Source(2, 5) + SourceIndex(0)
2 >Emitted(6, 6) Source(2, 6) + SourceIndex(0)
3 >Emitted(6, 7) Source(2, 7) + SourceIndex(0)
---
>>> b;
1->^^^^
2 > ^
3 > ^
1->
>
2 > b
3 > ;
1->Emitted(7, 5) Source(3, 5) + SourceIndex(0)
2 >Emitted(7, 6) Source(3, 6) + SourceIndex(0)
3 >Emitted(7, 7) Source(3, 7) + SourceIndex(0)
---
>>>}
1 >^
2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^->
1 >
>}
1 >Emitted(8, 2) Source(4, 2) + SourceIndex(0)
---
>>>//# sourceMappingURL=ES5For-of26.js.map
@@ -0,0 +1,13 @@
tests/cases/conformance/statements/for-ofStatements/ES5For-of27.ts(1,11): error TS2459: Type 'number' has no property 'x' and no string index signature.
tests/cases/conformance/statements/for-ofStatements/ES5For-of27.ts(1,21): error TS2459: Type 'number' has no property 'y' and no string index signature.
==== tests/cases/conformance/statements/for-ofStatements/ES5For-of27.ts (2 errors) ====
for (var {x: a = 0, y: b = 1} of [2, 3]) {
~
!!! error TS2459: Type 'number' has no property 'x' and no string index signature.
~
!!! error TS2459: Type 'number' has no property 'y' and no string index signature.
a;
b;
}

Some files were not shown because too many files have changed in this diff Show More