Skip to content

Commit

Permalink
Turn off a few rules and more cleanup post merge
Browse files Browse the repository at this point in the history
  • Loading branch information
danquirk committed Jul 9, 2015
1 parent be1371d commit 5dfa610
Show file tree
Hide file tree
Showing 13 changed files with 241 additions and 246 deletions.
3 changes: 1 addition & 2 deletions scripts/errorCheck.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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');
});
});

54 changes: 27 additions & 27 deletions src/compiler/binder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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,

Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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));
Expand All @@ -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
Expand Down Expand Up @@ -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.
Expand All @@ -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;
Expand All @@ -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.
//
Expand Down Expand Up @@ -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:
//
Expand All @@ -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;
}
Expand Down Expand Up @@ -490,7 +490,7 @@ namespace ts {
if (stat.kind === SyntaxKind.ExportDeclaration || stat.kind === SyntaxKind.ExportAssignment) {
return true;
}
}
};
}
return false;
}
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 &&
Expand Down
17 changes: 8 additions & 9 deletions src/compiler/checker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand All @@ -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
Expand Down Expand Up @@ -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 ?
Expand Down Expand Up @@ -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));
}
}
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/compiler/commandLineParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,7 @@ namespace ts {
}
else if (fileExtensionIs(name, ".ts")) {
if (!contains(sysFiles, name + "x")) {
fileNames.push(name)
fileNames.push(name);
}
}
else {
Expand Down
12 changes: 6 additions & 6 deletions src/compiler/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand All @@ -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];
}
Expand Down
Loading

0 comments on commit 5dfa610

Please sign in to comment.