Turn off a few rules and more cleanup post merge
This commit is contained in:
Родитель
be1371d3cd
Коммит
5dfa6104f9
|
@ -74,7 +74,7 @@ fs.readFile('src/compiler/diagnosticInformationMap.generated.ts', 'utf-8', (err,
|
|||
console.log('Consumed ' + allSrc.length + ' characters of source');
|
||||
|
||||
let count = 0;
|
||||
console.log('== List of errors not used in source ==')
|
||||
console.log('== List of errors not used in source ==');
|
||||
for (let errName of errorNames) {
|
||||
if (allSrc.indexOf(errName) < 0) {
|
||||
console.log(errName);
|
||||
|
@ -84,4 +84,3 @@ fs.readFile('src/compiler/diagnosticInformationMap.generated.ts', 'utf-8', (err,
|
|||
console.log(count + ' of ' + errorNames.length + ' errors are not used in source');
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@ namespace ts {
|
|||
}
|
||||
|
||||
export function getModuleInstanceState(node: Node): ModuleInstanceState {
|
||||
// A module is uninstantiated if it contains only
|
||||
// A module is uninstantiated if it contains only
|
||||
// 1. interface declarations, type alias declarations
|
||||
if (node.kind === SyntaxKind.InterfaceDeclaration || node.kind === SyntaxKind.TypeAliasDeclaration) {
|
||||
return ModuleInstanceState.NonInstantiated;
|
||||
|
@ -53,7 +53,7 @@ namespace ts {
|
|||
}
|
||||
|
||||
const enum ContainerFlags {
|
||||
// The current node is not a container, and no container manipulation should happen before
|
||||
// The current node is not a container, and no container manipulation should happen before
|
||||
// recursing into it.
|
||||
None = 0,
|
||||
|
||||
|
@ -90,7 +90,7 @@ namespace ts {
|
|||
let lastContainer: Node;
|
||||
|
||||
// If this file is an external module, then it is automatically in strict-mode according to
|
||||
// ES6. If it is not an external module, then we'll determine if it is in strict mode or
|
||||
// ES6. If it is not an external module, then we'll determine if it is in strict mode or
|
||||
// not depending on if we see "use strict" in certain places (or if we hit a class/namespace).
|
||||
let inStrictMode = !!file.externalModuleIndicator;
|
||||
|
||||
|
@ -179,7 +179,7 @@ namespace ts {
|
|||
* @param parent - node's parent declaration.
|
||||
* @param node - The declaration to be added to the symbol table
|
||||
* @param includes - The SymbolFlags that node has in addition to its declaration type (eg: export, ambient, etc.)
|
||||
* @param excludes - The flags which node cannot be declared alongside in a symbol table. Used to report forbidden declarations.
|
||||
* @param excludes - The flags which node cannot be declared alongside in a symbol table. Used to report forbidden declarations.
|
||||
*/
|
||||
function declareSymbol(symbolTable: SymbolTable, parent: Symbol, node: Declaration, includes: SymbolFlags, excludes: SymbolFlags): Symbol {
|
||||
Debug.assert(!hasDynamicName(node));
|
||||
|
@ -192,13 +192,13 @@ namespace ts {
|
|||
|
||||
// Check and see if the symbol table already has a symbol with this name. If not,
|
||||
// create a new symbol with this name and add it to the table. Note that we don't
|
||||
// give the new symbol any flags *yet*. This ensures that it will not conflict
|
||||
// give the new symbol any flags *yet*. This ensures that it will not conflict
|
||||
// with the 'excludes' flags we pass in.
|
||||
//
|
||||
// If we do get an existing symbol, see if it conflicts with the new symbol we're
|
||||
// creating. For example, a 'var' symbol and a 'class' symbol will conflict within
|
||||
// the same symbol table. If we have a conflict, report the issue on each
|
||||
// declaration we have for this symbol, and then create a new symbol for this
|
||||
// the same symbol table. If we have a conflict, report the issue on each
|
||||
// declaration we have for this symbol, and then create a new symbol for this
|
||||
// declaration.
|
||||
//
|
||||
// If we created a new symbol, either because we didn't have a symbol with this name
|
||||
|
@ -259,7 +259,7 @@ namespace ts {
|
|||
// ExportType, or ExportContainer flag, and an associated export symbol with all the correct flags set
|
||||
// on it. There are 2 main reasons:
|
||||
//
|
||||
// 1. We treat locals and exports of the same name as mutually exclusive within a container.
|
||||
// 1. We treat locals and exports of the same name as mutually exclusive within a container.
|
||||
// That means the binder will issue a Duplicate Identifier error if you mix locals and exports
|
||||
// with the same name in the same container.
|
||||
// TODO: Make this a more specific error and decouple it from the exclusion logic.
|
||||
|
@ -282,11 +282,11 @@ namespace ts {
|
|||
}
|
||||
}
|
||||
|
||||
// All container nodes are kept on a linked list in declaration order. This list is used by
|
||||
// the getLocalNameOfContainer function in the type checker to validate that the local name
|
||||
// All container nodes are kept on a linked list in declaration order. This list is used by
|
||||
// the getLocalNameOfContainer function in the type checker to validate that the local name
|
||||
// used for a container is unique.
|
||||
function bindChildren(node: Node) {
|
||||
// Before we recurse into a node's chilren, we first save the existing parent, container
|
||||
// Before we recurse into a node's chilren, we first save the existing parent, container
|
||||
// and block-container. Then after we pop out of processing the children, we restore
|
||||
// these saved values.
|
||||
let saveParent = parent;
|
||||
|
@ -302,9 +302,9 @@ namespace ts {
|
|||
// may contain locals, we proactively initialize the .locals field. We do this because
|
||||
// it's highly likely that the .locals will be needed to place some child in (for example,
|
||||
// a parameter, or variable declaration).
|
||||
//
|
||||
//
|
||||
// However, we do not proactively create the .locals for block-containers because it's
|
||||
// totally normal and common for block-containers to never actually have a block-scoped
|
||||
// totally normal and common for block-containers to never actually have a block-scoped
|
||||
// variable in them. We don't want to end up allocating an object for every 'block' we
|
||||
// run into when most of them won't be necessary.
|
||||
//
|
||||
|
@ -373,7 +373,7 @@ namespace ts {
|
|||
|
||||
case SyntaxKind.Block:
|
||||
// do not treat blocks directly inside a function as a block-scoped-container.
|
||||
// Locals that reside in this block should go to the function locals. Othewise 'x'
|
||||
// Locals that reside in this block should go to the function locals. Othewise 'x'
|
||||
// would not appear to be a redeclaration of a block scoped local in the following
|
||||
// example:
|
||||
//
|
||||
|
@ -386,7 +386,7 @@ namespace ts {
|
|||
// the block, then there would be no collision.
|
||||
//
|
||||
// By not creating a new block-scoped-container here, we ensure that both 'var x'
|
||||
// and 'let x' go into the Function-container's locals, and we do get a collision
|
||||
// and 'let x' go into the Function-container's locals, and we do get a collision
|
||||
// conflict.
|
||||
return isFunctionLike(node.parent) ? ContainerFlags.None : ContainerFlags.IsBlockScopedContainer;
|
||||
}
|
||||
|
@ -490,7 +490,7 @@ namespace ts {
|
|||
if (stat.kind === SyntaxKind.ExportDeclaration || stat.kind === SyntaxKind.ExportAssignment) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -536,8 +536,8 @@ namespace ts {
|
|||
// For a given function symbol "<...>(...) => T" we want to generate a symbol identical
|
||||
// to the one we would get for: { <...>(...): T }
|
||||
//
|
||||
// We do that by making an anonymous type literal symbol, and then setting the function
|
||||
// symbol as its sole member. To the rest of the system, this symbol will be indistinguishable
|
||||
// We do that by making an anonymous type literal symbol, and then setting the function
|
||||
// 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.
|
||||
let symbol = createSymbol(SymbolFlags.Signature, getDeclarationName(node));
|
||||
addDeclarationToSymbol(symbol, node, SymbolFlags.Signature);
|
||||
|
@ -638,7 +638,7 @@ namespace ts {
|
|||
}
|
||||
|
||||
function getStrictModeIdentifierMessage(node: Node) {
|
||||
// Provide specialized messages to help the user understand why we think they're in
|
||||
// Provide specialized messages to help the user understand why we think they're in
|
||||
// strict mode.
|
||||
if (getContainingClass(node)) {
|
||||
return Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_strict_mode;
|
||||
|
@ -696,7 +696,7 @@ namespace ts {
|
|||
}
|
||||
|
||||
function getStrictModeEvalOrArgumentsMessage(node: Node) {
|
||||
// Provide specialized messages to help the user understand why we think they're in
|
||||
// Provide specialized messages to help the user understand why we think they're in
|
||||
// strict mode.
|
||||
if (getContainingClass(node)) {
|
||||
return Diagnostics.Invalid_use_of_0_Class_definitions_are_automatically_in_strict_mode;
|
||||
|
@ -766,18 +766,18 @@ namespace ts {
|
|||
}
|
||||
|
||||
// First we bind declaration nodes to a symbol if possible. We'll both create a symbol
|
||||
// and then potentially add the symbol to an appropriate symbol table. Possible
|
||||
// and then potentially add the symbol to an appropriate symbol table. Possible
|
||||
// destination symbol tables are:
|
||||
//
|
||||
//
|
||||
// 1) The 'exports' table of the current container's symbol.
|
||||
// 2) The 'members' table of the current container's symbol.
|
||||
// 3) The 'locals' table of the current container.
|
||||
//
|
||||
// However, not all symbols will end up in any of these tables. 'Anonymous' symbols
|
||||
// However, not all symbols will end up in any of these tables. 'Anonymous' symbols
|
||||
// (like TypeLiterals for example) will not be put in any table.
|
||||
bindWorker(node);
|
||||
|
||||
// Then we recurse into the children of the node to bind them as well. For certain
|
||||
// Then we recurse into the children of the node to bind them as well. For certain
|
||||
// symbols we do specialized work when we recurse. For example, we'll keep track of
|
||||
// the current 'container' node when it changes. This helps us know which symbol table
|
||||
// a local should go into for example.
|
||||
|
@ -972,9 +972,9 @@ namespace ts {
|
|||
let symbol = node.symbol;
|
||||
|
||||
// TypeScript 1.0 spec (April 2014): 8.4
|
||||
// Every class automatically contains a static property member named 'prototype', the
|
||||
// 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
|
||||
// argument for each type parameter. It is an error to explicitly declare a static
|
||||
// property member with the name 'prototype'.
|
||||
//
|
||||
// Note: we check for this here because this class may be merging into a module. The
|
||||
|
@ -1039,7 +1039,7 @@ namespace ts {
|
|||
declareSymbolAndAddToSymbolTable(node, SymbolFlags.FunctionScopedVariable, SymbolFlags.ParameterExcludes);
|
||||
}
|
||||
|
||||
// If this is a property-parameter, then also declare the property symbol into the
|
||||
// If this is a property-parameter, then also declare the property symbol into the
|
||||
// containing class.
|
||||
if (node.flags & NodeFlags.AccessibilityModifier &&
|
||||
node.parent.kind === SyntaxKind.Constructor &&
|
||||
|
|
|
@ -3874,8 +3874,8 @@ namespace ts {
|
|||
* getExportedTypeFromNamespace('JSX', 'Element') returns the JSX.Element type
|
||||
*/
|
||||
function getExportedTypeFromNamespace(namespace: string, name: string): Type {
|
||||
var namespaceSymbol = getGlobalSymbol(namespace, SymbolFlags.Namespace, /*diagnosticMessage*/ undefined);
|
||||
var typeSymbol = namespaceSymbol && getSymbol(namespaceSymbol.exports, name, SymbolFlags.Type);
|
||||
let namespaceSymbol = getGlobalSymbol(namespace, SymbolFlags.Namespace, /*diagnosticMessage*/ undefined);
|
||||
let typeSymbol = namespaceSymbol && getSymbol(namespaceSymbol.exports, name, SymbolFlags.Type);
|
||||
return typeSymbol && getDeclaredTypeOfSymbol(typeSymbol);
|
||||
}
|
||||
|
||||
|
@ -4697,7 +4697,6 @@ namespace ts {
|
|||
}
|
||||
let id = relation !== identityRelation || source.id < target.id ? source.id + "," + target.id : target.id + "," + source.id;
|
||||
let related = relation[id];
|
||||
//let related: RelationComparisonResult = undefined; // relation[id];
|
||||
if (related !== undefined) {
|
||||
// If we computed this relation already and it was failed and reported, or if we're not being asked to elaborate
|
||||
// errors, we can use the cached value. Otherwise, recompute the relation
|
||||
|
@ -7214,7 +7213,7 @@ namespace ts {
|
|||
return links.resolvedJsxType = anyType;
|
||||
}
|
||||
|
||||
var propsName = getJsxElementPropertiesName();
|
||||
let propsName = getJsxElementPropertiesName();
|
||||
if (propsName === undefined) {
|
||||
// There is no type ElementAttributesProperty, return 'any'
|
||||
return links.resolvedJsxType = anyType;
|
||||
|
@ -7224,7 +7223,7 @@ namespace ts {
|
|||
return links.resolvedJsxType = elemInstanceType;
|
||||
}
|
||||
else {
|
||||
var attributesType = getTypeOfPropertyOfType(elemInstanceType, propsName);
|
||||
let attributesType = getTypeOfPropertyOfType(elemInstanceType, propsName);
|
||||
|
||||
if (!attributesType) {
|
||||
// There is no property named 'props' on this instance type
|
||||
|
@ -7381,7 +7380,7 @@ namespace ts {
|
|||
*/
|
||||
function checkClassPropertyAccess(node: PropertyAccessExpression | QualifiedName, left: Expression | QualifiedName, type: Type, prop: Symbol): boolean {
|
||||
let flags = getDeclarationFlagsFromSymbol(prop);
|
||||
let declaringClass = <InterfaceType>getDeclaredTypeOfSymbol(prop.parent);;
|
||||
let declaringClass = <InterfaceType>getDeclaredTypeOfSymbol(prop.parent);
|
||||
|
||||
if (left.kind === SyntaxKind.SuperKeyword) {
|
||||
let errorNode = node.kind === SyntaxKind.PropertyAccessExpression ?
|
||||
|
@ -10121,7 +10120,7 @@ namespace ts {
|
|||
|
||||
// Abstract methods cannot have an implementation.
|
||||
// Extra checks are to avoid reporting multiple errors relating to the "abstractness" of the node.
|
||||
if(node.flags & NodeFlags.Abstract && node.body) {
|
||||
if (node.flags & NodeFlags.Abstract && node.body) {
|
||||
error(node, Diagnostics.Method_0_cannot_have_an_implementation_because_it_is_marked_abstract, declarationNameToString(node.name));
|
||||
}
|
||||
}
|
||||
|
@ -10895,7 +10894,7 @@ namespace ts {
|
|||
let promiseConstructor = getMergedSymbol(promiseType.symbol);
|
||||
if (!promiseConstructor || !symbolIsValue(promiseConstructor)) {
|
||||
error(node, Diagnostics.Type_0_is_not_a_valid_async_function_return_type, typeToString(promiseType));
|
||||
return unknownType
|
||||
return unknownType;
|
||||
}
|
||||
|
||||
// Validate the promise constructor type.
|
||||
|
@ -12177,7 +12176,7 @@ namespace ts {
|
|||
|
||||
// Interfaces cannot be merged with non-ambient classes.
|
||||
if (getSymbolOfNode(node).flags & SymbolFlags.Interface && !isInAmbientContext(node)) {
|
||||
error(node, Diagnostics.Only_an_ambient_class_can_be_merged_with_an_interface)
|
||||
error(node, Diagnostics.Only_an_ambient_class_can_be_merged_with_an_interface);
|
||||
}
|
||||
|
||||
forEach(node.members, checkSourceElement);
|
||||
|
|
|
@ -436,7 +436,7 @@ namespace ts {
|
|||
}
|
||||
else if (fileExtensionIs(name, ".ts")) {
|
||||
if (!contains(sysFiles, name + "x")) {
|
||||
fileNames.push(name)
|
||||
fileNames.push(name);
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -600,20 +600,20 @@ namespace ts {
|
|||
|
||||
function getNormalizedPathComponentsOfUrl(url: string) {
|
||||
// Get root length of http://www.website.com/folder1/foler2/
|
||||
// In this example the root is: http://www.website.com/
|
||||
// In this example the root is: http://www.website.com/
|
||||
// normalized path components should be ["http://www.website.com/", "folder1", "folder2"]
|
||||
|
||||
let urlLength = url.length;
|
||||
// Initial root length is http:// part
|
||||
let rootLength = url.indexOf("://") + "://".length;
|
||||
while (rootLength < urlLength) {
|
||||
// Consume all immediate slashes in the protocol
|
||||
// Consume all immediate slashes in the protocol
|
||||
// eg.initial rootlength is just file:// but it needs to consume another "/" in file:///
|
||||
if (url.charCodeAt(rootLength) === CharacterCodes.slash) {
|
||||
rootLength++;
|
||||
}
|
||||
else {
|
||||
// non slash character means we continue proceeding to next component of root search
|
||||
// non slash character means we continue proceeding to next component of root search
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -626,15 +626,15 @@ namespace ts {
|
|||
// Find the index of "/" after website.com so the root can be http://www.website.com/ (from existing http://)
|
||||
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/
|
||||
// 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
|
||||
rootLength = indexOfNextSlash + 1;
|
||||
return normalizedPathComponents(url, rootLength);
|
||||
}
|
||||
else {
|
||||
// Can't find the host assume the rest of the string as component
|
||||
// Can't find the host assume the rest of the string as component
|
||||
// but make sure we append "/" to it as root is not joined using "/"
|
||||
// eg. if url passed in was http://website.com we want to use root as [http://website.com/]
|
||||
// eg. if url passed in was http://website.com we want to use root as [http://website.com/]
|
||||
// so that other path manipulations will be correct and it can be merged with relative paths correctly
|
||||
return [url + directorySeparator];
|
||||
}
|
||||
|
|
|
@ -130,7 +130,7 @@ namespace ts {
|
|||
moduleElementDeclarationEmitInfo,
|
||||
synchronousDeclarationOutput: writer.getText(),
|
||||
referencePathsOutput,
|
||||
}
|
||||
};
|
||||
|
||||
function hasInternalAnnotation(range: CommentRange) {
|
||||
let text = currentSourceFile.text;
|
||||
|
@ -198,7 +198,7 @@ namespace ts {
|
|||
// we would write alias foo declaration when we visit it since it would now be marked as visible
|
||||
if (moduleElementEmitInfo) {
|
||||
if (moduleElementEmitInfo.node.kind === SyntaxKind.ImportDeclaration) {
|
||||
// we have to create asynchronous output only after we have collected complete information
|
||||
// we have to create asynchronous output only after we have collected complete information
|
||||
// because it is possible to enable multiple bindings as asynchronously visible
|
||||
moduleElementEmitInfo.isVisible = true;
|
||||
}
|
||||
|
@ -600,7 +600,7 @@ namespace ts {
|
|||
}
|
||||
|
||||
function writeImportEqualsDeclaration(node: ImportEqualsDeclaration) {
|
||||
// note usage of writer. methods instead of aliases created, just to make sure we are using
|
||||
// note usage of writer. methods instead of aliases created, just to make sure we are using
|
||||
// correct writer especially to handle asynchronous alias writing
|
||||
emitJsDocComments(node);
|
||||
if (node.flags & NodeFlags.Export) {
|
||||
|
@ -642,7 +642,7 @@ namespace ts {
|
|||
|
||||
function writeImportDeclaration(node: ImportDeclaration) {
|
||||
if (!node.importClause && !(node.flags & NodeFlags.Export)) {
|
||||
// do not write non-exported import declarations that don't have import clauses
|
||||
// do not write non-exported import declarations that don't have import clauses
|
||||
return;
|
||||
}
|
||||
emitJsDocComments(node);
|
||||
|
@ -1565,7 +1565,7 @@ namespace ts {
|
|||
? referencedFile.fileName // Declaration file, use declaration file name
|
||||
: shouldEmitToOwnFile(referencedFile, compilerOptions)
|
||||
? getOwnEmitOutputFilePath(referencedFile, host, ".d.ts") // Own output file so get the .d.ts file
|
||||
: removeFileExtension(compilerOptions.out) + ".d.ts";// Global out file
|
||||
: removeFileExtension(compilerOptions.out) + ".d.ts"; // Global out file
|
||||
|
||||
declFileName = getRelativePathToDirectoryOrUrl(
|
||||
getDirectoryPath(normalizeSlashes(jsFilePath)),
|
||||
|
@ -1604,4 +1604,4 @@ namespace ts {
|
|||
return declarationOutput;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -585,7 +585,7 @@ namespace ts {
|
|||
fixupParentReferences(sourceFile);
|
||||
}
|
||||
|
||||
// If this is a javascript file, proactively see if we can get JSDoc comments for
|
||||
// If this is a javascript file, proactively see if we can get JSDoc comments for
|
||||
// relevant nodes in the file. We'll use these to provide typing informaion if they're
|
||||
// available.
|
||||
if (isJavaScript(fileName)) {
|
||||
|
@ -685,17 +685,17 @@ namespace ts {
|
|||
function setDecoratorContext(val: boolean) {
|
||||
setContextFlag(val, ParserContextFlags.Decorator);
|
||||
}
|
||||
|
||||
|
||||
function setAwaitContext(val: boolean) {
|
||||
setContextFlag(val, ParserContextFlags.Await);
|
||||
}
|
||||
|
||||
|
||||
function doOutsideOfContext<T>(context: ParserContextFlags, func: () => T): T {
|
||||
// contextFlagsToClear will contain only the context flags that are
|
||||
// contextFlagsToClear will contain only the context flags that are
|
||||
// currently set that we need to temporarily clear
|
||||
// We don't just blindly reset to the previous flags to ensure
|
||||
// that we do not mutate cached flags for the incremental
|
||||
// parser (ThisNodeHasError, ThisNodeOrAnySubNodesHasError, and
|
||||
// parser (ThisNodeHasError, ThisNodeOrAnySubNodesHasError, and
|
||||
// HasAggregatedChildData).
|
||||
let contextFlagsToClear = context & contextFlags;
|
||||
if (contextFlagsToClear) {
|
||||
|
@ -710,13 +710,13 @@ namespace ts {
|
|||
// no need to do anything special as we are not in any of the requested contexts
|
||||
return func();
|
||||
}
|
||||
|
||||
|
||||
function doInsideOfContext<T>(context: ParserContextFlags, func: () => T): T {
|
||||
// contextFlagsToSet will contain only the context flags that
|
||||
// are not currently set that we need to temporarily enable.
|
||||
// We don't just blindly reset to the previous flags to ensure
|
||||
// that we do not mutate cached flags for the incremental
|
||||
// parser (ThisNodeHasError, ThisNodeOrAnySubNodesHasError, and
|
||||
// parser (ThisNodeHasError, ThisNodeOrAnySubNodesHasError, and
|
||||
// HasAggregatedChildData).
|
||||
let contextFlagsToSet = context & ~contextFlags;
|
||||
if (contextFlagsToSet) {
|
||||
|
@ -727,11 +727,11 @@ namespace ts {
|
|||
setContextFlag(false, contextFlagsToSet);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
// no need to do anything special as we are already in all of the requested contexts
|
||||
return func();
|
||||
}
|
||||
|
||||
|
||||
function allowInAnd<T>(func: () => T): T {
|
||||
return doOutsideOfContext(ParserContextFlags.DisallowIn, func);
|
||||
}
|
||||
|
@ -739,7 +739,7 @@ namespace ts {
|
|||
function disallowInAnd<T>(func: () => T): T {
|
||||
return doInsideOfContext(ParserContextFlags.DisallowIn, func);
|
||||
}
|
||||
|
||||
|
||||
function doInYieldContext<T>(func: () => T): T {
|
||||
return doInsideOfContext(ParserContextFlags.Yield, func);
|
||||
}
|
||||
|
@ -751,23 +751,23 @@ namespace ts {
|
|||
function doInDecoratorContext<T>(func: () => T): T {
|
||||
return doInsideOfContext(ParserContextFlags.Decorator, func);
|
||||
}
|
||||
|
||||
|
||||
function doInAwaitContext<T>(func: () => T): T {
|
||||
return doInsideOfContext(ParserContextFlags.Await, func);
|
||||
}
|
||||
|
||||
|
||||
function doOutsideOfAwaitContext<T>(func: () => T): T {
|
||||
return doOutsideOfContext(ParserContextFlags.Await, func);
|
||||
}
|
||||
|
||||
|
||||
function doInYieldAndAwaitContext<T>(func: () => T): T {
|
||||
return doInsideOfContext(ParserContextFlags.Yield | ParserContextFlags.Await, func);
|
||||
}
|
||||
|
||||
|
||||
function doOutsideOfYieldAndAwaitContext<T>(func: () => T): T {
|
||||
return doOutsideOfContext(ParserContextFlags.Yield | ParserContextFlags.Await, func);
|
||||
}
|
||||
|
||||
|
||||
function inContext(flags: ParserContextFlags) {
|
||||
return (contextFlags & flags) !== 0;
|
||||
}
|
||||
|
@ -787,7 +787,7 @@ namespace ts {
|
|||
function inAwaitContext() {
|
||||
return inContext(ParserContextFlags.Await);
|
||||
}
|
||||
|
||||
|
||||
function parseErrorAtCurrentToken(message: DiagnosticMessage, arg0?: any): void {
|
||||
let start = scanner.getTokenPos();
|
||||
let length = scanner.getTextPos() - start;
|
||||
|
@ -843,7 +843,7 @@ namespace ts {
|
|||
function scanJsxIdentifier(): SyntaxKind {
|
||||
return token = scanner.scanJsxIdentifier();
|
||||
}
|
||||
|
||||
|
||||
function speculationHelper<T>(callback: () => T, isLookAhead: boolean): T {
|
||||
// Keep track of the state we'll need to rollback to if lookahead fails (or if the
|
||||
// caller asked us to always reset our state).
|
||||
|
@ -903,7 +903,7 @@ namespace ts {
|
|||
if (token === SyntaxKind.YieldKeyword && inYieldContext()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// If we have a 'await' keyword, and we're in the [Await] context, then 'await' is
|
||||
// considered a keyword and is not an identifier.
|
||||
if (token === SyntaxKind.AwaitKeyword && inAwaitContext()) {
|
||||
|
@ -1102,7 +1102,7 @@ namespace ts {
|
|||
function parseContextualModifier(t: SyntaxKind): boolean {
|
||||
return token === t && tryParse(nextTokenCanFollowModifier);
|
||||
}
|
||||
|
||||
|
||||
function nextTokenCanFollowModifier() {
|
||||
if (token === SyntaxKind.ConstKeyword) {
|
||||
// 'const' is only a modifier if followed by 'enum'.
|
||||
|
@ -1121,7 +1121,7 @@ namespace ts {
|
|||
nextToken();
|
||||
return canFollowModifier();
|
||||
}
|
||||
|
||||
|
||||
function parseAnyContextualModifier(): boolean {
|
||||
return isModifier(token) && tryParse(nextTokenCanFollowModifier);
|
||||
}
|
||||
|
@ -1229,7 +1229,7 @@ namespace ts {
|
|||
// if we see "extends {}" then only treat the {} as what we're extending (and not
|
||||
// the class body) if we have:
|
||||
//
|
||||
// extends {} {
|
||||
// extends {} {
|
||||
// extends {},
|
||||
// extends {} extends
|
||||
// extends {} implements
|
||||
|
@ -2019,7 +2019,7 @@ namespace ts {
|
|||
// ambient contexts.
|
||||
return finishNode(node);
|
||||
}
|
||||
|
||||
|
||||
function parseBindingElementInitializer(inParameter: boolean) {
|
||||
return inParameter ? parseParameterInitializer() : parseNonParameterInitializer();
|
||||
}
|
||||
|
@ -2027,7 +2027,7 @@ namespace ts {
|
|||
function parseParameterInitializer() {
|
||||
return parseInitializer(/*inParameter*/ true);
|
||||
}
|
||||
|
||||
|
||||
function fillSignature(
|
||||
returnToken: SyntaxKind,
|
||||
yieldContext: boolean,
|
||||
|
@ -2065,15 +2065,15 @@ namespace ts {
|
|||
if (parseExpected(SyntaxKind.OpenParenToken)) {
|
||||
let savedYieldContext = inYieldContext();
|
||||
let savedAwaitContext = inAwaitContext();
|
||||
|
||||
|
||||
setYieldContext(yieldContext);
|
||||
setAwaitContext(awaitContext);
|
||||
|
||||
|
||||
let result = parseDelimitedList(ParsingContext.Parameters, parseParameter);
|
||||
|
||||
|
||||
setYieldContext(savedYieldContext);
|
||||
setAwaitContext(savedAwaitContext);
|
||||
|
||||
|
||||
if (!parseExpected(SyntaxKind.CloseParenToken) && requireCompleteParameterList) {
|
||||
// Caller insisted that we had to end with a ) We didn't. So just return
|
||||
// undefined here.
|
||||
|
@ -2088,7 +2088,7 @@ namespace ts {
|
|||
// then just return an empty set of parameters.
|
||||
return requireCompleteParameterList ? undefined : createMissingList<ParameterDeclaration>();
|
||||
}
|
||||
|
||||
|
||||
function parseTypeMemberSemicolon() {
|
||||
// We allow type members to be separated by commas or (possibly ASI) semicolons.
|
||||
// First check if it was a comma. If so, we're done with the member.
|
||||
|
@ -2471,7 +2471,7 @@ namespace ts {
|
|||
|
||||
function parseType(): TypeNode {
|
||||
// The rules about 'yield' only apply to actual code/expression contexts. They don't
|
||||
// apply to 'type' contexts. So we disable these parameters here before moving on.
|
||||
// apply to 'type' contexts. So we disable these parameters here before moving on.
|
||||
return doOutsideOfContext(ParserContextFlags.TypeExcludesFlags, parseTypeWorker);
|
||||
}
|
||||
|
||||
|
@ -2559,7 +2559,7 @@ namespace ts {
|
|||
token !== SyntaxKind.AtToken &&
|
||||
isStartOfExpression();
|
||||
}
|
||||
|
||||
|
||||
function allowInAndParseExpression(): Expression {
|
||||
return allowInAnd(parseExpression);
|
||||
}
|
||||
|
@ -2748,7 +2748,7 @@ namespace ts {
|
|||
// It's definitely not a parenthesized arrow function expression.
|
||||
return undefined;
|
||||
}
|
||||
|
||||
|
||||
// If we definitely have an arrow function, then we can just parse one, not requiring a
|
||||
// following => or { token. Otherwise, we *might* have an arrow function. Try to parse
|
||||
// it out, but don't allow any ambiguity, and return 'undefined' if this could be an
|
||||
|
@ -2761,7 +2761,7 @@ namespace ts {
|
|||
// Didn't appear to actually be a parenthesized arrow function. Just bail out.
|
||||
return undefined;
|
||||
}
|
||||
|
||||
|
||||
let isAsync = !!(arrowFunction.flags & NodeFlags.Async);
|
||||
|
||||
// If we have an arrow, then try to parse the body. Even if not, try to parse if we
|
||||
|
@ -2804,7 +2804,7 @@ namespace ts {
|
|||
return Tristate.False;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
let first = token;
|
||||
let second = nextToken();
|
||||
|
||||
|
@ -2892,7 +2892,7 @@ namespace ts {
|
|||
if (isArrowFunctionInJsx) {
|
||||
return Tristate.True;
|
||||
}
|
||||
|
||||
|
||||
return Tristate.False;
|
||||
}
|
||||
|
||||
|
@ -2909,7 +2909,7 @@ namespace ts {
|
|||
let node = <ArrowFunction>createNode(SyntaxKind.ArrowFunction);
|
||||
setModifiers(node, parseModifiersForArrowFunction());
|
||||
let isAsync = !!(node.flags & NodeFlags.Async);
|
||||
|
||||
|
||||
// Arrow functions are never generators.
|
||||
//
|
||||
// If we're speculatively parsing a signature for a parenthesized arrow function, then
|
||||
|
@ -2966,7 +2966,7 @@ namespace ts {
|
|||
// Note: even when 'ignoreMissingOpenBrace' is passed as true, parseBody will still error.
|
||||
return parseFunctionBlock(/*allowYield*/ false, /*allowAwait*/ isAsync, /*ignoreMissingOpenBrace*/ true);
|
||||
}
|
||||
|
||||
|
||||
return isAsync
|
||||
? doInAwaitContext(parseAssignmentExpressionOrHigher)
|
||||
: doOutsideOfAwaitContext(parseAssignmentExpressionOrHigher);
|
||||
|
@ -3133,7 +3133,7 @@ namespace ts {
|
|||
node.expression = parseUnaryExpressionOrHigher();
|
||||
return finishNode(node);
|
||||
}
|
||||
|
||||
|
||||
function isAwaitExpression(): boolean {
|
||||
if (token === SyntaxKind.AwaitKeyword) {
|
||||
if (inAwaitContext()) {
|
||||
|
@ -3158,7 +3158,7 @@ namespace ts {
|
|||
if (isAwaitExpression()) {
|
||||
return parseAwaitExpression();
|
||||
}
|
||||
|
||||
|
||||
switch (token) {
|
||||
case SyntaxKind.PlusToken:
|
||||
case SyntaxKind.MinusToken:
|
||||
|
@ -3177,7 +3177,7 @@ namespace ts {
|
|||
if (sourceFile.languageVariant !== LanguageVariant.JSX) {
|
||||
return parseTypeAssertion();
|
||||
}
|
||||
if(lookAhead(nextTokenIsIdentifierOrKeyword)) {
|
||||
if (lookAhead(nextTokenIsIdentifierOrKeyword)) {
|
||||
return parseJsxElementOrSelfClosingElement();
|
||||
}
|
||||
// Fall through
|
||||
|
@ -3307,7 +3307,7 @@ namespace ts {
|
|||
node.name = parseRightSideOfDot(/*allowIdentifierNames*/ true);
|
||||
return finishNode(node);
|
||||
}
|
||||
|
||||
|
||||
function parseJsxElementOrSelfClosingElement(): JsxElement|JsxSelfClosingElement {
|
||||
let opening = parseJsxOpeningOrSelfClosingElement();
|
||||
if (opening.kind === SyntaxKind.JsxOpeningElement) {
|
||||
|
@ -3349,7 +3349,7 @@ namespace ts {
|
|||
let saveParsingContext = parsingContext;
|
||||
parsingContext |= 1 << ParsingContext.JsxChildren;
|
||||
|
||||
while(true) {
|
||||
while (true) {
|
||||
token = scanner.reScanJsxToken();
|
||||
if (token === SyntaxKind.LessThanSlashToken) {
|
||||
break;
|
||||
|
@ -3367,7 +3367,7 @@ namespace ts {
|
|||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
function parseJsxOpeningOrSelfClosingElement(): JsxOpeningElement|JsxSelfClosingElement {
|
||||
let fullStart = scanner.getStartPos();
|
||||
|
||||
|
@ -3392,7 +3392,7 @@ namespace ts {
|
|||
|
||||
return finishNode(node);
|
||||
}
|
||||
|
||||
|
||||
function parseJsxElementName(): EntityName {
|
||||
scanJsxIdentifier();
|
||||
let elementName: EntityName = parseIdentifierName();
|
||||
|
@ -3477,7 +3477,7 @@ namespace ts {
|
|||
continue;
|
||||
}
|
||||
|
||||
// when in the [Decorator] context, we do not parse ElementAccess as it could be part of a ComputedPropertyName
|
||||
// when in the [Decorator] context, we do not parse ElementAccess as it could be part of a ComputedPropertyName
|
||||
if (!inDecoratorContext() && parseOptional(SyntaxKind.OpenBracketToken)) {
|
||||
let indexedAccess = <ElementAccessExpression>createNode(SyntaxKind.ElementAccessExpression, expression.pos);
|
||||
indexedAccess.expression = expression;
|
||||
|
@ -3599,7 +3599,7 @@ namespace ts {
|
|||
case SyntaxKind.CommaToken: // foo<x>,
|
||||
case SyntaxKind.OpenBraceToken: // foo<x> {
|
||||
// We don't want to treat these as type arguments. Otherwise we'll parse this
|
||||
// as an invocation expression. Instead, we want to parse out the expression
|
||||
// as an invocation expression. Instead, we want to parse out the expression
|
||||
// in isolation from the type arguments.
|
||||
|
||||
default:
|
||||
|
@ -3627,7 +3627,7 @@ namespace ts {
|
|||
case SyntaxKind.OpenBraceToken:
|
||||
return parseObjectLiteralExpression();
|
||||
case SyntaxKind.AsyncKeyword:
|
||||
// Async arrow functions are parsed earlier in parseAssignmentExpressionOrHigher.
|
||||
// Async arrow functions are parsed earlier in parseAssignmentExpressionOrHigher.
|
||||
// If we encounter `async [no LineTerminator here] function` then this is an async
|
||||
// function; otherwise, its an identifier.
|
||||
if (!lookAhead(nextTokenIsFunctionKeywordOnSameLine)) {
|
||||
|
@ -3759,12 +3759,12 @@ namespace ts {
|
|||
if (saveDecoratorContext) {
|
||||
setDecoratorContext(false);
|
||||
}
|
||||
|
||||
|
||||
let node = <FunctionExpression>createNode(SyntaxKind.FunctionExpression);
|
||||
setModifiers(node, parseModifiers());
|
||||
parseExpected(SyntaxKind.FunctionKeyword);
|
||||
node.asteriskToken = parseOptionalToken(SyntaxKind.AsteriskToken);
|
||||
|
||||
|
||||
let isGenerator = !!node.asteriskToken;
|
||||
let isAsync = !!(node.flags & NodeFlags.Async);
|
||||
node.name =
|
||||
|
@ -3772,14 +3772,14 @@ namespace ts {
|
|||
isGenerator ? doInYieldContext(parseOptionalIdentifier) :
|
||||
isAsync ? doInAwaitContext(parseOptionalIdentifier) :
|
||||
parseOptionalIdentifier();
|
||||
|
||||
|
||||
fillSignature(SyntaxKind.ColonToken, /*yieldContext*/ isGenerator, /*awaitContext*/ isAsync, /*requireCompleteParameterList*/ false, node);
|
||||
node.body = parseFunctionBlock(/*allowYield*/ isGenerator, /*allowAwait*/ isAsync, /*ignoreMissingOpenBrace*/ false);
|
||||
|
||||
|
||||
if (saveDecoratorContext) {
|
||||
setDecoratorContext(true);
|
||||
}
|
||||
|
||||
|
||||
return finishNode(node);
|
||||
}
|
||||
|
||||
|
@ -3815,11 +3815,11 @@ namespace ts {
|
|||
function parseFunctionBlock(allowYield: boolean, allowAwait: boolean, ignoreMissingOpenBrace: boolean, diagnosticMessage?: DiagnosticMessage): Block {
|
||||
let savedYieldContext = inYieldContext();
|
||||
setYieldContext(allowYield);
|
||||
|
||||
|
||||
let savedAwaitContext = inAwaitContext();
|
||||
setAwaitContext(allowAwait);
|
||||
|
||||
// We may be in a [Decorator] context when parsing a function expression or
|
||||
// We may be in a [Decorator] context when parsing a function expression or
|
||||
// arrow function. The body of the function is not in [Decorator] context.
|
||||
let saveDecoratorContext = inDecoratorContext();
|
||||
if (saveDecoratorContext) {
|
||||
|
@ -4081,7 +4081,7 @@ namespace ts {
|
|||
nextToken();
|
||||
return isIdentifierOrKeyword() && !scanner.hasPrecedingLineBreak();
|
||||
}
|
||||
|
||||
|
||||
function nextTokenIsFunctionKeywordOnSameLine() {
|
||||
nextToken();
|
||||
return token === SyntaxKind.FunctionKeyword && !scanner.hasPrecedingLineBreak();
|
||||
|
@ -4150,7 +4150,7 @@ namespace ts {
|
|||
return true;
|
||||
}
|
||||
continue;
|
||||
|
||||
|
||||
case SyntaxKind.PublicKeyword:
|
||||
case SyntaxKind.PrivateKeyword:
|
||||
case SyntaxKind.ProtectedKeyword:
|
||||
|
@ -4229,7 +4229,7 @@ namespace ts {
|
|||
}
|
||||
|
||||
function isLetDeclaration() {
|
||||
// In ES6 'let' always starts a lexical declaration if followed by an identifier or {
|
||||
// In ES6 'let' always starts a lexical declaration if followed by an identifier or {
|
||||
// or [.
|
||||
return lookAhead(nextTokenIsIdentifierOrStartOfDestructuring);
|
||||
}
|
||||
|
@ -4335,7 +4335,7 @@ namespace ts {
|
|||
default:
|
||||
if (decorators || modifiers) {
|
||||
// We reached this point because we encountered decorators and/or modifiers and assumed a declaration
|
||||
// would follow. For recovery and error reporting purposes, return an incomplete declaration.
|
||||
// would follow. For recovery and error reporting purposes, return an incomplete declaration.
|
||||
let node = <Statement>createMissingNode(SyntaxKind.MissingDeclaration, /*reportAtCurrentPosition*/ true, Diagnostics.Declaration_expected);
|
||||
node.pos = fullStart;
|
||||
node.decorators = decorators;
|
||||
|
@ -4694,7 +4694,7 @@ namespace ts {
|
|||
modifiers = <ModifiersArray>[];
|
||||
modifiers.pos = modifierStart;
|
||||
}
|
||||
|
||||
|
||||
flags |= modifierToFlag(modifierKind);
|
||||
modifiers.push(finishNode(createNode(modifierKind, modifierStart)));
|
||||
}
|
||||
|
@ -4719,7 +4719,7 @@ namespace ts {
|
|||
modifiers.flags = flags;
|
||||
modifiers.end = scanner.getStartPos();
|
||||
}
|
||||
|
||||
|
||||
return modifiers;
|
||||
}
|
||||
|
||||
|
@ -4779,7 +4779,7 @@ namespace ts {
|
|||
function parseClassDeclaration(fullStart: number, decorators: NodeArray<Decorator>, modifiers: ModifiersArray): ClassDeclaration {
|
||||
return <ClassDeclaration>parseClassDeclarationOrExpression(fullStart, decorators, modifiers, SyntaxKind.ClassDeclaration);
|
||||
}
|
||||
|
||||
|
||||
function parseClassDeclarationOrExpression(fullStart: number, decorators: NodeArray<Decorator>, modifiers: ModifiersArray, kind: SyntaxKind): ClassLikeDeclaration {
|
||||
let node = <ClassLikeDeclaration>createNode(kind, fullStart);
|
||||
node.decorators = decorators;
|
||||
|
@ -4791,7 +4791,7 @@ namespace ts {
|
|||
|
||||
if (parseExpected(SyntaxKind.OpenBraceToken)) {
|
||||
// ClassTail[Yield,Await] : (Modified) See 14.5
|
||||
// ClassHeritage[?Yield,?Await]opt { ClassBody[?Yield,?Await]opt }
|
||||
// ClassHeritage[?Yield,?Await]opt { ClassBody[?Yield,?Await]opt }
|
||||
node.members = parseClassMembers();
|
||||
parseExpected(SyntaxKind.CloseBraceToken);
|
||||
}
|
||||
|
@ -5639,8 +5639,8 @@ namespace ts {
|
|||
let tags: NodeArray<JSDocTag>;
|
||||
let pos: number;
|
||||
|
||||
// NOTE(cyrusn): This is essentially a handwritten scanner for JSDocComments. I
|
||||
// considered using an actual Scanner, but this would complicate things. The
|
||||
// NOTE(cyrusn): This is essentially a handwritten scanner for JSDocComments. I
|
||||
// considered using an actual Scanner, but this would complicate things. The
|
||||
// scanner would need to know it was in a Doc Comment. Otherwise, it would then
|
||||
// produce comments *inside* the doc comment. In the end it was just easier to
|
||||
// write a simple scanner rather than go that route.
|
||||
|
@ -5655,7 +5655,7 @@ namespace ts {
|
|||
let canParseTag = true;
|
||||
let seenAsterisk = true;
|
||||
|
||||
for (pos = start + "/**".length; pos < end;) {
|
||||
for (pos = start + "/**".length; pos < end; ) {
|
||||
let ch = content.charCodeAt(pos);
|
||||
pos++;
|
||||
|
||||
|
|
|
@ -346,7 +346,7 @@ namespace ts {
|
|||
if (!isDeclarationFile(sourceFile)) {
|
||||
let resolver = getDiagnosticsProducingTypeChecker().getEmitResolver(sourceFile, cancellationToken);
|
||||
// Don't actually write any files since we're just getting diagnostics.
|
||||
var writeFile: WriteFileCallback = () => { };
|
||||
let writeFile: WriteFileCallback = () => { };
|
||||
return ts.getDeclarationDiagnostics(getEmitHost(writeFile), resolver, sourceFile);
|
||||
}
|
||||
});
|
||||
|
|
|
@ -41,16 +41,16 @@ namespace ts {
|
|||
|
||||
function getWScriptSystem(): System {
|
||||
|
||||
var fso = new ActiveXObject("Scripting.FileSystemObject");
|
||||
let fso = new ActiveXObject("Scripting.FileSystemObject");
|
||||
|
||||
var fileStream = new ActiveXObject("ADODB.Stream");
|
||||
let fileStream = new ActiveXObject("ADODB.Stream");
|
||||
fileStream.Type = 2 /*text*/;
|
||||
|
||||
var binaryStream = new ActiveXObject("ADODB.Stream");
|
||||
let binaryStream = new ActiveXObject("ADODB.Stream");
|
||||
binaryStream.Type = 1 /*binary*/;
|
||||
|
||||
var args: string[] = [];
|
||||
for (var i = 0; i < WScript.Arguments.length; i++) {
|
||||
let args: string[] = [];
|
||||
for (let i = 0; i < WScript.Arguments.length; i++) {
|
||||
args[i] = WScript.Arguments.Item(i);
|
||||
}
|
||||
|
||||
|
@ -68,7 +68,7 @@ namespace ts {
|
|||
// Load file and read the first two bytes into a string with no interpretation
|
||||
fileStream.Charset = "x-ansi";
|
||||
fileStream.LoadFromFile(fileName);
|
||||
var bom = fileStream.ReadText(2) || "";
|
||||
let bom = fileStream.ReadText(2) || "";
|
||||
// Position must be at 0 before encoding can be changed
|
||||
fileStream.Position = 0;
|
||||
// [0xFF,0xFE] and [0xFE,0xFF] mean utf-16 (little or big endian), otherwise default to utf-8
|
||||
|
@ -114,28 +114,28 @@ namespace ts {
|
|||
}
|
||||
|
||||
function getNames(collection: any): string[]{
|
||||
var result: string[] = [];
|
||||
for (var e = new Enumerator(collection); !e.atEnd(); e.moveNext()) {
|
||||
let result: string[] = [];
|
||||
for (let e = new Enumerator(collection); !e.atEnd(); e.moveNext()) {
|
||||
result.push(e.item().Name);
|
||||
}
|
||||
return result.sort();
|
||||
}
|
||||
|
||||
function readDirectory(path: string, extension?: string, exclude?: string[]): string[] {
|
||||
var result: string[] = [];
|
||||
let result: string[] = [];
|
||||
exclude = map(exclude, s => getCanonicalPath(combinePaths(path, s)));
|
||||
visitDirectory(path);
|
||||
return result;
|
||||
function visitDirectory(path: string) {
|
||||
var folder = fso.GetFolder(path || ".");
|
||||
var files = getNames(folder.files);
|
||||
let folder = fso.GetFolder(path || ".");
|
||||
let files = getNames(folder.files);
|
||||
for (let current of files) {
|
||||
let name = combinePaths(path, current);
|
||||
if ((!extension || fileExtensionIs(name, extension)) && !contains(exclude, getCanonicalPath(name))) {
|
||||
result.push(name);
|
||||
}
|
||||
}
|
||||
var subfolders = getNames(folder.subfolders);
|
||||
let subfolders = getNames(folder.subfolders);
|
||||
for (let current of subfolders) {
|
||||
let name = combinePaths(path, current);
|
||||
if (!contains(exclude, getCanonicalPath(name))) {
|
||||
|
@ -197,14 +197,14 @@ namespace ts {
|
|||
if (!_fs.existsSync(fileName)) {
|
||||
return undefined;
|
||||
}
|
||||
var buffer = _fs.readFileSync(fileName);
|
||||
var len = buffer.length;
|
||||
let buffer = _fs.readFileSync(fileName);
|
||||
let len = buffer.length;
|
||||
if (len >= 2 && buffer[0] === 0xFE && buffer[1] === 0xFF) {
|
||||
// Big endian UTF-16 byte order mark detected. Since big endian is not supported by node.js,
|
||||
// flip all byte pairs and treat as little endian.
|
||||
len &= ~1;
|
||||
for (var i = 0; i < len; i += 2) {
|
||||
var temp = buffer[i];
|
||||
for (let i = 0; i < len; i += 2) {
|
||||
let temp = buffer[i];
|
||||
buffer[i] = buffer[i + 1];
|
||||
buffer[i + 1] = temp;
|
||||
}
|
||||
|
@ -236,17 +236,17 @@ namespace ts {
|
|||
}
|
||||
|
||||
function readDirectory(path: string, extension?: string, exclude?: string[]): string[] {
|
||||
var result: string[] = [];
|
||||
let result: string[] = [];
|
||||
exclude = map(exclude, s => getCanonicalPath(combinePaths(path, s)));
|
||||
visitDirectory(path);
|
||||
return result;
|
||||
function visitDirectory(path: string) {
|
||||
var files = _fs.readdirSync(path || ".").sort();
|
||||
var directories: string[] = [];
|
||||
let files = _fs.readdirSync(path || ".").sort();
|
||||
let directories: string[] = [];
|
||||
for (let current of files) {
|
||||
var name = combinePaths(path, current);
|
||||
let name = combinePaths(path, current);
|
||||
if (!contains(exclude, getCanonicalPath(name))) {
|
||||
var stat = _fs.statSync(name);
|
||||
let stat = _fs.statSync(name);
|
||||
if (stat.isFile()) {
|
||||
if (!extension || fileExtensionIs(name, extension)) {
|
||||
result.push(name);
|
||||
|
@ -331,4 +331,4 @@ namespace ts {
|
|||
return undefined; // Unsupported host
|
||||
}
|
||||
})();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,15 +11,15 @@ namespace ts {
|
|||
* and if it is, attempts to set the appropriate language.
|
||||
*/
|
||||
function validateLocaleAndSetLanguage(locale: string, errors: Diagnostic[]): boolean {
|
||||
var matchResult = /^([a-z]+)([_\-]([a-z]+))?$/.exec(locale.toLowerCase());
|
||||
let matchResult = /^([a-z]+)([_\-]([a-z]+))?$/.exec(locale.toLowerCase());
|
||||
|
||||
if (!matchResult) {
|
||||
errors.push(createCompilerDiagnostic(Diagnostics.Locale_must_be_of_the_form_language_or_language_territory_For_example_0_or_1, 'en', 'ja-jp'));
|
||||
return false;
|
||||
}
|
||||
|
||||
var language = matchResult[1];
|
||||
var territory = matchResult[3];
|
||||
let language = matchResult[1];
|
||||
let territory = matchResult[3];
|
||||
|
||||
// First try the entire locale, then fall back to just language if that's all we have.
|
||||
if (!trySetLanguageAndTerritory(language, territory, errors) &&
|
||||
|
@ -33,10 +33,10 @@ namespace ts {
|
|||
}
|
||||
|
||||
function trySetLanguageAndTerritory(language: string, territory: string, errors: Diagnostic[]): boolean {
|
||||
var compilerFilePath = normalizePath(sys.getExecutingFilePath());
|
||||
var containingDirectoryPath = getDirectoryPath(compilerFilePath);
|
||||
let compilerFilePath = normalizePath(sys.getExecutingFilePath());
|
||||
let containingDirectoryPath = getDirectoryPath(compilerFilePath);
|
||||
|
||||
var filePath = combinePaths(containingDirectoryPath, language);
|
||||
let filePath = combinePaths(containingDirectoryPath, language);
|
||||
|
||||
if (territory) {
|
||||
filePath = filePath + "-" + territory;
|
||||
|
@ -49,8 +49,9 @@ namespace ts {
|
|||
}
|
||||
|
||||
// TODO: Add codePage support for readFile?
|
||||
let fileContents = '';
|
||||
try {
|
||||
var fileContents = sys.readFile(filePath);
|
||||
fileContents = sys.readFile(filePath);
|
||||
}
|
||||
catch (e) {
|
||||
errors.push(createCompilerDiagnostic(Diagnostics.Unable_to_open_file_0, filePath));
|
||||
|
@ -68,7 +69,7 @@ namespace ts {
|
|||
}
|
||||
|
||||
function countLines(program: Program): number {
|
||||
var count = 0;
|
||||
let count = 0;
|
||||
forEach(program.getSourceFiles(), file => {
|
||||
count += getLineStarts(file).length;
|
||||
});
|
||||
|
@ -76,27 +77,27 @@ namespace ts {
|
|||
}
|
||||
|
||||
function getDiagnosticText(message: DiagnosticMessage, ...args: any[]): string {
|
||||
var diagnostic = createCompilerDiagnostic.apply(undefined, arguments);
|
||||
let diagnostic = createCompilerDiagnostic.apply(undefined, arguments);
|
||||
return <string>diagnostic.messageText;
|
||||
}
|
||||
|
||||
function reportDiagnostic(diagnostic: Diagnostic) {
|
||||
var output = "";
|
||||
let output = "";
|
||||
|
||||
if (diagnostic.file) {
|
||||
var loc = getLineAndCharacterOfPosition(diagnostic.file, diagnostic.start);
|
||||
let loc = getLineAndCharacterOfPosition(diagnostic.file, diagnostic.start);
|
||||
|
||||
output += `${ diagnostic.file.fileName }(${ loc.line + 1 },${ loc.character + 1 }): `;
|
||||
}
|
||||
|
||||
var category = DiagnosticCategory[diagnostic.category].toLowerCase();
|
||||
let category = DiagnosticCategory[diagnostic.category].toLowerCase();
|
||||
output += `${ category } TS${ diagnostic.code }: ${ flattenDiagnosticMessageText(diagnostic.messageText, sys.newLine) }${ sys.newLine }`;
|
||||
|
||||
sys.write(output);
|
||||
}
|
||||
|
||||
function reportDiagnostics(diagnostics: Diagnostic[]) {
|
||||
for (var i = 0; i < diagnostics.length; i++) {
|
||||
for (let i = 0; i < diagnostics.length; i++) {
|
||||
reportDiagnostic(diagnostics[i]);
|
||||
}
|
||||
}
|
||||
|
@ -133,15 +134,15 @@ namespace ts {
|
|||
}
|
||||
|
||||
export function executeCommandLine(args: string[]): void {
|
||||
var commandLine = parseCommandLine(args);
|
||||
var configFileName: string; // Configuration file name (if any)
|
||||
var configFileWatcher: FileWatcher; // Configuration file watcher
|
||||
var cachedProgram: Program; // Program cached from last compilation
|
||||
var rootFileNames: string[]; // Root fileNames for compilation
|
||||
var compilerOptions: CompilerOptions; // Compiler options for compilation
|
||||
var compilerHost: CompilerHost; // Compiler host
|
||||
var hostGetSourceFile: typeof compilerHost.getSourceFile; // getSourceFile method from default host
|
||||
var timerHandle: number; // Handle for 0.25s wait timer
|
||||
let commandLine = parseCommandLine(args);
|
||||
let configFileName: string; // Configuration file name (if any)
|
||||
let configFileWatcher: FileWatcher; // Configuration file watcher
|
||||
let cachedProgram: Program; // Program cached from last compilation
|
||||
let rootFileNames: string[]; // Root fileNames for compilation
|
||||
let compilerOptions: CompilerOptions; // Compiler options for compilation
|
||||
let compilerHost: CompilerHost; // Compiler host
|
||||
let hostGetSourceFile: typeof compilerHost.getSourceFile; // getSourceFile method from default host
|
||||
let timerHandle: number; // Handle for 0.25s wait timer
|
||||
|
||||
if (commandLine.options.locale) {
|
||||
if (!isJSONSupported()) {
|
||||
|
@ -181,7 +182,7 @@ namespace ts {
|
|||
}
|
||||
}
|
||||
else if (commandLine.fileNames.length === 0 && isJSONSupported()) {
|
||||
var searchPath = normalizePath(sys.getCurrentDirectory());
|
||||
let searchPath = normalizePath(sys.getCurrentDirectory());
|
||||
configFileName = findConfigFile(searchPath);
|
||||
}
|
||||
|
||||
|
@ -247,14 +248,14 @@ namespace ts {
|
|||
function getSourceFile(fileName: string, languageVersion: ScriptTarget, onError ?: (message: string) => void) {
|
||||
// Return existing SourceFile object if one is available
|
||||
if (cachedProgram) {
|
||||
var sourceFile = cachedProgram.getSourceFile(fileName);
|
||||
let sourceFile = cachedProgram.getSourceFile(fileName);
|
||||
// A modified source file has no watcher and should not be reused
|
||||
if (sourceFile && sourceFile.fileWatcher) {
|
||||
return sourceFile;
|
||||
}
|
||||
}
|
||||
// Use default host function
|
||||
var sourceFile = hostGetSourceFile(fileName, languageVersion, onError);
|
||||
let sourceFile = hostGetSourceFile(fileName, languageVersion, onError);
|
||||
if (sourceFile && compilerOptions.watch) {
|
||||
// Attach a file watcher
|
||||
sourceFile.fileWatcher = sys.watchFile(sourceFile.fileName, () => sourceFileChanged(sourceFile));
|
||||
|
@ -265,7 +266,7 @@ namespace ts {
|
|||
// Change cached program to the given program
|
||||
function setCachedProgram(program: Program) {
|
||||
if (cachedProgram) {
|
||||
var newSourceFiles = program ? program.getSourceFiles() : undefined;
|
||||
let newSourceFiles = program ? program.getSourceFiles() : undefined;
|
||||
forEach(cachedProgram.getSourceFiles(), sourceFile => {
|
||||
if (!(newSourceFiles && contains(newSourceFiles, sourceFile))) {
|
||||
if (sourceFile.fileWatcher) {
|
||||
|
@ -316,8 +317,8 @@ namespace ts {
|
|||
checkTime = 0;
|
||||
emitTime = 0;
|
||||
|
||||
var program = createProgram(fileNames, compilerOptions, compilerHost);
|
||||
var exitStatus = compileProgram();
|
||||
let program = createProgram(fileNames, compilerOptions, compilerHost);
|
||||
let exitStatus = compileProgram();
|
||||
|
||||
if (compilerOptions.listFiles) {
|
||||
forEach(program.getSourceFiles(), file => {
|
||||
|
@ -326,7 +327,7 @@ namespace ts {
|
|||
}
|
||||
|
||||
if (compilerOptions.diagnostics) {
|
||||
var memoryUsed = sys.getMemoryUsage ? sys.getMemoryUsage() : -1;
|
||||
let memoryUsed = sys.getMemoryUsage ? sys.getMemoryUsage() : -1;
|
||||
reportCountStatistic("Files", program.getSourceFiles().length);
|
||||
reportCountStatistic("Lines", countLines(program));
|
||||
reportCountStatistic("Nodes", program.getNodeCount());
|
||||
|
@ -354,18 +355,18 @@ namespace ts {
|
|||
return { program, exitStatus };
|
||||
|
||||
function compileProgram(): ExitStatus {
|
||||
// First get any syntactic errors.
|
||||
var diagnostics = program.getSyntacticDiagnostics();
|
||||
// First get any syntactic errors.
|
||||
let diagnostics = program.getSyntacticDiagnostics();
|
||||
reportDiagnostics(diagnostics);
|
||||
|
||||
// If we didn't have any syntactic errors, then also try getting the global and
|
||||
// If we didn't have any syntactic errors, then also try getting the global and
|
||||
// semantic errors.
|
||||
if (diagnostics.length === 0) {
|
||||
var diagnostics = program.getGlobalDiagnostics();
|
||||
let diagnostics = program.getGlobalDiagnostics();
|
||||
reportDiagnostics(diagnostics);
|
||||
|
||||
if (diagnostics.length === 0) {
|
||||
var diagnostics = program.getSemanticDiagnostics();
|
||||
let diagnostics = program.getSemanticDiagnostics();
|
||||
reportDiagnostics(diagnostics);
|
||||
}
|
||||
}
|
||||
|
@ -378,7 +379,7 @@ namespace ts {
|
|||
}
|
||||
|
||||
// Otherwise, emit and report any errors we ran into.
|
||||
var emitOutput = program.emit();
|
||||
let emitOutput = program.emit();
|
||||
reportDiagnostics(emitOutput.diagnostics);
|
||||
|
||||
// If the emitter didn't emit anything, then pass that value along.
|
||||
|
@ -401,22 +402,22 @@ namespace ts {
|
|||
}
|
||||
|
||||
function printHelp() {
|
||||
var output = "";
|
||||
let output = "";
|
||||
|
||||
// We want to align our "syntax" and "examples" commands to a certain margin.
|
||||
var syntaxLength = getDiagnosticText(Diagnostics.Syntax_Colon_0, "").length;
|
||||
var examplesLength = getDiagnosticText(Diagnostics.Examples_Colon_0, "").length;
|
||||
var marginLength = Math.max(syntaxLength, examplesLength);
|
||||
let syntaxLength = getDiagnosticText(Diagnostics.Syntax_Colon_0, "").length;
|
||||
let examplesLength = getDiagnosticText(Diagnostics.Examples_Colon_0, "").length;
|
||||
let marginLength = Math.max(syntaxLength, examplesLength);
|
||||
|
||||
// Build up the syntactic skeleton.
|
||||
var syntax = makePadding(marginLength - syntaxLength);
|
||||
let syntax = makePadding(marginLength - syntaxLength);
|
||||
syntax += "tsc [" + getDiagnosticText(Diagnostics.options) + "] [" + getDiagnosticText(Diagnostics.file) + " ...]";
|
||||
|
||||
output += getDiagnosticText(Diagnostics.Syntax_Colon_0, syntax);
|
||||
output += sys.newLine + sys.newLine;
|
||||
|
||||
// Build up the list of examples.
|
||||
var padding = makePadding(marginLength);
|
||||
let padding = makePadding(marginLength);
|
||||
output += getDiagnosticText(Diagnostics.Examples_Colon_0, makePadding(marginLength - examplesLength) + "tsc hello.ts") + sys.newLine;
|
||||
output += padding + "tsc --out file.js file.ts" + sys.newLine;
|
||||
output += padding + "tsc @args.txt" + sys.newLine;
|
||||
|
@ -425,17 +426,17 @@ namespace ts {
|
|||
output += getDiagnosticText(Diagnostics.Options_Colon) + sys.newLine;
|
||||
|
||||
// Sort our options by their names, (e.g. "--noImplicitAny" comes before "--watch")
|
||||
var optsList = filter(optionDeclarations.slice(), v => !v.experimental);
|
||||
let optsList = filter(optionDeclarations.slice(), v => !v.experimental);
|
||||
optsList.sort((a, b) => compareValues<string>(a.name.toLowerCase(), b.name.toLowerCase()));
|
||||
|
||||
// We want our descriptions to align at the same column in our output,
|
||||
// so we keep track of the longest option usage string.
|
||||
var marginLength = 0;
|
||||
var usageColumn: string[] = []; // Things like "-d, --declaration" go in here.
|
||||
var descriptionColumn: string[] = [];
|
||||
marginLength = 0;
|
||||
let usageColumn: string[] = []; // Things like "-d, --declaration" go in here.
|
||||
let descriptionColumn: string[] = [];
|
||||
|
||||
for (var i = 0; i < optsList.length; i++) {
|
||||
var option = optsList[i];
|
||||
for (let i = 0; i < optsList.length; i++) {
|
||||
let option = optsList[i];
|
||||
|
||||
// If an option lacks a description,
|
||||
// it is not officially supported.
|
||||
|
@ -443,7 +444,7 @@ namespace ts {
|
|||
continue;
|
||||
}
|
||||
|
||||
var usageText = " ";
|
||||
let usageText = " ";
|
||||
if (option.shortName) {
|
||||
usageText += "-" + option.shortName;
|
||||
usageText += getParamType(option);
|
||||
|
@ -461,15 +462,15 @@ namespace ts {
|
|||
}
|
||||
|
||||
// Special case that can't fit in the loop.
|
||||
var usageText = " @<" + getDiagnosticText(Diagnostics.file) + ">";
|
||||
let usageText = " @<" + getDiagnosticText(Diagnostics.file) + ">";
|
||||
usageColumn.push(usageText);
|
||||
descriptionColumn.push(getDiagnosticText(Diagnostics.Insert_command_line_options_and_files_from_a_file));
|
||||
marginLength = Math.max(usageText.length, marginLength);
|
||||
|
||||
// Print out each row, aligning all the descriptions on the same column.
|
||||
for (var i = 0; i < usageColumn.length; i++) {
|
||||
var usage = usageColumn[i];
|
||||
var description = descriptionColumn[i];
|
||||
for (let i = 0; i < usageColumn.length; i++) {
|
||||
let usage = usageColumn[i];
|
||||
let description = descriptionColumn[i];
|
||||
output += usage + makePadding(marginLength - usage.length + 2) + description + sys.newLine;
|
||||
}
|
||||
|
||||
|
|
|
@ -273,7 +273,7 @@ namespace ts {
|
|||
// Module references
|
||||
ExternalModuleReference,
|
||||
|
||||
//JSX
|
||||
// JSX
|
||||
JsxElement,
|
||||
JsxSelfClosingElement,
|
||||
JsxOpeningElement,
|
||||
|
|
|
@ -92,7 +92,7 @@ namespace ts {
|
|||
let thisNodeOrAnySubNodesHasError = ((node.parserContextFlags & ParserContextFlags.ThisNodeHasError) !== 0) ||
|
||||
forEachChild(node, containsParseError);
|
||||
|
||||
// If so, mark ourselves accordingly.
|
||||
// If so, mark ourselves accordingly.
|
||||
if (thisNodeOrAnySubNodesHasError) {
|
||||
node.parserContextFlags |= ParserContextFlags.ThisNodeOrAnySubNodesHasError;
|
||||
}
|
||||
|
@ -129,13 +129,13 @@ namespace ts {
|
|||
|
||||
// Returns true if this node is missing from the actual source code. 'missing' is different
|
||||
// from 'undefined/defined'. When a node is undefined (which can happen for optional nodes
|
||||
// in the tree), it is definitel missing. HOwever, a node may be defined, but still be
|
||||
// in the tree), it is definitel missing. HOwever, a node may be defined, but still be
|
||||
// missing. This happens whenever the parser knows it needs to parse something, but can't
|
||||
// get anything in the source code that it expects at that location. For example:
|
||||
//
|
||||
// let a: ;
|
||||
//
|
||||
// Here, the Type in the Type-Annotation is not-optional (as there is a colon in the source
|
||||
// Here, the Type in the Type-Annotation is not-optional (as there is a colon in the source
|
||||
// code). So the parser will attempt to parse out a type, and will create an actual node.
|
||||
// However, this node will be 'missing' in the sense that no actual source-code/tokens are
|
||||
// contained within it.
|
||||
|
@ -211,7 +211,7 @@ namespace ts {
|
|||
isCatchClauseVariableDeclaration(declaration);
|
||||
}
|
||||
|
||||
// Gets the nearest enclosing block scope container that has the provided node
|
||||
// Gets the nearest enclosing block scope container that has the provided node
|
||||
// as a descendant, that is not the provided node.
|
||||
export function getEnclosingBlockScopeContainer(node: Node): Node {
|
||||
let current = node.parent;
|
||||
|
@ -307,7 +307,7 @@ namespace ts {
|
|||
}
|
||||
|
||||
if (errorNode === undefined) {
|
||||
// If we don't have a better node, then just set the error on the first token of
|
||||
// If we don't have a better node, then just set the error on the first token of
|
||||
// construct.
|
||||
return getSpanOfTokenAtPosition(sourceFile, node.pos);
|
||||
}
|
||||
|
@ -339,10 +339,10 @@ namespace ts {
|
|||
return node;
|
||||
}
|
||||
|
||||
// Returns the node flags for this node and all relevant parent nodes. This is done so that
|
||||
// Returns the node flags for this node and all relevant parent nodes. This is done so that
|
||||
// nodes like variable declarations and binding elements can returned a view of their flags
|
||||
// that includes the modifiers from their container. i.e. flags like export/declare aren't
|
||||
// stored on the variable declaration directly, but on the containing variable statement
|
||||
// stored on the variable declaration directly, but on the containing variable statement
|
||||
// (if it has one). Similarly, flags for let/const are store on the variable declaration
|
||||
// list. By calling this function, all those flags are combined so that the client can treat
|
||||
// the node as if it actually had those flags.
|
||||
|
@ -662,7 +662,7 @@ namespace ts {
|
|||
node = node.parent;
|
||||
break;
|
||||
case SyntaxKind.Decorator:
|
||||
// Decorators are always applied outside of the body of a class or method.
|
||||
// Decorators are always applied outside of the body of a class or method.
|
||||
if (node.parent.kind === SyntaxKind.Parameter && isClassElement(node.parent.parent)) {
|
||||
// If the decorator's parent is a Parameter, we resolve the this container from
|
||||
// the grandparent class declaration.
|
||||
|
@ -717,7 +717,7 @@ namespace ts {
|
|||
node = node.parent;
|
||||
break;
|
||||
case SyntaxKind.Decorator:
|
||||
// Decorators are always applied outside of the body of a class or method.
|
||||
// Decorators are always applied outside of the body of a class or method.
|
||||
if (node.parent.kind === SyntaxKind.Parameter && isClassElement(node.parent.parent)) {
|
||||
// If the decorator's parent is a Parameter, we resolve the this container from
|
||||
// the grandparent class declaration.
|
||||
|
@ -746,14 +746,14 @@ namespace ts {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export function getEntityNameFromTypeNode(node: TypeNode): EntityName | Expression {
|
||||
if (node) {
|
||||
if (node) {
|
||||
switch (node.kind) {
|
||||
case SyntaxKind.TypeReference:
|
||||
return (<TypeReferenceNode>node).typeName;
|
||||
case SyntaxKind.ExpressionWithTypeArguments:
|
||||
return (<ExpressionWithTypeArguments>node).expression
|
||||
return (<ExpressionWithTypeArguments>node).expression;
|
||||
case SyntaxKind.Identifier:
|
||||
case SyntaxKind.QualifiedName:
|
||||
return (<EntityName><Node>node);
|
||||
|
@ -1031,7 +1031,7 @@ namespace ts {
|
|||
|
||||
export function getCorrespondingJSDocParameterTag(parameter: ParameterDeclaration): JSDocParameterTag {
|
||||
if (parameter.name && parameter.name.kind === SyntaxKind.Identifier) {
|
||||
// If it's a parameter, see if the parent has a jsdoc comment with an @param
|
||||
// If it's a parameter, see if the parent has a jsdoc comment with an @param
|
||||
// annotation.
|
||||
let parameterName = (<Identifier>parameter.name).text;
|
||||
|
||||
|
@ -1969,7 +1969,7 @@ namespace ts {
|
|||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export function isRightSideOfQualifiedNameOrPropertyAccess(node: Node) {
|
||||
return (node.parent.kind === SyntaxKind.QualifiedName && (<QualifiedName>node.parent).right === node) ||
|
||||
(node.parent.kind === SyntaxKind.PropertyAccessExpression && (<PropertyAccessExpression>node.parent).name === node);
|
||||
|
@ -1988,7 +1988,7 @@ namespace ts {
|
|||
}
|
||||
|
||||
/**
|
||||
* Replace each instance of non-ascii characters by one, two, three, or four escape sequences
|
||||
* Replace each instance of non-ascii characters by one, two, three, or four escape sequences
|
||||
* representing the UTF-8 encoding of the character, and return the expanded char code list.
|
||||
*/
|
||||
function getExpandedCharCodes(input: string): number[] {
|
||||
|
@ -2178,10 +2178,10 @@ namespace ts {
|
|||
export let unchangedTextChangeRange = createTextChangeRange(createTextSpan(0, 0), 0);
|
||||
|
||||
/**
|
||||
* Called to merge all the changes that occurred across several versions of a script snapshot
|
||||
* Called to merge all the changes that occurred across several versions of a script snapshot
|
||||
* into a single change. i.e. if a user keeps making successive edits to a script we will
|
||||
* have a text change from V1 to V2, V2 to V3, ..., Vn.
|
||||
*
|
||||
* have a text change from V1 to V2, V2 to V3, ..., Vn.
|
||||
*
|
||||
* This function will then merge those changes into a single change range valid between V1 and
|
||||
* Vn.
|
||||
*/
|
||||
|
@ -2212,17 +2212,17 @@ namespace ts {
|
|||
//
|
||||
// 0 10 20 30 40 50 60 70 80 90 100
|
||||
// -------------------------------------------------------------------------------------------------------
|
||||
// | /
|
||||
// | /----
|
||||
// T1 | /----
|
||||
// | /----
|
||||
// | /----
|
||||
// | /
|
||||
// | /----
|
||||
// T1 | /----
|
||||
// | /----
|
||||
// | /----
|
||||
// -------------------------------------------------------------------------------------------------------
|
||||
// | \
|
||||
// | \
|
||||
// T2 | \
|
||||
// | \
|
||||
// | \
|
||||
// | \
|
||||
// | \
|
||||
// T2 | \
|
||||
// | \
|
||||
// | \
|
||||
// -------------------------------------------------------------------------------------------------------
|
||||
//
|
||||
// Merging these turns out to not be too difficult. First, determining the new start of the change is trivial
|
||||
|
@ -2230,17 +2230,17 @@ namespace ts {
|
|||
//
|
||||
// 0 10 20 30 40 50 60 70 80 90 100
|
||||
// ------------------------------------------------------------*------------------------------------------
|
||||
// | /
|
||||
// | /----
|
||||
// T1 | /----
|
||||
// | /----
|
||||
// | /----
|
||||
// | /
|
||||
// | /----
|
||||
// T1 | /----
|
||||
// | /----
|
||||
// | /----
|
||||
// ----------------------------------------$-------------------$------------------------------------------
|
||||
// . | \
|
||||
// . | \
|
||||
// T2 . | \
|
||||
// . | \
|
||||
// . | \
|
||||
// . | \
|
||||
// . | \
|
||||
// T2 . | \
|
||||
// . | \
|
||||
// . | \
|
||||
// ----------------------------------------------------------------------*--------------------------------
|
||||
//
|
||||
// (Note the dots represent the newly inferrred start.
|
||||
|
@ -2251,22 +2251,22 @@ namespace ts {
|
|||
//
|
||||
// 0 10 20 30 40 50 60 70 80 90 100
|
||||
// --------------------------------------------------------------------------------*----------------------
|
||||
// | /
|
||||
// | /----
|
||||
// T1 | /----
|
||||
// | /----
|
||||
// | /----
|
||||
// | /
|
||||
// | /----
|
||||
// T1 | /----
|
||||
// | /----
|
||||
// | /----
|
||||
// ------------------------------------------------------------$------------------------------------------
|
||||
// . | \
|
||||
// . | \
|
||||
// T2 . | \
|
||||
// . | \
|
||||
// . | \
|
||||
// . | \
|
||||
// . | \
|
||||
// T2 . | \
|
||||
// . | \
|
||||
// . | \
|
||||
// ----------------------------------------------------------------------*--------------------------------
|
||||
//
|
||||
// In other words (in this case), we're recognizing that the second edit happened after where the first edit
|
||||
// ended with a delta of 20 characters (60 - 40). Thus, if we go back in time to where the first edit started
|
||||
// that's the same as if we started at char 80 instead of 60.
|
||||
// that's the same as if we started at char 80 instead of 60.
|
||||
//
|
||||
// As it so happens, the same logic applies if the second edit precedes the first edit. In that case rahter
|
||||
// than pusing the first edit forward to match the second, we'll push the second edit forward to match the
|
||||
|
@ -2276,7 +2276,7 @@ namespace ts {
|
|||
// semantics: { { start: 10, length: 70 }, newLength: 60 }
|
||||
//
|
||||
// The math then works out as follows.
|
||||
// If we have { oldStart1, oldEnd1, newEnd1 } and { oldStart2, oldEnd2, newEnd2 } then we can compute the
|
||||
// If we have { oldStart1, oldEnd1, newEnd1 } and { oldStart2, oldEnd2, newEnd2 } then we can compute the
|
||||
// final result like so:
|
||||
//
|
||||
// {
|
||||
|
|
|
@ -4,15 +4,11 @@
|
|||
"comment-format": [true,
|
||||
"check-space"
|
||||
],
|
||||
"curly": true,
|
||||
"indent": true,
|
||||
"one-line": [true,
|
||||
"check-open-brace"
|
||||
],
|
||||
"no-empty": true,
|
||||
"no-trailing-whitespace": true,
|
||||
"no-unreachable": true,
|
||||
"no-unused-variable": true,
|
||||
"no-use-before-declare": true,
|
||||
"no-var-keyword": true,
|
||||
"quotemark": true,
|
||||
|
@ -24,4 +20,4 @@
|
|||
"check-type"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче