mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Fix as many linter errors as possible
This commit is contained in:
@@ -211,6 +211,9 @@ namespace ts {
|
||||
let assignableRelation: Map<RelationComparisonResult> = {};
|
||||
let identityRelation: Map<RelationComparisonResult> = {};
|
||||
|
||||
// This is for caching the result of getSymbolDisplayBuilder. Do not access directly.
|
||||
let _displayBuilder: SymbolDisplayBuilder;
|
||||
|
||||
type TypeSystemEntity = Symbol | Type | Signature;
|
||||
|
||||
const enum TypeSystemPropertyName {
|
||||
@@ -1490,8 +1493,6 @@ namespace ts {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
// This is for caching the result of getSymbolDisplayBuilder. Do not access directly.
|
||||
let _displayBuilder: SymbolDisplayBuilder;
|
||||
function getSymbolDisplayBuilder(): SymbolDisplayBuilder {
|
||||
|
||||
function getNameOfSymbol(symbol: Symbol): string {
|
||||
@@ -3448,7 +3449,7 @@ namespace ts {
|
||||
// type, a property is considered known if it is known in any constituent type.
|
||||
function isKnownProperty(type: Type, name: string): boolean {
|
||||
if (type.flags & TypeFlags.ObjectType && type !== globalObjectType) {
|
||||
var resolved = resolveStructuredTypeMembers(type);
|
||||
const resolved = resolveStructuredTypeMembers(type);
|
||||
return !!(resolved.properties.length === 0 ||
|
||||
resolved.stringIndexType ||
|
||||
resolved.numberIndexType ||
|
||||
|
||||
@@ -219,10 +219,10 @@ namespace ts {
|
||||
export function reduceLeft<T, U>(array: T[], f: (a: U, x: T) => U, initial: U): U;
|
||||
export function reduceLeft<T, U>(array: T[], f: (a: U, x: T) => U, initial?: U): U {
|
||||
if (array) {
|
||||
var count = array.length;
|
||||
const count = array.length;
|
||||
if (count > 0) {
|
||||
var pos = 0;
|
||||
var result = arguments.length <= 2 ? array[pos++] : initial;
|
||||
let pos = 0;
|
||||
let result = arguments.length <= 2 ? array[pos++] : initial;
|
||||
while (pos < count) {
|
||||
result = f(<U>result, array[pos++]);
|
||||
}
|
||||
@@ -236,9 +236,9 @@ namespace ts {
|
||||
export function reduceRight<T, U>(array: T[], f: (a: U, x: T) => U, initial: U): U;
|
||||
export function reduceRight<T, U>(array: T[], f: (a: U, x: T) => U, initial?: U): U {
|
||||
if (array) {
|
||||
var pos = array.length - 1;
|
||||
let pos = array.length - 1;
|
||||
if (pos >= 0) {
|
||||
var result = arguments.length <= 2 ? array[pos--] : initial;
|
||||
let result = arguments.length <= 2 ? array[pos--] : initial;
|
||||
while (pos >= 0) {
|
||||
result = f(<U>result, array[pos--]);
|
||||
}
|
||||
@@ -805,4 +805,4 @@ namespace ts {
|
||||
Debug.assert(false, message);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+10
-9
@@ -1248,7 +1248,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
|
||||
// Don't emit empty strings
|
||||
if (children[i].kind === SyntaxKind.JsxText) {
|
||||
let text = getTextToEmit(<JsxText>children[i]);
|
||||
if(text !== undefined) {
|
||||
if (text !== undefined) {
|
||||
write(', "');
|
||||
write(text);
|
||||
write('"');
|
||||
@@ -4255,11 +4255,12 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
|
||||
emitDetachedComments(ctor.body.statements);
|
||||
}
|
||||
emitCaptureThisForNodeIfNecessary(node);
|
||||
let superCall: ExpressionStatement;
|
||||
if (ctor) {
|
||||
emitDefaultValueAssignments(ctor);
|
||||
emitRestParameter(ctor);
|
||||
if (baseTypeElement) {
|
||||
var superCall = findInitialSuperCall(ctor);
|
||||
superCall = findInitialSuperCall(ctor);
|
||||
if (superCall) {
|
||||
writeLine();
|
||||
emit(superCall);
|
||||
@@ -4936,7 +4937,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
|
||||
let temp = createAndRecordTempVariable(TempFlags.Auto);
|
||||
write("(typeof (");
|
||||
emitNodeWithoutSourceMap(temp);
|
||||
write(" = ")
|
||||
write(" = ");
|
||||
emitEntityNameAsExpression(typeName, /*useFallback*/ true);
|
||||
write(") === 'function' && ");
|
||||
emitNodeWithoutSourceMap(temp);
|
||||
@@ -4995,7 +4996,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
|
||||
//
|
||||
// For the rules on serializing the type of each parameter declaration, see `serializeTypeOfDeclaration`.
|
||||
if (node) {
|
||||
var valueDeclaration: FunctionLikeDeclaration;
|
||||
let valueDeclaration: FunctionLikeDeclaration;
|
||||
if (node.kind === SyntaxKind.ClassDeclaration) {
|
||||
valueDeclaration = getFirstConstructorWithBody(<ClassDeclaration>node);
|
||||
}
|
||||
@@ -5004,8 +5005,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
|
||||
}
|
||||
|
||||
if (valueDeclaration) {
|
||||
var parameters = valueDeclaration.parameters;
|
||||
var parameterCount = parameters.length;
|
||||
const parameters = valueDeclaration.parameters;
|
||||
const parameterCount = parameters.length;
|
||||
if (parameterCount > 0) {
|
||||
for (var i = 0; i < parameterCount; i++) {
|
||||
if (i > 0) {
|
||||
@@ -5013,7 +5014,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
|
||||
}
|
||||
|
||||
if (parameters[i].dotDotDotToken) {
|
||||
var parameterType = parameters[i].type;
|
||||
let parameterType = parameters[i].type;
|
||||
if (parameterType.kind === SyntaxKind.ArrayType) {
|
||||
parameterType = (<ArrayTypeNode>parameterType).elementType;
|
||||
}
|
||||
@@ -5825,7 +5826,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
|
||||
writeLine();
|
||||
write("}");
|
||||
writeLine();
|
||||
write(`${exportFunctionForFile}(exports);`)
|
||||
write(`${exportFunctionForFile}(exports);`);
|
||||
decreaseIndent();
|
||||
writeLine();
|
||||
write("}");
|
||||
@@ -6173,7 +6174,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
|
||||
// exports_(reexports);
|
||||
let reexportsVariableName = makeUniqueName("reexports");
|
||||
writeLine();
|
||||
write(`var ${reexportsVariableName} = {};`)
|
||||
write(`var ${reexportsVariableName} = {};`);
|
||||
writeLine();
|
||||
for (let e of (<ExportDeclaration>importNode).exportClause.elements) {
|
||||
write(`${reexportsVariableName}["`);
|
||||
|
||||
@@ -3148,7 +3148,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
function parseAwaitExpression() {
|
||||
var node = <AwaitExpression>createNode(SyntaxKind.AwaitExpression);
|
||||
const node = <AwaitExpression>createNode(SyntaxKind.AwaitExpression);
|
||||
nextToken();
|
||||
node.expression = parseUnaryExpressionOrHigher();
|
||||
return finishNode(node);
|
||||
@@ -5140,7 +5140,7 @@ namespace ts {
|
||||
// the 'from' keyword can be parsed as a named export when the export clause is unterminated (i.e. `export { from "moduleName";`)
|
||||
// If we don't have a 'from' keyword, see if we have a string literal such that ASI won't take effect.
|
||||
if (token === SyntaxKind.FromKeyword || (token === SyntaxKind.StringLiteral && !scanner.hasPrecedingLineBreak())) {
|
||||
parseExpected(SyntaxKind.FromKeyword)
|
||||
parseExpected(SyntaxKind.FromKeyword);
|
||||
node.moduleSpecifier = parseModuleSpecifier();
|
||||
}
|
||||
}
|
||||
|
||||
+11
-11
@@ -31,7 +31,7 @@ namespace ts {
|
||||
declare var __filename: string;
|
||||
declare var Buffer: {
|
||||
new (str: string, encoding ?: string): any;
|
||||
}
|
||||
};
|
||||
|
||||
declare class Enumerator {
|
||||
public atEnd(): boolean;
|
||||
@@ -188,13 +188,13 @@ namespace ts {
|
||||
};
|
||||
}
|
||||
function getNodeSystem(): System {
|
||||
var _fs = require("fs");
|
||||
var _path = require("path");
|
||||
var _os = require('os');
|
||||
const _fs = require("fs");
|
||||
const _path = require("path");
|
||||
const _os = require('os');
|
||||
|
||||
var platform: string = _os.platform();
|
||||
const platform: string = _os.platform();
|
||||
// win32\win64 are case insensitive platforms, MacOS (darwin) by default is also case insensitive
|
||||
var useCaseSensitiveFileNames = platform !== "win32" && platform !== "win64" && platform !== "darwin";
|
||||
const useCaseSensitiveFileNames = platform !== "win32" && platform !== "win64" && platform !== "darwin";
|
||||
|
||||
function readFile(fileName: string, encoding?: string): string {
|
||||
if (!_fs.existsSync(fileName)) {
|
||||
@@ -271,10 +271,10 @@ namespace ts {
|
||||
newLine: _os.EOL,
|
||||
useCaseSensitiveFileNames: useCaseSensitiveFileNames,
|
||||
write(s: string): void {
|
||||
var buffer = new Buffer(s, 'utf8');
|
||||
var offset: number = 0;
|
||||
var toWrite: number = buffer.length;
|
||||
var written = 0;
|
||||
const buffer = new Buffer(s, 'utf8');
|
||||
let offset: number = 0;
|
||||
let toWrite: number = buffer.length;
|
||||
let written = 0;
|
||||
// 1 is a standard descriptor for stdout
|
||||
while ((written = _fs.writeSync(1, buffer, offset, toWrite)) < toWrite) {
|
||||
offset += written;
|
||||
@@ -297,7 +297,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
callback(fileName);
|
||||
};
|
||||
}
|
||||
},
|
||||
resolvePath: function (path: string): string {
|
||||
return _path.resolve(path);
|
||||
|
||||
@@ -24,6 +24,8 @@
|
||||
/// <reference path='sourceMapRecorder.ts'/>
|
||||
/// <reference path='runnerbase.ts'/>
|
||||
|
||||
// Block scoped definitions work poorly for global variables, temporarily enable var
|
||||
/* tslint:disable:no-var-keyword */
|
||||
var Buffer: BufferConstructor = require('buffer').Buffer;
|
||||
|
||||
// this will work in the browser via browserify
|
||||
@@ -32,6 +34,7 @@ var assert: typeof _chai.assert = _chai.assert;
|
||||
var expect: typeof _chai.expect = _chai.expect;
|
||||
declare var __dirname: string; // Node-specific
|
||||
var global = <any>Function("return this").call(null);
|
||||
/* tslint:enable:no-var-keyword */
|
||||
|
||||
module Utils {
|
||||
// Setup some globals based on the current environment
|
||||
@@ -412,6 +415,7 @@ module Harness {
|
||||
log(text: string): void;
|
||||
getMemoryUsage?(): number;
|
||||
}
|
||||
export var IO: IO;
|
||||
|
||||
module IOImpl {
|
||||
declare class Enumerator {
|
||||
@@ -690,7 +694,6 @@ module Harness {
|
||||
}
|
||||
}
|
||||
|
||||
export var IO: IO;
|
||||
switch (Utils.getExecutionEnvironment()) {
|
||||
case Utils.ExecutionEnvironment.CScript:
|
||||
IO = IOImpl.CScript;
|
||||
|
||||
@@ -74,10 +74,11 @@ module RWC {
|
||||
});
|
||||
|
||||
// Add files to compilation
|
||||
let isInInputList = (resolvedPath: string) => (inputFile: { unitName: string; content: string; }) => inputFile.unitName === resolvedPath;
|
||||
for (let fileRead of ioLog.filesRead) {
|
||||
// Check if the file is already added into the set of input files.
|
||||
var resolvedPath = ts.normalizeSlashes(ts.sys.resolvePath(fileRead.path));
|
||||
let inInputList = ts.forEach(inputFiles, inputFile => inputFile.unitName === resolvedPath);
|
||||
const resolvedPath = ts.normalizeSlashes(ts.sys.resolvePath(fileRead.path));
|
||||
let inInputList = ts.forEach(inputFiles, isInInputList(resolvedPath));
|
||||
|
||||
if (!Harness.isLibraryFile(fileRead.path)) {
|
||||
if (inInputList) {
|
||||
|
||||
Reference in New Issue
Block a user