Fix lint errors

This commit is contained in:
Andy Hanson 2017-03-17 13:37:12 -07:00
parent 230e1da1f9
commit 2305c10a65
26 changed files with 139 additions and 226 deletions

View file

@ -1,4 +1,4 @@
/// <reference path="core.ts" />
/// <reference path="core.ts" />
/// <reference path="diagnosticInformationMap.generated.ts" />
namespace ts {

View file

@ -298,8 +298,8 @@ namespace ts {
let noDiagnosticsTypeChecker: TypeChecker;
let classifiableNames: Map<string>;
let cachedSemanticDiagnosticsForFile: DiagnosticCache = {};
let cachedDeclarationDiagnosticsForFile: DiagnosticCache = {};
const cachedSemanticDiagnosticsForFile: DiagnosticCache = {};
const cachedDeclarationDiagnosticsForFile: DiagnosticCache = {};
let resolvedTypeReferenceDirectives = createMap<ResolvedTypeReferenceDirective>();
let fileProcessingDiagnostics = createDiagnosticCollection();
@ -1105,7 +1105,7 @@ namespace ts {
return getAndCacheDiagnostics(sourceFile, cancellationToken, cachedDeclarationDiagnosticsForFile, getDeclarationDiagnosticsForFileNoCache);
}
function getDeclarationDiagnosticsForFileNoCache(sourceFile: SourceFile| undefined, cancellationToken: CancellationToken) {
function getDeclarationDiagnosticsForFileNoCache(sourceFile: SourceFile | undefined, cancellationToken: CancellationToken) {
return runWithCancellationToken(() => {
const resolver = getDiagnosticsProducingTypeChecker().getEmitResolver(sourceFile, cancellationToken);
// Don't actually write any files since we're just getting diagnostics.

View file

@ -927,12 +927,11 @@ namespace FourSlash {
this.assertObjectsEqual<ReferencesJson>(fullActual, fullExpected);
}
function rangeToReferenceEntry(r: Range) {
let { isWriteAccess, isDefinition, isInString } = (r.marker && r.marker.data) || { isWriteAccess: false, isDefinition: false, isInString: undefined };
isWriteAccess = !!isWriteAccess; isDefinition = !!isDefinition;
const result: any = { fileName: r.fileName, textSpan: { start: r.start, length: r.end - r.start }, isWriteAccess, isDefinition };
function rangeToReferenceEntry(r: Range): ts.ReferenceEntry {
const { isWriteAccess, isDefinition, isInString } = (r.marker && r.marker.data) || { isWriteAccess: false, isDefinition: false, isInString: undefined };
const result: ts.ReferenceEntry = { fileName: r.fileName, textSpan: { start: r.start, length: r.end - r.start }, isWriteAccess: !!isWriteAccess, isDefinition: !!isDefinition };
if (isInString !== undefined) {
result.isInString = isInString;
result.isInString = isInString
}
return result;
}
@ -2291,7 +2290,6 @@ namespace FourSlash {
else {
if (actual === undefined) {
this.raiseError(`${name} failed - expected the template {newText: "${expected.newText}", caretOffset: "${expected.caretOffset}"} but got nothing instead`);
}
if (actual.newText !== expected.newText) {

View file

@ -1,88 +0,0 @@
///<reference path='_project.ts'/>
describe('getFormattingEditsForRange', function() {
//
// Verify that formatting the typescript file "sourceFileName" results in the
// baseline file "baselineFileName".
//
function getFormattingEditsForRange(sourceFileName: string) {
var baselineFileName = "tests/cases/unittests/services/testCode/formatting/" + sourceFileName + "BaseLine.ts";
sourceFileName = "tests/cases/unittests/services/testCode/formatting/" + sourceFileName + ".ts";
var typescriptLS = new Harness.TypeScriptLS();
typescriptLS.addDefaultLibrary();
typescriptLS.addFile(sourceFileName);
var ls = typescriptLS.getLanguageService();
var script = ls.languageService.getScriptAST(sourceFileName);
assert.notNull(script);
var edits = ls.languageService.getFormattingEditsForRange(sourceFileName, 0, script.limChar, new Services.FormatCodeOptions());
typescriptLS.checkEdits(sourceFileName, baselineFileName, edits);
}
describe('test cases for formatting engine', function() {
it("formats typescript constructs properly", function() {
getFormattingEditsForRange('typescriptConstructs');
});
it("formats document ready function properly", function() {
getFormattingEditsForRange('documentReadyFunction');
});
it("formats on closing bracket properly", function() {
getFormattingEditsForRange('onClosingBracket');
});
it("formats various javascript constructs", function() {
getFormattingEditsForRange('various');
});
it("formats main javascript program", function() {
getFormattingEditsForRange('main');
});
it("formats on semicolon properly", function() {
getFormattingEditsForRange('onSemiColon');
});
it("formats enum with trailling tab characters properly", function() {
getFormattingEditsForRange('tabAfterCloseCurly');
});
it("formats object literal", function() {
getFormattingEditsForRange('objectLiteral');
});
it("formats with statements", function() {
getFormattingEditsForRange('withStatement');
});
it("formats ':' and '?' in parameters", function() {
getFormattingEditsForRange('colonAndQMark');
});
it("formats 'import' declaration", function() {
getFormattingEditsForRange('importDeclaration');
});
it("formats exported class with implicit module", function() {
//TODO: this is to force generation of implicit module in AST
var svGenTarget = TypeScript.moduleGenTarget;
try {
TypeScript.moduleGenTarget = TypeScript.ModuleGenTarget.Asynchronous;
getFormattingEditsForRange('implicitModule');
}
finally {
TypeScript.moduleGenTarget = svGenTarget;
}
});
it("formats constructor statements correctelly", function() {
getFormattingEditsForRange('spaceAfterConstructor');
});
it("formats classes and interfaces correctelly", function() {
getFormattingEditsForRange('classes');
});
it("formats modules correctly", function() {
getFormattingEditsForRange('modules');
});
it("formats fat arrow expressions correctelly", function() {
getFormattingEditsForRange('fatArrowFunctions');
});
it("formats empty object/interface literals correctelly", function() {
getFormattingEditsForRange('emptyInterfaceLiteral');
});
it("formats variable declaration lists", function() {
getFormattingEditsForRange('formatVariableDeclarationList');
});
});
});

View file

@ -2,6 +2,9 @@
/// <reference path="..\..\services\textChanges.ts" />
/// <reference path="..\harness.ts" />
// Some tests have trailing whitespace
// tslint:disable trim-trailing-whitespace
namespace ts {
describe("textChanges", () => {
function findChild(name: string, n: Node) {
@ -572,7 +575,7 @@ import {
} from "bar"`;
runSingleFileTest("insertNodeInListAfter10", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => {
changeTracker.insertNodeInListAfter(sourceFile, findChild("x", sourceFile), createImportSpecifier(createIdentifier("b"), createIdentifier("a")));
})
});
}
{
const text = `
@ -581,7 +584,7 @@ import {
} from "bar"`;
runSingleFileTest("insertNodeInListAfter11", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => {
changeTracker.insertNodeInListAfter(sourceFile, findChild("x", sourceFile), createImportSpecifier(createIdentifier("b"), createIdentifier("a")));
})
});
}
{
const text = `
@ -590,7 +593,7 @@ import {
} from "bar"`;
runSingleFileTest("insertNodeInListAfter12", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => {
changeTracker.insertNodeInListAfter(sourceFile, findChild("x", sourceFile), createImportSpecifier(undefined, createIdentifier("a")));
})
});
}
{
const text = `
@ -599,7 +602,7 @@ import {
} from "bar"`;
runSingleFileTest("insertNodeInListAfter13", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => {
changeTracker.insertNodeInListAfter(sourceFile, findChild("x", sourceFile), createImportSpecifier(undefined, createIdentifier("a")));
})
});
}
{
const text = `
@ -609,7 +612,7 @@ import {
} from "bar"`;
runSingleFileTest("insertNodeInListAfter14", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => {
changeTracker.insertNodeInListAfter(sourceFile, findChild("x", sourceFile), createImportSpecifier(createIdentifier("b"), createIdentifier("a")));
})
});
}
{
const text = `
@ -619,7 +622,7 @@ import {
} from "bar"`;
runSingleFileTest("insertNodeInListAfter15", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => {
changeTracker.insertNodeInListAfter(sourceFile, findChild("x", sourceFile), createImportSpecifier(createIdentifier("b"), createIdentifier("a")));
})
});
}
{
const text = `
@ -629,7 +632,7 @@ import {
} from "bar"`;
runSingleFileTest("insertNodeInListAfter16", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => {
changeTracker.insertNodeInListAfter(sourceFile, findChild("x", sourceFile), createImportSpecifier(undefined, createIdentifier("a")));
})
});
}
{
const text = `
@ -639,7 +642,7 @@ import {
} from "bar"`;
runSingleFileTest("insertNodeInListAfter17", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => {
changeTracker.insertNodeInListAfter(sourceFile, findChild("x", sourceFile), createImportSpecifier(undefined, createIdentifier("a")));
})
});
}
{
const text = `
@ -648,7 +651,7 @@ import {
} from "bar"`;
runSingleFileTest("insertNodeInListAfter18", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => {
changeTracker.insertNodeInListAfter(sourceFile, findChild("x", sourceFile), createImportSpecifier(undefined, createIdentifier("a")));
})
});
}
{
const text = `
@ -656,7 +659,7 @@ class A {
x;
}`;
runSingleFileTest("insertNodeAfterMultipleNodes", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => {
let newNodes = [];
const newNodes = [];
for (let i = 0; i < 11 /*error doesn't occur with fewer nodes*/; ++i) {
newNodes.push(
createProperty(undefined, undefined, i + "", undefined, undefined, undefined));
@ -714,7 +717,7 @@ class A {
class A {
x = foo
}
`
`;
runSingleFileTest("insertNodeInClassAfterNodeWithoutSeparator1", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => {
const newNode = createProperty(
/*decorators*/ undefined,
@ -732,7 +735,7 @@ class A {
x() {
}
}
`
`;
runSingleFileTest("insertNodeInClassAfterNodeWithoutSeparator2", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => {
const newNode = createProperty(
/*decorators*/ undefined,
@ -749,7 +752,7 @@ class A {
interface A {
x
}
`
`;
runSingleFileTest("insertNodeInInterfaceAfterNodeWithoutSeparator1", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => {
const newNode = createProperty(
/*decorators*/ undefined,
@ -766,7 +769,7 @@ interface A {
interface A {
x()
}
`
`;
runSingleFileTest("insertNodeInInterfaceAfterNodeWithoutSeparator2", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => {
const newNode = createProperty(
/*decorators*/ undefined,
@ -781,7 +784,7 @@ interface A {
{
const text = `
let x = foo
`
`;
runSingleFileTest("insertNodeInStatementListAfterNodeWithoutSeparator1", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => {
const newNode = createStatement(createParen(createLiteral(1)));
changeTracker.insertNodeAfter(sourceFile, findVariableStatementContaining("x", sourceFile), newNode, { suffix: newLineCharacter });

View file

@ -5,9 +5,7 @@ interface DOMTokenList {
}
interface NodeList {
/**
/**
* Returns an array of key, value pairs for every entry in the list
*/
entries(): IterableIterator<[number, Node]>;
@ -17,23 +15,23 @@ interface NodeList {
* @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value.
*/
forEach(callbackfn: (value: Node, index: number, listObj: NodeList) => void, thisArg?: any): void;
/**
/**
* Returns an list of keys in the list
*/
keys(): IterableIterator<number>;
/**
/**
* Returns an list of values in the list
*/
values(): IterableIterator<Node>;
[Symbol.iterator](): IterableIterator<Node>
[Symbol.iterator](): IterableIterator<Node>;
}
interface NodeListOf<TNode extends Node> {
/**
/**
* Returns an array of key, value pairs for every entry in the list
*/
entries(): IterableIterator<[number, TNode]>;
@ -44,14 +42,14 @@ interface NodeListOf<TNode extends Node> {
* @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value.
*/
forEach(callbackfn: (value: TNode, index: number, listObj: NodeListOf<TNode>) => void, thisArg?: any): void;
/**
/**
* Returns an list of keys in the list
*/
keys(): IterableIterator<number>;
/**
/**
* Returns an list of values in the list
*/
values(): IterableIterator<TNode>;
[Symbol.iterator](): IterableIterator<TNode>
values(): IterableIterator<TNode>;
[Symbol.iterator](): IterableIterator<TNode>;
}

View file

@ -17,7 +17,7 @@ declare var Map: MapConstructor;
interface ReadonlyMap<K, V> {
forEach(callbackfn: (value: V, key: K, map: ReadonlyMap<K, V>) => void, thisArg?: any): void;
get(key: K): V|undefined;
get(key: K): V | undefined;
has(key: K): boolean;
readonly size: number;
}

View file

@ -268,7 +268,7 @@ interface Object {
* Determines whether an object has a property with the specified name.
* @param v A property name.
*/
hasOwnProperty(v: PropertyKey): boolean
hasOwnProperty(v: PropertyKey): boolean;
/**
* Determines whether a specified property is enumerable.
@ -486,10 +486,10 @@ interface String {
bold(): string;
/** Returns a <tt> HTML element */
fixed(): string
fixed(): string;
/** Returns a <font> HTML element and sets the color attribute value */
fontcolor(color: string): string
fontcolor(color: string): string;
/** Returns a <font> HTML element and sets the size attribute value */
fontsize(size: number): string;

View file

@ -91,7 +91,7 @@ interface IArguments {
}
interface Map<K, V> {
[Symbol.iterator](): IterableIterator<[K,V]>;
[Symbol.iterator](): IterableIterator<[K, V]>;
entries(): IterableIterator<[K, V]>;
keys(): IterableIterator<K>;
values(): IterableIterator<V>;

View file

@ -12,11 +12,11 @@ interface ProxyHandler<T> {
enumerate? (target: T): PropertyKey[];
ownKeys? (target: T): PropertyKey[];
apply? (target: T, thisArg: any, argArray?: any): any;
construct? (target: T, argArray: any, newTarget?: any): object
construct? (target: T, argArray: any, newTarget?: any): object;
}
interface ProxyConstructor {
revocable<T>(target: T, handler: ProxyHandler<T>): { proxy: T; revoke: () => void; };
new <T>(target: T, handler: ProxyHandler<T>): T
new <T>(target: T, handler: ProxyHandler<T>): T;
}
declare var Proxy: ProxyConstructor;

View file

@ -7,8 +7,8 @@ interface Symbol {
}
interface SymbolConstructor {
/**
* A reference to the prototype.
/**
* A reference to the prototype.
*/
readonly prototype: Symbol;
@ -16,17 +16,17 @@ interface SymbolConstructor {
* Returns a new unique Symbol value.
* @param description Description of the new Symbol object.
*/
(description?: string|number): symbol;
(description?: string | number): symbol;
/**
* Returns a Symbol object from the global symbol registry matching the given key if found.
* Returns a Symbol object from the global symbol registry matching the given key if found.
* Otherwise, returns a new symbol with this key.
* @param key key to search for.
*/
for(key: string): symbol;
/**
* Returns a key from the global symbol registry matching the given Symbol if found.
* Returns a key from the global symbol registry matching the given Symbol if found.
* Otherwise, returns a undefined.
* @param sym Symbol to find the key for.
*/

View file

@ -1,55 +1,55 @@
/// <reference path="lib.es2015.symbol.d.ts" />
interface SymbolConstructor {
/**
* A method that determines if a constructor object recognizes an object as one of the
* constructors instances. Called by the semantics of the instanceof operator.
/**
* A method that determines if a constructor object recognizes an object as one of the
* constructors instances. Called by the semantics of the instanceof operator.
*/
readonly hasInstance: symbol;
/**
/**
* A Boolean value that if true indicates that an object should flatten to its array elements
* by Array.prototype.concat.
*/
readonly isConcatSpreadable: symbol;
/**
* A regular expression method that matches the regular expression against a string. Called
* by the String.prototype.match method.
* A regular expression method that matches the regular expression against a string. Called
* by the String.prototype.match method.
*/
readonly match: symbol;
/**
* A regular expression method that replaces matched substrings of a string. Called by the
/**
* A regular expression method that replaces matched substrings of a string. Called by the
* String.prototype.replace method.
*/
readonly replace: symbol;
/**
* A regular expression method that returns the index within a string that matches the
* A regular expression method that returns the index within a string that matches the
* regular expression. Called by the String.prototype.search method.
*/
readonly search: symbol;
/**
* A function valued property that is the constructor function that is used to create
/**
* A function valued property that is the constructor function that is used to create
* derived objects.
*/
readonly species: symbol;
/**
* A regular expression method that splits a string at the indices that match the regular
* A regular expression method that splits a string at the indices that match the regular
* expression. Called by the String.prototype.split method.
*/
readonly split: symbol;
/**
/**
* A method that converts an object to a corresponding primitive value.
* Called by the ToPrimitive abstract operation.
*/
readonly toPrimitive: symbol;
/**
/**
* A String value that is used in the creation of the default string description of an object.
* Called by the built-in method Object.prototype.toString.
*/
@ -165,7 +165,7 @@ interface RegExp {
* Replaces text in a string, using this regular expression.
* @param string A String object or string literal whose contents matching against
* this regular expression will be replaced
* @param replaceValue A String object or string literal containing the text to replace for every
* @param replaceValue A String object or string literal containing the text to replace for every
* successful match of this regular expression.
*/
[Symbol.replace](string: string, replaceValue: string): string;
@ -241,10 +241,10 @@ interface String {
}
/**
* Represents a raw buffer of binary data, which is used to store data for the
* different typed arrays. ArrayBuffers cannot be read from or written to directly,
* but can be passed to a typed array or DataView Object to interpret the raw
* buffer as needed.
* Represents a raw buffer of binary data, which is used to store data for the
* different typed arrays. ArrayBuffers cannot be read from or written to directly,
* but can be passed to a typed array or DataView Object to interpret the raw
* buffer as needed.
*/
interface ArrayBuffer {
readonly [Symbol.toStringTag]: "ArrayBuffer";
@ -255,7 +255,7 @@ interface DataView {
}
/**
* A typed array of 8-bit integer values. The contents are initialized to 0. If the requested
* A typed array of 8-bit integer values. The contents are initialized to 0. If the requested
* number of bytes could not be allocated an exception is raised.
*/
interface Int8Array {
@ -263,7 +263,7 @@ interface Int8Array {
}
/**
* A typed array of 8-bit unsigned integer values. The contents are initialized to 0. If the
* A typed array of 8-bit unsigned integer values. The contents are initialized to 0. If the
* requested number of bytes could not be allocated an exception is raised.
*/
interface Uint8Array {
@ -271,7 +271,7 @@ interface Uint8Array {
}
/**
* A typed array of 8-bit unsigned integer (clamped) values. The contents are initialized to 0.
* A typed array of 8-bit unsigned integer (clamped) values. The contents are initialized to 0.
* If the requested number of bytes could not be allocated an exception is raised.
*/
interface Uint8ClampedArray {
@ -279,7 +279,7 @@ interface Uint8ClampedArray {
}
/**
* A typed array of 16-bit signed integer values. The contents are initialized to 0. If the
* A typed array of 16-bit signed integer values. The contents are initialized to 0. If the
* requested number of bytes could not be allocated an exception is raised.
*/
interface Int16Array {
@ -287,7 +287,7 @@ interface Int16Array {
}
/**
* A typed array of 16-bit unsigned integer values. The contents are initialized to 0. If the
* A typed array of 16-bit unsigned integer values. The contents are initialized to 0. If the
* requested number of bytes could not be allocated an exception is raised.
*/
interface Uint16Array {
@ -295,7 +295,7 @@ interface Uint16Array {
}
/**
* A typed array of 32-bit signed integer values. The contents are initialized to 0. If the
* A typed array of 32-bit signed integer values. The contents are initialized to 0. If the
* requested number of bytes could not be allocated an exception is raised.
*/
interface Int32Array {
@ -303,7 +303,7 @@ interface Int32Array {
}
/**
* A typed array of 32-bit unsigned integer values. The contents are initialized to 0. If the
* A typed array of 32-bit unsigned integer values. The contents are initialized to 0. If the
* requested number of bytes could not be allocated an exception is raised.
*/
interface Uint32Array {
@ -319,7 +319,7 @@ interface Float32Array {
}
/**
* A typed array of 64-bit float values. The contents are initialized to 0. If the requested
* A typed array of 64-bit float values. The contents are initialized to 0. If the requested
* number of bytes could not be allocated an exception is raised.
*/
interface Float64Array {

View file

@ -13,8 +13,8 @@ interface SharedArrayBuffer {
length: number;
/**
* Returns a section of an SharedArrayBuffer.
*/
slice(begin:number, end?:number): SharedArrayBuffer;
*/
slice(begin: number, end?: number): SharedArrayBuffer;
readonly [Symbol.species]: SharedArrayBuffer;
readonly [Symbol.toStringTag]: "SharedArrayBuffer";
}

View file

@ -1,27 +1,27 @@
interface String {
/**
* Pads the current string with a given string (possibly repeated) so that the resulting string reaches a given length.
* The padding is applied from the start (left) of the current string.
*
* @param maxLength The length of the resulting string once the current string has been padded.
* If this parameter is smaller than the current string's length, the current string will be returned as it is.
*
* @param fillString The string to pad the current string with.
* If this string is too long, it will be truncated and the left-most part will be applied.
* The default value for this parameter is " " (U+0020).
*/
padStart(maxLength: number, fillString?: string): string;
/**
* Pads the current string with a given string (possibly repeated) so that the resulting string reaches a given length.
* The padding is applied from the end (right) of the current string.
*
* @param maxLength The length of the resulting string once the current string has been padded.
* If this parameter is smaller than the current string's length, the current string will be returned as it is.
*
* @param fillString The string to pad the current string with.
* If this string is too long, it will be truncated and the left-most part will be applied.
* The default value for this parameter is " " (U+0020).
*/
padEnd(maxLength: number, fillString?: string): string;
}
interface String {
/**
* Pads the current string with a given string (possibly repeated) so that the resulting string reaches a given length.
* The padding is applied from the start (left) of the current string.
*
* @param maxLength The length of the resulting string once the current string has been padded.
* If this parameter is smaller than the current string's length, the current string will be returned as it is.
*
* @param fillString The string to pad the current string with.
* If this string is too long, it will be truncated and the left-most part will be applied.
* The default value for this parameter is " " (U+0020).
*/
padStart(maxLength: number, fillString?: string): string;
/**
* Pads the current string with a given string (possibly repeated) so that the resulting string reaches a given length.
* The padding is applied from the end (right) of the current string.
*
* @param maxLength The length of the resulting string once the current string has been padded.
* If this parameter is smaller than the current string's length, the current string will be returned as it is.
*
* @param fillString The string to pad the current string with.
* If this string is too long, it will be truncated and the left-most part will be applied.
* The default value for this parameter is " " (U+0020).
*/
padEnd(maxLength: number, fillString?: string): string;
}

18
src/lib/es5.d.ts vendored
View file

@ -2,6 +2,8 @@
/// ECMAScript APIs
/////////////////////////////
// tslint:disable no-var-keyword
declare const NaN: number;
declare const Infinity: number;
@ -490,7 +492,7 @@ interface NumberConstructor {
declare const Number: NumberConstructor;
interface TemplateStringsArray extends ReadonlyArray<string> {
readonly raw: ReadonlyArray<string>
readonly raw: ReadonlyArray<string>;
}
interface Math {
@ -1354,14 +1356,14 @@ type Readonly<T> = {
*/
type Pick<T, K extends keyof T> = {
[P in K]: T[P];
}
};
/**
* Construct a type with a set of properties K of type T
*/
type Record<K extends string, T> = {
[P in K]: T;
}
};
/**
* Marker for contextual 'this' type
@ -1383,7 +1385,7 @@ interface ArrayBuffer {
/**
* Returns a section of an ArrayBuffer.
*/
slice(begin:number, end?:number): ArrayBuffer;
slice(begin: number, end?: number): ArrayBuffer;
}
interface ArrayBufferConstructor {
@ -4169,7 +4171,7 @@ declare const Float64Array: Float64ArrayConstructor;
/// ECMAScript Internationalization API
/////////////////////////////
declare module Intl {
declare namespace Intl {
interface CollatorOptions {
usage?: string;
localeMatcher?: string;
@ -4197,7 +4199,7 @@ declare module Intl {
new (locales?: string | string[], options?: CollatorOptions): Collator;
(locales?: string | string[], options?: CollatorOptions): Collator;
supportedLocalesOf(locales: string | string[], options?: CollatorOptions): string[];
}
};
interface NumberFormatOptions {
localeMatcher?: string;
@ -4234,7 +4236,7 @@ declare module Intl {
new (locales?: string | string[], options?: NumberFormatOptions): NumberFormat;
(locales?: string | string[], options?: NumberFormatOptions): NumberFormat;
supportedLocalesOf(locales: string | string[], options?: NumberFormatOptions): string[];
}
};
interface DateTimeFormatOptions {
localeMatcher?: string;
@ -4277,7 +4279,7 @@ declare module Intl {
new (locales?: string | string[], options?: DateTimeFormatOptions): DateTimeFormat;
(locales?: string | string[], options?: DateTimeFormatOptions): DateTimeFormat;
supportedLocalesOf(locales: string | string[], options?: DateTimeFormatOptions): string[];
}
};
}
interface String {

View file

@ -29,7 +29,7 @@ interface TextStreamBase {
/**
* Closes a text stream.
* It is not necessary to close standard streams; they close automatically when the process ends. If
* It is not necessary to close standard streams; they close automatically when the process ends. If
* you close a standard stream, be aware that any other pointers to that standard stream become invalid.
*/
Close(): void;

View file

@ -1,6 +1,6 @@
/////////////////////////////
/// WorkerGlobalScope APIs
/// WorkerGlobalScope APIs
/////////////////////////////
// These are only available in a Web Worker
// These are only available in a Web Worker
declare function importScripts(...urls: string[]): void;

View file

@ -1,4 +1,4 @@
/// <reference path="..\compiler\commandLineParser.ts" />
/// <reference path="..\compiler\commandLineParser.ts" />
/// <reference path="..\services\services.ts" />
/// <reference path="session.ts" />

View file

@ -33,7 +33,7 @@ namespace ts.server {
}
export class SessionClient implements LanguageService {
private sequence: number = 0;
private sequence = 0;
private lineMaps: ts.Map<number[]> = ts.createMap<number[]>();
private messages: string[] = [];
private lastRenameEntry: RenameEntry;

View file

@ -135,7 +135,7 @@ namespace ts.server {
try {
this.fd = fs.openSync(this.logFilename, "w");
}
catch(_) {
catch (_) {
// swallow the error and keep logging disabled if file cannot be opened
}
}
@ -315,7 +315,7 @@ namespace ts.server {
}
const body: protocol.TypesInstallerInitializationFailedEventBody = {
message: response.message
}
};
const eventName: protocol.TypesInstallerInitializationFailedEventName = "typesInstallerInitializationFailed";
this.eventSender.event(body, eventName);
return;
@ -473,14 +473,14 @@ namespace ts.server {
const cmdLineVerbosity = getLogLevel(findArgument("--logVerbosity"));
const envLogOptions = parseLoggingEnvironmentString(process.env["TSS_LOG"]);
const logFileName = cmdLineLogFileName
? stripQuotes(cmdLineLogFileName)
const logFileName = cmdLineLogFileName
? stripQuotes(cmdLineLogFileName)
: envLogOptions.logToFile
? envLogOptions.file || (__dirname + "/.log" + process.pid.toString())
: undefined;
const logVerbosity = cmdLineVerbosity || envLogOptions.detailLevel;
return new Logger(logFileName, envLogOptions.traceToConsole, logVerbosity)
return new Logger(logFileName, envLogOptions.traceToConsole, logVerbosity);
}
// This places log file in the directory containing editorServices.js
// TODO: check that this location is writable

View file

@ -24,7 +24,7 @@ namespace ts.server.typingsInstaller {
try {
fs.appendFileSync(this.logFile, text + sys.newLine);
}
catch(e) {
catch (e) {
this.logEnabled = false;
}
}

View file

@ -301,7 +301,6 @@ namespace ts.codefix {
}
function getTextChangeForImportClause(importClause: ImportClause): FileTextChanges[] {
//const newImportText = isDefault ? `default as ${name}` : name;
const importList = <NamedImports>importClause.namedBindings;
const newImportSpecifier = createImportSpecifier(/*propertyName*/ undefined, createIdentifier(name));
// case 1:
@ -556,7 +555,7 @@ namespace ts.codefix {
}
function createChangeTracker() {
return textChanges.ChangeTracker.fromCodeFixContext(context);;
return textChanges.ChangeTracker.fromCodeFixContext(context);
}
function createCodeAction(

View file

@ -36,11 +36,11 @@ namespace ts.FindAllReferences {
}
else if (node.kind === SyntaxKind.ObjectLiteralExpression) {
entry.kind = ScriptElementKind.interfaceElement;
entry.displayParts = [punctuationPart(SyntaxKind.OpenParenToken), textPart("object literal"), punctuationPart(SyntaxKind.CloseParenToken)]
entry.displayParts = [punctuationPart(SyntaxKind.OpenParenToken), textPart("object literal"), punctuationPart(SyntaxKind.CloseParenToken)];
}
else if (node.kind === SyntaxKind.ClassExpression) {
entry.kind = ScriptElementKind.localClassElement;
entry.displayParts = [punctuationPart(SyntaxKind.OpenParenToken), textPart("anonymous local class"), punctuationPart(SyntaxKind.CloseParenToken)]
entry.displayParts = [punctuationPart(SyntaxKind.OpenParenToken), textPart("anonymous local class"), punctuationPart(SyntaxKind.CloseParenToken)];
}
else {
entry.kind = getNodeKind(node);

View file

@ -57,7 +57,7 @@ namespace ts.textChanges {
* ^ - pos for the next variable declaration will point here
* const y; // this is y
* ^ - end for previous variable declaration
* Usually leading trivia of the variable declaration 'y' should not include trailing trivia (whitespace, comment 'this is x' and newline) from the preceding
* Usually leading trivia of the variable declaration 'y' should not include trailing trivia (whitespace, comment 'this is x' and newline) from the preceding
* variable declaration and trailing trivia for 'y' should include (whitespace, comment 'this is y', newline).
* By default when removing nodes we adjust start and end positions to respect specification of the trivia above.
* If pos\end should be interpreted literally 'useNonAdjustedStartPosition' or 'useNonAdjustedEndPosition' should be set to true
@ -265,7 +265,7 @@ namespace ts.textChanges {
options: {},
range: { pos: after.end, end: after.end },
node: createToken(SyntaxKind.SemicolonToken)
})
});
}
}
const endPosition = getAdjustedEndPosition(sourceFile, after, options);
@ -275,7 +275,7 @@ namespace ts.textChanges {
/**
* This function should be used to insert nodes in lists when nodes don't carry separators as the part of the node range,
* i.e. arguments in arguments lists, parameters in parameter lists etc. Statements or class elements are different in sense that
* i.e. arguments in arguments lists, parameters in parameter lists etc. Statements or class elements are different in sense that
* for them separators are treated as the part of the node.
*/
public insertNodeInListAfter(sourceFile: SourceFile, after: Node, newNode: Node) {
@ -307,8 +307,8 @@ namespace ts.textChanges {
// c,
// result - '*' denotes leading trivia that will be inserted after new text (displayed as '#')
// a,*
//***insertedtext<separator>#
//###b,
// ***insertedtext<separator>#
// ###b,
// c,
// find line and character of the next element
const lineAndCharOfNextElement = getLineAndCharacterOfPosition(sourceFile, skipWhitespacesAndLineBreaks(sourceFile.text, containingList[index + 1].getFullStart()));
@ -317,7 +317,7 @@ namespace ts.textChanges {
let prefix: string;
let startPos: number;
if (lineAndCharOfNextToken.line === lineAndCharOfNextElement.line) {
// next element is located on the same line with separator:
// next element is located on the same line with separator:
// a,$$$$b
// ^ ^
// | |-next element
@ -393,7 +393,7 @@ namespace ts.textChanges {
// insert element before the line break on the line that contains 'after' element
let insertPos = skipTrivia(sourceFile.text, end, /*stopAfterLineBreak*/ true, /*stopAtComments*/ false);
if (insertPos !== end && isLineBreak(sourceFile.text.charCodeAt(insertPos - 1))) {
insertPos--
insertPos--;
}
this.changes.push({
sourceFile,

View file

@ -1,4 +1,4 @@
lib.d.ts(32,18): error TS2300: Duplicate identifier 'eval'.
lib.d.ts(34,18): error TS2300: Duplicate identifier 'eval'.
tests/cases/compiler/variableDeclarationInStrictMode1.ts(2,5): error TS1100: Invalid use of 'eval' in strict mode.
tests/cases/compiler/variableDeclarationInStrictMode1.ts(2,5): error TS2300: Duplicate identifier 'eval'.

View file

@ -1,4 +1,5 @@
{
"rulesDirectory": "built/local/tslint",
"rules": {
"no-bom": true,
"class-name": true,
@ -49,5 +50,5 @@
"object-literal-surrounding-space": true,
"no-type-assertion-whitespace": true,
"no-in-operator": true
}
}
}