Merge branch 'master' into moveModuleTransformToEnd

This commit is contained in:
Ron Buckton 2016-10-20 17:07:07 -07:00
commit c40c7f9679
180 changed files with 63624 additions and 60083 deletions

View file

@ -183,5 +183,3 @@ jake baseline-accept
```
to establish the new baselines as the desired behavior. This will change the files in `tests\baselines\reference`, which should be included as part of your commit. It's important to carefully validate changes in the baselines.
**Note** that `baseline-accept` should only be run after a full test run! Accepting baselines after running a subset of tests will delete baseline files for the tests that didn't run.

View file

@ -74,8 +74,8 @@ var compilerSources = [
"transformers/es2017.ts",
"transformers/es2016.ts",
"transformers/es2015.ts",
"transformers/es5.ts",
"transformers/generators.ts",
"transformers/es5.ts",
"transformers/module/es2015.ts",
"transformers/module/system.ts",
"transformers/module/module.ts",
@ -111,6 +111,7 @@ var servicesSources = [
"transformers/es2016.ts",
"transformers/es2015.ts",
"transformers/generators.ts",
"transformers/es5.ts",
"transformers/module/es2015.ts",
"transformers/module/system.ts",
"transformers/module/module.ts",
@ -356,6 +357,7 @@ function concatenateFiles(destinationFile, sourceFiles) {
if (!fs.existsSync(sourceFiles[i])) {
fail(sourceFiles[i] + " does not exist!");
}
fs.appendFileSync(temp, "\n\n");
fs.appendFileSync(temp, fs.readFileSync(sourceFiles[i]));
}
// Move the file to the final destination
@ -446,6 +448,8 @@ function compileFile(outFile, sources, prereqs, prefixes, useBuiltCompiler, opts
options += " --stripInternal";
}
options += " --target es5 --noUnusedLocals --noUnusedParameters";
var cmd = host + " " + compilerPath + " " + options + " ";
cmd = cmd + sources.join(" ");
console.log(cmd + "\n");

13
jenkins.sh Executable file
View file

@ -0,0 +1,13 @@
#!/usr/bin/env bash
# Set up NVM
export NVM_DIR="/home/dotnet-bot/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh"
nvm install $1
npm uninstall typescript
npm uninstall tslint
npm install
npm update
npm test

View file

@ -39,3 +39,5 @@ function createCancellationToken(args) {
};
}
module.exports = createCancellationToken;
//# sourceMappingURL=cancellationToken.js.map

12
lib/lib.d.ts vendored
View file

@ -13,7 +13,11 @@ See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
***************************************************************************** */
/// <reference no-default-lib="true"/>
/////////////////////////////
/// ECMAScript APIs
/////////////////////////////
@ -4149,6 +4153,8 @@ interface Date {
*/
toLocaleTimeString(locales?: string | string[], options?: Intl.DateTimeFormatOptions): string;
}
/////////////////////////////
/// IE DOM APIs
@ -18774,12 +18780,16 @@ type ScrollLogicalPosition = "start" | "center" | "end" | "nearest";
type IDBValidKey = number | string | Date | IDBArrayKey;
type BufferSource = ArrayBuffer | ArrayBufferView;
type MouseWheelEvent = WheelEvent;
type ScrollRestoration = "auto" | "manual";
type ScrollRestoration = "auto" | "manual";
/////////////////////////////
/// WorkerGlobalScope APIs
/////////////////////////////
// These are only available in a Web Worker
declare function importScripts(...urls: string[]): void;
/////////////////////////////

4
lib/lib.dom.d.ts vendored
View file

@ -13,7 +13,11 @@ See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
***************************************************************************** */
/// <reference no-default-lib="true"/>
/////////////////////////////
/// IE DOM APIs

View file

@ -13,7 +13,11 @@ See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
***************************************************************************** */
/// <reference no-default-lib="true"/>
/// <reference path="lib.dom.d.ts" />
interface DOMTokenList {

View file

@ -13,7 +13,11 @@ See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
***************************************************************************** */
/// <reference no-default-lib="true"/>
interface Map<K, V> {
clear(): void;
delete(key: K): boolean;

View file

@ -13,7 +13,11 @@ See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
***************************************************************************** */
/// <reference no-default-lib="true"/>
declare type PropertyKey = string | number | symbol;
interface Array<T> {

4
lib/lib.es2015.d.ts vendored
View file

@ -13,7 +13,11 @@ See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
***************************************************************************** */
/// <reference no-default-lib="true"/>
/// <reference path="lib.es2015.core.d.ts" />
/// <reference path="lib.es2015.collection.d.ts" />
/// <reference path="lib.es2015.generator.d.ts" />

View file

@ -13,7 +13,11 @@ See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
***************************************************************************** */
/// <reference no-default-lib="true"/>
interface GeneratorFunction extends Function { }
interface GeneratorFunctionConstructor {

View file

@ -13,7 +13,11 @@ See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
***************************************************************************** */
/// <reference no-default-lib="true"/>
/// <reference path="lib.es2015.symbol.d.ts" />
interface SymbolConstructor {

View file

@ -13,7 +13,11 @@ See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
***************************************************************************** */
/// <reference no-default-lib="true"/>
/**
* Represents the completion of an asynchronous operation
*/

View file

@ -13,7 +13,11 @@ See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
***************************************************************************** */
/// <reference no-default-lib="true"/>
interface ProxyHandler<T> {
getPrototypeOf? (target: T): any;
setPrototypeOf? (target: T, v: any): boolean;

View file

@ -13,7 +13,11 @@ See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
***************************************************************************** */
/// <reference no-default-lib="true"/>
declare namespace Reflect {
function apply(target: Function, thisArgument: any, argumentsList: ArrayLike<any>): any;
function construct(target: Function, argumentsList: ArrayLike<any>, newTarget?: any): any;

View file

@ -13,7 +13,11 @@ See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
***************************************************************************** */
/// <reference no-default-lib="true"/>
interface Symbol {
/** Returns a string representation of an object. */
toString(): string;

View file

@ -13,7 +13,11 @@ See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
***************************************************************************** */
/// <reference no-default-lib="true"/>
/// <reference path="lib.es2015.symbol.d.ts" />
interface SymbolConstructor {

View file

@ -13,7 +13,11 @@ See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
***************************************************************************** */
/// <reference no-default-lib="true"/>
interface Array<T> {
/**
* Determines whether an array includes a certain element, returning true or false as appropriate.

4
lib/lib.es2016.d.ts vendored
View file

@ -13,6 +13,10 @@ See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
***************************************************************************** */
/// <reference no-default-lib="true"/>
/// <reference path="lib.es2015.d.ts" />
/// <reference path="lib.es2016.array.include.d.ts" />

4
lib/lib.es2017.d.ts vendored
View file

@ -13,7 +13,11 @@ See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
***************************************************************************** */
/// <reference no-default-lib="true"/>
/// <reference path="lib.es2016.d.ts" />
/// <reference path="lib.es2017.object.d.ts" />
/// <reference path="lib.es2017.sharedmemory.d.ts" />

View file

@ -13,7 +13,11 @@ See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
***************************************************************************** */
/// <reference no-default-lib="true"/>
interface ObjectConstructor {
/**
* Returns an array of values of the enumerable properties of an object

View file

@ -13,7 +13,11 @@ See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
***************************************************************************** */
/// <reference no-default-lib="true"/>
/// <reference path="lib.es2015.symbol.d.ts" />
/// <reference path="lib.es2015.symbol.wellknown.d.ts" />

4
lib/lib.es5.d.ts vendored
View file

@ -13,7 +13,11 @@ See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
***************************************************************************** */
/// <reference no-default-lib="true"/>
/////////////////////////////
/// ECMAScript APIs
/////////////////////////////

44
lib/lib.es6.d.ts vendored
View file

@ -13,7 +13,11 @@ See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
***************************************************************************** */
/// <reference no-default-lib="true"/>
/////////////////////////////
/// ECMAScript APIs
/////////////////////////////
@ -4149,6 +4153,8 @@ interface Date {
*/
toLocaleTimeString(locales?: string | string[], options?: Intl.DateTimeFormatOptions): string;
}
declare type PropertyKey = string | number | symbol;
interface Array<T> {
@ -4673,6 +4679,8 @@ interface StringConstructor {
*/
raw(template: TemplateStringsArray, ...substitutions: any[]): string;
}
interface Map<K, V> {
clear(): void;
delete(key: K): boolean;
@ -4745,6 +4753,8 @@ interface WeakSetConstructor {
readonly prototype: WeakSet<any>;
}
declare var WeakSet: WeakSetConstructor;
interface GeneratorFunction extends Function { }
interface GeneratorFunctionConstructor {
@ -4757,6 +4767,8 @@ interface GeneratorFunctionConstructor {
readonly prototype: GeneratorFunction;
}
declare var GeneratorFunction: GeneratorFunctionConstructor;
/// <reference path="lib.es2015.symbol.d.ts" />
interface SymbolConstructor {
@ -5201,7 +5213,9 @@ interface Float64ArrayConstructor {
* @param thisArg Value of 'this' used to invoke the mapfn.
*/
from(arrayLike: Iterable<number>, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array;
}/**
}
/**
* Represents the completion of an asynchronous operation
*/
interface Promise<T> {
@ -5454,7 +5468,9 @@ interface PromiseConstructor {
resolve(): Promise<void>;
}
declare var Promise: PromiseConstructor;interface ProxyHandler<T> {
declare var Promise: PromiseConstructor;
interface ProxyHandler<T> {
getPrototypeOf? (target: T): any;
setPrototypeOf? (target: T, v: any): boolean;
isExtensible? (target: T): boolean;
@ -5475,7 +5491,9 @@ interface ProxyConstructor {
revocable<T>(target: T, handler: ProxyHandler<T>): { proxy: T; revoke: () => void; };
new <T>(target: T, handler: ProxyHandler<T>): T
}
declare var Proxy: ProxyConstructor;declare namespace Reflect {
declare var Proxy: ProxyConstructor;
declare namespace Reflect {
function apply(target: Function, thisArgument: any, argumentsList: ArrayLike<any>): any;
function construct(target: Function, argumentsList: ArrayLike<any>, newTarget?: any): any;
function defineProperty(target: any, propertyKey: PropertyKey, attributes: PropertyDescriptor): boolean;
@ -5489,7 +5507,9 @@ declare var Proxy: ProxyConstructor;declare namespace Reflect {
function preventExtensions(target: any): boolean;
function set(target: any, propertyKey: PropertyKey, value: any, receiver?: any): boolean;
function setPrototypeOf(target: any, proto: any): boolean;
}interface Symbol {
}
interface Symbol {
/** Returns a string representation of an object. */
toString(): string;
@ -5524,7 +5544,9 @@ interface SymbolConstructor {
keyFor(sym: symbol): string | undefined;
}
declare var Symbol: SymbolConstructor;/// <reference path="lib.es2015.symbol.d.ts" />
declare var Symbol: SymbolConstructor;
/// <reference path="lib.es2015.symbol.d.ts" />
interface SymbolConstructor {
/**
@ -5850,7 +5872,9 @@ interface Float32Array {
*/
interface Float64Array {
readonly [Symbol.toStringTag]: "Float64Array";
}
}
/////////////////////////////
/// IE DOM APIs
/////////////////////////////
@ -20475,12 +20499,16 @@ type ScrollLogicalPosition = "start" | "center" | "end" | "nearest";
type IDBValidKey = number | string | Date | IDBArrayKey;
type BufferSource = ArrayBuffer | ArrayBufferView;
type MouseWheelEvent = WheelEvent;
type ScrollRestoration = "auto" | "manual";
type ScrollRestoration = "auto" | "manual";
/////////////////////////////
/// WorkerGlobalScope APIs
/////////////////////////////
// These are only available in a Web Worker
declare function importScripts(...urls: string[]): void;
/////////////////////////////
@ -20772,6 +20800,8 @@ interface DateConstructor {
interface Date {
getVarDate: () => VarDate;
}
/// <reference path="lib.dom.d.ts" />
interface DOMTokenList {

View file

@ -13,7 +13,11 @@ See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
***************************************************************************** */
/// <reference no-default-lib="true"/>
/////////////////////////////

View file

@ -13,7 +13,11 @@ See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
***************************************************************************** */
/// <reference no-default-lib="true"/>
/////////////////////////////
/// IE Worker APIs

17056
lib/tsc.js

File diff suppressed because it is too large Load diff

File diff suppressed because one or more lines are too long

9338
lib/tsserverlibrary.d.ts vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

528
lib/typescript.d.ts vendored
View file

@ -47,241 +47,241 @@ declare namespace ts {
ConflictMarkerTrivia = 7,
NumericLiteral = 8,
StringLiteral = 9,
RegularExpressionLiteral = 10,
NoSubstitutionTemplateLiteral = 11,
TemplateHead = 12,
TemplateMiddle = 13,
TemplateTail = 14,
OpenBraceToken = 15,
CloseBraceToken = 16,
OpenParenToken = 17,
CloseParenToken = 18,
OpenBracketToken = 19,
CloseBracketToken = 20,
DotToken = 21,
DotDotDotToken = 22,
SemicolonToken = 23,
CommaToken = 24,
LessThanToken = 25,
LessThanSlashToken = 26,
GreaterThanToken = 27,
LessThanEqualsToken = 28,
GreaterThanEqualsToken = 29,
EqualsEqualsToken = 30,
ExclamationEqualsToken = 31,
EqualsEqualsEqualsToken = 32,
ExclamationEqualsEqualsToken = 33,
EqualsGreaterThanToken = 34,
PlusToken = 35,
MinusToken = 36,
AsteriskToken = 37,
AsteriskAsteriskToken = 38,
SlashToken = 39,
PercentToken = 40,
PlusPlusToken = 41,
MinusMinusToken = 42,
LessThanLessThanToken = 43,
GreaterThanGreaterThanToken = 44,
GreaterThanGreaterThanGreaterThanToken = 45,
AmpersandToken = 46,
BarToken = 47,
CaretToken = 48,
ExclamationToken = 49,
TildeToken = 50,
AmpersandAmpersandToken = 51,
BarBarToken = 52,
QuestionToken = 53,
ColonToken = 54,
AtToken = 55,
EqualsToken = 56,
PlusEqualsToken = 57,
MinusEqualsToken = 58,
AsteriskEqualsToken = 59,
AsteriskAsteriskEqualsToken = 60,
SlashEqualsToken = 61,
PercentEqualsToken = 62,
LessThanLessThanEqualsToken = 63,
GreaterThanGreaterThanEqualsToken = 64,
GreaterThanGreaterThanGreaterThanEqualsToken = 65,
AmpersandEqualsToken = 66,
BarEqualsToken = 67,
CaretEqualsToken = 68,
Identifier = 69,
BreakKeyword = 70,
CaseKeyword = 71,
CatchKeyword = 72,
ClassKeyword = 73,
ConstKeyword = 74,
ContinueKeyword = 75,
DebuggerKeyword = 76,
DefaultKeyword = 77,
DeleteKeyword = 78,
DoKeyword = 79,
ElseKeyword = 80,
EnumKeyword = 81,
ExportKeyword = 82,
ExtendsKeyword = 83,
FalseKeyword = 84,
FinallyKeyword = 85,
ForKeyword = 86,
FunctionKeyword = 87,
IfKeyword = 88,
ImportKeyword = 89,
InKeyword = 90,
InstanceOfKeyword = 91,
NewKeyword = 92,
NullKeyword = 93,
ReturnKeyword = 94,
SuperKeyword = 95,
SwitchKeyword = 96,
ThisKeyword = 97,
ThrowKeyword = 98,
TrueKeyword = 99,
TryKeyword = 100,
TypeOfKeyword = 101,
VarKeyword = 102,
VoidKeyword = 103,
WhileKeyword = 104,
WithKeyword = 105,
ImplementsKeyword = 106,
InterfaceKeyword = 107,
LetKeyword = 108,
PackageKeyword = 109,
PrivateKeyword = 110,
ProtectedKeyword = 111,
PublicKeyword = 112,
StaticKeyword = 113,
YieldKeyword = 114,
AbstractKeyword = 115,
AsKeyword = 116,
AnyKeyword = 117,
AsyncKeyword = 118,
AwaitKeyword = 119,
BooleanKeyword = 120,
ConstructorKeyword = 121,
DeclareKeyword = 122,
GetKeyword = 123,
IsKeyword = 124,
ModuleKeyword = 125,
NamespaceKeyword = 126,
NeverKeyword = 127,
ReadonlyKeyword = 128,
RequireKeyword = 129,
NumberKeyword = 130,
SetKeyword = 131,
StringKeyword = 132,
SymbolKeyword = 133,
TypeKeyword = 134,
UndefinedKeyword = 135,
FromKeyword = 136,
GlobalKeyword = 137,
OfKeyword = 138,
QualifiedName = 139,
ComputedPropertyName = 140,
TypeParameter = 141,
Parameter = 142,
Decorator = 143,
PropertySignature = 144,
PropertyDeclaration = 145,
MethodSignature = 146,
MethodDeclaration = 147,
Constructor = 148,
GetAccessor = 149,
SetAccessor = 150,
CallSignature = 151,
ConstructSignature = 152,
IndexSignature = 153,
TypePredicate = 154,
TypeReference = 155,
FunctionType = 156,
ConstructorType = 157,
TypeQuery = 158,
TypeLiteral = 159,
ArrayType = 160,
TupleType = 161,
UnionType = 162,
IntersectionType = 163,
ParenthesizedType = 164,
ThisType = 165,
LiteralType = 166,
ObjectBindingPattern = 167,
ArrayBindingPattern = 168,
BindingElement = 169,
ArrayLiteralExpression = 170,
ObjectLiteralExpression = 171,
PropertyAccessExpression = 172,
ElementAccessExpression = 173,
CallExpression = 174,
NewExpression = 175,
TaggedTemplateExpression = 176,
TypeAssertionExpression = 177,
ParenthesizedExpression = 178,
FunctionExpression = 179,
ArrowFunction = 180,
DeleteExpression = 181,
TypeOfExpression = 182,
VoidExpression = 183,
AwaitExpression = 184,
PrefixUnaryExpression = 185,
PostfixUnaryExpression = 186,
BinaryExpression = 187,
ConditionalExpression = 188,
TemplateExpression = 189,
YieldExpression = 190,
SpreadElementExpression = 191,
ClassExpression = 192,
OmittedExpression = 193,
ExpressionWithTypeArguments = 194,
AsExpression = 195,
NonNullExpression = 196,
TemplateSpan = 197,
SemicolonClassElement = 198,
Block = 199,
VariableStatement = 200,
EmptyStatement = 201,
ExpressionStatement = 202,
IfStatement = 203,
DoStatement = 204,
WhileStatement = 205,
ForStatement = 206,
ForInStatement = 207,
ForOfStatement = 208,
ContinueStatement = 209,
BreakStatement = 210,
ReturnStatement = 211,
WithStatement = 212,
SwitchStatement = 213,
LabeledStatement = 214,
ThrowStatement = 215,
TryStatement = 216,
DebuggerStatement = 217,
VariableDeclaration = 218,
VariableDeclarationList = 219,
FunctionDeclaration = 220,
ClassDeclaration = 221,
InterfaceDeclaration = 222,
TypeAliasDeclaration = 223,
EnumDeclaration = 224,
ModuleDeclaration = 225,
ModuleBlock = 226,
CaseBlock = 227,
NamespaceExportDeclaration = 228,
ImportEqualsDeclaration = 229,
ImportDeclaration = 230,
ImportClause = 231,
NamespaceImport = 232,
NamedImports = 233,
ImportSpecifier = 234,
ExportAssignment = 235,
ExportDeclaration = 236,
NamedExports = 237,
ExportSpecifier = 238,
MissingDeclaration = 239,
ExternalModuleReference = 240,
JsxElement = 241,
JsxSelfClosingElement = 242,
JsxOpeningElement = 243,
JsxText = 244,
JsxText = 10,
RegularExpressionLiteral = 11,
NoSubstitutionTemplateLiteral = 12,
TemplateHead = 13,
TemplateMiddle = 14,
TemplateTail = 15,
OpenBraceToken = 16,
CloseBraceToken = 17,
OpenParenToken = 18,
CloseParenToken = 19,
OpenBracketToken = 20,
CloseBracketToken = 21,
DotToken = 22,
DotDotDotToken = 23,
SemicolonToken = 24,
CommaToken = 25,
LessThanToken = 26,
LessThanSlashToken = 27,
GreaterThanToken = 28,
LessThanEqualsToken = 29,
GreaterThanEqualsToken = 30,
EqualsEqualsToken = 31,
ExclamationEqualsToken = 32,
EqualsEqualsEqualsToken = 33,
ExclamationEqualsEqualsToken = 34,
EqualsGreaterThanToken = 35,
PlusToken = 36,
MinusToken = 37,
AsteriskToken = 38,
AsteriskAsteriskToken = 39,
SlashToken = 40,
PercentToken = 41,
PlusPlusToken = 42,
MinusMinusToken = 43,
LessThanLessThanToken = 44,
GreaterThanGreaterThanToken = 45,
GreaterThanGreaterThanGreaterThanToken = 46,
AmpersandToken = 47,
BarToken = 48,
CaretToken = 49,
ExclamationToken = 50,
TildeToken = 51,
AmpersandAmpersandToken = 52,
BarBarToken = 53,
QuestionToken = 54,
ColonToken = 55,
AtToken = 56,
EqualsToken = 57,
PlusEqualsToken = 58,
MinusEqualsToken = 59,
AsteriskEqualsToken = 60,
AsteriskAsteriskEqualsToken = 61,
SlashEqualsToken = 62,
PercentEqualsToken = 63,
LessThanLessThanEqualsToken = 64,
GreaterThanGreaterThanEqualsToken = 65,
GreaterThanGreaterThanGreaterThanEqualsToken = 66,
AmpersandEqualsToken = 67,
BarEqualsToken = 68,
CaretEqualsToken = 69,
Identifier = 70,
BreakKeyword = 71,
CaseKeyword = 72,
CatchKeyword = 73,
ClassKeyword = 74,
ConstKeyword = 75,
ContinueKeyword = 76,
DebuggerKeyword = 77,
DefaultKeyword = 78,
DeleteKeyword = 79,
DoKeyword = 80,
ElseKeyword = 81,
EnumKeyword = 82,
ExportKeyword = 83,
ExtendsKeyword = 84,
FalseKeyword = 85,
FinallyKeyword = 86,
ForKeyword = 87,
FunctionKeyword = 88,
IfKeyword = 89,
ImportKeyword = 90,
InKeyword = 91,
InstanceOfKeyword = 92,
NewKeyword = 93,
NullKeyword = 94,
ReturnKeyword = 95,
SuperKeyword = 96,
SwitchKeyword = 97,
ThisKeyword = 98,
ThrowKeyword = 99,
TrueKeyword = 100,
TryKeyword = 101,
TypeOfKeyword = 102,
VarKeyword = 103,
VoidKeyword = 104,
WhileKeyword = 105,
WithKeyword = 106,
ImplementsKeyword = 107,
InterfaceKeyword = 108,
LetKeyword = 109,
PackageKeyword = 110,
PrivateKeyword = 111,
ProtectedKeyword = 112,
PublicKeyword = 113,
StaticKeyword = 114,
YieldKeyword = 115,
AbstractKeyword = 116,
AsKeyword = 117,
AnyKeyword = 118,
AsyncKeyword = 119,
AwaitKeyword = 120,
BooleanKeyword = 121,
ConstructorKeyword = 122,
DeclareKeyword = 123,
GetKeyword = 124,
IsKeyword = 125,
ModuleKeyword = 126,
NamespaceKeyword = 127,
NeverKeyword = 128,
ReadonlyKeyword = 129,
RequireKeyword = 130,
NumberKeyword = 131,
SetKeyword = 132,
StringKeyword = 133,
SymbolKeyword = 134,
TypeKeyword = 135,
UndefinedKeyword = 136,
FromKeyword = 137,
GlobalKeyword = 138,
OfKeyword = 139,
QualifiedName = 140,
ComputedPropertyName = 141,
TypeParameter = 142,
Parameter = 143,
Decorator = 144,
PropertySignature = 145,
PropertyDeclaration = 146,
MethodSignature = 147,
MethodDeclaration = 148,
Constructor = 149,
GetAccessor = 150,
SetAccessor = 151,
CallSignature = 152,
ConstructSignature = 153,
IndexSignature = 154,
TypePredicate = 155,
TypeReference = 156,
FunctionType = 157,
ConstructorType = 158,
TypeQuery = 159,
TypeLiteral = 160,
ArrayType = 161,
TupleType = 162,
UnionType = 163,
IntersectionType = 164,
ParenthesizedType = 165,
ThisType = 166,
LiteralType = 167,
ObjectBindingPattern = 168,
ArrayBindingPattern = 169,
BindingElement = 170,
ArrayLiteralExpression = 171,
ObjectLiteralExpression = 172,
PropertyAccessExpression = 173,
ElementAccessExpression = 174,
CallExpression = 175,
NewExpression = 176,
TaggedTemplateExpression = 177,
TypeAssertionExpression = 178,
ParenthesizedExpression = 179,
FunctionExpression = 180,
ArrowFunction = 181,
DeleteExpression = 182,
TypeOfExpression = 183,
VoidExpression = 184,
AwaitExpression = 185,
PrefixUnaryExpression = 186,
PostfixUnaryExpression = 187,
BinaryExpression = 188,
ConditionalExpression = 189,
TemplateExpression = 190,
YieldExpression = 191,
SpreadElementExpression = 192,
ClassExpression = 193,
OmittedExpression = 194,
ExpressionWithTypeArguments = 195,
AsExpression = 196,
NonNullExpression = 197,
TemplateSpan = 198,
SemicolonClassElement = 199,
Block = 200,
VariableStatement = 201,
EmptyStatement = 202,
ExpressionStatement = 203,
IfStatement = 204,
DoStatement = 205,
WhileStatement = 206,
ForStatement = 207,
ForInStatement = 208,
ForOfStatement = 209,
ContinueStatement = 210,
BreakStatement = 211,
ReturnStatement = 212,
WithStatement = 213,
SwitchStatement = 214,
LabeledStatement = 215,
ThrowStatement = 216,
TryStatement = 217,
DebuggerStatement = 218,
VariableDeclaration = 219,
VariableDeclarationList = 220,
FunctionDeclaration = 221,
ClassDeclaration = 222,
InterfaceDeclaration = 223,
TypeAliasDeclaration = 224,
EnumDeclaration = 225,
ModuleDeclaration = 226,
ModuleBlock = 227,
CaseBlock = 228,
NamespaceExportDeclaration = 229,
ImportEqualsDeclaration = 230,
ImportDeclaration = 231,
ImportClause = 232,
NamespaceImport = 233,
NamedImports = 234,
ImportSpecifier = 235,
ExportAssignment = 236,
ExportDeclaration = 237,
NamedExports = 238,
ExportSpecifier = 239,
MissingDeclaration = 240,
ExternalModuleReference = 241,
JsxElement = 242,
JsxSelfClosingElement = 243,
JsxOpeningElement = 244,
JsxClosingElement = 245,
JsxAttribute = 246,
JsxSpreadAttribute = 247,
@ -327,31 +327,31 @@ declare namespace ts {
NotEmittedStatement = 287,
PartiallyEmittedExpression = 288,
Count = 289,
FirstAssignment = 56,
LastAssignment = 68,
FirstCompoundAssignment = 57,
LastCompoundAssignment = 68,
FirstReservedWord = 70,
LastReservedWord = 105,
FirstKeyword = 70,
LastKeyword = 138,
FirstFutureReservedWord = 106,
LastFutureReservedWord = 114,
FirstTypeNode = 154,
LastTypeNode = 166,
FirstPunctuation = 15,
LastPunctuation = 68,
FirstAssignment = 57,
LastAssignment = 69,
FirstCompoundAssignment = 58,
LastCompoundAssignment = 69,
FirstReservedWord = 71,
LastReservedWord = 106,
FirstKeyword = 71,
LastKeyword = 139,
FirstFutureReservedWord = 107,
LastFutureReservedWord = 115,
FirstTypeNode = 155,
LastTypeNode = 167,
FirstPunctuation = 16,
LastPunctuation = 69,
FirstToken = 0,
LastToken = 138,
LastToken = 139,
FirstTriviaToken = 2,
LastTriviaToken = 7,
FirstLiteralToken = 8,
LastLiteralToken = 11,
FirstTemplateToken = 11,
LastTemplateToken = 14,
FirstBinaryOperator = 25,
LastBinaryOperator = 68,
FirstNode = 139,
LastLiteralToken = 12,
FirstTemplateToken = 12,
LastTemplateToken = 15,
FirstBinaryOperator = 26,
LastBinaryOperator = 69,
FirstNode = 140,
FirstJSDocNode = 257,
LastJSDocNode = 282,
FirstJSDocTagNode = 273,
@ -406,6 +406,7 @@ declare namespace ts {
AccessibilityModifier = 28,
ParameterPropertyModifier = 92,
NonPublicAccessibilityModifier = 24,
TypeScriptModifier = 2270,
}
enum JsxFlags {
None = 0,
@ -1351,8 +1352,9 @@ declare namespace ts {
TrueCondition = 32,
FalseCondition = 64,
SwitchClause = 128,
Referenced = 256,
Shared = 512,
ArrayMutation = 256,
Referenced = 512,
Shared = 1024,
Label = 12,
Condition = 96,
}
@ -1380,6 +1382,10 @@ declare namespace ts {
clauseEnd: number;
antecedent: FlowNode;
}
interface FlowArrayMutation extends FlowNode {
node: CallExpression | BinaryExpression;
antecedent: FlowNode;
}
type FlowType = Type | IncompleteType;
interface IncompleteType {
flags: TypeFlags;
@ -1913,7 +1919,6 @@ declare namespace ts {
AMD = 2,
UMD = 3,
System = 4,
ES6 = 5,
ES2015 = 5,
}
enum JsxEmit {
@ -1939,9 +1944,10 @@ declare namespace ts {
enum ScriptTarget {
ES3 = 0,
ES5 = 1,
ES6 = 2,
ES2015 = 2,
Latest = 2,
ES2016 = 3,
ES2017 = 4,
Latest = 4,
}
enum LanguageVariant {
Standard = 0,

File diff suppressed because it is too large Load diff

View file

@ -47,241 +47,241 @@ declare namespace ts {
ConflictMarkerTrivia = 7,
NumericLiteral = 8,
StringLiteral = 9,
RegularExpressionLiteral = 10,
NoSubstitutionTemplateLiteral = 11,
TemplateHead = 12,
TemplateMiddle = 13,
TemplateTail = 14,
OpenBraceToken = 15,
CloseBraceToken = 16,
OpenParenToken = 17,
CloseParenToken = 18,
OpenBracketToken = 19,
CloseBracketToken = 20,
DotToken = 21,
DotDotDotToken = 22,
SemicolonToken = 23,
CommaToken = 24,
LessThanToken = 25,
LessThanSlashToken = 26,
GreaterThanToken = 27,
LessThanEqualsToken = 28,
GreaterThanEqualsToken = 29,
EqualsEqualsToken = 30,
ExclamationEqualsToken = 31,
EqualsEqualsEqualsToken = 32,
ExclamationEqualsEqualsToken = 33,
EqualsGreaterThanToken = 34,
PlusToken = 35,
MinusToken = 36,
AsteriskToken = 37,
AsteriskAsteriskToken = 38,
SlashToken = 39,
PercentToken = 40,
PlusPlusToken = 41,
MinusMinusToken = 42,
LessThanLessThanToken = 43,
GreaterThanGreaterThanToken = 44,
GreaterThanGreaterThanGreaterThanToken = 45,
AmpersandToken = 46,
BarToken = 47,
CaretToken = 48,
ExclamationToken = 49,
TildeToken = 50,
AmpersandAmpersandToken = 51,
BarBarToken = 52,
QuestionToken = 53,
ColonToken = 54,
AtToken = 55,
EqualsToken = 56,
PlusEqualsToken = 57,
MinusEqualsToken = 58,
AsteriskEqualsToken = 59,
AsteriskAsteriskEqualsToken = 60,
SlashEqualsToken = 61,
PercentEqualsToken = 62,
LessThanLessThanEqualsToken = 63,
GreaterThanGreaterThanEqualsToken = 64,
GreaterThanGreaterThanGreaterThanEqualsToken = 65,
AmpersandEqualsToken = 66,
BarEqualsToken = 67,
CaretEqualsToken = 68,
Identifier = 69,
BreakKeyword = 70,
CaseKeyword = 71,
CatchKeyword = 72,
ClassKeyword = 73,
ConstKeyword = 74,
ContinueKeyword = 75,
DebuggerKeyword = 76,
DefaultKeyword = 77,
DeleteKeyword = 78,
DoKeyword = 79,
ElseKeyword = 80,
EnumKeyword = 81,
ExportKeyword = 82,
ExtendsKeyword = 83,
FalseKeyword = 84,
FinallyKeyword = 85,
ForKeyword = 86,
FunctionKeyword = 87,
IfKeyword = 88,
ImportKeyword = 89,
InKeyword = 90,
InstanceOfKeyword = 91,
NewKeyword = 92,
NullKeyword = 93,
ReturnKeyword = 94,
SuperKeyword = 95,
SwitchKeyword = 96,
ThisKeyword = 97,
ThrowKeyword = 98,
TrueKeyword = 99,
TryKeyword = 100,
TypeOfKeyword = 101,
VarKeyword = 102,
VoidKeyword = 103,
WhileKeyword = 104,
WithKeyword = 105,
ImplementsKeyword = 106,
InterfaceKeyword = 107,
LetKeyword = 108,
PackageKeyword = 109,
PrivateKeyword = 110,
ProtectedKeyword = 111,
PublicKeyword = 112,
StaticKeyword = 113,
YieldKeyword = 114,
AbstractKeyword = 115,
AsKeyword = 116,
AnyKeyword = 117,
AsyncKeyword = 118,
AwaitKeyword = 119,
BooleanKeyword = 120,
ConstructorKeyword = 121,
DeclareKeyword = 122,
GetKeyword = 123,
IsKeyword = 124,
ModuleKeyword = 125,
NamespaceKeyword = 126,
NeverKeyword = 127,
ReadonlyKeyword = 128,
RequireKeyword = 129,
NumberKeyword = 130,
SetKeyword = 131,
StringKeyword = 132,
SymbolKeyword = 133,
TypeKeyword = 134,
UndefinedKeyword = 135,
FromKeyword = 136,
GlobalKeyword = 137,
OfKeyword = 138,
QualifiedName = 139,
ComputedPropertyName = 140,
TypeParameter = 141,
Parameter = 142,
Decorator = 143,
PropertySignature = 144,
PropertyDeclaration = 145,
MethodSignature = 146,
MethodDeclaration = 147,
Constructor = 148,
GetAccessor = 149,
SetAccessor = 150,
CallSignature = 151,
ConstructSignature = 152,
IndexSignature = 153,
TypePredicate = 154,
TypeReference = 155,
FunctionType = 156,
ConstructorType = 157,
TypeQuery = 158,
TypeLiteral = 159,
ArrayType = 160,
TupleType = 161,
UnionType = 162,
IntersectionType = 163,
ParenthesizedType = 164,
ThisType = 165,
LiteralType = 166,
ObjectBindingPattern = 167,
ArrayBindingPattern = 168,
BindingElement = 169,
ArrayLiteralExpression = 170,
ObjectLiteralExpression = 171,
PropertyAccessExpression = 172,
ElementAccessExpression = 173,
CallExpression = 174,
NewExpression = 175,
TaggedTemplateExpression = 176,
TypeAssertionExpression = 177,
ParenthesizedExpression = 178,
FunctionExpression = 179,
ArrowFunction = 180,
DeleteExpression = 181,
TypeOfExpression = 182,
VoidExpression = 183,
AwaitExpression = 184,
PrefixUnaryExpression = 185,
PostfixUnaryExpression = 186,
BinaryExpression = 187,
ConditionalExpression = 188,
TemplateExpression = 189,
YieldExpression = 190,
SpreadElementExpression = 191,
ClassExpression = 192,
OmittedExpression = 193,
ExpressionWithTypeArguments = 194,
AsExpression = 195,
NonNullExpression = 196,
TemplateSpan = 197,
SemicolonClassElement = 198,
Block = 199,
VariableStatement = 200,
EmptyStatement = 201,
ExpressionStatement = 202,
IfStatement = 203,
DoStatement = 204,
WhileStatement = 205,
ForStatement = 206,
ForInStatement = 207,
ForOfStatement = 208,
ContinueStatement = 209,
BreakStatement = 210,
ReturnStatement = 211,
WithStatement = 212,
SwitchStatement = 213,
LabeledStatement = 214,
ThrowStatement = 215,
TryStatement = 216,
DebuggerStatement = 217,
VariableDeclaration = 218,
VariableDeclarationList = 219,
FunctionDeclaration = 220,
ClassDeclaration = 221,
InterfaceDeclaration = 222,
TypeAliasDeclaration = 223,
EnumDeclaration = 224,
ModuleDeclaration = 225,
ModuleBlock = 226,
CaseBlock = 227,
NamespaceExportDeclaration = 228,
ImportEqualsDeclaration = 229,
ImportDeclaration = 230,
ImportClause = 231,
NamespaceImport = 232,
NamedImports = 233,
ImportSpecifier = 234,
ExportAssignment = 235,
ExportDeclaration = 236,
NamedExports = 237,
ExportSpecifier = 238,
MissingDeclaration = 239,
ExternalModuleReference = 240,
JsxElement = 241,
JsxSelfClosingElement = 242,
JsxOpeningElement = 243,
JsxText = 244,
JsxText = 10,
RegularExpressionLiteral = 11,
NoSubstitutionTemplateLiteral = 12,
TemplateHead = 13,
TemplateMiddle = 14,
TemplateTail = 15,
OpenBraceToken = 16,
CloseBraceToken = 17,
OpenParenToken = 18,
CloseParenToken = 19,
OpenBracketToken = 20,
CloseBracketToken = 21,
DotToken = 22,
DotDotDotToken = 23,
SemicolonToken = 24,
CommaToken = 25,
LessThanToken = 26,
LessThanSlashToken = 27,
GreaterThanToken = 28,
LessThanEqualsToken = 29,
GreaterThanEqualsToken = 30,
EqualsEqualsToken = 31,
ExclamationEqualsToken = 32,
EqualsEqualsEqualsToken = 33,
ExclamationEqualsEqualsToken = 34,
EqualsGreaterThanToken = 35,
PlusToken = 36,
MinusToken = 37,
AsteriskToken = 38,
AsteriskAsteriskToken = 39,
SlashToken = 40,
PercentToken = 41,
PlusPlusToken = 42,
MinusMinusToken = 43,
LessThanLessThanToken = 44,
GreaterThanGreaterThanToken = 45,
GreaterThanGreaterThanGreaterThanToken = 46,
AmpersandToken = 47,
BarToken = 48,
CaretToken = 49,
ExclamationToken = 50,
TildeToken = 51,
AmpersandAmpersandToken = 52,
BarBarToken = 53,
QuestionToken = 54,
ColonToken = 55,
AtToken = 56,
EqualsToken = 57,
PlusEqualsToken = 58,
MinusEqualsToken = 59,
AsteriskEqualsToken = 60,
AsteriskAsteriskEqualsToken = 61,
SlashEqualsToken = 62,
PercentEqualsToken = 63,
LessThanLessThanEqualsToken = 64,
GreaterThanGreaterThanEqualsToken = 65,
GreaterThanGreaterThanGreaterThanEqualsToken = 66,
AmpersandEqualsToken = 67,
BarEqualsToken = 68,
CaretEqualsToken = 69,
Identifier = 70,
BreakKeyword = 71,
CaseKeyword = 72,
CatchKeyword = 73,
ClassKeyword = 74,
ConstKeyword = 75,
ContinueKeyword = 76,
DebuggerKeyword = 77,
DefaultKeyword = 78,
DeleteKeyword = 79,
DoKeyword = 80,
ElseKeyword = 81,
EnumKeyword = 82,
ExportKeyword = 83,
ExtendsKeyword = 84,
FalseKeyword = 85,
FinallyKeyword = 86,
ForKeyword = 87,
FunctionKeyword = 88,
IfKeyword = 89,
ImportKeyword = 90,
InKeyword = 91,
InstanceOfKeyword = 92,
NewKeyword = 93,
NullKeyword = 94,
ReturnKeyword = 95,
SuperKeyword = 96,
SwitchKeyword = 97,
ThisKeyword = 98,
ThrowKeyword = 99,
TrueKeyword = 100,
TryKeyword = 101,
TypeOfKeyword = 102,
VarKeyword = 103,
VoidKeyword = 104,
WhileKeyword = 105,
WithKeyword = 106,
ImplementsKeyword = 107,
InterfaceKeyword = 108,
LetKeyword = 109,
PackageKeyword = 110,
PrivateKeyword = 111,
ProtectedKeyword = 112,
PublicKeyword = 113,
StaticKeyword = 114,
YieldKeyword = 115,
AbstractKeyword = 116,
AsKeyword = 117,
AnyKeyword = 118,
AsyncKeyword = 119,
AwaitKeyword = 120,
BooleanKeyword = 121,
ConstructorKeyword = 122,
DeclareKeyword = 123,
GetKeyword = 124,
IsKeyword = 125,
ModuleKeyword = 126,
NamespaceKeyword = 127,
NeverKeyword = 128,
ReadonlyKeyword = 129,
RequireKeyword = 130,
NumberKeyword = 131,
SetKeyword = 132,
StringKeyword = 133,
SymbolKeyword = 134,
TypeKeyword = 135,
UndefinedKeyword = 136,
FromKeyword = 137,
GlobalKeyword = 138,
OfKeyword = 139,
QualifiedName = 140,
ComputedPropertyName = 141,
TypeParameter = 142,
Parameter = 143,
Decorator = 144,
PropertySignature = 145,
PropertyDeclaration = 146,
MethodSignature = 147,
MethodDeclaration = 148,
Constructor = 149,
GetAccessor = 150,
SetAccessor = 151,
CallSignature = 152,
ConstructSignature = 153,
IndexSignature = 154,
TypePredicate = 155,
TypeReference = 156,
FunctionType = 157,
ConstructorType = 158,
TypeQuery = 159,
TypeLiteral = 160,
ArrayType = 161,
TupleType = 162,
UnionType = 163,
IntersectionType = 164,
ParenthesizedType = 165,
ThisType = 166,
LiteralType = 167,
ObjectBindingPattern = 168,
ArrayBindingPattern = 169,
BindingElement = 170,
ArrayLiteralExpression = 171,
ObjectLiteralExpression = 172,
PropertyAccessExpression = 173,
ElementAccessExpression = 174,
CallExpression = 175,
NewExpression = 176,
TaggedTemplateExpression = 177,
TypeAssertionExpression = 178,
ParenthesizedExpression = 179,
FunctionExpression = 180,
ArrowFunction = 181,
DeleteExpression = 182,
TypeOfExpression = 183,
VoidExpression = 184,
AwaitExpression = 185,
PrefixUnaryExpression = 186,
PostfixUnaryExpression = 187,
BinaryExpression = 188,
ConditionalExpression = 189,
TemplateExpression = 190,
YieldExpression = 191,
SpreadElementExpression = 192,
ClassExpression = 193,
OmittedExpression = 194,
ExpressionWithTypeArguments = 195,
AsExpression = 196,
NonNullExpression = 197,
TemplateSpan = 198,
SemicolonClassElement = 199,
Block = 200,
VariableStatement = 201,
EmptyStatement = 202,
ExpressionStatement = 203,
IfStatement = 204,
DoStatement = 205,
WhileStatement = 206,
ForStatement = 207,
ForInStatement = 208,
ForOfStatement = 209,
ContinueStatement = 210,
BreakStatement = 211,
ReturnStatement = 212,
WithStatement = 213,
SwitchStatement = 214,
LabeledStatement = 215,
ThrowStatement = 216,
TryStatement = 217,
DebuggerStatement = 218,
VariableDeclaration = 219,
VariableDeclarationList = 220,
FunctionDeclaration = 221,
ClassDeclaration = 222,
InterfaceDeclaration = 223,
TypeAliasDeclaration = 224,
EnumDeclaration = 225,
ModuleDeclaration = 226,
ModuleBlock = 227,
CaseBlock = 228,
NamespaceExportDeclaration = 229,
ImportEqualsDeclaration = 230,
ImportDeclaration = 231,
ImportClause = 232,
NamespaceImport = 233,
NamedImports = 234,
ImportSpecifier = 235,
ExportAssignment = 236,
ExportDeclaration = 237,
NamedExports = 238,
ExportSpecifier = 239,
MissingDeclaration = 240,
ExternalModuleReference = 241,
JsxElement = 242,
JsxSelfClosingElement = 243,
JsxOpeningElement = 244,
JsxClosingElement = 245,
JsxAttribute = 246,
JsxSpreadAttribute = 247,
@ -327,31 +327,31 @@ declare namespace ts {
NotEmittedStatement = 287,
PartiallyEmittedExpression = 288,
Count = 289,
FirstAssignment = 56,
LastAssignment = 68,
FirstCompoundAssignment = 57,
LastCompoundAssignment = 68,
FirstReservedWord = 70,
LastReservedWord = 105,
FirstKeyword = 70,
LastKeyword = 138,
FirstFutureReservedWord = 106,
LastFutureReservedWord = 114,
FirstTypeNode = 154,
LastTypeNode = 166,
FirstPunctuation = 15,
LastPunctuation = 68,
FirstAssignment = 57,
LastAssignment = 69,
FirstCompoundAssignment = 58,
LastCompoundAssignment = 69,
FirstReservedWord = 71,
LastReservedWord = 106,
FirstKeyword = 71,
LastKeyword = 139,
FirstFutureReservedWord = 107,
LastFutureReservedWord = 115,
FirstTypeNode = 155,
LastTypeNode = 167,
FirstPunctuation = 16,
LastPunctuation = 69,
FirstToken = 0,
LastToken = 138,
LastToken = 139,
FirstTriviaToken = 2,
LastTriviaToken = 7,
FirstLiteralToken = 8,
LastLiteralToken = 11,
FirstTemplateToken = 11,
LastTemplateToken = 14,
FirstBinaryOperator = 25,
LastBinaryOperator = 68,
FirstNode = 139,
LastLiteralToken = 12,
FirstTemplateToken = 12,
LastTemplateToken = 15,
FirstBinaryOperator = 26,
LastBinaryOperator = 69,
FirstNode = 140,
FirstJSDocNode = 257,
LastJSDocNode = 282,
FirstJSDocTagNode = 273,
@ -406,6 +406,7 @@ declare namespace ts {
AccessibilityModifier = 28,
ParameterPropertyModifier = 92,
NonPublicAccessibilityModifier = 24,
TypeScriptModifier = 2270,
}
enum JsxFlags {
None = 0,
@ -1351,8 +1352,9 @@ declare namespace ts {
TrueCondition = 32,
FalseCondition = 64,
SwitchClause = 128,
Referenced = 256,
Shared = 512,
ArrayMutation = 256,
Referenced = 512,
Shared = 1024,
Label = 12,
Condition = 96,
}
@ -1380,6 +1382,10 @@ declare namespace ts {
clauseEnd: number;
antecedent: FlowNode;
}
interface FlowArrayMutation extends FlowNode {
node: CallExpression | BinaryExpression;
antecedent: FlowNode;
}
type FlowType = Type | IncompleteType;
interface IncompleteType {
flags: TypeFlags;
@ -1913,7 +1919,6 @@ declare namespace ts {
AMD = 2,
UMD = 3,
System = 4,
ES6 = 5,
ES2015 = 5,
}
enum JsxEmit {
@ -1939,9 +1944,10 @@ declare namespace ts {
enum ScriptTarget {
ES3 = 0,
ES5 = 1,
ES6 = 2,
ES2015 = 2,
Latest = 2,
ES2016 = 3,
ES2017 = 4,
Latest = 4,
}
enum LanguageVariant {
Standard = 0,

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

22
netci.groovy Normal file
View file

@ -0,0 +1,22 @@
// Import the utility functionality.
import jobs.generation.Utilities;
// Defines a the new of the repo, used elsewhere in the file
def project = GithubProject
def branch = GithubBranchName
def nodeVersions = ['stable', '4']
nodeVersions.each { nodeVer ->
def newJobName = "typescript_node.${nodeVer}"
def newJob = job(Utilities.getFullJobName(project, newJobName, true)) {
steps {
shell("./jenkins.sh ${nodeVer}")
}
}
Utilities.standardJobSetup(newJob, project, true, "*/${branch}")
Utilities.setMachineAffinity(newJob, 'Ubuntu', '20161020')
Utilities.addGithubPRTriggerForBranch(newJob, branch, "TypeScript Test Run ${newJobName}")
}

View file

@ -10,6 +10,8 @@ function endsWith(s: string, suffix: string) {
class DeclarationsWalker {
private visitedTypes: ts.Type[] = [];
private text = "";
private removedTypes: ts.Type[] = [];
private constructor(private typeChecker: ts.TypeChecker, private protocolFile: ts.SourceFile) {
}
@ -17,9 +19,18 @@ class DeclarationsWalker {
let text = "declare namespace ts.server.protocol {\n";
var walker = new DeclarationsWalker(typeChecker, protocolFile);
walker.visitTypeNodes(protocolFile);
return walker.text
text = walker.text
? `declare namespace ts.server.protocol {\n${walker.text}}`
: "";
if (walker.removedTypes) {
text += "\ndeclare namespace ts {\n";
text += " // these types are empty stubs for types from services and should not be used directly\n"
for (const type of walker.removedTypes) {
text += ` export type ${type.symbol.name} = never;\n`;
}
text += "}"
}
return text;
}
private processType(type: ts.Type): void {
@ -41,19 +52,18 @@ class DeclarationsWalker {
if (sourceFile === this.protocolFile || path.basename(sourceFile.fileName) === "lib.d.ts") {
return;
}
// splice declaration in final d.ts file
let text = decl.getFullText();
if (decl.kind === ts.SyntaxKind.EnumDeclaration && !(decl.flags & ts.NodeFlags.Const)) {
// patch enum declaration to make them constan
const declStart = decl.getStart() - decl.getFullStart();
const prefix = text.substring(0, declStart);
const suffix = text.substring(declStart + "enum".length, decl.getEnd() - decl.getFullStart());
text = prefix + "const enum" + suffix;
if (decl.kind === ts.SyntaxKind.EnumDeclaration) {
this.removedTypes.push(type);
return;
}
this.text += `${text}\n`;
else {
// splice declaration in final d.ts file
let text = decl.getFullText();
this.text += `${text}\n`;
// recursively pull all dependencies into result dts file
// recursively pull all dependencies into result dts file
this.visitTypeNodes(decl);
this.visitTypeNodes(decl);
}
}
}
}
@ -69,15 +79,37 @@ class DeclarationsWalker {
case ts.SyntaxKind.Parameter:
case ts.SyntaxKind.IndexSignature:
if (((<ts.VariableDeclaration | ts.MethodDeclaration | ts.PropertyDeclaration | ts.ParameterDeclaration | ts.PropertySignature | ts.MethodSignature | ts.IndexSignatureDeclaration>node.parent).type) === node) {
const type = this.typeChecker.getTypeAtLocation(node);
if (type && !(type.flags & ts.TypeFlags.TypeParameter)) {
this.processType(type);
}
this.processTypeOfNode(node);
}
break;
case ts.SyntaxKind.InterfaceDeclaration:
const heritageClauses = (<ts.InterfaceDeclaration>node.parent).heritageClauses;
if (heritageClauses) {
if (heritageClauses[0].token !== ts.SyntaxKind.ExtendsKeyword) {
throw new Error(`Unexpected kind of heritage clause: ${ts.SyntaxKind[heritageClauses[0].kind]}`);
}
for (const type of heritageClauses[0].types) {
this.processTypeOfNode(type);
}
}
break;
}
}
ts.forEachChild(node, n => this.visitTypeNodes(n));
}
private processTypeOfNode(node: ts.Node): void {
if (node.kind === ts.SyntaxKind.UnionType) {
for (const t of (<ts.UnionTypeNode>node).types) {
this.processTypeOfNode(t);
}
}
else {
const type = this.typeChecker.getTypeAtLocation(node);
if (type && !(type.flags & (ts.TypeFlags.TypeParameter))) {
this.processType(type);
}
}
}
}
@ -128,9 +160,12 @@ function generateProtocolFile(protocolTs: string, typeScriptServicesDts: string)
if (extraDeclarations) {
protocolDts += extraDeclarations;
}
protocolDts += "\nimport protocol = ts.server.protocol;";
protocolDts += "\nexport = protocol;";
protocolDts += "\nexport as namespace protocol;";
// do sanity check and try to compile generated text as standalone program
const sanityCheckProgram = getProgramWithProtocolText(protocolDts, /*includeTypeScriptServices*/ false);
const diagnostics = [...program.getSyntacticDiagnostics(), ...program.getSemanticDiagnostics(), ...program.getGlobalDiagnostics()];
const diagnostics = [...sanityCheckProgram.getSyntacticDiagnostics(), ...sanityCheckProgram.getSemanticDiagnostics(), ...sanityCheckProgram.getGlobalDiagnostics()];
if (diagnostics.length) {
const flattenedDiagnostics = diagnostics.map(d => ts.flattenDiagnosticMessageText(d.messageText, "\n")).join("\n");
throw new Error(`Unexpected errors during sanity check: ${flattenedDiagnostics}`);

View file

@ -984,24 +984,44 @@ namespace ts {
}
function bindTryStatement(node: TryStatement): void {
const postFinallyLabel = createBranchLabel();
const preFinallyLabel = createBranchLabel();
const preTryFlow = currentFlow;
// TODO: Every statement in try block is potentially an exit point!
bind(node.tryBlock);
addAntecedent(postFinallyLabel, currentFlow);
addAntecedent(preFinallyLabel, currentFlow);
const flowAfterTry = currentFlow;
let flowAfterCatch = unreachableFlow;
if (node.catchClause) {
currentFlow = preTryFlow;
bind(node.catchClause);
addAntecedent(postFinallyLabel, currentFlow);
addAntecedent(preFinallyLabel, currentFlow);
flowAfterCatch = currentFlow;
}
if (node.finallyBlock) {
currentFlow = preTryFlow;
// in finally flow is combined from pre-try/flow from try/flow from catch
// pre-flow is necessary to make sure that finally is reachable even if finally flows in both try and finally blocks are unreachable
addAntecedent(preFinallyLabel, preTryFlow);
currentFlow = finishFlowLabel(preFinallyLabel);
bind(node.finallyBlock);
// if flow after finally is unreachable - keep it
// otherwise check if flows after try and after catch are unreachable
// if yes - convert current flow to unreachable
// i.e.
// try { return "1" } finally { console.log(1); }
// console.log(2); // this line should be unreachable even if flow falls out of finally block
if (!(currentFlow.flags & FlowFlags.Unreachable)) {
if ((flowAfterTry.flags & FlowFlags.Unreachable) && (flowAfterCatch.flags & FlowFlags.Unreachable)) {
currentFlow = flowAfterTry === reportedUnreachableFlow || flowAfterCatch === reportedUnreachableFlow
? reportedUnreachableFlow
: unreachableFlow;
}
}
}
// if try statement has finally block and flow after finally block is unreachable - keep it
// otherwise use whatever flow was accumulated at postFinallyLabel
if (!node.finallyBlock || !(currentFlow.flags & FlowFlags.Unreachable)) {
currentFlow = finishFlowLabel(postFinallyLabel);
else {
currentFlow = finishFlowLabel(preFinallyLabel);
}
}
@ -2052,7 +2072,9 @@ namespace ts {
function setCommonJsModuleIndicator(node: Node) {
if (!file.commonJsModuleIndicator) {
file.commonJsModuleIndicator = node;
bindSourceFileAsExternalModule();
if (!file.externalModuleIndicator) {
bindSourceFileAsExternalModule();
}
}
}

View file

@ -368,7 +368,7 @@ namespace ts {
return emitResolver;
}
function error(location: Node, message: DiagnosticMessage, arg0?: any, arg1?: any, arg2?: any): void {
function error(location: Node, message: DiagnosticMessage, arg0?: string | number, arg1?: string | number, arg2?: string | number): void {
const diagnostic = location
? createDiagnosticForNode(location, message, arg0, arg1, arg2)
: createCompilerDiagnostic(message, arg0, arg1, arg2);
@ -591,7 +591,11 @@ namespace ts {
// nodes are in different files and order cannot be determines
return true;
}
// declaration is after usage
// can be legal if usage is deferred (i.e. inside function or in initializer of instance property)
if (isUsedInFunctionOrNonStaticProperty(usage)) {
return true;
}
const sourceFiles = host.getSourceFiles();
return indexOf(sourceFiles, declarationFile) <= indexOf(sourceFiles, useFile);
}
@ -605,7 +609,8 @@ namespace ts {
// declaration is after usage
// can be legal if usage is deferred (i.e. inside function or in initializer of instance property)
return isUsedInFunctionOrNonStaticProperty(declaration, usage);
const container = getEnclosingBlockScopeContainer(declaration);
return isUsedInFunctionOrNonStaticProperty(usage, container);
function isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration: VariableDeclaration, usage: Node): boolean {
const container = getEnclosingBlockScopeContainer(declaration);
@ -634,8 +639,7 @@ namespace ts {
return false;
}
function isUsedInFunctionOrNonStaticProperty(declaration: Declaration, usage: Node): boolean {
const container = getEnclosingBlockScopeContainer(declaration);
function isUsedInFunctionOrNonStaticProperty(usage: Node, container?: Node): boolean {
let current = usage;
while (current) {
if (current === container) {
@ -1054,7 +1058,7 @@ namespace ts {
if (node.moduleReference.kind === SyntaxKind.ExternalModuleReference) {
return resolveExternalModuleSymbol(resolveExternalModuleName(node, getExternalModuleImportEqualsDeclarationExpression(node)));
}
return getSymbolOfPartOfRightHandSideOfImportEquals(<EntityName>node.moduleReference, node);
return getSymbolOfPartOfRightHandSideOfImportEquals(<EntityName>node.moduleReference);
}
function getTargetOfImportClause(node: ImportClause): Symbol {
@ -1267,7 +1271,7 @@ namespace ts {
}
// This function is only for imports with entity names
function getSymbolOfPartOfRightHandSideOfImportEquals(entityName: EntityName, importDeclaration: ImportEqualsDeclaration, dontResolveAlias?: boolean): Symbol {
function getSymbolOfPartOfRightHandSideOfImportEquals(entityName: EntityName, dontResolveAlias?: boolean): Symbol {
// There are three things we might try to look for. In the following examples,
// the search term is enclosed in |...|:
//
@ -2583,7 +2587,7 @@ namespace ts {
}
}
function buildDisplayForTypeArgumentsAndDelimiters(typeParameters: TypeParameter[], mapper: TypeMapper, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags, symbolStack?: Symbol[]) {
function buildDisplayForTypeArgumentsAndDelimiters(typeParameters: TypeParameter[], mapper: TypeMapper, writer: SymbolWriter, enclosingDeclaration?: Node) {
if (typeParameters && typeParameters.length) {
writePunctuation(writer, SyntaxKind.LessThanToken);
let flags = TypeFormatFlags.InFirstTypeArgument;
@ -3144,8 +3148,7 @@ namespace ts {
// Use contextual parameter type if one is available
let type: Type;
if (declaration.symbol.name === "this") {
const thisParameter = getContextualThisParameter(func);
type = thisParameter ? getTypeOfSymbol(thisParameter) : undefined;
type = getContextualThisParameterType(func);
}
else {
type = getContextuallyTypedParameterType(<ParameterDeclaration>declaration);
@ -4789,9 +4792,6 @@ namespace ts {
if (isJSConstructSignature) {
minArgumentCount--;
}
if (!thisParameter && isObjectLiteralMethod(declaration)) {
thisParameter = getContextualThisParameter(declaration);
}
const classType = declaration.kind === SyntaxKind.Constructor ?
getDeclaredTypeOfClassOrInterface(getMergedSymbol((<ClassDeclaration>declaration.parent).symbol))
@ -4799,7 +4799,7 @@ namespace ts {
const typeParameters = classType ? classType.localTypeParameters :
declaration.typeParameters ? getTypeParametersFromDeclaration(declaration.typeParameters) :
getTypeParametersFromJSDocTemplate(declaration);
const returnType = getSignatureReturnTypeFromDeclaration(declaration, minArgumentCount, isJSConstructSignature, classType);
const returnType = getSignatureReturnTypeFromDeclaration(declaration, isJSConstructSignature, classType);
const typePredicate = declaration.type && declaration.type.kind === SyntaxKind.TypePredicate ?
createTypePredicateFromTypePredicateNode(declaration.type as TypePredicateNode) :
undefined;
@ -4809,7 +4809,7 @@ namespace ts {
return links.resolvedSignature;
}
function getSignatureReturnTypeFromDeclaration(declaration: SignatureDeclaration, minArgumentCount: number, isJSConstructSignature: boolean, classType: Type) {
function getSignatureReturnTypeFromDeclaration(declaration: SignatureDeclaration, isJSConstructSignature: boolean, classType: Type) {
if (isJSConstructSignature) {
return getTypeFromTypeNode(declaration.parameters[0].type);
}
@ -5174,10 +5174,7 @@ namespace ts {
return undefined;
}
function resolveTypeReferenceName(
node: TypeReferenceNode | ExpressionWithTypeArguments | JSDocTypeReference,
typeReferenceName: EntityNameExpression | EntityName) {
function resolveTypeReferenceName(typeReferenceName: EntityNameExpression | EntityName) {
if (!typeReferenceName) {
return unknownSymbol;
}
@ -5215,7 +5212,7 @@ namespace ts {
let type: Type;
if (node.kind === SyntaxKind.JSDocTypeReference) {
const typeReferenceName = getTypeReferenceName(node);
symbol = resolveTypeReferenceName(node, typeReferenceName);
symbol = resolveTypeReferenceName(typeReferenceName);
type = getTypeReferenceType(node, symbol);
}
else {
@ -5607,6 +5604,11 @@ namespace ts {
}
}
// We normalize combinations of intersection and union types based on the distributive property of the '&'
// operator. Specifically, because X & (A | B) is equivalent to X & A | X & B, we can transform intersection
// types with union type constituents into equivalent union types with intersection type constituents and
// effectively ensure that union types are always at the top level in type representations.
//
// We do not perform structural deduplication on intersection types. Intersection types are created only by the &
// type operator and we can't reduce those because we want to support recursive intersection types. For example,
// a type alias of the form "type List<T> = T & { next: List<T> }" cannot be reduced during its declaration.
@ -5616,6 +5618,15 @@ namespace ts {
if (types.length === 0) {
return emptyObjectType;
}
for (let i = 0; i < types.length; i++) {
const type = types[i];
if (type.flags & TypeFlags.Union) {
// We are attempting to construct a type of the form X & (A | B) & Y. Transform this into a type of
// the form X & A & Y | X & B & Y and recursively reduce until no union type constituents remain.
return getUnionType(map((<UnionType>type).types, t => getIntersectionType(replaceElement(types, i, t))),
/*subtypeReduction*/ false, aliasSymbol, aliasTypeArguments);
}
}
const typeSet = [] as TypeSet;
addTypesToIntersection(typeSet, types);
if (typeSet.containsAny) {
@ -6101,9 +6112,24 @@ namespace ts {
}
function isContextSensitiveFunctionLikeDeclaration(node: FunctionLikeDeclaration) {
const areAllParametersUntyped = !forEach(node.parameters, p => p.type);
const isNullaryArrow = node.kind === SyntaxKind.ArrowFunction && !node.parameters.length;
return !node.typeParameters && areAllParametersUntyped && !isNullaryArrow;
// Functions with type parameters are not context sensitive.
if (node.typeParameters) {
return false;
}
// Functions with any parameters that lack type annotations are context sensitive.
if (forEach(node.parameters, p => !p.type)) {
return true;
}
// For arrow functions we now know we're not context sensitive.
if (node.kind === SyntaxKind.ArrowFunction) {
return false;
}
// If the first parameter is not an explicit 'this' parameter, then the function has
// an implicit 'this' parameter which is subject to contextual typing. Otherwise we
// know that all parameters (including 'this') have type annotations and nothing is
// subject to contextual typing.
const parameter = firstOrUndefined(node.parameters);
return !(parameter && parameterIsThisKeyword(parameter));
}
function isContextSensitiveFunctionOrObjectLiteralMethod(func: Node): func is FunctionExpression | ArrowFunction | MethodDeclaration {
@ -6548,7 +6574,9 @@ namespace ts {
const saveErrorInfo = errorInfo;
// Note that these checks are specifically ordered to produce correct results.
// Note that these checks are specifically ordered to produce correct results. In particular,
// we need to deconstruct unions before intersections (because unions are always at the top),
// and we need to handle "each" relations before "some" relations for the same kind of type.
if (source.flags & TypeFlags.Union) {
if (relation === comparableRelation) {
result = someTypeRelatedToType(source as UnionType, target, reportErrors && !(source.flags & TypeFlags.Primitive));
@ -6556,44 +6584,36 @@ namespace ts {
else {
result = eachTypeRelatedToType(source as UnionType, target, reportErrors && !(source.flags & TypeFlags.Primitive));
}
if (result) {
return result;
}
}
else if (target.flags & TypeFlags.Union) {
if (result = typeRelatedToSomeType(source, <UnionType>target, reportErrors && !(source.flags & TypeFlags.Primitive) && !(target.flags & TypeFlags.Primitive))) {
return result;
}
}
else if (target.flags & TypeFlags.Intersection) {
result = typeRelatedToEachType(source, target as IntersectionType, reportErrors);
if (result) {
if (result = typeRelatedToEachType(source, target as IntersectionType, reportErrors)) {
return result;
}
}
else {
// It is necessary to try these "some" checks on both sides because there may be nested "each" checks
// on either side that need to be prioritized. For example, A | B = (A | B) & (C | D) or
// A & B = (A & B) | (C & D).
if (source.flags & TypeFlags.Intersection) {
// Check to see if any constituents of the intersection are immediately related to the target.
//
// Don't report errors though. Checking whether a constituent is related to the source is not actually
// useful and leads to some confusing error messages. Instead it is better to let the below checks
// take care of this, or to not elaborate at all. For instance,
//
// - For an object type (such as 'C = A & B'), users are usually more interested in structural errors.
//
// - For a union type (such as '(A | B) = (C & D)'), it's better to hold onto the whole intersection
// than to report that 'D' is not assignable to 'A' or 'B'.
//
// - For a primitive type or type parameter (such as 'number = A & B') there is no point in
// breaking the intersection apart.
if (result = someTypeRelatedToType(<IntersectionType>source, target, /*reportErrors*/ false)) {
return result;
}
}
if (target.flags & TypeFlags.Union) {
if (result = typeRelatedToSomeType(source, <UnionType>target, reportErrors && !(source.flags & TypeFlags.Primitive) && !(target.flags & TypeFlags.Primitive))) {
return result;
}
else if (source.flags & TypeFlags.Intersection) {
// Check to see if any constituents of the intersection are immediately related to the target.
//
// Don't report errors though. Checking whether a constituent is related to the source is not actually
// useful and leads to some confusing error messages. Instead it is better to let the below checks
// take care of this, or to not elaborate at all. For instance,
//
// - For an object type (such as 'C = A & B'), users are usually more interested in structural errors.
//
// - For a union type (such as '(A | B) = (C & D)'), it's better to hold onto the whole intersection
// than to report that 'D' is not assignable to 'A' or 'B'.
//
// - For a primitive type or type parameter (such as 'number = A & B') there is no point in
// breaking the intersection apart.
if (result = someTypeRelatedToType(<IntersectionType>source, target, /*reportErrors*/ false)) {
return result;
}
}
@ -6662,8 +6682,8 @@ namespace ts {
}
if (source.flags & TypeFlags.Union && target.flags & TypeFlags.Union ||
source.flags & TypeFlags.Intersection && target.flags & TypeFlags.Intersection) {
if (result = eachTypeRelatedToSomeType(<UnionOrIntersectionType>source, <UnionOrIntersectionType>target, /*reportErrors*/ false)) {
if (result &= eachTypeRelatedToSomeType(<UnionOrIntersectionType>target, <UnionOrIntersectionType>source, /*reportErrors*/ false)) {
if (result = eachTypeRelatedToSomeType(<UnionOrIntersectionType>source, <UnionOrIntersectionType>target)) {
if (result &= eachTypeRelatedToSomeType(<UnionOrIntersectionType>target, <UnionOrIntersectionType>source)) {
return result;
}
}
@ -6724,7 +6744,7 @@ namespace ts {
return false;
}
function eachTypeRelatedToSomeType(source: UnionOrIntersectionType, target: UnionOrIntersectionType, reportErrors: boolean): Ternary {
function eachTypeRelatedToSomeType(source: UnionOrIntersectionType, target: UnionOrIntersectionType): Ternary {
let result = Ternary.True;
const sourceTypes = source.types;
for (const sourceType of sourceTypes) {
@ -8526,7 +8546,7 @@ namespace ts {
// An evolving array type tracks the element types that have so far been seen in an
// 'x.push(value)' or 'x[n] = value' operation along the control flow graph. Evolving
// array types are ultimately converted into manifest array types (using getFinalArrayType)
// and never escape the getFlowTypeOfReference function.
// and never escape the getFlowTypeOfReference function.
function createEvolvingArrayType(elementType: Type): AnonymousType {
const result = <AnonymousType>createObjectType(TypeFlags.Anonymous);
result.elementType = elementType;
@ -9629,7 +9649,7 @@ namespace ts {
}
}
const thisType = getThisTypeOfDeclaration(container);
const thisType = getThisTypeOfDeclaration(container) || getContextualThisParameterType(container);
if (thisType) {
return thisType;
}
@ -9869,14 +9889,16 @@ namespace ts {
}
}
function getContextualThisParameter(func: FunctionLikeDeclaration): Symbol {
function getContextualThisParameterType(func: FunctionLikeDeclaration): Type {
if (isContextSensitiveFunctionOrObjectLiteralMethod(func) && func.kind !== SyntaxKind.ArrowFunction) {
const contextualSignature = getContextualSignature(func);
if (contextualSignature) {
return contextualSignature.thisParameter;
const thisParameter = contextualSignature.thisParameter;
if (thisParameter) {
return getTypeOfSymbol(thisParameter);
}
}
}
return undefined;
}
@ -11057,14 +11079,20 @@ namespace ts {
function checkJsxOpeningLikeElement(node: JsxOpeningLikeElement) {
checkGrammarJsxElement(node);
checkJsxPreconditions(node);
// The reactNamespace symbol should be marked as 'used' so we don't incorrectly elide its import. And if there
// is no reactNamespace symbol in scope when targeting React emit, we should issue an error.
const reactRefErr = compilerOptions.jsx === JsxEmit.React ? Diagnostics.Cannot_find_name_0 : undefined;
const reactNamespace = compilerOptions.reactNamespace ? compilerOptions.reactNamespace : "React";
const reactSym = resolveName(node.tagName, reactNamespace, SymbolFlags.Value, reactRefErr, reactNamespace);
if (reactSym) {
getSymbolLinks(reactSym).referenced = true;
// Mark local symbol as referenced here because it might not have been marked
// if jsx emit was not react as there wont be error being emitted
reactSym.isReferenced = true;
// If react symbol is alias, mark it as refereced
if (reactSym.flags & SymbolFlags.Alias && !isConstEnumOrConstEnumOnlyModule(resolveAlias(reactSym))) {
markAliasSymbolAsReferenced(reactSym);
}
}
const targetAttributesType = getJsxElementAttributesType(node);
@ -11759,7 +11787,7 @@ namespace ts {
// If the effective argument is 'undefined', then it is an argument that is present but is synthetic.
if (arg === undefined || arg.kind !== SyntaxKind.OmittedExpression) {
const paramType = getTypeAtPosition(signature, i);
let argType = getEffectiveArgumentType(node, i, arg);
let argType = getEffectiveArgumentType(node, i);
// If the effective argument type is 'undefined', there is no synthetic type
// for the argument. In that case, we should check the argument.
@ -11845,7 +11873,7 @@ namespace ts {
if (arg === undefined || arg.kind !== SyntaxKind.OmittedExpression) {
// Check spread elements against rest type (from arity check we know spread argument corresponds to a rest parameter)
const paramType = getTypeAtPosition(signature, i);
let argType = getEffectiveArgumentType(node, i, arg);
let argType = getEffectiveArgumentType(node, i);
// If the effective argument type is 'undefined', there is no synthetic type
// for the argument. In that case, we should check the argument.
@ -12138,7 +12166,7 @@ namespace ts {
/**
* Gets the effective argument type for an argument in a call expression.
*/
function getEffectiveArgumentType(node: CallLikeExpression, argIndex: number, arg: Expression): Type {
function getEffectiveArgumentType(node: CallLikeExpression, argIndex: number): Type {
// Decorators provide special arguments, a tagged template expression provides
// a special first argument, and string literals get string literal types
// unless we're reporting errors
@ -12791,7 +12819,10 @@ namespace ts {
}
// In JavaScript files, calls to any identifier 'require' are treated as external module imports
if (isInJavaScriptFile(node) && isRequireCall(node, /*checkArgumentIsStringLiteral*/true)) {
if (isInJavaScriptFile(node) &&
isRequireCall(node, /*checkArgumentIsStringLiteral*/true) &&
// Make sure require is not a local function
!resolveName(node.expression, (<Identifier>node.expression).text, SymbolFlags.Value, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined)) {
return resolveExternalModuleTypeByLiteral(<StringLiteral>node.arguments[0]);
}
@ -12840,21 +12871,36 @@ namespace ts {
function assignContextualParameterTypes(signature: Signature, context: Signature, mapper: TypeMapper) {
const len = signature.parameters.length - (signature.hasRestParameter ? 1 : 0);
if (context.thisParameter) {
if (!signature.thisParameter) {
signature.thisParameter = createTransientSymbol(context.thisParameter, undefined);
if (isInferentialContext(mapper)) {
for (let i = 0; i < len; i++) {
const declaration = <ParameterDeclaration>signature.parameters[i].valueDeclaration;
if (declaration.type) {
inferTypes(mapper.context, getTypeFromTypeNode(declaration.type), getTypeAtPosition(context, i));
}
}
}
if (context.thisParameter) {
const parameter = signature.thisParameter;
if (!parameter || parameter.valueDeclaration && !(<ParameterDeclaration>parameter.valueDeclaration).type) {
if (!parameter) {
signature.thisParameter = createTransientSymbol(context.thisParameter, undefined);
}
assignTypeToParameterAndFixTypeParameters(signature.thisParameter, getTypeOfSymbol(context.thisParameter), mapper);
}
assignTypeToParameterAndFixTypeParameters(signature.thisParameter, getTypeOfSymbol(context.thisParameter), mapper);
}
for (let i = 0; i < len; i++) {
const parameter = signature.parameters[i];
const contextualParameterType = getTypeAtPosition(context, i);
assignTypeToParameterAndFixTypeParameters(parameter, contextualParameterType, mapper);
if (!(<ParameterDeclaration>parameter.valueDeclaration).type) {
const contextualParameterType = getTypeAtPosition(context, i);
assignTypeToParameterAndFixTypeParameters(parameter, contextualParameterType, mapper);
}
}
if (signature.hasRestParameter && isRestParameterIndex(context, signature.parameters.length - 1)) {
const parameter = lastOrUndefined(signature.parameters);
const contextualParameterType = getTypeOfSymbol(lastOrUndefined(context.parameters));
assignTypeToParameterAndFixTypeParameters(parameter, contextualParameterType, mapper);
if (!(<ParameterDeclaration>parameter.valueDeclaration).type) {
const contextualParameterType = getTypeOfSymbol(lastOrUndefined(context.parameters));
assignTypeToParameterAndFixTypeParameters(parameter, contextualParameterType, mapper);
}
}
}
@ -13525,15 +13571,15 @@ namespace ts {
return booleanType;
}
function checkObjectLiteralAssignment(node: ObjectLiteralExpression, sourceType: Type, contextualMapper?: TypeMapper): Type {
function checkObjectLiteralAssignment(node: ObjectLiteralExpression, sourceType: Type): Type {
const properties = node.properties;
for (const p of properties) {
checkObjectLiteralDestructuringPropertyAssignment(sourceType, p, contextualMapper);
checkObjectLiteralDestructuringPropertyAssignment(sourceType, p);
}
return sourceType;
}
function checkObjectLiteralDestructuringPropertyAssignment(objectLiteralType: Type, property: ObjectLiteralElementLike, contextualMapper?: TypeMapper) {
function checkObjectLiteralDestructuringPropertyAssignment(objectLiteralType: Type, property: ObjectLiteralElementLike) {
if (property.kind === SyntaxKind.PropertyAssignment || property.kind === SyntaxKind.ShorthandPropertyAssignment) {
const name = <PropertyName>(<PropertyAssignment>property).name;
if (name.kind === SyntaxKind.ComputedPropertyName) {
@ -13648,7 +13694,7 @@ namespace ts {
target = (<BinaryExpression>target).left;
}
if (target.kind === SyntaxKind.ObjectLiteralExpression) {
return checkObjectLiteralAssignment(<ObjectLiteralExpression>target, sourceType, contextualMapper);
return checkObjectLiteralAssignment(<ObjectLiteralExpression>target, sourceType);
}
if (target.kind === SyntaxKind.ArrayLiteralExpression) {
return checkArrayLiteralAssignment(<ArrayLiteralExpression>target, sourceType, contextualMapper);
@ -17086,7 +17132,9 @@ namespace ts {
checkTypeAssignableTo(staticType, getTypeWithoutSignatures(staticBaseType), node.name || node,
Diagnostics.Class_static_side_0_incorrectly_extends_base_class_static_side_1);
if (baseType.symbol.valueDeclaration && !isInAmbientContext(baseType.symbol.valueDeclaration)) {
if (baseType.symbol.valueDeclaration &&
!isInAmbientContext(baseType.symbol.valueDeclaration) &&
baseType.symbol.valueDeclaration.kind === SyntaxKind.ClassDeclaration) {
if (!isBlockScopedNameDeclaredBeforeUse(baseType.symbol.valueDeclaration, node)) {
error(baseTypeNode, Diagnostics.A_class_must_be_declared_after_its_base_class);
}
@ -18557,7 +18605,7 @@ namespace ts {
// Since we already checked for ExportAssignment, this really could only be an Import
const importEqualsDeclaration = <ImportEqualsDeclaration>getAncestor(entityName, SyntaxKind.ImportEqualsDeclaration);
Debug.assert(importEqualsDeclaration !== undefined);
return getSymbolOfPartOfRightHandSideOfImportEquals(<EntityName>entityName, importEqualsDeclaration, /*dontResolveAlias*/ true);
return getSymbolOfPartOfRightHandSideOfImportEquals(<EntityName>entityName, /*dontResolveAlias*/ true);
}
if (isRightSideOfQualifiedNameOrPropertyAccess(entityName)) {
@ -19940,7 +19988,7 @@ namespace ts {
}
}
function checkGrammarTypeParameterList(node: FunctionLikeDeclaration, typeParameters: NodeArray<TypeParameterDeclaration>, file: SourceFile): boolean {
function checkGrammarTypeParameterList(typeParameters: NodeArray<TypeParameterDeclaration>, file: SourceFile): boolean {
if (checkGrammarForDisallowedTrailingComma(typeParameters)) {
return true;
}
@ -19991,7 +20039,7 @@ namespace ts {
function checkGrammarFunctionLikeDeclaration(node: FunctionLikeDeclaration): boolean {
// Prevent cascading error by short-circuit
const file = getSourceFileOfNode(node);
return checkGrammarDecorators(node) || checkGrammarModifiers(node) || checkGrammarTypeParameterList(node, node.typeParameters, file) ||
return checkGrammarDecorators(node) || checkGrammarModifiers(node) || checkGrammarTypeParameterList(node.typeParameters, file) ||
checkGrammarParameterList(node.parameters) || checkGrammarArrowFunction(node, file);
}
@ -20177,7 +20225,7 @@ namespace ts {
}
}
function checkGrammarForInvalidQuestionMark(node: Declaration, questionToken: Node, message: DiagnosticMessage): boolean {
function checkGrammarForInvalidQuestionMark(questionToken: Node, message: DiagnosticMessage): boolean {
if (questionToken) {
return grammarErrorOnNode(questionToken, message);
}
@ -20223,7 +20271,7 @@ namespace ts {
let currentKind: number;
if (prop.kind === SyntaxKind.PropertyAssignment || prop.kind === SyntaxKind.ShorthandPropertyAssignment) {
// Grammar checking for computedPropertyName and shorthandPropertyAssignment
checkGrammarForInvalidQuestionMark(prop, (<PropertyAssignment>prop).questionToken, Diagnostics.An_object_member_cannot_be_declared_optional);
checkGrammarForInvalidQuestionMark((<PropertyAssignment>prop).questionToken, Diagnostics.An_object_member_cannot_be_declared_optional);
if (name.kind === SyntaxKind.NumericLiteral) {
checkGrammarNumericLiteral(<NumericLiteral>name);
}
@ -20407,7 +20455,7 @@ namespace ts {
}
if (node.parent.kind === SyntaxKind.ObjectLiteralExpression) {
if (checkGrammarForInvalidQuestionMark(node, node.questionToken, Diagnostics.An_object_member_cannot_be_declared_optional)) {
if (checkGrammarForInvalidQuestionMark(node.questionToken, Diagnostics.An_object_member_cannot_be_declared_optional)) {
return true;
}
else if (node.body === undefined) {

View file

@ -515,10 +515,7 @@ namespace ts {
/* @internal */
export function createCompilerDiagnosticForInvalidCustomType(opt: CommandLineOptionOfCustomType): Diagnostic {
const namesOfType: string[] = [];
for (const key in opt.type) {
namesOfType.push(` '${key}'`);
}
const namesOfType = Object.keys(opt.type).map(key => `'${key}'`).join(", ");
return createCompilerDiagnostic(Diagnostics.Argument_for_0_option_must_be_Colon_1, `--${opt.name}`, namesOfType);
}

View file

@ -188,7 +188,7 @@ namespace ts {
}
}
function emitLeadingComment(commentPos: number, commentEnd: number, kind: SyntaxKind, hasTrailingNewLine: boolean, rangePos: number) {
function emitLeadingComment(commentPos: number, commentEnd: number, _kind: SyntaxKind, hasTrailingNewLine: boolean, rangePos: number) {
if (!hasWrittenComment) {
emitNewLineBeforeLeadingCommentOfPosition(currentLineMap, writer, rangePos, commentPos);
hasWrittenComment = true;
@ -211,7 +211,7 @@ namespace ts {
forEachTrailingCommentToEmit(pos, emitTrailingComment);
}
function emitTrailingComment(commentPos: number, commentEnd: number, kind: SyntaxKind, hasTrailingNewLine: boolean) {
function emitTrailingComment(commentPos: number, commentEnd: number, _kind: SyntaxKind, hasTrailingNewLine: boolean) {
// trailing comments are emitted at space/*trailing comment1 */space/*trailing comment2*/
if (!writer.isAtStartOfLine()) {
writer.write(" ");
@ -242,7 +242,7 @@ namespace ts {
}
}
function emitTrailingCommentOfPosition(commentPos: number, commentEnd: number, kind: SyntaxKind, hasTrailingNewLine: boolean) {
function emitTrailingCommentOfPosition(commentPos: number, commentEnd: number, _kind: SyntaxKind, hasTrailingNewLine: boolean) {
// trailing comments of a position are emitted at /*trailing comment1 */space/*trailing comment*/space
emitPos(commentPos);

View file

@ -568,6 +568,12 @@ namespace ts {
: array;
}
export function replaceElement<T>(array: T[], index: number, value: T): T[] {
const result = array.slice(0);
result[index] = value;
return result;
}
/**
* Performs a binary search, finding the index at which 'value' occurs in 'array'.
* If no such index is found, returns the 2's-complement of first index at which
@ -899,6 +905,14 @@ namespace ts {
return Array.isArray ? Array.isArray(value) : value instanceof Array;
}
/** Does nothing. */
export function noop(): void {}
/** Throws an error because a function is not implemented. */
export function notImplemented(): never {
throw new Error("Not implemented");
}
export function memoize<T>(callback: () => T): () => T {
let value: T;
return () => {
@ -939,7 +953,7 @@ namespace ts {
return t => compose(a(t));
}
else {
return t => u => u;
return _ => u => u;
}
}
@ -976,10 +990,10 @@ namespace ts {
}
}
function formatStringFromArgs(text: string, args: { [index: number]: any; }, baseIndex?: number): string {
function formatStringFromArgs(text: string, args: { [index: number]: string; }, baseIndex?: number): string {
baseIndex = baseIndex || 0;
return text.replace(/{(\d+)}/g, (match, index?) => args[+index + baseIndex]);
return text.replace(/{(\d+)}/g, (_match, index?) => args[+index + baseIndex]);
}
export let localizedDiagnosticMessages: Map<string> = undefined;
@ -988,7 +1002,7 @@ namespace ts {
return localizedDiagnosticMessages && localizedDiagnosticMessages[message.key] || message.message;
}
export function createFileDiagnostic(file: SourceFile, start: number, length: number, message: DiagnosticMessage, ...args: any[]): Diagnostic;
export function createFileDiagnostic(file: SourceFile, start: number, length: number, message: DiagnosticMessage, ...args: (string | number)[]): Diagnostic;
export function createFileDiagnostic(file: SourceFile, start: number, length: number, message: DiagnosticMessage): Diagnostic {
const end = start + length;
@ -1018,7 +1032,7 @@ namespace ts {
}
/* internal */
export function formatMessage(dummy: any, message: DiagnosticMessage): string {
export function formatMessage(_dummy: any, message: DiagnosticMessage): string {
let text = getLocaleSpecificMessage(message);
if (arguments.length > 2) {
@ -1028,7 +1042,7 @@ namespace ts {
return text;
}
export function createCompilerDiagnostic(message: DiagnosticMessage, ...args: any[]): Diagnostic;
export function createCompilerDiagnostic(message: DiagnosticMessage, ...args: (string | number)[]): Diagnostic;
export function createCompilerDiagnostic(message: DiagnosticMessage): Diagnostic {
let text = getLocaleSpecificMessage(message);
@ -1659,7 +1673,7 @@ namespace ts {
basePaths: string[];
}
export function getFileMatcherPatterns(path: string, extensions: string[], excludes: string[], includes: string[], useCaseSensitiveFileNames: boolean, currentDirectory: string): FileMatcherPatterns {
export function getFileMatcherPatterns(path: string, excludes: string[], includes: string[], useCaseSensitiveFileNames: boolean, currentDirectory: string): FileMatcherPatterns {
path = normalizePath(path);
currentDirectory = normalizePath(currentDirectory);
const absolutePath = combinePaths(currentDirectory, path);
@ -1676,7 +1690,7 @@ namespace ts {
path = normalizePath(path);
currentDirectory = normalizePath(currentDirectory);
const patterns = getFileMatcherPatterns(path, extensions, excludes, includes, useCaseSensitiveFileNames, currentDirectory);
const patterns = getFileMatcherPatterns(path, excludes, includes, useCaseSensitiveFileNames, currentDirectory);
const regexFlag = useCaseSensitiveFileNames ? "" : "i";
const includeFileRegex = patterns.includeFilePattern && new RegExp(patterns.includeFilePattern, regexFlag);
@ -1910,11 +1924,11 @@ namespace ts {
this.declarations = undefined;
}
function Type(this: Type, checker: TypeChecker, flags: TypeFlags) {
function Type(this: Type, _checker: TypeChecker, flags: TypeFlags) {
this.flags = flags;
}
function Signature(checker: TypeChecker) {
function Signature() {
}
function Node(this: Node, kind: SyntaxKind, pos: number, end: number) {
@ -1947,9 +1961,6 @@ namespace ts {
}
export namespace Debug {
declare var process: any;
declare var require: any;
export let currentAssertionLevel = AssertionLevel.None;
export function shouldAssert(level: AssertionLevel): boolean {

View file

@ -63,7 +63,7 @@ namespace ts {
let isCurrentFileExternalModule: boolean;
let reportedDeclarationError = false;
let errorNameNode: DeclarationName;
const emitJsDocComments = compilerOptions.removeComments ? function (declaration: Node) { } : writeJsDocComments;
const emitJsDocComments = compilerOptions.removeComments ? noop : writeJsDocComments;
const emit = compilerOptions.stripInternal ? stripInternal : emitNode;
let noDeclare: boolean;
@ -580,7 +580,7 @@ namespace ts {
writeAsynchronousModuleElements(nodes);
}
function getDefaultExportAccessibilityDiagnostic(diagnostic: SymbolAccessibilityResult): SymbolAccessibilityDiagnostic {
function getDefaultExportAccessibilityDiagnostic(): SymbolAccessibilityDiagnostic {
return {
diagnosticMessage: Diagnostics.Default_export_of_the_module_has_or_is_using_private_name_0,
errorNode: node
@ -710,7 +710,7 @@ namespace ts {
}
writer.writeLine();
function getImportEntityNameVisibilityError(symbolAccessibilityResult: SymbolAccessibilityResult): SymbolAccessibilityDiagnostic {
function getImportEntityNameVisibilityError(): SymbolAccessibilityDiagnostic {
return {
diagnosticMessage: Diagnostics.Import_declaration_0_is_using_private_name_1,
errorNode: node,
@ -888,7 +888,7 @@ namespace ts {
writeLine();
enclosingDeclaration = prevEnclosingDeclaration;
function getTypeAliasDeclarationVisibilityError(symbolAccessibilityResult: SymbolAccessibilityResult): SymbolAccessibilityDiagnostic {
function getTypeAliasDeclarationVisibilityError(): SymbolAccessibilityDiagnostic {
return {
diagnosticMessage: Diagnostics.Exported_type_alias_0_has_or_is_using_private_name_1,
errorNode: node.type,
@ -955,7 +955,7 @@ namespace ts {
}
}
function getTypeParameterConstraintVisibilityError(symbolAccessibilityResult: SymbolAccessibilityResult): SymbolAccessibilityDiagnostic {
function getTypeParameterConstraintVisibilityError(): SymbolAccessibilityDiagnostic {
// Type parameter constraints are named by user so we should always be able to name it
let diagnosticMessage: DiagnosticMessage;
switch (node.parent.kind) {
@ -1029,7 +1029,7 @@ namespace ts {
resolver.writeBaseConstructorTypeOfClass(<ClassLikeDeclaration>enclosingDeclaration, enclosingDeclaration, TypeFormatFlags.UseTypeOfFunction | TypeFormatFlags.UseTypeAliasValue, writer);
}
function getHeritageClauseVisibilityError(symbolAccessibilityResult: SymbolAccessibilityResult): SymbolAccessibilityDiagnostic {
function getHeritageClauseVisibilityError(): SymbolAccessibilityDiagnostic {
let diagnosticMessage: DiagnosticMessage;
// Heritage clause is written by user so it can always be named
if (node.parent.parent.kind === SyntaxKind.ClassDeclaration) {
@ -1743,7 +1743,7 @@ namespace ts {
}
return addedBundledEmitReference;
function getDeclFileName(emitFileNames: EmitFileNames, sourceFiles: SourceFile[], isBundledEmit: boolean) {
function getDeclFileName(emitFileNames: EmitFileNames, _sourceFiles: SourceFile[], isBundledEmit: boolean) {
// Dont add reference path to this file if it is a bundled emit and caller asked not emit bundled file path
if (isBundledEmit && !addBundledFileReference) {
return;

View file

@ -14,7 +14,7 @@ namespace ts {
}
const id = (s: SourceFile) => s;
const nullTransformers: Transformer[] = [ctx => id];
const nullTransformers: Transformer[] = [_ => id];
// targetSourceFile is when users only want one file in entire project to be emitted. This is used in compileOnSave feature
export function emitFiles(resolver: EmitResolver, host: EmitHost, targetSourceFile: SourceFile, emitOnlyDtsFiles?: boolean): EmitResult {
@ -593,7 +593,7 @@ const _super = (function (geti, seti) {
case SyntaxKind.ExpressionWithTypeArguments:
return emitExpressionWithTypeArguments(<ExpressionWithTypeArguments>node);
case SyntaxKind.ThisType:
return emitThisType(<ThisTypeNode>node);
return emitThisType();
case SyntaxKind.LiteralType:
return emitLiteralType(<LiteralTypeNode>node);
@ -609,7 +609,7 @@ const _super = (function (geti, seti) {
case SyntaxKind.TemplateSpan:
return emitTemplateSpan(<TemplateSpan>node);
case SyntaxKind.SemicolonClassElement:
return emitSemicolonClassElement(<SemicolonClassElement>node);
return emitSemicolonClassElement();
// Statements
case SyntaxKind.Block:
@ -617,7 +617,7 @@ const _super = (function (geti, seti) {
case SyntaxKind.VariableStatement:
return emitVariableStatement(<VariableStatement>node);
case SyntaxKind.EmptyStatement:
return emitEmptyStatement(<EmptyStatement>node);
return emitEmptyStatement();
case SyntaxKind.ExpressionStatement:
return emitExpressionStatement(<ExpressionStatement>node);
case SyntaxKind.IfStatement:
@ -1014,7 +1014,7 @@ const _super = (function (geti, seti) {
write(";");
}
function emitSemicolonClassElement(node: SemicolonClassElement) {
function emitSemicolonClassElement() {
write(";");
}
@ -1084,7 +1084,7 @@ const _super = (function (geti, seti) {
write(")");
}
function emitThisType(node: ThisTypeNode) {
function emitThisType() {
write("this");
}
@ -1397,7 +1397,7 @@ const _super = (function (geti, seti) {
// Statements
//
function emitBlock(node: Block, format?: ListFormat) {
function emitBlock(node: Block) {
if (isSingleLineEmptyBlock(node)) {
writeToken(SyntaxKind.OpenBraceToken, node.pos, /*contextNode*/ node);
write(" ");
@ -1425,7 +1425,7 @@ const _super = (function (geti, seti) {
write(";");
}
function emitEmptyStatement(node: EmptyStatement) {
function emitEmptyStatement() {
write(";");
}
@ -1623,13 +1623,13 @@ const _super = (function (geti, seti) {
if (getEmitFlags(node) & EmitFlags.ReuseTempVariableScope) {
emitSignatureHead(node);
emitBlockFunctionBody(node, body);
emitBlockFunctionBody(body);
}
else {
const savedTempFlags = tempFlags;
tempFlags = 0;
emitSignatureHead(node);
emitBlockFunctionBody(node, body);
emitBlockFunctionBody(body);
tempFlags = savedTempFlags;
}
@ -1656,7 +1656,7 @@ const _super = (function (geti, seti) {
emitWithPrefix(": ", node.type);
}
function shouldEmitBlockFunctionBodyOnSingleLine(parentNode: Node, body: Block) {
function shouldEmitBlockFunctionBodyOnSingleLine(body: Block) {
// We must emit a function body as a single-line body in the following case:
// * The body has NodeEmitFlags.SingleLine specified.
@ -1694,12 +1694,12 @@ const _super = (function (geti, seti) {
return true;
}
function emitBlockFunctionBody(parentNode: Node, body: Block) {
function emitBlockFunctionBody(body: Block) {
write(" {");
increaseIndent();
emitBodyWithDetachedComments(body, body.statements,
shouldEmitBlockFunctionBodyOnSingleLine(parentNode, body)
shouldEmitBlockFunctionBodyOnSingleLine(body)
? emitBlockFunctionBodyOnSingleLine
: emitBlockFunctionBodyWorker);

View file

@ -5,7 +5,7 @@ namespace ts {
/* @internal */
export function trace(host: ModuleResolutionHost, message: DiagnosticMessage, ...args: any[]): void;
export function trace(host: ModuleResolutionHost, message: DiagnosticMessage): void {
export function trace(host: ModuleResolutionHost): void {
host.trace(formatMessage.apply(undefined, arguments));
}

View file

@ -572,10 +572,10 @@ namespace ts {
// attached to the EOF token.
let parseErrorBeforeNextFinishedNode = false;
export function parseSourceFile(fileName: string, _sourceText: string, languageVersion: ScriptTarget, _syntaxCursor: IncrementalParser.SyntaxCursor, setParentNodes?: boolean, scriptKind?: ScriptKind): SourceFile {
export function parseSourceFile(fileName: string, sourceText: string, languageVersion: ScriptTarget, syntaxCursor: IncrementalParser.SyntaxCursor, setParentNodes?: boolean, scriptKind?: ScriptKind): SourceFile {
scriptKind = ensureScriptKind(fileName, scriptKind);
initializeState(fileName, _sourceText, languageVersion, _syntaxCursor, scriptKind);
initializeState(sourceText, languageVersion, syntaxCursor, scriptKind);
const result = parseSourceFileWorker(fileName, languageVersion, setParentNodes, scriptKind);
@ -589,7 +589,7 @@ namespace ts {
return scriptKind === ScriptKind.TSX || scriptKind === ScriptKind.JSX || scriptKind === ScriptKind.JS ? LanguageVariant.JSX : LanguageVariant.Standard;
}
function initializeState(fileName: string, _sourceText: string, languageVersion: ScriptTarget, _syntaxCursor: IncrementalParser.SyntaxCursor, scriptKind: ScriptKind) {
function initializeState(_sourceText: string, languageVersion: ScriptTarget, _syntaxCursor: IncrementalParser.SyntaxCursor, scriptKind: ScriptKind) {
NodeConstructor = objectAllocator.getNodeConstructor();
TokenConstructor = objectAllocator.getTokenConstructor();
IdentifierConstructor = objectAllocator.getIdentifierConstructor();
@ -5259,7 +5259,7 @@ namespace ts {
parseExpected(SyntaxKind.ClassKeyword);
node.name = parseNameOfClassDeclarationOrExpression();
node.typeParameters = parseTypeParameters();
node.heritageClauses = parseHeritageClauses(/*isClassHeritageClause*/ true);
node.heritageClauses = parseHeritageClauses();
if (parseExpected(SyntaxKind.OpenBraceToken)) {
// ClassTail[Yield,Await] : (Modified) See 14.5
@ -5289,7 +5289,7 @@ namespace ts {
return token() === SyntaxKind.ImplementsKeyword && lookAhead(nextTokenIsIdentifierOrKeyword);
}
function parseHeritageClauses(isClassHeritageClause: boolean): NodeArray<HeritageClause> {
function parseHeritageClauses(): NodeArray<HeritageClause> {
// ClassTail[Yield,Await] : (Modified) See 14.5
// ClassHeritage[?Yield,?Await]opt { ClassBody[?Yield,?Await]opt }
@ -5337,7 +5337,7 @@ namespace ts {
parseExpected(SyntaxKind.InterfaceKeyword);
node.name = parseIdentifier();
node.typeParameters = parseTypeParameters();
node.heritageClauses = parseHeritageClauses(/*isClassHeritageClause*/ false);
node.heritageClauses = parseHeritageClauses();
node.members = parseObjectTypeMembers();
return addJSDocComment(finishNode(node));
}
@ -5817,7 +5817,7 @@ namespace ts {
}
export function parseJSDocTypeExpressionForTests(content: string, start: number, length: number) {
initializeState("file.js", content, ScriptTarget.Latest, /*_syntaxCursor:*/ undefined, ScriptKind.JS);
initializeState(content, ScriptTarget.Latest, /*_syntaxCursor:*/ undefined, ScriptKind.JS);
sourceFile = createSourceFile("file.js", ScriptTarget.Latest, ScriptKind.JS);
scanner.setText(content, start, length);
currentToken = scanner.scan();
@ -6134,7 +6134,7 @@ namespace ts {
}
export function parseIsolatedJSDocComment(content: string, start: number, length: number) {
initializeState("file.js", content, ScriptTarget.Latest, /*_syntaxCursor:*/ undefined, ScriptKind.JS);
initializeState(content, ScriptTarget.Latest, /*_syntaxCursor:*/ undefined, ScriptKind.JS);
sourceFile = <SourceFile>{ languageVariant: LanguageVariant.Standard, text: content };
const jsDoc = parseJSDocCommentWorker(start, length);
const diagnostics = parseDiagnostics;

View file

@ -12,7 +12,7 @@ namespace ts.performance {
const profilerEvent = typeof onProfilerEvent === "function" && onProfilerEvent.profiler === true
? onProfilerEvent
: (markName: string) => { };
: (_markName: string) => { };
let enabled = false;
let profilerStart = 0;

View file

@ -724,7 +724,7 @@ namespace ts {
}
}
function getSyntacticDiagnosticsForFile(sourceFile: SourceFile, cancellationToken: CancellationToken): Diagnostic[] {
function getSyntacticDiagnosticsForFile(sourceFile: SourceFile): Diagnostic[] {
return sourceFile.parseDiagnostics;
}
@ -761,16 +761,16 @@ namespace ts {
// Instead, we just report errors for using TypeScript-only constructs from within a
// JavaScript file.
const checkDiagnostics = isSourceFileJavaScript(sourceFile) ?
getJavaScriptSemanticDiagnosticsForFile(sourceFile, cancellationToken) :
getJavaScriptSemanticDiagnosticsForFile(sourceFile) :
typeChecker.getDiagnostics(sourceFile, cancellationToken);
const fileProcessingDiagnosticsInFile = fileProcessingDiagnostics.getDiagnostics(sourceFile.fileName);
const programDiagnosticsInFile = programDiagnostics.getDiagnostics(sourceFile.fileName);
return bindDiagnostics.concat(checkDiagnostics).concat(fileProcessingDiagnosticsInFile).concat(programDiagnosticsInFile);
return bindDiagnostics.concat(checkDiagnostics, fileProcessingDiagnosticsInFile, programDiagnosticsInFile);
});
}
function getJavaScriptSemanticDiagnosticsForFile(sourceFile: SourceFile, cancellationToken: CancellationToken): Diagnostic[] {
function getJavaScriptSemanticDiagnosticsForFile(sourceFile: SourceFile): Diagnostic[] {
return runWithCancellationToken(() => {
const diagnostics: Diagnostic[] = [];
walk(sourceFile);
@ -950,8 +950,7 @@ namespace ts {
return runWithCancellationToken(() => {
const resolver = getDiagnosticsProducingTypeChecker().getEmitResolver(sourceFile, cancellationToken);
// Don't actually write any files since we're just getting diagnostics.
const writeFile: WriteFileCallback = () => { };
return ts.getDeclarationDiagnostics(getEmitHost(writeFile), resolver, sourceFile);
return ts.getDeclarationDiagnostics(getEmitHost(noop), resolver, sourceFile);
});
}
@ -977,7 +976,7 @@ namespace ts {
}
function processRootFile(fileName: string, isDefaultLib: boolean) {
processSourceFile(normalizePath(fileName), isDefaultLib, /*isReference*/ true);
processSourceFile(normalizePath(fileName), isDefaultLib);
}
function fileReferenceIsEqualTo(a: FileReference, b: FileReference): boolean {
@ -1088,7 +1087,7 @@ namespace ts {
/**
* 'isReference' indicates whether the file was brought in via a reference directive (rather than an import declaration)
*/
function processSourceFile(fileName: string, isDefaultLib: boolean, isReference: boolean, refFile?: SourceFile, refPos?: number, refEnd?: number) {
function processSourceFile(fileName: string, isDefaultLib: boolean, refFile?: SourceFile, refPos?: number, refEnd?: number) {
let diagnosticArgument: string[];
let diagnostic: DiagnosticMessage;
if (hasExtension(fileName)) {
@ -1096,7 +1095,7 @@ namespace ts {
diagnostic = Diagnostics.File_0_has_unsupported_extension_The_only_supported_extensions_are_1;
diagnosticArgument = [fileName, "'" + supportedExtensions.join("', '") + "'"];
}
else if (!findSourceFile(fileName, toPath(fileName, currentDirectory, getCanonicalFileName), isDefaultLib, isReference, refFile, refPos, refEnd)) {
else if (!findSourceFile(fileName, toPath(fileName, currentDirectory, getCanonicalFileName), isDefaultLib, refFile, refPos, refEnd)) {
diagnostic = Diagnostics.File_0_not_found;
diagnosticArgument = [fileName];
}
@ -1106,13 +1105,13 @@ namespace ts {
}
}
else {
const nonTsFile: SourceFile = options.allowNonTsExtensions && findSourceFile(fileName, toPath(fileName, currentDirectory, getCanonicalFileName), isDefaultLib, isReference, refFile, refPos, refEnd);
const nonTsFile: SourceFile = options.allowNonTsExtensions && findSourceFile(fileName, toPath(fileName, currentDirectory, getCanonicalFileName), isDefaultLib, refFile, refPos, refEnd);
if (!nonTsFile) {
if (options.allowNonTsExtensions) {
diagnostic = Diagnostics.File_0_not_found;
diagnosticArgument = [fileName];
}
else if (!forEach(supportedExtensions, extension => findSourceFile(fileName + extension, toPath(fileName + extension, currentDirectory, getCanonicalFileName), isDefaultLib, isReference, refFile, refPos, refEnd))) {
else if (!forEach(supportedExtensions, extension => findSourceFile(fileName + extension, toPath(fileName + extension, currentDirectory, getCanonicalFileName), isDefaultLib, refFile, refPos, refEnd))) {
diagnostic = Diagnostics.File_0_not_found;
fileName += ".ts";
diagnosticArgument = [fileName];
@ -1141,7 +1140,7 @@ namespace ts {
}
// Get source file from normalized fileName
function findSourceFile(fileName: string, path: Path, isDefaultLib: boolean, isReference: boolean, refFile?: SourceFile, refPos?: number, refEnd?: number): SourceFile {
function findSourceFile(fileName: string, path: Path, isDefaultLib: boolean, refFile?: SourceFile, refPos?: number, refEnd?: number): SourceFile {
if (filesByName.contains(path)) {
const file = filesByName.get(path);
// try to check if we've already seen this file but with a different casing in path
@ -1155,18 +1154,18 @@ namespace ts {
if (file && sourceFilesFoundSearchingNodeModules[file.path] && currentNodeModulesDepth == 0) {
sourceFilesFoundSearchingNodeModules[file.path] = false;
if (!options.noResolve) {
processReferencedFiles(file, getDirectoryPath(fileName), isDefaultLib);
processReferencedFiles(file, isDefaultLib);
processTypeReferenceDirectives(file);
}
modulesWithElidedImports[file.path] = false;
processImportedModules(file, getDirectoryPath(fileName));
processImportedModules(file);
}
// See if we need to reprocess the imports due to prior skipped imports
else if (file && modulesWithElidedImports[file.path]) {
if (currentNodeModulesDepth < maxNodeModulesJsDepth) {
modulesWithElidedImports[file.path] = false;
processImportedModules(file, getDirectoryPath(fileName));
processImportedModules(file);
}
}
@ -1202,14 +1201,13 @@ namespace ts {
skipDefaultLib = skipDefaultLib || file.hasNoDefaultLib;
const basePath = getDirectoryPath(fileName);
if (!options.noResolve) {
processReferencedFiles(file, basePath, isDefaultLib);
processReferencedFiles(file, isDefaultLib);
processTypeReferenceDirectives(file);
}
// always process imported modules to record module name resolutions
processImportedModules(file, basePath);
processImportedModules(file);
if (isDefaultLib) {
files.unshift(file);
@ -1222,10 +1220,10 @@ namespace ts {
return file;
}
function processReferencedFiles(file: SourceFile, basePath: string, isDefaultLib: boolean) {
function processReferencedFiles(file: SourceFile, isDefaultLib: boolean) {
forEach(file.referencedFiles, ref => {
const referencedFileName = resolveTripleslashReference(ref.fileName, file.fileName);
processSourceFile(referencedFileName, isDefaultLib, /*isReference*/ true, file, ref.pos, ref.end);
processSourceFile(referencedFileName, isDefaultLib, file, ref.pos, ref.end);
});
}
@ -1256,7 +1254,7 @@ namespace ts {
if (resolvedTypeReferenceDirective) {
if (resolvedTypeReferenceDirective.primary) {
// resolved from the primary path
processSourceFile(resolvedTypeReferenceDirective.resolvedFileName, /*isDefaultLib*/ false, /*isReference*/ true, refFile, refPos, refEnd);
processSourceFile(resolvedTypeReferenceDirective.resolvedFileName, /*isDefaultLib*/ false, refFile, refPos, refEnd);
}
else {
// If we already resolved to this file, it must have been a secondary reference. Check file contents
@ -1276,7 +1274,7 @@ namespace ts {
}
else {
// First resolution of this library
processSourceFile(resolvedTypeReferenceDirective.resolvedFileName, /*isDefaultLib*/ false, /*isReference*/ true, refFile, refPos, refEnd);
processSourceFile(resolvedTypeReferenceDirective.resolvedFileName, /*isDefaultLib*/ false, refFile, refPos, refEnd);
}
}
}
@ -1302,7 +1300,7 @@ namespace ts {
return host.getCanonicalFileName(fileName);
}
function processImportedModules(file: SourceFile, basePath: string) {
function processImportedModules(file: SourceFile) {
collectExternalModuleReferences(file);
if (file.imports.length || file.moduleAugmentations.length) {
file.resolvedModules = createMap<ResolvedModule>();
@ -1333,7 +1331,7 @@ namespace ts {
else if (shouldAddFile) {
findSourceFile(resolution.resolvedFileName,
toPath(resolution.resolvedFileName, currentDirectory, getCanonicalFileName),
/*isDefaultLib*/ false, /*isReference*/ false,
/*isDefaultLib*/ false,
file,
skipTrivia(file.text, file.imports[i].pos),
file.imports[i].end);
@ -1541,7 +1539,7 @@ namespace ts {
if (!options.noEmit && !options.suppressOutputPathCheck) {
const emitHost = getEmitHost();
const emitFilesSeen = createFileMap<boolean>(!host.useCaseSensitiveFileNames() ? key => key.toLocaleLowerCase() : undefined);
forEachExpectedEmitFile(emitHost, (emitFileNames, sourceFiles, isBundledEmit) => {
forEachExpectedEmitFile(emitHost, (emitFileNames) => {
verifyEmitFilePath(emitFileNames.jsFilePath, emitFilesSeen);
verifyEmitFilePath(emitFileNames.declarationFilePath, emitFilesSeen);
});
@ -1553,13 +1551,13 @@ namespace ts {
const emitFilePath = toPath(emitFileName, currentDirectory, getCanonicalFileName);
// Report error if the output overwrites input file
if (filesByName.contains(emitFilePath)) {
createEmitBlockingDiagnostics(emitFileName, emitFilePath, Diagnostics.Cannot_write_file_0_because_it_would_overwrite_input_file);
createEmitBlockingDiagnostics(emitFileName, Diagnostics.Cannot_write_file_0_because_it_would_overwrite_input_file);
}
// Report error if multiple files write into same file
if (emitFilesSeen.contains(emitFilePath)) {
// Already seen the same emit file - report error
createEmitBlockingDiagnostics(emitFileName, emitFilePath, Diagnostics.Cannot_write_file_0_because_it_would_be_overwritten_by_multiple_input_files);
createEmitBlockingDiagnostics(emitFileName, Diagnostics.Cannot_write_file_0_because_it_would_be_overwritten_by_multiple_input_files);
}
else {
emitFilesSeen.set(emitFilePath, true);
@ -1568,7 +1566,7 @@ namespace ts {
}
}
function createEmitBlockingDiagnostics(emitFileName: string, emitFilePath: Path, message: DiagnosticMessage) {
function createEmitBlockingDiagnostics(emitFileName: string, message: DiagnosticMessage) {
hasEmitBlockingDiagnostics.set(toPath(emitFileName, currentDirectory, getCanonicalFileName), true);
programDiagnostics.add(createCompilerDiagnostic(message, emitFileName));
}

View file

@ -723,7 +723,7 @@ namespace ts {
return iterateCommentRanges(/*reduce*/ true, text, pos, /*trailing*/ true, cb, state, initial);
}
function appendCommentRange(pos: number, end: number, kind: SyntaxKind, hasTrailingNewLine: boolean, state: any, comments: CommentRange[]) {
function appendCommentRange(pos: number, end: number, kind: SyntaxKind, hasTrailingNewLine: boolean, _state: any, comments: CommentRange[]) {
if (!comments) {
comments = [];
}

View file

@ -34,6 +34,8 @@ namespace ts {
realpath?(path: string): string;
/*@internal*/ getEnvironmentVariable(name: string): string;
/*@internal*/ tryEnableSourceMapsForHost?(): void;
setTimeout?(callback: (...args: any[]) => void, ms: number, ...args: any[]): any;
clearTimeout?(timeoutId: any): void;
}
export interface FileWatcher {
@ -46,13 +48,9 @@ namespace ts {
}
declare var require: any;
declare var module: any;
declare var process: any;
declare var global: any;
declare var __filename: string;
declare var Buffer: {
new (str: string, encoding?: string): any;
};
declare class Enumerator {
public atEnd(): boolean;
@ -324,7 +322,7 @@ namespace ts {
const platform: string = _os.platform();
const useCaseSensitiveFileNames = isFileSystemCaseSensitive();
function readFile(fileName: string, encoding?: string): string {
function readFile(fileName: string, _encoding?: string): string {
if (!fileExists(fileName)) {
return undefined;
}
@ -564,7 +562,9 @@ namespace ts {
catch (e) {
// Could not enable source maps.
}
}
},
setTimeout,
clearTimeout
};
return nodeSystem;
}
@ -576,7 +576,7 @@ namespace ts {
args: ChakraHost.args,
useCaseSensitiveFileNames: !!ChakraHost.useCaseSensitiveFileNames,
write: ChakraHost.echo,
readFile(path: string, encoding?: string) {
readFile(path: string, _encoding?: string) {
// encoding is automatically handled by the implementation in ChakraHost
return ChakraHost.readFile(path);
},
@ -595,9 +595,9 @@ namespace ts {
getExecutingFilePath: () => ChakraHost.executingFile,
getCurrentDirectory: () => ChakraHost.currentDirectory,
getDirectories: ChakraHost.getDirectories,
getEnvironmentVariable: ChakraHost.getEnvironmentVariable || ((name: string) => ""),
getEnvironmentVariable: ChakraHost.getEnvironmentVariable || (() => ""),
readDirectory: (path: string, extensions?: string[], excludes?: string[], includes?: string[]) => {
const pattern = getFileMatcherPatterns(path, extensions, excludes, includes, !!ChakraHost.useCaseSensitiveFileNames, ChakraHost.currentDirectory);
const pattern = getFileMatcherPatterns(path, excludes, includes, !!ChakraHost.useCaseSensitiveFileNames, ChakraHost.currentDirectory);
return ChakraHost.readDirectory(path, extensions, pattern.basePaths, pattern.excludePattern, pattern.includeFilePattern, pattern.includeDirectoryPattern);
},
exit: ChakraHost.quit,

View file

@ -4,8 +4,8 @@
/// <reference path="transformers/es2017.ts" />
/// <reference path="transformers/es2016.ts" />
/// <reference path="transformers/es2015.ts" />
/// <reference path="transformers/es5.ts" />
/// <reference path="transformers/generators.ts" />
/// <reference path="transformers/es5.ts" />
/// <reference path="transformers/module/module.ts" />
/// <reference path="transformers/module/system.ts" />
/// <reference path="transformers/module/es2015.ts" />
@ -168,7 +168,7 @@ namespace ts {
hoistFunctionDeclaration,
startLexicalEnvironment,
endLexicalEnvironment,
onSubstituteNode: (emitContext, node) => node,
onSubstituteNode: (_emitContext, node) => node,
enableSubstitution,
isSubstitutionEnabled,
onEmitNode: (node, emitContext, emitCallback) => emitCallback(node, emitContext),

View file

@ -51,7 +51,7 @@ namespace ts {
location = value;
}
flattenDestructuring(context, node, value, location, emitAssignment, emitTempVariableAssignment, visitor);
flattenDestructuring(node, value, location, emitAssignment, emitTempVariableAssignment, visitor);
if (needsValue) {
expressions.push(value);
@ -87,13 +87,12 @@ namespace ts {
* @param visitor An optional visitor to use to visit expressions.
*/
export function flattenParameterDestructuring(
context: TransformationContext,
node: ParameterDeclaration,
value: Expression,
visitor?: (node: Node) => VisitResult<Node>) {
const declarations: VariableDeclaration[] = [];
flattenDestructuring(context, node, value, node, emitAssignment, emitTempVariableAssignment, visitor);
flattenDestructuring(node, value, node, emitAssignment, emitTempVariableAssignment, visitor);
return declarations;
@ -123,7 +122,6 @@ namespace ts {
* @param visitor An optional visitor to use to visit expressions.
*/
export function flattenVariableDestructuring(
context: TransformationContext,
node: VariableDeclaration,
value?: Expression,
visitor?: (node: Node) => VisitResult<Node>,
@ -131,7 +129,7 @@ namespace ts {
const declarations: VariableDeclaration[] = [];
let pendingAssignments: Expression[];
flattenDestructuring(context, node, value, node, emitAssignment, emitTempVariableAssignment, visitor);
flattenDestructuring(node, value, node, emitAssignment, emitTempVariableAssignment, visitor);
return declarations;
@ -181,7 +179,6 @@ namespace ts {
* @param visitor An optional visitor to use to visit expressions.
*/
export function flattenVariableDestructuringToExpression(
context: TransformationContext,
node: VariableDeclaration,
recordTempVariable: (name: Identifier) => void,
createAssignmentCallback?: (name: Identifier, value: Expression, location?: TextRange) => Expression,
@ -189,7 +186,7 @@ namespace ts {
const pendingAssignments: Expression[] = [];
flattenDestructuring(context, node, /*value*/ undefined, node, emitAssignment, emitTempVariableAssignment, visitor);
flattenDestructuring(node, /*value*/ undefined, node, emitAssignment, emitTempVariableAssignment, visitor);
const expression = inlineExpressions(pendingAssignments);
aggregateTransformFlags(expression);
@ -221,7 +218,6 @@ namespace ts {
}
function flattenDestructuring(
context: TransformationContext,
root: VariableDeclaration | ParameterDeclaration | BindingElement | BinaryExpression,
value: Expression,
location: TextRange,

View file

@ -396,7 +396,7 @@ namespace ts {
return visitYieldExpression(<YieldExpression>node);
case SyntaxKind.SuperKeyword:
return visitSuperKeyword(<PrimaryExpression>node);
return visitSuperKeyword();
case SyntaxKind.YieldExpression:
// `yield` will be handled by a generators transform.
@ -1120,7 +1120,7 @@ namespace ts {
createVariableStatement(
/*modifiers*/ undefined,
createVariableDeclarationList(
flattenParameterDestructuring(context, parameter, temp, visitor)
flattenParameterDestructuring(parameter, temp, visitor)
)
),
EmitFlags.CustomPrologue
@ -1692,7 +1692,7 @@ namespace ts {
if (decl.initializer) {
let assignment: Expression;
if (isBindingPattern(decl.name)) {
assignment = flattenVariableDestructuringToExpression(context, decl, hoistVariableDeclaration, /*createAssignmentCallback*/ undefined, visitor);
assignment = flattenVariableDestructuringToExpression(decl, hoistVariableDeclaration, /*createAssignmentCallback*/ undefined, visitor);
}
else {
assignment = createBinary(<Identifier>decl.name, SyntaxKind.EqualsToken, visitNode(decl.initializer, visitor, isExpression));
@ -1845,7 +1845,7 @@ namespace ts {
if (isBindingPattern(node.name)) {
const recordTempVariablesInLine = !enclosingVariableStatement
|| !hasModifier(enclosingVariableStatement, ModifierFlags.Export);
return flattenVariableDestructuring(context, node, /*value*/ undefined, visitor,
return flattenVariableDestructuring(node, /*value*/ undefined, visitor,
recordTempVariablesInLine ? undefined : hoistVariableDeclaration);
}
@ -1948,7 +1948,6 @@ namespace ts {
// This works whether the declaration is a var, let, or const.
// It will use rhsIterationValue _a[_i] as the initializer.
const declarations = flattenVariableDestructuring(
context,
firstOriginalDeclaration,
createElementAccess(rhsReference, counter),
visitor
@ -2550,15 +2549,15 @@ namespace ts {
break;
case SyntaxKind.PropertyAssignment:
expressions.push(transformPropertyAssignmentToExpression(node, <PropertyAssignment>property, receiver, node.multiLine));
expressions.push(transformPropertyAssignmentToExpression(<PropertyAssignment>property, receiver, node.multiLine));
break;
case SyntaxKind.ShorthandPropertyAssignment:
expressions.push(transformShorthandPropertyAssignmentToExpression(node, <ShorthandPropertyAssignment>property, receiver, node.multiLine));
expressions.push(transformShorthandPropertyAssignmentToExpression(<ShorthandPropertyAssignment>property, receiver, node.multiLine));
break;
case SyntaxKind.MethodDeclaration:
expressions.push(transformObjectLiteralMethodDeclarationToExpression(node, <MethodDeclaration>property, receiver, node.multiLine));
expressions.push(transformObjectLiteralMethodDeclarationToExpression(<MethodDeclaration>property, receiver, node.multiLine));
break;
default:
@ -2575,7 +2574,7 @@ namespace ts {
* @param property The PropertyAssignment node.
* @param receiver The receiver for the assignment.
*/
function transformPropertyAssignmentToExpression(node: ObjectLiteralExpression, property: PropertyAssignment, receiver: Expression, startsOnNewLine: boolean) {
function transformPropertyAssignmentToExpression(property: PropertyAssignment, receiver: Expression, startsOnNewLine: boolean) {
const expression = createAssignment(
createMemberAccessForPropertyName(
receiver,
@ -2597,7 +2596,7 @@ namespace ts {
* @param property The ShorthandPropertyAssignment node.
* @param receiver The receiver for the assignment.
*/
function transformShorthandPropertyAssignmentToExpression(node: ObjectLiteralExpression, property: ShorthandPropertyAssignment, receiver: Expression, startsOnNewLine: boolean) {
function transformShorthandPropertyAssignmentToExpression(property: ShorthandPropertyAssignment, receiver: Expression, startsOnNewLine: boolean) {
const expression = createAssignment(
createMemberAccessForPropertyName(
receiver,
@ -2619,7 +2618,7 @@ namespace ts {
* @param method The MethodDeclaration node.
* @param receiver The receiver for the assignment.
*/
function transformObjectLiteralMethodDeclarationToExpression(node: ObjectLiteralExpression, method: MethodDeclaration, receiver: Expression, startsOnNewLine: boolean) {
function transformObjectLiteralMethodDeclarationToExpression(method: MethodDeclaration, receiver: Expression, startsOnNewLine: boolean) {
const expression = createAssignment(
createMemberAccessForPropertyName(
receiver,
@ -2809,7 +2808,7 @@ namespace ts {
// expressions into an array literal.
const numElements = elements.length;
const segments = flatten(
spanMap(elements, partitionSpreadElement, (partition, visitPartition, start, end) =>
spanMap(elements, partitionSpreadElement, (partition, visitPartition, _start, end) =>
visitPartition(partition, multiLine, hasTrailingComma && end === numElements)
)
);
@ -2831,7 +2830,7 @@ namespace ts {
: visitSpanOfNonSpreadElements;
}
function visitSpanOfSpreadElements(chunk: Expression[], multiLine: boolean, hasTrailingComma: boolean): VisitResult<Expression> {
function visitSpanOfSpreadElements(chunk: Expression[]): VisitResult<Expression> {
return map(chunk, visitExpressionOfSpreadElement);
}
@ -3020,7 +3019,7 @@ namespace ts {
/**
* Visits the `super` keyword
*/
function visitSuperKeyword(node: PrimaryExpression): LeftHandSideExpression {
function visitSuperKeyword(): LeftHandSideExpression {
return enclosingNonAsyncFunctionBody
&& isClassElement(enclosingNonAsyncFunctionBody)
&& !hasModifier(enclosingNonAsyncFunctionBody, ModifierFlags.Static)

View file

@ -956,7 +956,7 @@ namespace ts {
* @param elements The elements to visit.
* @param multiLine Whether array literals created should be emitted on multiple lines.
*/
function visitElements(elements: NodeArray<Expression>, multiLine: boolean) {
function visitElements(elements: NodeArray<Expression>, _multiLine?: boolean) {
// [source]
// ar = [1, yield, 2];
//
@ -1102,7 +1102,7 @@ namespace ts {
createFunctionApply(
cacheExpression(visitNode(target, visitor, isLeftHandSideExpression)),
thisArg,
visitElements(node.arguments, /*multiLine*/ false),
visitElements(node.arguments),
/*location*/ node
),
node
@ -1131,7 +1131,7 @@ namespace ts {
createFunctionApply(
cacheExpression(visitNode(target, visitor, isExpression)),
thisArg,
visitElements(node.arguments, /*multiLine*/ false)
visitElements(node.arguments)
),
/*typeArguments*/ undefined,
[],

View file

@ -22,7 +22,8 @@ namespace ts {
function visitor(node: Node): VisitResult<Node> {
switch (node.kind) {
case SyntaxKind.ImportEqualsDeclaration:
return visitImportEqualsDeclaration(<ImportEqualsDeclaration>node);
// Elide `import=` as it is not legal with --module ES6
return undefined;
case SyntaxKind.ExportAssignment:
return visitExportAssignment(<ExportAssignment>node);
}
@ -30,11 +31,6 @@ namespace ts {
return node;
}
function visitImportEqualsDeclaration(node: ImportEqualsDeclaration): VisitResult<ImportEqualsDeclaration> {
// Elide `import=` as it is not legal with --module ES6
return undefined;
}
function visitExportAssignment(node: ExportAssignment): VisitResult<ExportAssignment> {
// Elide `export=` as it is not legal with --module ES6
return node.isExportEquals ? undefined : node;

View file

@ -758,7 +758,6 @@ namespace ts {
function transformInitializedVariable(node: VariableDeclaration): Expression {
if (isBindingPattern(node.name)) {
return flattenVariableDestructuringToExpression(
context,
node,
hoistVariableDeclaration,
createExportExpression

View file

@ -572,7 +572,9 @@ namespace ts {
return visitImportEqualsDeclaration(<ImportEqualsDeclaration>node);
case SyntaxKind.ExportDeclaration:
return visitExportDeclaration(<ExportDeclaration>node);
// ExportDeclarations are elided as they are handled via
// `appendExportsOfDeclaration`.
return undefined;
case SyntaxKind.ExportAssignment:
return visitExportAssignment(<ExportAssignment>node);
@ -628,16 +630,6 @@ namespace ts {
return singleOrMany(statements);
}
/**
* Visits an ExportDeclaration node. ExportDeclarations are elided as they are handled via
* `appendExportsOfDeclaration`.
*
* @param The node to visit.
*/
function visitExportDeclaration(node: ExportDeclaration): VisitResult<Statement> {
return undefined;
}
/**
* Visits an ExportAssignment node.
*
@ -816,7 +808,7 @@ namespace ts {
function transformInitializedVariable(node: VariableDeclaration, isExportedDeclaration: boolean): Expression {
const createAssignment = isExportedDeclaration ? createExportedVariableAssignment : createNonExportedVariableAssignment;
return isBindingPattern(node.name)
? flattenVariableDestructuringToExpression(context, node, hoistVariableDeclaration, createAssignment, destructuringVisitor)
? flattenVariableDestructuringToExpression(node, hoistVariableDeclaration, createAssignment, destructuringVisitor)
: createAssignment(node.name, visitNode(node.initializer, destructuringVisitor, isExpression));
}

View file

@ -569,7 +569,7 @@ namespace ts {
// HasLexicalDeclaration (N) : Determines if the argument identifier has a binding in this environment record that was created using
// a lexical declaration such as a LexicalDeclaration or a ClassDeclaration.
if (staticProperties.length) {
addInitializedPropertyStatements(statements, node, staticProperties, getLocalName(node));
addInitializedPropertyStatements(statements, staticProperties, getLocalName(node));
}
// Write any decorators of the node.
@ -763,7 +763,7 @@ namespace ts {
function visitClassExpression(node: ClassExpression): Expression {
const staticProperties = getInitializedProperties(node, /*isStatic*/ true);
const heritageClauses = visitNodes(node.heritageClauses, visitor, isHeritageClause);
const members = transformClassMembers(node, heritageClauses !== undefined);
const members = transformClassMembers(node, some(heritageClauses, c => c.token === SyntaxKind.ExtendsKeyword));
const classExpression = setOriginalNode(
createClassExpression(
@ -790,7 +790,7 @@ namespace ts {
// the body of a class with static initializers.
setEmitFlags(classExpression, EmitFlags.Indented | getEmitFlags(classExpression));
expressions.push(startOnNewLine(createAssignment(temp, classExpression)));
addRange(expressions, generateInitializedPropertyExpressions(node, staticProperties, temp));
addRange(expressions, generateInitializedPropertyExpressions(staticProperties, temp));
expressions.push(startOnNewLine(temp));
return inlineExpressions(expressions);
}
@ -836,7 +836,7 @@ namespace ts {
}
const parameters = transformConstructorParameters(constructor);
const body = transformConstructorBody(node, constructor, hasExtendsClause, parameters);
const body = transformConstructorBody(node, constructor, hasExtendsClause);
// constructor(${parameters}) {
// ${body}
@ -890,9 +890,8 @@ namespace ts {
* @param node The current class.
* @param constructor The current class constructor.
* @param hasExtendsClause A value indicating whether the class has an extends clause.
* @param parameters The transformed parameters for the constructor.
*/
function transformConstructorBody(node: ClassExpression | ClassDeclaration, constructor: ConstructorDeclaration, hasExtendsClause: boolean, parameters: ParameterDeclaration[]) {
function transformConstructorBody(node: ClassExpression | ClassDeclaration, constructor: ConstructorDeclaration, hasExtendsClause: boolean) {
const statements: Statement[] = [];
let indexOfFirstStatement = 0;
@ -944,7 +943,7 @@ namespace ts {
// }
//
const properties = getInitializedProperties(node, /*isStatic*/ false);
addInitializedPropertyStatements(statements, node, properties, createThis());
addInitializedPropertyStatements(statements, properties, createThis());
if (constructor) {
// The class already had a constructor, so we should add the existing statements, skipping the initial super call.
@ -1084,13 +1083,12 @@ namespace ts {
/**
* Generates assignment statements for property initializers.
*
* @param node The class node.
* @param properties An array of property declarations to transform.
* @param receiver The receiver on which each property should be assigned.
*/
function addInitializedPropertyStatements(statements: Statement[], node: ClassExpression | ClassDeclaration, properties: PropertyDeclaration[], receiver: LeftHandSideExpression) {
function addInitializedPropertyStatements(statements: Statement[], properties: PropertyDeclaration[], receiver: LeftHandSideExpression) {
for (const property of properties) {
const statement = createStatement(transformInitializedProperty(node, property, receiver));
const statement = createStatement(transformInitializedProperty(property, receiver));
setSourceMapRange(statement, moveRangePastModifiers(property));
setCommentRange(statement, property);
statements.push(statement);
@ -1100,14 +1098,13 @@ namespace ts {
/**
* Generates assignment expressions for property initializers.
*
* @param node The class node.
* @param properties An array of property declarations to transform.
* @param receiver The receiver on which each property should be assigned.
*/
function generateInitializedPropertyExpressions(node: ClassExpression | ClassDeclaration, properties: PropertyDeclaration[], receiver: LeftHandSideExpression) {
function generateInitializedPropertyExpressions(properties: PropertyDeclaration[], receiver: LeftHandSideExpression) {
const expressions: Expression[] = [];
for (const property of properties) {
const expression = transformInitializedProperty(node, property, receiver);
const expression = transformInitializedProperty(property, receiver);
expression.startsOnNewLine = true;
setSourceMapRange(expression, moveRangePastModifiers(property));
setCommentRange(expression, property);
@ -1120,11 +1117,10 @@ namespace ts {
/**
* Transforms a property initializer into an assignment statement.
*
* @param node The class containing the property.
* @param property The property declaration.
* @param receiver The object receiving the property assignment.
*/
function transformInitializedProperty(node: ClassExpression | ClassDeclaration, property: PropertyDeclaration, receiver: LeftHandSideExpression) {
function transformInitializedProperty(property: PropertyDeclaration, receiver: LeftHandSideExpression) {
const propertyName = visitPropertyNameOfClassElement(property);
const initializer = visitNode(property.initializer, visitor, isExpression);
const memberAccess = createMemberAccessForPropertyName(receiver, propertyName, /*location*/ propertyName);
@ -2350,7 +2346,6 @@ namespace ts {
const name = node.name;
if (isBindingPattern(name)) {
return flattenVariableDestructuringToExpression(
context,
node,
hoistVariableDeclaration,
createNamespaceExportExpression,

View file

@ -29,7 +29,7 @@ namespace ts {
}
}
function reportEmittedFiles(files: string[], host: CompilerHost): void {
function reportEmittedFiles(files: string[]): void {
if (!files || files.length == 0) {
return;
}
@ -111,7 +111,7 @@ namespace ts {
return count;
}
function getDiagnosticText(message: DiagnosticMessage, ...args: any[]): string {
function getDiagnosticText(_message: DiagnosticMessage, ..._args: any[]): string {
const diagnostic = createCompilerDiagnostic.apply(undefined, arguments);
return <string>diagnostic.messageText;
}
@ -250,8 +250,8 @@ namespace ts {
let compilerOptions: CompilerOptions; // Compiler options for compilation
let compilerHost: CompilerHost; // Compiler host
let hostGetSourceFile: typeof compilerHost.getSourceFile; // getSourceFile method from default host
let timerHandleForRecompilation: number; // Handle for 0.25s wait timer to trigger recompilation
let timerHandleForDirectoryChanges: number; // Handle for 0.25s wait timer to trigger directory change handler
let timerHandleForRecompilation: any; // Handle for 0.25s wait timer to trigger recompilation
let timerHandleForDirectoryChanges: any; // Handle for 0.25s wait timer to trigger directory change handler
// This map stores and reuses results of fileExists check that happen inside 'createProgram'
// This allows to save time in module resolution heavy scenarios when existence of the same file might be checked multiple times.
@ -456,7 +456,7 @@ namespace ts {
const sourceFile = hostGetSourceFile(fileName, languageVersion, onError);
if (sourceFile && isWatchSet(compilerOptions) && sys.watchFile) {
// Attach a file watcher
sourceFile.fileWatcher = sys.watchFile(sourceFile.fileName, (fileName: string, removed?: boolean) => sourceFileChanged(sourceFile, removed));
sourceFile.fileWatcher = sys.watchFile(sourceFile.fileName, (_fileName: string, removed?: boolean) => sourceFileChanged(sourceFile, removed));
}
return sourceFile;
}
@ -503,10 +503,14 @@ namespace ts {
}
function startTimerForHandlingDirectoryChanges() {
if (timerHandleForDirectoryChanges) {
clearTimeout(timerHandleForDirectoryChanges);
if (!sys.setTimeout || !sys.clearTimeout) {
return;
}
timerHandleForDirectoryChanges = setTimeout(directoryChangeHandler, 250);
if (timerHandleForDirectoryChanges) {
sys.clearTimeout(timerHandleForDirectoryChanges);
}
timerHandleForDirectoryChanges = sys.setTimeout(directoryChangeHandler, 250);
}
function directoryChangeHandler() {
@ -525,10 +529,14 @@ namespace ts {
// operations (such as saving all modified files in an editor) a chance to complete before we kick
// off a new compilation.
function startTimerForRecompilation() {
if (timerHandleForRecompilation) {
clearTimeout(timerHandleForRecompilation);
if (!sys.setTimeout || !sys.clearTimeout) {
return;
}
timerHandleForRecompilation = setTimeout(recompile, 250);
if (timerHandleForRecompilation) {
sys.clearTimeout(timerHandleForRecompilation);
}
timerHandleForRecompilation = sys.setTimeout(recompile, 250);
}
function recompile() {
@ -617,7 +625,7 @@ namespace ts {
reportDiagnostics(sortAndDeduplicateDiagnostics(diagnostics), compilerHost);
reportEmittedFiles(emitOutput.emittedFiles, compilerHost);
reportEmittedFiles(emitOutput.emittedFiles);
if (emitOutput.emitSkipped && diagnostics.length > 0) {
// If the emitter didn't emit anything, then pass that value along.

View file

@ -8,7 +8,10 @@
"outFile": "../../built/local/tsc.js",
"sourceMap": true,
"declaration": true,
"stripInternal": true
"stripInternal": true,
"target": "es5",
"noUnusedLocals": true,
"noUnusedParameters": true
},
"files": [
"core.ts",
@ -29,6 +32,7 @@
"transformers/es2015.ts",
"transformers/es5.ts",
"transformers/generators.ts",
"transformers/es5.ts",
"transformers/destructuring.ts",
"transformers/module/module.ts",
"transformers/module/system.ts",

View file

@ -45,6 +45,7 @@ namespace ts {
// Literals
NumericLiteral,
StringLiteral,
JsxText,
RegularExpressionLiteral,
NoSubstitutionTemplateLiteral,
// Pseudo-literals
@ -302,7 +303,6 @@ namespace ts {
JsxElement,
JsxSelfClosingElement,
JsxOpeningElement,
JsxText,
JsxClosingElement,
JsxAttribute,
JsxSpreadAttribute,

View file

@ -63,11 +63,11 @@ namespace ts {
// Completely ignore indentation for string writers. And map newlines to
// a single space.
writeLine: () => str += " ",
increaseIndent: () => { },
decreaseIndent: () => { },
increaseIndent: noop,
decreaseIndent: noop,
clear: () => str = "",
trackSymbol: () => { },
reportInaccessibleThisError: () => { }
trackSymbol: noop,
reportInaccessibleThisError: noop
};
}
@ -503,7 +503,7 @@ namespace ts {
return getFullWidth(name) === 0 ? "(Missing)" : getTextOfNode(name);
}
export function createDiagnosticForNode(node: Node, message: DiagnosticMessage, arg0?: any, arg1?: any, arg2?: any): Diagnostic {
export function createDiagnosticForNode(node: Node, message: DiagnosticMessage, arg0?: string | number, arg1?: string | number, arg2?: string | number): Diagnostic {
const sourceFile = getSourceFileOfNode(node);
const span = getErrorSpanForNode(sourceFile, node);
return createFileDiagnostic(sourceFile, span.start, span.length, message, arg0, arg1, arg2);
@ -2568,7 +2568,7 @@ namespace ts {
const options = host.getCompilerOptions();
// Emit on each source file
if (options.outFile || options.out) {
onBundledEmit(host, sourceFiles);
onBundledEmit(sourceFiles);
}
else {
for (const sourceFile of sourceFiles) {
@ -2601,7 +2601,7 @@ namespace ts {
action(jsFilePath, sourceMapFilePath, declarationFilePath, [sourceFile], /*isBundledEmit*/ false);
}
function onBundledEmit(host: EmitHost, sourceFiles: SourceFile[]) {
function onBundledEmit(sourceFiles: SourceFile[]) {
if (sourceFiles.length) {
const jsFilePath = options.outFile || options.out;
const sourceMapFilePath = getSourceMapFilePath(jsFilePath, options);
@ -4298,7 +4298,7 @@ namespace ts {
case ScriptTarget.ES2016:
return "lib.es2016.d.ts";
case ScriptTarget.ES2015:
return "lib.es2015.d.ts";
return "lib.es6.d.ts";
default:
return "lib.d.ts";

View file

@ -1331,18 +1331,18 @@ namespace ts {
export namespace Debug {
export const failNotOptional = shouldAssert(AssertionLevel.Normal)
? (message?: string) => assert(false, message || "Node not optional.")
: (message?: string) => {};
: noop;
export const failBadSyntaxKind = shouldAssert(AssertionLevel.Normal)
? (node: Node, message?: string) => assert(false, message || "Unexpected node.", () => `Node ${formatSyntaxKind(node.kind)} was unexpected.`)
: (node: Node, message?: string) => {};
: noop;
export const assertNode = shouldAssert(AssertionLevel.Normal)
? (node: Node, test: (node: Node) => boolean, message?: string) => assert(
test === undefined || test(node),
message || "Unexpected node.",
() => `Node ${formatSyntaxKind(node.kind)} did not pass test '${getFunctionName(test)}'.`)
: (node: Node, test: (node: Node) => boolean, message?: string) => {};
: noop;
function getFunctionName(func: Function) {
if (typeof func !== "function") {

View file

@ -47,19 +47,6 @@ namespace FourSlash {
ranges: Range[];
}
interface MemberListData {
result: {
maybeInaccurate: boolean;
isMemberCompletion: boolean;
entries: {
name: string;
type: string;
kind: string;
kindModifiers: string;
}[];
};
}
export interface Marker {
fileName: string;
position: number;
@ -178,15 +165,9 @@ namespace FourSlash {
// Return object may lack some functionalities for other purposes.
function createScriptSnapShot(sourceText: string): ts.IScriptSnapshot {
return {
getText: (start: number, end: number) => {
return sourceText.substr(start, end - start);
},
getLength: () => {
return sourceText.length;
},
getChangeRange: (oldSnapshot: ts.IScriptSnapshot) => {
return <ts.TextChangeRange>undefined;
}
getText: (start: number, end: number) => sourceText.substr(start, end - start),
getLength: () => sourceText.length,
getChangeRange: () => undefined
};
}
@ -419,9 +400,8 @@ namespace FourSlash {
public verifyErrorExistsBetweenMarkers(startMarkerName: string, endMarkerName: string, negative: boolean) {
const startMarker = this.getMarkerByName(startMarkerName);
const endMarker = this.getMarkerByName(endMarkerName);
const predicate = function(errorMinChar: number, errorLimChar: number, startPos: number, endPos: number) {
return ((errorMinChar === startPos) && (errorLimChar === endPos)) ? true : false;
};
const predicate = (errorMinChar: number, errorLimChar: number, startPos: number, endPos: number) =>
((errorMinChar === startPos) && (errorLimChar === endPos)) ? true : false;
const exists = this.anyErrorInRange(predicate, startMarker, endMarker);
@ -471,14 +451,12 @@ namespace FourSlash {
let predicate: (errorMinChar: number, errorLimChar: number, startPos: number, endPos: number) => boolean;
if (after) {
predicate = function(errorMinChar: number, errorLimChar: number, startPos: number, endPos: number) {
return ((errorMinChar >= startPos) && (errorLimChar >= startPos)) ? true : false;
};
predicate = (errorMinChar: number, errorLimChar: number, startPos: number) =>
((errorMinChar >= startPos) && (errorLimChar >= startPos)) ? true : false;
}
else {
predicate = function(errorMinChar: number, errorLimChar: number, startPos: number, endPos: number) {
return ((errorMinChar <= startPos) && (errorLimChar <= startPos)) ? true : false;
};
predicate = (errorMinChar: number, errorLimChar: number, startPos: number) =>
((errorMinChar <= startPos) && (errorLimChar <= startPos)) ? true : false;
}
const exists = this.anyErrorInRange(predicate, marker);
@ -1179,7 +1157,7 @@ namespace FourSlash {
private alignmentForExtraInfo = 50;
private spanInfoToString(pos: number, spanInfo: ts.TextSpan, prefixString: string) {
private spanInfoToString(spanInfo: ts.TextSpan, prefixString: string) {
let resultString = "SpanInfo: " + JSON.stringify(spanInfo);
if (spanInfo) {
const spanString = this.activeFile.content.substr(spanInfo.start, spanInfo.length);
@ -1230,7 +1208,7 @@ namespace FourSlash {
startColumn = 0;
length = 0;
}
const spanInfo = this.spanInfoToString(pos, getSpanAtPos(pos), prefixString);
const spanInfo = this.spanInfoToString(getSpanAtPos(pos), prefixString);
if (previousSpanInfo && previousSpanInfo !== spanInfo) {
addSpanInfoString();
previousSpanInfo = spanInfo;
@ -1300,10 +1278,10 @@ namespace FourSlash {
}
}
emitOutput.outputFiles.forEach((outputFile, idx, array) => {
for (const outputFile of emitOutput.outputFiles) {
const fileName = "FileName : " + outputFile.name + Harness.IO.newLine();
resultString = resultString + fileName + outputFile.text;
});
}
resultString += Harness.IO.newLine();
});
@ -1328,7 +1306,7 @@ namespace FourSlash {
}
public printBreakpointLocation(pos: number) {
Harness.IO.log("\n**Pos: " + pos + " " + this.spanInfoToString(pos, this.getBreakpointStatementLocation(pos), " "));
Harness.IO.log("\n**Pos: " + pos + " " + this.spanInfoToString(this.getBreakpointStatementLocation(pos), " "));
}
public printBreakpointAtCurrentLocation() {
@ -1830,7 +1808,7 @@ namespace FourSlash {
return result;
}
private rangeText({fileName, start, end}: Range, more = false): string {
private rangeText({fileName, start, end}: Range): string {
return this.getFileContent(fileName).slice(start, end);
}
@ -1925,7 +1903,7 @@ namespace FourSlash {
}
public printNameOrDottedNameSpans(pos: number) {
Harness.IO.log(this.spanInfoToString(pos, this.getNameOrDottedNameSpan(pos), "**"));
Harness.IO.log(this.spanInfoToString(this.getNameOrDottedNameSpan(pos), "**"));
}
private verifyClassifications(expected: { classificationType: string; text: string; textSpan?: TextSpan }[], actual: ts.ClassifiedSpan[]) {

View file

@ -220,9 +220,7 @@ namespace Utils {
}
export function sourceFileToJSON(file: ts.Node): string {
return JSON.stringify(file, (k, v) => {
return isNodeOrArray(v) ? serializeNode(v) : v;
}, " ");
return JSON.stringify(file, (_, v) => isNodeOrArray(v) ? serializeNode(v) : v, " ");
function getKindName(k: number | string): string {
if (typeof k === "string") {
@ -692,7 +690,7 @@ namespace Harness {
export const getCurrentDirectory = () => "";
export const args = () => <string[]>[];
export const getExecutingFilePath = () => "";
export const exit = (exitCode: number) => { };
export const exit = ts.noop;
export const getDirectories = () => <string[]>[];
export let log = (s: string) => console.log(s);
@ -742,7 +740,7 @@ namespace Harness {
}
}
export function createDirectory(path: string) {
export function createDirectory() {
// Do nothing (?)
}
@ -750,7 +748,7 @@ namespace Harness {
Http.writeToServerSync(serverRoot + path, "DELETE");
}
export function directoryExists(path: string): boolean {
export function directoryExists(): boolean {
return false;
}
@ -792,7 +790,7 @@ namespace Harness {
return response.status === 200;
}
export function _listFilesImpl(path: string, spec?: RegExp, options?: any) {
export let listFiles = Utils.memoize((path: string, spec?: RegExp): string[] => {
const response = Http.getFileFromServerSync(serverRoot + path);
if (response.status === 200) {
const results = response.responseText.split(",");
@ -806,8 +804,7 @@ namespace Harness {
else {
return [""];
}
};
export let listFiles = Utils.memoize(_listFilesImpl);
});
export function readFile(file: string) {
const response = Http.getFileFromServerSync(serverRoot + file);
@ -991,7 +988,7 @@ namespace Harness {
}
}
function getSourceFile(fileName: string, languageVersion: ts.ScriptTarget) {
function getSourceFile(fileName: string) {
fileName = ts.normalizePath(fileName);
const path = ts.toPath(fileName, currentDirectory, getCanonicalFileName);
if (fileMap.contains(path)) {
@ -1051,7 +1048,7 @@ namespace Harness {
getDirectories: d => {
const path = ts.toPath(d, currentDirectory, getCanonicalFileName);
const result: string[] = [];
fileMap.forEachValue((key, value) => {
fileMap.forEachValue(key => {
if (key.indexOf(path) === 0 && key.lastIndexOf("/") > path.length) {
let dirName = key.substr(path.length, key.indexOf("/", path.length + 1) - path.length);
if (dirName[0] === "/") {
@ -1669,9 +1666,9 @@ namespace Harness {
}
// This does not need to exist strictly speaking, but many tests will need to be updated if it's removed
export function compileString(code: string, unitName: string, callback: (result: CompilerResult) => void) {
export function compileString(_code: string, _unitName: string, _callback: (result: CompilerResult) => void) {
// NEWTODO: Re-implement 'compileString'
throw new Error("compileString NYI");
return ts.notImplemented();
}
export interface GeneratedFile {
@ -1853,8 +1850,8 @@ namespace Harness {
// unit tests always list files explicitly
const parseConfigHost: ts.ParseConfigHost = {
useCaseSensitiveFileNames: false,
readDirectory: (name) => [],
fileExists: (name) => true,
readDirectory: () => [],
fileExists: () => true,
readFile: (name) => ts.forEach(testUnitData, data => data.name.toLowerCase() === name.toLowerCase() ? data.content : undefined)
};

View file

@ -165,7 +165,7 @@ namespace Harness.LanguageService {
throw new Error("No script with name '" + fileName + "'");
}
public openFile(fileName: string, content?: string, scriptKindName?: string): void {
public openFile(_fileName: string, _content?: string, _scriptKindName?: string): void {
}
/**
@ -198,7 +198,7 @@ namespace Harness.LanguageService {
const script = this.getScriptInfo(fileName);
return script ? new ScriptSnapshot(script) : undefined;
}
getScriptKind(fileName: string): ts.ScriptKind { return ts.ScriptKind.Unknown; }
getScriptKind(): ts.ScriptKind { return ts.ScriptKind.Unknown; }
getScriptVersion(fileName: string): string {
const script = this.getScriptInfo(fileName);
return script ? script.version.toString() : undefined;
@ -214,7 +214,7 @@ namespace Harness.LanguageService {
this.getCurrentDirectory(),
(p) => this.virtualFileSystem.getAccessibleFileSystemEntries(p));
}
readFile(path: string, encoding?: string): string {
readFile(path: string): string {
const snapshot = this.getScriptSnapshot(path);
return snapshot.getText(0, snapshot.getLength());
}
@ -223,9 +223,9 @@ namespace Harness.LanguageService {
}
log(s: string): void { }
trace(s: string): void { }
error(s: string): void { }
log(_: string): void { }
trace(_: string): void { }
error(_: string): void { }
}
export class NativeLanguageServiceAdapter implements LanguageServiceAdapter {
@ -308,19 +308,15 @@ namespace Harness.LanguageService {
const nativeScriptSnapshot = this.nativeHost.getScriptSnapshot(fileName);
return nativeScriptSnapshot && new ScriptSnapshotProxy(nativeScriptSnapshot);
}
getScriptKind(fileName: string): ts.ScriptKind { return this.nativeHost.getScriptKind(fileName); }
getScriptKind(): ts.ScriptKind { return this.nativeHost.getScriptKind(); }
getScriptVersion(fileName: string): string { return this.nativeHost.getScriptVersion(fileName); }
getLocalizedDiagnosticMessages(): string { return JSON.stringify({}); }
readDirectory(rootDir: string, extension: string): string {
throw new Error("NYI");
}
readDirectoryNames(path: string): string {
throw new Error("Not implemented.");
}
readFileNames(path: string): string {
throw new Error("Not implemented.");
readDirectory(_rootDir: string, _extension: string): string {
return ts.notImplemented();
}
readDirectoryNames = ts.notImplemented;
readFileNames = ts.notImplemented;
fileExists(fileName: string) { return this.getScriptInfo(fileName) !== undefined; }
readFile(fileName: string) {
const snapshot = this.nativeHost.getScriptSnapshot(fileName);
@ -329,7 +325,7 @@ namespace Harness.LanguageService {
log(s: string): void { this.nativeHost.log(s); }
trace(s: string): void { this.nativeHost.trace(s); }
error(s: string): void { this.nativeHost.error(s); }
directoryExists(directoryName: string): boolean {
directoryExists(): boolean {
// for tests pessimistically assume that directory always exists
return true;
}
@ -338,8 +334,8 @@ namespace Harness.LanguageService {
class ClassifierShimProxy implements ts.Classifier {
constructor(private shim: ts.ClassifierShim) {
}
getEncodedLexicalClassifications(text: string, lexState: ts.EndOfLineState, classifyKeywordsInGenerics?: boolean): ts.Classifications {
throw new Error("NYI");
getEncodedLexicalClassifications(_text: string, _lexState: ts.EndOfLineState, _classifyKeywordsInGenerics?: boolean): ts.Classifications {
return ts.notImplemented();
}
getClassificationsForLine(text: string, lexState: ts.EndOfLineState, classifyKeywordsInGenerics?: boolean): ts.ClassificationResult {
const result = this.shim.getClassificationsForLine(text, lexState, classifyKeywordsInGenerics).split("\n");
@ -411,7 +407,7 @@ namespace Harness.LanguageService {
getCompletionEntryDetails(fileName: string, position: number, entryName: string): ts.CompletionEntryDetails {
return unwrapJSONCallResult(this.shim.getCompletionEntryDetails(fileName, position, entryName));
}
getCompletionEntrySymbol(fileName: string, position: number, entryName: string): ts.Symbol {
getCompletionEntrySymbol(): ts.Symbol {
throw new Error("getCompletionEntrySymbol not implemented across the shim layer.");
}
getQuickInfoAtPosition(fileName: string, position: number): ts.QuickInfo {
@ -490,7 +486,7 @@ namespace Harness.LanguageService {
isValidBraceCompletionAtPosition(fileName: string, position: number, openingBrace: number): boolean {
return unwrapJSONCallResult(this.shim.isValidBraceCompletionAtPosition(fileName, position, openingBrace));
}
getCodeFixesAtPosition(fileName: string, start: number, end: number, errorCodes: number[]): ts.CodeAction[] {
getCodeFixesAtPosition(): ts.CodeAction[] {
throw new Error("Not supported on the shim.");
}
getEmitOutput(fileName: string): ts.EmitOutput {
@ -499,10 +495,10 @@ namespace Harness.LanguageService {
getProgram(): ts.Program {
throw new Error("Program can not be marshaled across the shim layer.");
}
getNonBoundSourceFile(fileName: string): ts.SourceFile {
getNonBoundSourceFile(): ts.SourceFile {
throw new Error("SourceFile can not be marshaled across the shim layer.");
}
getSourceFile(fileName: string): ts.SourceFile {
getSourceFile(): ts.SourceFile {
throw new Error("SourceFile can not be marshaled across the shim layer.");
}
dispose(): void { this.shim.dispose({}); }
@ -572,11 +568,11 @@ namespace Harness.LanguageService {
super(cancellationToken, settings);
}
onMessage(message: string): void {
onMessage(): void {
}
writeMessage(message: string): void {
writeMessage(): void {
}
@ -604,11 +600,11 @@ namespace Harness.LanguageService {
this.newLine = this.host.getNewLine();
}
onMessage(message: string): void {
onMessage(): void {
}
writeMessage(message: string): void {
writeMessage(_message: string): void {
}
write(message: string): void {
@ -624,7 +620,7 @@ namespace Harness.LanguageService {
return snapshot && snapshot.getText(0, snapshot.getLength());
}
writeFile(name: string, text: string, writeByteOrderMark: boolean): void {
writeFile(): void {
}
resolvePath(path: string): string {
@ -635,7 +631,7 @@ namespace Harness.LanguageService {
return !!this.host.getScriptSnapshot(path);
}
directoryExists(path: string): boolean {
directoryExists(): boolean {
// for tests assume that directory exists
return true;
}
@ -644,18 +640,18 @@ namespace Harness.LanguageService {
return "";
}
exit(exitCode: number): void {
exit(): void {
}
createDirectory(directoryName: string): void {
throw new Error("Not Implemented Yet.");
createDirectory(_directoryName: string): void {
return ts.notImplemented();
}
getCurrentDirectory(): string {
return this.host.getCurrentDirectory();
}
getDirectories(path: string): string[] {
getDirectories(): string[] {
return [];
}
@ -663,16 +659,16 @@ namespace Harness.LanguageService {
return ts.sys.getEnvironmentVariable(name);
}
readDirectory(path: string, extension?: string[], exclude?: string[], include?: string[]): string[] {
throw new Error("Not implemented Yet.");
readDirectory(_path: string, _extension?: string[], _exclude?: string[], _include?: string[]): string[] {
return ts.notImplemented();
}
watchFile(fileName: string, callback: (fileName: string) => void): ts.FileWatcher {
return { close() { } };
watchFile(): ts.FileWatcher {
return { close: ts.noop };
}
watchDirectory(path: string, callback: (path: string) => void, recursive?: boolean): ts.FileWatcher {
return { close() { } };
watchDirectory(): ts.FileWatcher {
return { close: ts.noop };
}
close(): void {
@ -717,7 +713,7 @@ namespace Harness.LanguageService {
clearTimeout(timeoutId);
}
setImmediate(callback: (...args: any[]) => void, ms: number, ...args: any[]): any {
setImmediate(callback: (...args: any[]) => void, _ms: number, ...args: any[]): any {
return setImmediate(callback, args);
}
@ -760,6 +756,6 @@ namespace Harness.LanguageService {
getHost() { return this.host; }
getLanguageService(): ts.LanguageService { return this.client; }
getClassifier(): ts.Classifier { throw new Error("getClassifier is not available using the server interface."); }
getPreProcessedFileInfo(fileName: string, fileContents: string): ts.PreProcessedFileInfo { throw new Error("getPreProcessedFileInfo is not available using the server interface."); }
getPreProcessedFileInfo(): ts.PreProcessedFileInfo { throw new Error("getPreProcessedFileInfo is not available using the server interface."); }
}
}

View file

@ -173,7 +173,7 @@ namespace Playback {
path => callAndRecord(underlying.fileExists(path), recordLog.fileExists, { path }),
memoize(path => {
// If we read from the file, it must exist
if (findFileByPath(wrapper, replayLog.filesRead, path, /*throwFileNotFoundError*/ false)) {
if (findFileByPath(replayLog.filesRead, path, /*throwFileNotFoundError*/ false)) {
return true;
}
else {
@ -217,7 +217,7 @@ namespace Playback {
recordLog.filesRead.push(logEntry);
return result;
},
memoize(path => findFileByPath(wrapper, replayLog.filesRead, path, /*throwFileNotFoundError*/ true).contents));
memoize(path => findFileByPath(replayLog.filesRead, path, /*throwFileNotFoundError*/ true).contents));
wrapper.readDirectory = recordReplay(wrapper.readDirectory, underlying)(
(path, extensions, exclude, include) => {
@ -226,7 +226,7 @@ namespace Playback {
recordLog.directoriesRead.push(logEntry);
return result;
},
(path, extensions, exclude) => {
path => {
// Because extensions is an array of all allowed extension, we will want to merge each of the replayLog.directoriesRead into one
// if each of the directoriesRead has matched path with the given path (directory with same path but different extension will considered
// different entry).
@ -244,7 +244,7 @@ namespace Playback {
wrapper.writeFile = recordReplay(wrapper.writeFile, underlying)(
(path: string, contents: string) => callAndRecord(underlying.writeFile(path, contents), recordLog.filesWritten, { path, contents, bom: false }),
(path: string, contents: string) => noOpReplay("writeFile"));
() => noOpReplay("writeFile"));
wrapper.exit = (exitCode) => {
if (recordLog !== undefined) {
@ -295,7 +295,7 @@ namespace Playback {
return results[0].result;
}
function findFileByPath(wrapper: { resolvePath(s: string): string }, logArray: IOLogFile[],
function findFileByPath(logArray: IOLogFile[],
expectedPath: string, throwFileNotFoundError: boolean): FileInformation {
const normalizedName = ts.normalizePath(expectedPath).toLowerCase();
// Try to find the result through normal fileName
@ -314,7 +314,7 @@ namespace Playback {
}
}
function noOpReplay(name: string) {
function noOpReplay(_name: string) {
// console.log("Swallowed write operation during replay: " + name);
}
@ -322,13 +322,17 @@ namespace Playback {
const wrapper: PlaybackIO = <any>{};
initWrapper(wrapper, underlying);
wrapper.directoryName = (path): string => { throw new Error("NotSupported"); };
wrapper.createDirectory = (path): void => { throw new Error("NotSupported"); };
wrapper.directoryExists = (path): boolean => { throw new Error("NotSupported"); };
wrapper.deleteFile = (path): void => { throw new Error("NotSupported"); };
wrapper.listFiles = (path, filter, options): string[] => { throw new Error("NotSupported"); };
wrapper.directoryName = notSupported;
wrapper.createDirectory = notSupported;
wrapper.directoryExists = notSupported;
wrapper.deleteFile = notSupported;
wrapper.listFiles = notSupported;
return wrapper;
function notSupported(): never {
throw new Error("NotSupported");
}
}
export function wrapSystem(underlying: ts.System): PlaybackSystem {

View file

@ -178,7 +178,7 @@ class ProjectRunner extends RunnerBase {
function createCompilerHost(): ts.CompilerHost {
return {
getSourceFile,
getDefaultLibFileName: options => Harness.Compiler.defaultLibFileName,
getDefaultLibFileName: () => Harness.Compiler.defaultLibFileName,
writeFile,
getCurrentDirectory,
getCanonicalFileName: Harness.Compiler.getCanonicalFileName,
@ -421,7 +421,7 @@ class ProjectRunner extends RunnerBase {
return undefined;
}
function writeFile(fileName: string, data: string, writeByteOrderMark: boolean) {
function writeFile() {
}
}

View file

@ -222,5 +222,5 @@ else {
}
if (!runUnitTests) {
// patch `describe` to skip unit tests
describe = <any>(function () { });
describe = ts.noop as any;
}

View file

@ -10,7 +10,10 @@
"stripInternal": true,
"types": [
"node", "mocha", "chai"
]
],
"target": "es5",
"noUnusedLocals": true,
"noUnusedParameters": true
},
"files": [
"../compiler/core.ts",
@ -31,6 +34,7 @@
"../compiler/transformers/es2015.ts",
"../compiler/transformers/es5.ts",
"../compiler/transformers/generators.ts",
"../compiler/transformers/es5.ts",
"../compiler/transformers/destructuring.ts",
"../compiler/transformers/module/module.ts",
"../compiler/transformers/module/system.ts",

View file

@ -21,16 +21,15 @@ namespace ts {
args: <string[]>[],
newLine: "\r\n",
useCaseSensitiveFileNames: false,
write: (s: string) => {
},
readFile: (path: string, encoding?: string): string => {
write: noop,
readFile: (path: string): string => {
return path in fileMap ? fileMap[path].content : undefined;
},
writeFile: (path: string, data: string, writeByteOrderMark?: boolean) => {
throw new Error("NYI");
writeFile: (_path: string, _data: string, _writeByteOrderMark?: boolean) => {
return ts.notImplemented();
},
resolvePath: (path: string): string => {
throw new Error("NYI");
resolvePath: (_path: string): string => {
return ts.notImplemented();
},
fileExists: (path: string): boolean => {
return path in fileMap;
@ -38,31 +37,25 @@ namespace ts {
directoryExists: (path: string): boolean => {
return existingDirectories[path] || false;
},
createDirectory: (path: string) => {
},
createDirectory: noop,
getExecutingFilePath: (): string => {
return "";
},
getCurrentDirectory: (): string => {
return "";
},
getDirectories: (path: string) => [],
getEnvironmentVariable: (name: string) => "",
readDirectory: (path: string, extension?: string[], exclude?: string[], include?: string[]): string[] => {
throw new Error("NYI");
},
exit: (exitCode?: number) => {
},
watchFile: (path, callback) => {
return {
close: () => { }
};
},
watchDirectory: (path, callback, recursive?) => {
return {
close: () => { }
};
getDirectories: () => [],
getEnvironmentVariable: () => "",
readDirectory: (_path: string, _extension?: string[], _exclude?: string[], _include?: string[]): string[] => {
return ts.notImplemented();
},
exit: noop,
watchFile: () => ({
close: noop
}),
watchDirectory: () => ({
close: noop
}),
setTimeout,
clearTimeout,
setImmediate,
@ -72,14 +65,14 @@ namespace ts {
function createProject(rootFile: string, serverHost: server.ServerHost): { project: server.Project, rootScriptInfo: server.ScriptInfo } {
const logger: server.Logger = {
close() { },
close: noop,
hasLevel: () => false,
loggingEnabled: () => false,
perftrc: (s: string) => { },
info: (s: string) => { },
startGroup: () => { },
endGroup: () => { },
msg: (s: string, type?: string) => { },
perftrc: noop,
info: noop,
startGroup: noop,
endGroup: noop,
msg: noop,
getLogFileName: (): string => undefined
};
@ -116,10 +109,7 @@ namespace ts {
const originalFileExists = serverHost.fileExists;
{
// patch fileExists to make sure that disk is not touched
serverHost.fileExists = (fileName): boolean => {
assert.isTrue(false, "fileExists should not be called");
return false;
};
serverHost.fileExists = notImplemented;
const newContent = `import {x} from "f1"
var x: string = 1;`;

View file

@ -60,7 +60,7 @@ namespace ts {
assertParseResult(["--lib", "es5,invalidOption", "0.ts"],
{
errors: [{
messageText: "Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'dom', 'dom.iterable', 'webworker', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2017.object', 'es2017.sharedmemory'",
messageText: "Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'dom', 'dom.iterable', 'webworker', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2017.object', 'es2017.sharedmemory'",
category: ts.Diagnostics.Argument_for_0_option_must_be_Colon_1.category,
code: ts.Diagnostics.Argument_for_0_option_must_be_Colon_1.code,
@ -87,7 +87,7 @@ namespace ts {
start: undefined,
length: undefined,
}, {
messageText: "Argument for '--jsx' option must be: 'preserve', 'react'",
messageText: "Argument for '--jsx' option must be: 'preserve', 'react'",
category: ts.Diagnostics.Argument_for_0_option_must_be_Colon_1.category,
code: ts.Diagnostics.Argument_for_0_option_must_be_Colon_1.code,
@ -113,7 +113,7 @@ namespace ts {
start: undefined,
length: undefined,
}, {
messageText: "Argument for '--module' option must be: 'none', 'commonjs', 'amd', 'system', 'umd', 'es6', 'es2015'",
messageText: "Argument for '--module' option must be: 'none', 'commonjs', 'amd', 'system', 'umd', 'es6', 'es2015'",
category: ts.Diagnostics.Argument_for_0_option_must_be_Colon_1.category,
code: ts.Diagnostics.Argument_for_0_option_must_be_Colon_1.code,
@ -139,7 +139,7 @@ namespace ts {
start: undefined,
length: undefined,
}, {
messageText: "Argument for '--newLine' option must be: 'crlf', 'lf'",
messageText: "Argument for '--newLine' option must be: 'crlf', 'lf'",
category: ts.Diagnostics.Argument_for_0_option_must_be_Colon_1.category,
code: ts.Diagnostics.Argument_for_0_option_must_be_Colon_1.code,
@ -165,7 +165,7 @@ namespace ts {
start: undefined,
length: undefined,
}, {
messageText: "Argument for '--target' option must be: 'es3', 'es5', 'es6', 'es2015', 'es2016', 'es2017'",
messageText: "Argument for '--target' option must be: 'es3', 'es5', 'es6', 'es2015', 'es2016', 'es2017'",
category: ts.Diagnostics.Argument_for_0_option_must_be_Colon_1.category,
code: ts.Diagnostics.Argument_for_0_option_must_be_Colon_1.code,
@ -191,7 +191,7 @@ namespace ts {
start: undefined,
length: undefined,
}, {
messageText: "Argument for '--moduleResolution' option must be: 'node', 'classic'",
messageText: "Argument for '--moduleResolution' option must be: 'node', 'classic'",
category: ts.Diagnostics.Argument_for_0_option_must_be_Colon_1.category,
code: ts.Diagnostics.Argument_for_0_option_must_be_Colon_1.code,
@ -263,7 +263,7 @@ namespace ts {
assertParseResult(["--lib", "es5,", "es7", "0.ts"],
{
errors: [{
messageText: "Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'dom', 'dom.iterable', 'webworker', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2017.object', 'es2017.sharedmemory'",
messageText: "Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'dom', 'dom.iterable', 'webworker', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2017.object', 'es2017.sharedmemory'",
category: ts.Diagnostics.Argument_for_0_option_must_be_Colon_1.category,
code: ts.Diagnostics.Argument_for_0_option_must_be_Colon_1.code,
@ -283,7 +283,7 @@ namespace ts {
assertParseResult(["--lib", "es5, ", "es7", "0.ts"],
{
errors: [{
messageText: "Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'dom', 'dom.iterable', 'webworker', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2017.object', 'es2017.sharedmemory'",
messageText: "Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'dom', 'dom.iterable', 'webworker', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2017.object', 'es2017.sharedmemory'",
category: ts.Diagnostics.Argument_for_0_option_must_be_Colon_1.category,
code: ts.Diagnostics.Argument_for_0_option_must_be_Colon_1.code,

View file

@ -94,7 +94,7 @@ namespace ts {
file: undefined,
start: 0,
length: 0,
messageText: "Argument for '--jsx' option must be: 'preserve', 'react'",
messageText: "Argument for '--jsx' option must be: 'preserve', 'react'",
code: Diagnostics.Argument_for_0_option_must_be_Colon_1.code,
category: Diagnostics.Argument_for_0_option_must_be_Colon_1.category
}]
@ -122,7 +122,7 @@ namespace ts {
file: undefined,
start: 0,
length: 0,
messageText: "Argument for '--module' option must be: 'none', 'commonjs', 'amd', 'system', 'umd', 'es6', 'es2015'",
messageText: "Argument for '--module' option must be: 'none', 'commonjs', 'amd', 'system', 'umd', 'es6', 'es2015'",
code: Diagnostics.Argument_for_0_option_must_be_Colon_1.code,
category: Diagnostics.Argument_for_0_option_must_be_Colon_1.category
}]
@ -150,7 +150,7 @@ namespace ts {
file: undefined,
start: 0,
length: 0,
messageText: "Argument for '--newLine' option must be: 'crlf', 'lf'",
messageText: "Argument for '--newLine' option must be: 'crlf', 'lf'",
code: Diagnostics.Argument_for_0_option_must_be_Colon_1.code,
category: Diagnostics.Argument_for_0_option_must_be_Colon_1.category
}]
@ -176,7 +176,7 @@ namespace ts {
file: undefined,
start: 0,
length: 0,
messageText: "Argument for '--target' option must be: 'es3', 'es5', 'es6', 'es2015', 'es2016', 'es2017'",
messageText: "Argument for '--target' option must be: 'es3', 'es5', 'es6', 'es2015', 'es2016', 'es2017'",
code: Diagnostics.Argument_for_0_option_must_be_Colon_1.code,
category: Diagnostics.Argument_for_0_option_must_be_Colon_1.category
}]
@ -202,7 +202,7 @@ namespace ts {
file: undefined,
start: 0,
length: 0,
messageText: "Argument for '--moduleResolution' option must be: 'node', 'classic'",
messageText: "Argument for '--moduleResolution' option must be: 'node', 'classic'",
code: Diagnostics.Argument_for_0_option_must_be_Colon_1.code,
category: Diagnostics.Argument_for_0_option_must_be_Colon_1.category
}]
@ -233,7 +233,7 @@ namespace ts {
file: undefined,
start: 0,
length: 0,
messageText: "Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'dom', 'dom.iterable', 'webworker', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2017.object', 'es2017.sharedmemory'",
messageText: "Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'dom', 'dom.iterable', 'webworker', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2017.object', 'es2017.sharedmemory'",
code: Diagnostics.Argument_for_0_option_must_be_Colon_1.code,
category: Diagnostics.Argument_for_0_option_must_be_Colon_1.category
}]
@ -264,7 +264,7 @@ namespace ts {
file: undefined,
start: 0,
length: 0,
messageText: "Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'dom', 'dom.iterable', 'webworker', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2017.object', 'es2017.sharedmemory'",
messageText: "Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'dom', 'dom.iterable', 'webworker', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2017.object', 'es2017.sharedmemory'",
code: Diagnostics.Argument_for_0_option_must_be_Colon_1.code,
category: Diagnostics.Argument_for_0_option_must_be_Colon_1.category
}]
@ -295,7 +295,7 @@ namespace ts {
file: undefined,
start: 0,
length: 0,
messageText: "Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'dom', 'dom.iterable', 'webworker', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2017.object', 'es2017.sharedmemory'",
messageText: "Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'dom', 'dom.iterable', 'webworker', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2017.object', 'es2017.sharedmemory'",
code: Diagnostics.Argument_for_0_option_must_be_Colon_1.code,
category: Diagnostics.Argument_for_0_option_must_be_Colon_1.category
}]
@ -326,7 +326,7 @@ namespace ts {
file: undefined,
start: 0,
length: 0,
messageText: "Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'dom', 'dom.iterable', 'webworker', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2017.object', 'es2017.sharedmemory'",
messageText: "Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'dom', 'dom.iterable', 'webworker', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2017.object', 'es2017.sharedmemory'",
code: Diagnostics.Argument_for_0_option_must_be_Colon_1.code,
category: Diagnostics.Argument_for_0_option_must_be_Colon_1.category
}]

View file

@ -101,7 +101,7 @@ namespace ts {
Harness.Baseline.runBaseline("JSDocParsing/DocComments.parsesCorrectly." + name + ".json",
() => JSON.stringify(comment.jsDoc,
(k, v) => v && v.pos !== undefined ? JSON.parse(Utils.sourceFileToJSON(v)) : v, 4));
(_, v) => v && v.pos !== undefined ? JSON.parse(Utils.sourceFileToJSON(v)) : v, 4));
});
}

View file

@ -290,7 +290,7 @@ namespace ts {
return path in files ? createSourceFile(fileName, files[path], languageVersion) : undefined;
},
getDefaultLibFileName: () => "lib.d.ts",
writeFile: (fileName, content): void => { throw new Error("NotImplemented"); },
writeFile: notImplemented,
getCurrentDirectory: () => currentDirectory,
getDirectories: () => [],
getCanonicalFileName: fileName => fileName.toLowerCase(),
@ -300,7 +300,7 @@ namespace ts {
const path = normalizePath(combinePaths(currentDirectory, fileName));
return path in files;
},
readFile: (fileName): string => { throw new Error("NotImplemented"); }
readFile: notImplemented
};
const program = createProgram(rootFiles, options, host);
@ -370,7 +370,7 @@ export = C;
return path in files ? createSourceFile(fileName, files[path], languageVersion) : undefined;
},
getDefaultLibFileName: () => "lib.d.ts",
writeFile: (fileName, content): void => { throw new Error("NotImplemented"); },
writeFile: notImplemented,
getCurrentDirectory: () => currentDirectory,
getDirectories: () => [],
getCanonicalFileName,
@ -380,7 +380,7 @@ export = C;
const path = getCanonicalFileName(normalizePath(combinePaths(currentDirectory, fileName)));
return path in files;
},
readFile: (fileName): string => { throw new Error("NotImplemented"); }
readFile: notImplemented
};
const program = createProgram(rootFiles, options, host);
const diagnostics = sortAndDeduplicateDiagnostics(program.getSemanticDiagnostics().concat(program.getOptionsDiagnostics()));
@ -911,15 +911,11 @@ import b = require("./moduleB");
});
});
function notImplemented(name: string): () => any {
return () => assert(`${name} is not implemented and should not be called`);
}
describe("ModuleResolutionHost.directoryExists", () => {
it("No 'fileExists' calls if containing directory is missing", () => {
const host: ModuleResolutionHost = {
readFile: notImplemented("readFile"),
fileExists: notImplemented("fileExists"),
readFile: notImplemented,
fileExists: notImplemented,
directoryExists: _ => false
};
@ -1022,9 +1018,7 @@ import b = require("./moduleB");
fileExists : fileName => fileName in sourceFiles,
getSourceFile: fileName => sourceFiles[fileName],
getDefaultLibFileName: () => "lib.d.ts",
writeFile(file, text) {
throw new Error("NYI");
},
writeFile: notImplemented,
getCurrentDirectory: () => "/",
getDirectories: () => [],
getCanonicalFileName: f => f.toLowerCase(),

View file

@ -111,13 +111,11 @@ namespace ts {
getDefaultLibFileName(): string {
return "lib.d.ts";
},
writeFile(file, text) {
throw new Error("NYI");
},
writeFile: notImplemented,
getCurrentDirectory(): string {
return "";
},
getDirectories(path: string): string[] {
getDirectories(): string[] {
return [];
},
getCanonicalFileName(fileName): string {
@ -244,17 +242,13 @@ namespace ts {
it("fails if change affects type references", () => {
const program_1 = newProgram(files, ["a.ts"], { types: ["a"] });
updateProgram(program_1, ["a.ts"], { types: ["b"] }, files => {
});
updateProgram(program_1, ["a.ts"], { types: ["b"] }, noop);
assert.isTrue(!program_1.structureIsReused);
});
it("succeeds if change doesn't affect type references", () => {
const program_1 = newProgram(files, ["a.ts"], { types: ["a"] });
updateProgram(program_1, ["a.ts"], { types: ["a"] }, files => {
});
updateProgram(program_1, ["a.ts"], { types: ["a"] }, noop);
assert.isTrue(program_1.structureIsReused);
});
@ -280,19 +274,19 @@ namespace ts {
it("fails if module kind changes", () => {
const program_1 = newProgram(files, ["a.ts"], { target, module: ModuleKind.CommonJS });
updateProgram(program_1, ["a.ts"], { target, module: ModuleKind.AMD }, files => void 0);
updateProgram(program_1, ["a.ts"], { target, module: ModuleKind.AMD }, noop);
assert.isTrue(!program_1.structureIsReused);
});
it("fails if rootdir changes", () => {
const program_1 = newProgram(files, ["a.ts"], { target, module: ModuleKind.CommonJS, rootDir: "/a/b" });
updateProgram(program_1, ["a.ts"], { target, module: ModuleKind.CommonJS, rootDir: "/a/c" }, files => void 0);
updateProgram(program_1, ["a.ts"], { target, module: ModuleKind.CommonJS, rootDir: "/a/c" }, noop);
assert.isTrue(!program_1.structureIsReused);
});
it("fails if config path changes", () => {
const program_1 = newProgram(files, ["a.ts"], { target, module: ModuleKind.CommonJS, configFilePath: "/a/b/tsconfig.json" });
updateProgram(program_1, ["a.ts"], { target, module: ModuleKind.CommonJS, configFilePath: "/a/c/tsconfig.json" }, files => void 0);
updateProgram(program_1, ["a.ts"], { target, module: ModuleKind.CommonJS, configFilePath: "/a/c/tsconfig.json" }, noop);
assert.isTrue(!program_1.structureIsReused);
});

View file

@ -62,7 +62,7 @@ describe("DocumentRegistry", () => {
const snapshot = ts.ScriptSnapshot.fromString(contents);
// Always treat any change as a full change.
snapshot.getChangeRange = old => ts.createTextChangeRange(ts.createTextSpan(0, contents.length), contents.length);
snapshot.getChangeRange = () => ts.createTextChangeRange(ts.createTextSpan(0, contents.length), contents.length);
// Simulate one LS getting the document.
documentRegistry.acquireDocument("file1.ts", defaultCompilerOptions, snapshot, /* version */ "1");

View file

@ -10,41 +10,47 @@ namespace ts.server {
useCaseSensitiveFileNames: true,
write(s): void { lastWrittenToHost = s; },
readFile(): string { return void 0; },
writeFile(): void {},
writeFile: noop,
resolvePath(): string { return void 0; },
fileExists: () => false,
directoryExists: () => false,
getDirectories: () => [],
createDirectory(): void {},
createDirectory: noop,
getExecutingFilePath(): string { return void 0; },
getCurrentDirectory(): string { return void 0; },
getEnvironmentVariable(name: string): string { return ""; },
getEnvironmentVariable(): string { return ""; },
readDirectory(): string[] { return []; },
exit(): void { },
setTimeout(callback, ms, ...args) { return 0; },
clearTimeout(timeoutId) { },
exit: noop,
setTimeout() { return 0; },
clearTimeout: noop,
setImmediate: () => 0,
clearImmediate() {}
clearImmediate: noop
};
const nullCancellationToken: HostCancellationToken = { isCancellationRequested: () => false };
const mockLogger: Logger = {
close(): void {},
close: noop,
hasLevel(): boolean { return false; },
loggingEnabled(): boolean { return false; },
perftrc(s: string): void {},
info(s: string): void {},
startGroup(): void {},
endGroup(): void {},
msg(s: string, type?: string): void {},
perftrc: noop,
info: noop,
startGroup: noop,
endGroup: noop,
msg: noop,
getLogFileName: (): string => undefined
};
class TestSession extends Session {
getProjectService() {
return this.projectService;
}
}
describe("the Session class", () => {
let session: Session;
let session: TestSession;
let lastSent: protocol.Message;
beforeEach(() => {
session = new Session(mockHost, nullCancellationToken, /*useOneInferredProject*/ false, /*typingsInstaller*/ undefined, Utils.byteLength, process.hrtime, mockLogger, /*canUseEvents*/ true);
session = new TestSession(mockHost, nullCancellationToken, /*useOneInferredProject*/ false, /*typingsInstaller*/ undefined, Utils.byteLength, process.hrtime, mockLogger, /*canUseEvents*/ true);
session.send = (msg: protocol.Message) => {
lastSent = msg;
};
@ -55,7 +61,7 @@ namespace ts.server {
const req: protocol.FileRequest = {
command: CommandNames.Open,
seq: 0,
type: "command",
type: "request",
arguments: {
file: undefined
}
@ -67,7 +73,7 @@ namespace ts.server {
const req: protocol.Request = {
command: "foobar",
seq: 0,
type: "command"
type: "request"
};
session.executeCommand(req);
@ -85,7 +91,7 @@ namespace ts.server {
const req: protocol.ConfigureRequest = {
command: CommandNames.Configure,
seq: 0,
type: "command",
type: "request",
arguments: {
hostInfo: "unit test",
formatOptions: {
@ -106,6 +112,47 @@ namespace ts.server {
body: undefined
});
});
it ("should handle literal types in request", () => {
const configureRequest: protocol.ConfigureRequest = {
command: CommandNames.Configure,
seq: 0,
type: "request",
arguments: {
formatOptions: {
indentStyle: "Block"
}
}
};
session.onMessage(JSON.stringify(configureRequest));
assert.equal(session.getProjectService().getFormatCodeOptions().indentStyle, IndentStyle.Block);
const setOptionsRequest: protocol.SetCompilerOptionsForInferredProjectsRequest = {
command: CommandNames.CompilerOptionsForInferredProjects,
seq: 1,
type: "request",
arguments: {
options: {
module: "System",
target: "ES5",
jsx: "React",
newLine: "Lf",
moduleResolution: "Node"
}
}
};
session.onMessage(JSON.stringify(setOptionsRequest));
assert.deepEqual(
session.getProjectService().getCompilerOptionsForInferredProjects(),
<CompilerOptions>{
module: ModuleKind.System,
target: ScriptTarget.ES5,
jsx: JsxEmit.React,
newLine: NewLineKind.LineFeed,
moduleResolution: ModuleResolutionKind.NodeJs
});
});
});
describe("onMessage", () => {
@ -118,7 +165,7 @@ namespace ts.server {
const req: protocol.Request = {
command: name,
seq: i,
type: "command"
type: "request"
};
i++;
session.onMessage(JSON.stringify(req));
@ -151,7 +198,7 @@ namespace ts.server {
const req: protocol.ConfigureRequest = {
command: CommandNames.Configure,
seq: 0,
type: "command",
type: "request",
arguments: {
hostInfo: "unit test",
formatOptions: {
@ -175,7 +222,7 @@ namespace ts.server {
describe("send", () => {
it("is an overrideable handle which sends protocol messages over the wire", () => {
const msg = { seq: 0, type: "none" };
const msg: server.protocol.Request = { seq: 0, type: "request", command: "" };
const strmsg = JSON.stringify(msg);
const len = 1 + Utils.byteLength(strmsg, "utf8");
const resultMsg = `Content-Length: ${len}\r\n\r\n${strmsg}\n`;
@ -198,12 +245,12 @@ namespace ts.server {
responseRequired: true
};
session.addProtocolHandler(command, (req) => result);
session.addProtocolHandler(command, () => result);
expect(session.executeCommand({
command,
seq: 0,
type: "command"
type: "request"
})).to.deep.equal(result);
});
it("throws when a duplicate handler is passed", () => {
@ -216,9 +263,9 @@ namespace ts.server {
};
const command = "newhandle";
session.addProtocolHandler(command, (req) => resp);
session.addProtocolHandler(command, () => resp);
expect(() => session.addProtocolHandler(command, (req) => resp))
expect(() => session.addProtocolHandler(command, () => resp))
.to.throw(`Protocol handler already exists for command "${command}"`);
});
});
@ -304,7 +351,7 @@ namespace ts.server {
expect(session.executeCommand({
seq: 0,
type: "command",
type: "request",
command: session.customHandler
})).to.deep.equal({
response: undefined,
@ -405,7 +452,7 @@ namespace ts.server {
this.seq++;
this.server.enqueue({
seq: this.seq,
type: "command",
type: "request",
command,
arguments: args
});

View file

@ -23,10 +23,6 @@ namespace ts.projectSystem {
readonly callback: TI.RequestCompletedAction;
}
export function notImplemented(): any {
throw new Error("Not yet implemented");
}
export const nullLogger: server.Logger = {
close: () => void 0,
hasLevel: () => void 0,
@ -72,7 +68,7 @@ namespace ts.projectSystem {
this.postExecActions.forEach((act, i) => assert.equal(act.requestKind, expected[i], "Unexpected post install action"));
}
onProjectClosed(p: server.Project) {
onProjectClosed() {
}
attach(projectService: server.ProjectService) {
@ -83,7 +79,7 @@ namespace ts.projectSystem {
return this.installTypingHost;
}
executeRequest(requestKind: TI.RequestKind, requestId: number, args: string[], cwd: string, cb: TI.RequestCompletedAction): void {
executeRequest(requestKind: TI.RequestKind, _requestId: number, _args: string[], _cwd: string, cb: TI.RequestCompletedAction): void {
switch (requestKind) {
case TI.NpmViewRequest:
case TI.NpmInstallRequest:
@ -122,7 +118,7 @@ namespace ts.projectSystem {
return JSON.stringify({ dependencies: dependencies });
}
export function getExecutingFilePathFromLibFile(libFilePath: string): string {
export function getExecutingFilePathFromLibFile(): string {
return combinePaths(getDirectoryPath(libFile.path), "tsc.js");
}
@ -154,27 +150,31 @@ namespace ts.projectSystem {
currentDirectory?: string;
}
export function createServerHost(fileOrFolderList: FileOrFolder[],
params?: TestServerHostCreationParameters,
libFilePath: string = libFile.path): TestServerHost {
export function createServerHost(fileOrFolderList: FileOrFolder[], params?: TestServerHostCreationParameters): TestServerHost {
if (!params) {
params = {};
}
const host = new TestServerHost(
params.useCaseSensitiveFileNames !== undefined ? params.useCaseSensitiveFileNames : false,
params.executingFilePath || getExecutingFilePathFromLibFile(libFilePath),
params.executingFilePath || getExecutingFilePathFromLibFile(),
params.currentDirectory || "/",
fileOrFolderList);
host.createFileOrFolder(safeList, /*createParentDirectory*/ true);
return host;
}
class TestSession extends server.Session {
getProjectService() {
return this.projectService;
}
};
export function createSession(host: server.ServerHost, typingsInstaller?: server.ITypingsInstaller, projectServiceEventHandler?: server.ProjectServiceEventHandler) {
if (typingsInstaller === undefined) {
typingsInstaller = new TestTypingsInstaller("/a/data/", /*throttleLimit*/5, host);
}
return new server.Session(host, nullCancellationToken, /*useSingleInferredProject*/ false, typingsInstaller, Utils.byteLength, process.hrtime, nullLogger, /*canUseEvents*/ projectServiceEventHandler !== undefined, projectServiceEventHandler);
return new TestSession(host, nullCancellationToken, /*useSingleInferredProject*/ false, typingsInstaller, Utils.byteLength, process.hrtime, nullLogger, /*canUseEvents*/ projectServiceEventHandler !== undefined, projectServiceEventHandler);
}
export interface CreateProjectServiceParameters {
@ -315,9 +315,9 @@ namespace ts.projectSystem {
count() {
let n = 0;
/* tslint:disable:no-unused-variable */
for (const _ in this.map) {
/* tslint:enable:no-unused-variable */
// TODO: GH#11734
_;
n++;
}
return n;
@ -466,7 +466,7 @@ namespace ts.projectSystem {
}
// TOOD: record and invoke callbacks to simulate timer events
setTimeout(callback: TimeOutCallback, time: number, ...args: any[]) {
setTimeout(callback: TimeOutCallback, _time: number, ...args: any[]) {
return this.timeoutCallbacks.register(callback, args);
};
@ -483,7 +483,7 @@ namespace ts.projectSystem {
this.timeoutCallbacks.invoke();
}
setImmediate(callback: TimeOutCallback, time: number, ...args: any[]) {
setImmediate(callback: TimeOutCallback, _time: number, ...args: any[]) {
return this.immediateCallbacks.register(callback, args);
}
@ -515,13 +515,14 @@ namespace ts.projectSystem {
this.reloadFS(filesOrFolders);
}
write() { }
readonly readFile = (s: string) => (<File>this.fs.get(this.toPath(s))).content;
readonly resolvePath = (s: string) => s;
readonly getExecutingFilePath = () => this.executingFilePath;
readonly getCurrentDirectory = () => this.currentDirectory;
readonly write = (s: string) => notImplemented();
readonly exit = () => notImplemented();
readonly getEnvironmentVariable = (v: string) => notImplemented();
readonly exit = notImplemented;
readonly getEnvironmentVariable = notImplemented;
}
export function makeSessionRequest<T>(command: string, args: T) {
@ -2420,4 +2421,53 @@ namespace ts.projectSystem {
assert.isTrue(inferredProject.containsFile(<server.NormalizedPath>file1.path));
});
});
describe("reload", () => {
it("should work with temp file", () => {
const f1 = {
path: "/a/b/app.ts",
content: "let x = 1"
};
const tmp = {
path: "/a/b/app.tmp",
content: "const y = 42"
};
const host = createServerHost([f1, tmp]);
const session = createSession(host);
// send open request
session.executeCommand(<server.protocol.OpenRequest>{
type: "request",
command: "open",
seq: 1,
arguments: { file: f1.path }
});
// reload from tmp file
session.executeCommand(<server.protocol.ReloadRequest>{
type: "request",
command: "reload",
seq: 2,
arguments: { file: f1.path, tmpfile: tmp.path }
});
// verify content
const projectServiice = session.getProjectService();
const snap1 = projectServiice.getScriptInfo(f1.path).snap();
assert.equal(snap1.getText(0, snap1.getLength()), tmp.content, "content should be equal to the content of temp file");
// reload from original file file
session.executeCommand(<server.protocol.ReloadRequest>{
type: "request",
command: "reload",
seq: 2,
arguments: { file: f1.path }
});
// verify content
const snap2 = projectServiice.getScriptInfo(f1.path).snap();
assert.equal(snap2.getText(0, snap2.getLength()), f1.content, "content should be equal to the content of original file");
});
});
}

View file

@ -81,7 +81,7 @@ namespace ts.projectSystem {
constructor() {
super(host);
}
executeRequest(requestKind: TI.RequestKind, requestId: number, args: string[], cwd: string, cb: server.typingsInstaller.RequestCompletedAction) {
executeRequest(requestKind: TI.RequestKind, _requestId: number, _args: string[], _cwd: string, cb: server.typingsInstaller.RequestCompletedAction) {
const installedTypings = ["@types/jquery"];
const typingFiles = [jquery];
executeCommand(this, host, installedTypings, typingFiles, requestKind, cb);
@ -125,7 +125,7 @@ namespace ts.projectSystem {
constructor() {
super(host);
}
executeRequest(requestKind: TI.RequestKind, requestId: number, args: string[], cwd: string, cb: server.typingsInstaller.RequestCompletedAction) {
executeRequest(requestKind: TI.RequestKind, _requestId: number, _args: string[], _cwd: string, cb: server.typingsInstaller.RequestCompletedAction) {
const installedTypings = ["@types/jquery"];
const typingFiles = [jquery];
executeCommand(this, host, installedTypings, typingFiles, requestKind, cb);
@ -221,7 +221,7 @@ namespace ts.projectSystem {
enqueueIsCalled = true;
super.enqueueInstallTypingsRequest(project, typingOptions);
}
executeRequest(requestKind: TI.RequestKind, requestId: number, args: string[], cwd: string, cb: TI.RequestCompletedAction): void {
executeRequest(requestKind: TI.RequestKind, _requestId: number, _args: string[], _cwd: string, cb: TI.RequestCompletedAction): void {
const installedTypings = ["@types/jquery"];
const typingFiles = [jquery];
executeCommand(this, host, installedTypings, typingFiles, requestKind, cb);
@ -275,7 +275,7 @@ namespace ts.projectSystem {
constructor() {
super(host);
}
executeRequest(requestKind: TI.RequestKind, requestId: number, args: string[], cwd: string, cb: TI.RequestCompletedAction): void {
executeRequest(requestKind: TI.RequestKind, _requestId: number, _args: string[], _cwd: string, cb: TI.RequestCompletedAction): void {
const installedTypings = ["@types/lodash", "@types/react"];
const typingFiles = [lodash, react];
executeCommand(this, host, installedTypings, typingFiles, requestKind, cb);
@ -323,7 +323,7 @@ namespace ts.projectSystem {
enqueueIsCalled = true;
super.enqueueInstallTypingsRequest(project, typingOptions);
}
executeRequest(requestKind: TI.RequestKind, requestId: number, args: string[], cwd: string, cb: TI.RequestCompletedAction): void {
executeRequest(requestKind: TI.RequestKind, _requestId: number, _args: string[], _cwd: string, cb: TI.RequestCompletedAction): void {
const installedTypings: string[] = [];
const typingFiles: FileOrFolder[] = [];
executeCommand(this, host, installedTypings, typingFiles, requestKind, cb);
@ -398,7 +398,7 @@ namespace ts.projectSystem {
constructor() {
super(host);
}
executeRequest(requestKind: TI.RequestKind, requestId: number, args: string[], cwd: string, cb: TI.RequestCompletedAction): void {
executeRequest(requestKind: TI.RequestKind, _requestId: number, _args: string[], _cwd: string, cb: TI.RequestCompletedAction): void {
const installedTypings = ["@types/commander", "@types/express", "@types/jquery", "@types/moment"];
const typingFiles = [commander, express, jquery, moment];
executeCommand(this, host, installedTypings, typingFiles, requestKind, cb);
@ -477,7 +477,7 @@ namespace ts.projectSystem {
constructor() {
super(host, { throttleLimit: 3 });
}
executeRequest(requestKind: TI.RequestKind, requestId: number, args: string[], cwd: string, cb: TI.RequestCompletedAction): void {
executeRequest(requestKind: TI.RequestKind, _requestId: number, _args: string[], _cwd: string, cb: TI.RequestCompletedAction): void {
const installedTypings = ["@types/commander", "@types/express", "@types/jquery", "@types/moment", "@types/lodash"];
executeCommand(this, host, installedTypings, typingFiles, requestKind, cb);
}
@ -567,7 +567,7 @@ namespace ts.projectSystem {
constructor() {
super(host, { throttleLimit: 3 });
}
executeRequest(requestKind: TI.RequestKind, requestId: number, args: string[], cwd: string, cb: TI.RequestCompletedAction): void {
executeRequest(requestKind: TI.RequestKind, _requestId: number, args: string[], _cwd: string, cb: TI.RequestCompletedAction): void {
if (requestKind === TI.NpmInstallRequest) {
let typingFiles: (FileOrFolder & { typings: string}) [] = [];
if (args.indexOf("@types/commander") >= 0) {
@ -655,7 +655,7 @@ namespace ts.projectSystem {
constructor() {
super(host, { globalTypingsCacheLocation: "/tmp" });
}
executeRequest(requestKind: TI.RequestKind, requestId: number, args: string[], cwd: string, cb: server.typingsInstaller.RequestCompletedAction) {
executeRequest(requestKind: TI.RequestKind, _requestId: number, _args: string[], _cwd: string, cb: server.typingsInstaller.RequestCompletedAction) {
const installedTypings = ["@types/jquery"];
const typingFiles = [jqueryDTS];
executeCommand(this, host, installedTypings, typingFiles, requestKind, cb);
@ -701,7 +701,7 @@ namespace ts.projectSystem {
constructor() {
super(host, { globalTypingsCacheLocation: "/tmp" });
}
executeRequest(requestKind: TI.RequestKind, requestId: number, args: string[], cwd: string, cb: server.typingsInstaller.RequestCompletedAction) {
executeRequest(requestKind: TI.RequestKind, _requestId: number, _args: string[], _cwd: string, cb: server.typingsInstaller.RequestCompletedAction) {
const installedTypings = ["@types/jquery"];
const typingFiles = [jqueryDTS];
executeCommand(this, host, installedTypings, typingFiles, requestKind, cb);
@ -766,7 +766,7 @@ namespace ts.projectSystem {
constructor() {
super(host, { globalTypingsCacheLocation: "/tmp" }, { isEnabled: () => true, writeLine: msg => messages.push(msg) });
}
executeRequest(requestKind: TI.RequestKind, requestId: number, args: string[], cwd: string, cb: server.typingsInstaller.RequestCompletedAction) {
executeRequest() {
assert(false, "runCommand should not be invoked");
}
})();

View file

@ -205,13 +205,13 @@ interface NumberConstructor {
* number. Only finite values of the type number, result in true.
* @param number A numeric value.
*/
isFinite(number: number): boolean;
isFinite(value: any): value is number;
/**
* Returns true if the value passed is an integer, false otherwise.
* @param number A numeric value.
*/
isInteger(number: number): boolean;
isInteger(value: any): value is number;
/**
* Returns a Boolean value that indicates whether a value is the reserved value NaN (not a
@ -219,13 +219,13 @@ interface NumberConstructor {
* to a number. Only values of the type number, that are also NaN, result in true.
* @param number A numeric value.
*/
isNaN(number: number): boolean;
isNaN(value: any): value is number;
/**
* Returns true if the value passed is a safe integer.
* @param number A numeric value.
*/
isSafeInteger(number: number): boolean;
isSafeInteger(value: any): value is number;
/**
* The value of the largest integer n such that n and n + 1 are both exactly representable as

View file

@ -122,7 +122,7 @@ namespace ts.server {
}
protected forEachFileInfo(action: (fileInfo: T) => any) {
this.fileInfos.forEachValue((path: Path, value: T) => action(value));
this.fileInfos.forEachValue((_path, value) => action(value));
}
abstract getFilesAffectedBy(scriptInfo: ScriptInfo): string[];

View file

@ -10,7 +10,10 @@
"stripInternal": true,
"types": [
"node"
]
],
"target": "es5",
"noUnusedLocals": true,
"noUnusedParameters": true
},
"files": [
"cancellationToken.ts"

View file

@ -5,11 +5,6 @@ namespace ts.server {
writeMessage(message: string): void;
}
interface CompletionEntry extends CompletionInfo {
fileName: string;
position: number;
}
interface RenameEntry extends RenameInfo {
fileName: string;
position: number;
@ -246,8 +241,8 @@ namespace ts.server {
return response.body[0];
}
getCompletionEntrySymbol(fileName: string, position: number, entryName: string): Symbol {
throw new Error("Not Implemented Yet.");
getCompletionEntrySymbol(_fileName: string, _position: number, _entryName: string): Symbol {
return notImplemented();
}
getNavigateToItems(searchValue: string): NavigateToItem[] {
@ -278,7 +273,7 @@ namespace ts.server {
});
}
getFormattingEditsForRange(fileName: string, start: number, end: number, options: ts.FormatCodeOptions): ts.TextChange[] {
getFormattingEditsForRange(fileName: string, start: number, end: number, _options: ts.FormatCodeOptions): ts.TextChange[] {
const startLineOffset = this.positionToOneBasedLineOffset(fileName, start);
const endLineOffset = this.positionToOneBasedLineOffset(fileName, end);
const args: protocol.FormatRequestArgs = {
@ -300,7 +295,7 @@ namespace ts.server {
return this.getFormattingEditsForRange(fileName, 0, this.host.getScriptSnapshot(fileName).getLength(), options);
}
getFormattingEditsAfterKeystroke(fileName: string, position: number, key: string, options: FormatCodeOptions): ts.TextChange[] {
getFormattingEditsAfterKeystroke(fileName: string, position: number, key: string, _options: FormatCodeOptions): ts.TextChange[] {
const lineOffset = this.positionToOneBasedLineOffset(fileName, position);
const args: protocol.FormatOnKeyRequestArgs = {
file: fileName,
@ -390,7 +385,7 @@ namespace ts.server {
});
}
findReferences(fileName: string, position: number): ReferencedSymbol[] {
findReferences(_fileName: string, _position: number): ReferencedSymbol[] {
// Not yet implemented.
return [];
}
@ -419,44 +414,50 @@ namespace ts.server {
});
}
getEmitOutput(fileName: string): EmitOutput {
throw new Error("Not Implemented Yet.");
getEmitOutput(_fileName: string): EmitOutput {
return notImplemented();
}
getSyntacticDiagnostics(fileName: string): Diagnostic[] {
const args: protocol.SyntacticDiagnosticsSyncRequestArgs = { file: fileName };
const args: protocol.SyntacticDiagnosticsSyncRequestArgs = { file: fileName, includeLinePosition: true };
const request = this.processRequest<protocol.SyntacticDiagnosticsSyncRequest>(CommandNames.SyntacticDiagnosticsSync, args);
const response = this.processResponse<protocol.SyntacticDiagnosticsSyncResponse>(request);
return (<protocol.Diagnostic[]>response.body).map(entry => this.convertDiagnostic(entry, fileName));
return (<protocol.DiagnosticWithLinePosition[]>response.body).map(entry => this.convertDiagnostic(entry, fileName));
}
getSemanticDiagnostics(fileName: string): Diagnostic[] {
const args: protocol.SemanticDiagnosticsSyncRequestArgs = { file: fileName };
const args: protocol.SemanticDiagnosticsSyncRequestArgs = { file: fileName, includeLinePosition: true };
const request = this.processRequest<protocol.SemanticDiagnosticsSyncRequest>(CommandNames.SemanticDiagnosticsSync, args);
const response = this.processResponse<protocol.SemanticDiagnosticsSyncResponse>(request);
return (<protocol.Diagnostic[]>response.body).map(entry => this.convertDiagnostic(entry, fileName));
return (<protocol.DiagnosticWithLinePosition[]>response.body).map(entry => this.convertDiagnostic(entry, fileName));
}
convertDiagnostic(entry: protocol.Diagnostic, fileName: string): Diagnostic {
const start = this.lineOffsetToPosition(fileName, entry.start);
const end = this.lineOffsetToPosition(fileName, entry.end);
convertDiagnostic(entry: protocol.DiagnosticWithLinePosition, _fileName: string): Diagnostic {
let category: DiagnosticCategory;
for (const id in DiagnosticCategory) {
if (typeof id === "string" && entry.category === id.toLowerCase()) {
category = (<any>DiagnosticCategory)[id];
}
}
Debug.assert(category !== undefined, "convertDiagnostic: category should not be undefined");
return {
file: undefined,
start: start,
length: end - start,
messageText: entry.text,
category: undefined,
start: entry.start,
length: entry.length,
messageText: entry.message,
category: category,
code: entry.code
};
}
getCompilerOptionsDiagnostics(): Diagnostic[] {
throw new Error("Not Implemented Yet.");
return notImplemented();
}
getRenameInfo(fileName: string, position: number, findInStrings?: boolean, findInComments?: boolean): RenameInfo {
@ -560,12 +561,12 @@ namespace ts.server {
this.lineOffsetToPosition(fileName, span.end, lineMap));
}
getNameOrDottedNameSpan(fileName: string, startPos: number, endPos: number): TextSpan {
throw new Error("Not Implemented Yet.");
getNameOrDottedNameSpan(_fileName: string, _startPos: number, _endPos: number): TextSpan {
return notImplemented();
}
getBreakpointStatementAtPosition(fileName: string, position: number): TextSpan {
throw new Error("Not Implemented Yet.");
getBreakpointStatementAtPosition(_fileName: string, _position: number): TextSpan {
return notImplemented();
}
getSignatureHelpItems(fileName: string, position: number): SignatureHelpItems {
@ -654,20 +655,20 @@ namespace ts.server {
}
}
getOutliningSpans(fileName: string): OutliningSpan[] {
throw new Error("Not Implemented Yet.");
getOutliningSpans(_fileName: string): OutliningSpan[] {
return notImplemented();
}
getTodoComments(fileName: string, descriptors: TodoCommentDescriptor[]): TodoComment[] {
throw new Error("Not Implemented Yet.");
getTodoComments(_fileName: string, _descriptors: TodoCommentDescriptor[]): TodoComment[] {
return notImplemented();
}
getDocCommentTemplateAtPosition(fileName: string, position: number): TextInsertion {
throw new Error("Not Implemented Yet.");
getDocCommentTemplateAtPosition(_fileName: string, _position: number): TextInsertion {
return notImplemented();
}
isValidBraceCompletionAtPosition(fileName: string, position: number, openingBrace: number): boolean {
throw new Error("Not Implemented Yet.");
isValidBraceCompletionAtPosition(_fileName: string, _position: number, _openingBrace: number): boolean {
return notImplemented();
}
getCodeFixesAtPosition(fileName: string, start: number, end: number, errorCodes: number[]): CodeAction[] {
@ -733,35 +734,35 @@ namespace ts.server {
});
}
getIndentationAtPosition(fileName: string, position: number, options: EditorOptions): number {
throw new Error("Not Implemented Yet.");
getIndentationAtPosition(_fileName: string, _position: number, _options: EditorOptions): number {
return notImplemented();
}
getSyntacticClassifications(fileName: string, span: TextSpan): ClassifiedSpan[] {
throw new Error("Not Implemented Yet.");
getSyntacticClassifications(_fileName: string, _span: TextSpan): ClassifiedSpan[] {
return notImplemented();
}
getSemanticClassifications(fileName: string, span: TextSpan): ClassifiedSpan[] {
throw new Error("Not Implemented Yet.");
getSemanticClassifications(_fileName: string, _span: TextSpan): ClassifiedSpan[] {
return notImplemented();
}
getEncodedSyntacticClassifications(fileName: string, span: TextSpan): Classifications {
throw new Error("Not Implemented Yet.");
getEncodedSyntacticClassifications(_fileName: string, _span: TextSpan): Classifications {
return notImplemented();
}
getEncodedSemanticClassifications(fileName: string, span: TextSpan): Classifications {
throw new Error("Not Implemented Yet.");
getEncodedSemanticClassifications(_fileName: string, _span: TextSpan): Classifications {
return notImplemented();
}
getProgram(): Program {
throw new Error("SourceFile objects are not serializable through the server protocol.");
}
getNonBoundSourceFile(fileName: string): SourceFile {
getNonBoundSourceFile(_fileName: string): SourceFile {
throw new Error("SourceFile objects are not serializable through the server protocol.");
}
getSourceFile(fileName: string): SourceFile {
getSourceFile(_fileName: string): SourceFile {
throw new Error("SourceFile objects are not serializable through the server protocol.");
}

View file

@ -17,6 +17,68 @@ namespace ts.server {
(event: ProjectServiceEvent): void;
}
function prepareConvertersForEnumLikeCompilerOptions(commandLineOptions: CommandLineOption[]): Map<Map<number>> {
const map: Map<Map<number>> = createMap<Map<number>>();
for (const option of commandLineOptions) {
if (typeof option.type === "object") {
const optionMap = <Map<number>>option.type;
// verify that map contains only numbers
for (const id in optionMap) {
Debug.assert(typeof optionMap[id] === "number");
}
map[option.name] = optionMap;
}
}
return map;
}
const compilerOptionConverters = prepareConvertersForEnumLikeCompilerOptions(optionDeclarations);
const indentStyle = createMap({
"none": IndentStyle.None,
"block": IndentStyle.Block,
"smart": IndentStyle.Smart
});
export function convertFormatOptions(protocolOptions: protocol.FormatCodeSettings): FormatCodeSettings {
if (typeof protocolOptions.indentStyle === "string") {
protocolOptions.indentStyle = indentStyle[protocolOptions.indentStyle.toLowerCase()];
Debug.assert(protocolOptions.indentStyle !== undefined);
}
return <any>protocolOptions;
}
export function convertCompilerOptions(protocolOptions: protocol.ExternalProjectCompilerOptions): CompilerOptions & protocol.CompileOnSaveMixin {
for (const id in compilerOptionConverters) {
const propertyValue = protocolOptions[id];
if (typeof propertyValue === "string") {
const mappedValues = compilerOptionConverters[id];
protocolOptions[id] = mappedValues[propertyValue.toLowerCase()];
}
}
return <any>protocolOptions;
}
export function tryConvertScriptKindName(scriptKindName: protocol.ScriptKindName | ScriptKind): ScriptKind {
return typeof scriptKindName === "string"
? convertScriptKindName(scriptKindName)
: scriptKindName;
}
export function convertScriptKindName(scriptKindName: protocol.ScriptKindName) {
switch (scriptKindName) {
case "JS":
return ScriptKind.JS;
case "JSX":
return ScriptKind.JSX;
case "TS":
return ScriptKind.TS;
case "TSX":
return ScriptKind.TSX;
default:
return ScriptKind.Unknown;
}
}
/**
* This helper function processes a list of projects and return the concatenated, sortd and deduplicated output of processing each project.
*/
@ -63,7 +125,7 @@ namespace ts.server {
const externalFilePropertyReader: FilePropertyReader<protocol.ExternalFile> = {
getFileName: x => x.fileName,
getScriptKind: x => x.scriptKind,
getScriptKind: x => tryConvertScriptKindName(x.scriptKind),
hasMixedContent: x => x.hasMixedContent
};
@ -214,6 +276,10 @@ namespace ts.server {
this.ensureInferredProjectsUpToDate();
}
getCompilerOptionsForInferredProjects() {
return this.compilerOptionsForInferredProjects;
}
updateTypingsForProject(response: SetTypings | InvalidateCachedTypings): void {
const project = this.findProject(response.projectName);
if (!project) {
@ -231,10 +297,10 @@ namespace ts.server {
}
setCompilerOptionsForInferredProjects(projectCompilerOptions: protocol.ExternalProjectCompilerOptions): void {
this.compilerOptionsForInferredProjects = projectCompilerOptions;
this.compilerOptionsForInferredProjects = convertCompilerOptions(projectCompilerOptions);
this.compileOnSaveForInferredProjects = projectCompilerOptions.compileOnSave;
for (const proj of this.inferredProjects) {
proj.setCompilerOptions(projectCompilerOptions);
proj.setCompilerOptions(this.compilerOptionsForInferredProjects);
proj.compileOnSaveEnabled = projectCompilerOptions.compileOnSave;
}
this.updateProjectGraphs(this.inferredProjects);
@ -744,12 +810,13 @@ namespace ts.server {
}
private createAndAddExternalProject(projectFileName: string, files: protocol.ExternalFile[], options: protocol.ExternalProjectCompilerOptions, typingOptions: TypingOptions) {
const compilerOptions = convertCompilerOptions(options);
const project = new ExternalProject(
projectFileName,
this,
this.documentRegistry,
options,
/*languageServiceEnabled*/ !this.exceededTotalSizeLimitForNonTsFiles(options, files, externalFilePropertyReader),
compilerOptions,
/*languageServiceEnabled*/ !this.exceededTotalSizeLimitForNonTsFiles(compilerOptions, files, externalFilePropertyReader),
options.compileOnSave === undefined ? true : options.compileOnSave);
this.addFilesToProjectAndUpdateGraph(project, files, externalFilePropertyReader, /*clientFileName*/ undefined, typingOptions, /*configFileErrors*/ undefined);
@ -1018,7 +1085,7 @@ namespace ts.server {
if (args.file) {
const info = this.getScriptInfoForNormalizedPath(toNormalizedPath(args.file));
if (info) {
info.setFormatOptions(args.formatOptions);
info.setFormatOptions(convertFormatOptions(args.formatOptions));
this.logger.info(`Host configuration update for file ${args.file}`);
}
}
@ -1028,7 +1095,7 @@ namespace ts.server {
this.logger.info(`Host information ${args.hostInfo}`);
}
if (args.formatOptions) {
mergeMaps(this.hostConfiguration.formatCodeOptions, args.formatOptions);
mergeMaps(this.hostConfiguration.formatCodeOptions, convertFormatOptions(args.formatOptions));
this.logger.info("Format host information updated");
}
}
@ -1142,7 +1209,7 @@ namespace ts.server {
const scriptInfo = this.getScriptInfo(file.fileName);
Debug.assert(!scriptInfo || !scriptInfo.isOpen);
const normalizedPath = scriptInfo ? scriptInfo.fileName : toNormalizedPath(file.fileName);
this.openClientFileWithNormalizedPath(normalizedPath, file.content, file.scriptKind, file.hasMixedContent);
this.openClientFileWithNormalizedPath(normalizedPath, file.content, tryConvertScriptKindName(file.scriptKind), file.hasMixedContent);
}
}
@ -1235,7 +1302,7 @@ namespace ts.server {
if (externalProject) {
if (!tsConfigFiles) {
// external project already exists and not config files were added - update the project and return;
this.updateNonInferredProject(externalProject, proj.rootFiles, externalFilePropertyReader, proj.options, proj.typingOptions, proj.options.compileOnSave, /*configFileErrors*/ undefined);
this.updateNonInferredProject(externalProject, proj.rootFiles, externalFilePropertyReader, convertCompilerOptions(proj.options), proj.typingOptions, proj.options.compileOnSave, /*configFileErrors*/ undefined);
return;
}
// some config files were added to external project (that previously were not there)

View file

@ -437,11 +437,11 @@ namespace ts.server {
}
}
reloadScript(filename: NormalizedPath): boolean {
reloadScript(filename: NormalizedPath, tempFileName?: NormalizedPath): boolean {
const script = this.projectService.getScriptInfoForNormalizedPath(filename);
if (script) {
Debug.assert(script.isAttached(this));
script.reloadFromFile();
script.reloadFromFile(tempFileName);
return true;
}
return false;

View file

@ -109,7 +109,7 @@ namespace ts.server.protocol {
/**
* One of "request", "response", or "event"
*/
type: string;
type: "request" | "response" | "event";
}
/**
@ -833,7 +833,7 @@ namespace ts.server.protocol {
/**
* Script kind of the file
*/
scriptKind?: ScriptKind;
scriptKind?: ScriptKindName | ts.ScriptKind;
/**
* Whether file has mixed content (i.e. .cshtml file that combines html markup with C#/JavaScript)
*/
@ -866,20 +866,23 @@ namespace ts.server.protocol {
typingOptions?: TypingOptions;
}
/**
* For external projects, some of the project settings are sent together with
* compiler settings.
*/
export interface ExternalProjectCompilerOptions extends CompilerOptions {
export interface CompileOnSaveMixin {
/**
* If compile on save is enabled for the project
*/
compileOnSave?: boolean;
}
/**
* For external projects, some of the project settings are sent together with
* compiler settings.
*/
export type ExternalProjectCompilerOptions = CompilerOptions & CompileOnSaveMixin;
/**
* Contains information about current project version
*/
/* @internal */
export interface ProjectVersionInfo {
/**
* Project name
@ -896,7 +899,7 @@ namespace ts.server.protocol {
/**
* Current set of compiler options for project
*/
options: CompilerOptions;
options: ts.CompilerOptions;
}
/**
@ -920,6 +923,7 @@ namespace ts.server.protocol {
* if changes is set - then this is the set of changes that should be applied to existing project
* otherwise - assume that nothing is changed
*/
/* @internal */
export interface ProjectFiles {
/**
* Information abount project verison
@ -938,6 +942,7 @@ namespace ts.server.protocol {
/**
* Combines project information with project level errors.
*/
/* @internal */
export interface ProjectFilesWithDiagnostics extends ProjectFiles {
/**
* List of errors in project
@ -1012,9 +1017,11 @@ namespace ts.server.protocol {
* Used to specify the script kind of the file explicitly. It could be one of the following:
* "TS", "JS", "TSX", "JSX"
*/
scriptKindName?: "TS" | "JS" | "TSX" | "JSX";
scriptKindName?: ScriptKindName;
}
export type ScriptKindName = "TS" | "JS" | "TSX" | "JSX";
/**
* Open request; value of command field is "open". Notify the
* server that the client has file open. The server will not
@ -1109,6 +1116,7 @@ namespace ts.server.protocol {
/**
* Arguments to SynchronizeProjectListRequest
*/
/* @internal */
export interface SynchronizeProjectListRequestArgs {
/**
* List of last known projects
@ -2056,4 +2064,141 @@ namespace ts.server.protocol {
export interface NavTreeResponse extends Response {
body?: NavigationTree;
}
export namespace IndentStyle {
export type None = "None";
export type Block = "Block";
export type Smart = "Smart";
}
export type IndentStyle = IndentStyle.None | IndentStyle.Block | IndentStyle.Smart;
export interface EditorSettings {
baseIndentSize?: number;
indentSize?: number;
tabSize?: number;
newLineCharacter?: string;
convertTabsToSpaces?: boolean;
indentStyle?: IndentStyle | ts.IndentStyle;
}
export interface FormatCodeSettings extends EditorSettings {
insertSpaceAfterCommaDelimiter?: boolean;
insertSpaceAfterSemicolonInForStatements?: boolean;
insertSpaceBeforeAndAfterBinaryOperators?: boolean;
insertSpaceAfterKeywordsInControlFlowStatements?: boolean;
insertSpaceAfterFunctionKeywordForAnonymousFunctions?: boolean;
insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis?: boolean;
insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets?: boolean;
insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces?: boolean;
insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces?: boolean;
placeOpenBraceOnNewLineForFunctions?: boolean;
placeOpenBraceOnNewLineForControlBlocks?: boolean;
}
export interface CompilerOptions {
allowJs?: boolean;
allowSyntheticDefaultImports?: boolean;
allowUnreachableCode?: boolean;
allowUnusedLabels?: boolean;
baseUrl?: string;
charset?: string;
declaration?: boolean;
declarationDir?: string;
disableSizeLimit?: boolean;
emitBOM?: boolean;
emitDecoratorMetadata?: boolean;
experimentalDecorators?: boolean;
forceConsistentCasingInFileNames?: boolean;
inlineSourceMap?: boolean;
inlineSources?: boolean;
isolatedModules?: boolean;
jsx?: JsxEmit | ts.JsxEmit;
lib?: string[];
locale?: string;
mapRoot?: string;
maxNodeModuleJsDepth?: number;
module?: ModuleKind | ts.ModuleKind;
moduleResolution?: ModuleResolutionKind | ts.ModuleResolutionKind;
newLine?: NewLineKind | ts.NewLineKind;
noEmit?: boolean;
noEmitHelpers?: boolean;
noEmitOnError?: boolean;
noErrorTruncation?: boolean;
noFallthroughCasesInSwitch?: boolean;
noImplicitAny?: boolean;
noImplicitReturns?: boolean;
noImplicitThis?: boolean;
noUnusedLocals?: boolean;
noUnusedParameters?: boolean;
noImplicitUseStrict?: boolean;
noLib?: boolean;
noResolve?: boolean;
out?: string;
outDir?: string;
outFile?: string;
paths?: MapLike<string[]>;
preserveConstEnums?: boolean;
project?: string;
reactNamespace?: string;
removeComments?: boolean;
rootDir?: string;
rootDirs?: string[];
skipLibCheck?: boolean;
skipDefaultLibCheck?: boolean;
sourceMap?: boolean;
sourceRoot?: string;
strictNullChecks?: boolean;
suppressExcessPropertyErrors?: boolean;
suppressImplicitAnyIndexErrors?: boolean;
target?: ScriptTarget | ts.ScriptTarget;
traceResolution?: boolean;
types?: string[];
/** Paths used to used to compute primary types search locations */
typeRoots?: string[];
[option: string]: CompilerOptionsValue | undefined;
}
export namespace JsxEmit {
export type None = "None";
export type Preserve = "Preserve";
export type React = "React";
}
export type JsxEmit = JsxEmit.None | JsxEmit.Preserve | JsxEmit.React;
export namespace ModuleKind {
export type None = "None";
export type CommonJS = "CommonJS";
export type AMD = "AMD";
export type UMD = "UMD";
export type System = "System";
export type ES6 = "ES6";
export type ES2015 = "ES2015";
}
export type ModuleKind = ModuleKind.None | ModuleKind.CommonJS | ModuleKind.AMD | ModuleKind.UMD | ModuleKind.System | ModuleKind.ES6 | ModuleKind.ES2015;
export namespace ModuleResolutionKind {
export type Classic = "Classic";
export type Node = "Node";
}
export type ModuleResolutionKind = ModuleResolutionKind.Classic | ModuleResolutionKind.Node;
export namespace NewLineKind {
export type Crlf = "Crlf";
export type Lf = "Lf";
}
export type NewLineKind = NewLineKind.Crlf | NewLineKind.Lf;
export namespace ScriptTarget {
export type ES3 = "ES3";
export type ES5 = "ES5";
export type ES6 = "ES6";
export type ES2015 = "ES2015";
}
export type ScriptTarget = ScriptTarget.ES3 | ScriptTarget.ES5 | ScriptTarget.ES6 | ScriptTarget.ES2015;
}

View file

@ -87,7 +87,6 @@ namespace ts.server {
if (this.containingProjects.length === 0) {
return Errors.ThrowNoProject();
}
Debug.assert(this.containingProjects.length !== 0);
return this.containingProjects[0];
}
@ -126,12 +125,12 @@ namespace ts.server {
this.host.writeFile(fileName, snap.getText(0, snap.getLength()));
}
reloadFromFile() {
reloadFromFile(tempFileName?: NormalizedPath) {
if (this.hasMixedContent) {
this.reload("");
}
else {
this.svc.reloadFromFile(this.fileName);
this.svc.reloadFromFile(tempFileName || this.fileName);
this.markContainingProjectsAsDirty();
}
}

View file

@ -41,7 +41,7 @@ namespace ts.server {
class BaseLineIndexWalker implements ILineIndexWalker {
goSubtree = true;
done = false;
leaf(rangeStart: number, rangeLength: number, ll: LineLeaf) {
leaf(_rangeStart: number, _rangeLength: number, _ll: LineLeaf) {
}
}
@ -150,7 +150,7 @@ namespace ts.server {
return this.lineIndex;
}
post(relativeStart: number, relativeLength: number, lineCollection: LineCollection, parent: LineCollection, nodeType: CharRangeSection): LineCollection {
post(_relativeStart: number, _relativeLength: number, lineCollection: LineCollection): LineCollection {
// have visited the path for start of range, now looking for end
// if range is on single line, we will never make this state transition
if (lineCollection === this.lineCollectionAtBranch) {
@ -161,7 +161,7 @@ namespace ts.server {
return undefined;
}
pre(relativeStart: number, relativeLength: number, lineCollection: LineCollection, parent: LineCollection, nodeType: CharRangeSection) {
pre(_relativeStart: number, _relativeLength: number, lineCollection: LineCollection, _parent: LineCollection, nodeType: CharRangeSection) {
// currentNode corresponds to parent, but in the new tree
const currentNode = this.stack[this.stack.length - 1];
@ -414,7 +414,7 @@ namespace ts.server {
const starts: number[] = [-1];
let count = 1;
let pos = 0;
this.index.every((ll, s, len) => {
this.index.every(ll => {
starts[count] = pos;
count++;
pos += ll.text.length;

View file

@ -53,14 +53,6 @@ namespace ts.server {
historySize?: number;
}
interface Key {
sequence?: string;
name?: string;
ctrl?: boolean;
meta?: boolean;
shift?: boolean;
}
interface Stats {
isFile(): boolean;
isDirectory(): boolean;
@ -192,7 +184,7 @@ namespace ts.server {
constructor(
private readonly logger: server.Logger,
private readonly eventPort: number,
eventPort: number,
readonly globalTypingsCacheLocation: string,
private newLine: string) {
if (eventPort) {
@ -218,7 +210,7 @@ namespace ts.server {
const match = /^--(debug|inspect)(=(\d+))?$/.exec(arg);
if (match) {
// if port is specified - use port + 1
// otherwise pick a default port depending on if 'debug' or 'inspect' and use its value + 1
// otherwise pick a default port depending on if 'debug' or 'inspect' and use its value + 1
const currentPort = match[3] !== undefined
? +match[3]
: match[1] === "debug" ? 5858 : 9229;

View file

@ -389,9 +389,9 @@ namespace ts.server {
});
}
private getDiagnosticsWorker(args: protocol.FileRequestArgs, selector: (project: Project, file: string) => Diagnostic[], includeLinePosition: boolean) {
private getDiagnosticsWorker(args: protocol.FileRequestArgs, isSemantic: boolean, selector: (project: Project, file: string) => Diagnostic[], includeLinePosition: boolean) {
const { project, file } = this.getFileAndProject(args);
if (shouldSkipSematicCheck(project)) {
if (isSemantic && shouldSkipSematicCheck(project)) {
return [];
}
const scriptInfo = project.getScriptInfoForNormalizedPath(file);
@ -492,11 +492,11 @@ namespace ts.server {
}
private getSyntacticDiagnosticsSync(args: protocol.SyntacticDiagnosticsSyncRequestArgs): protocol.Diagnostic[] | protocol.DiagnosticWithLinePosition[] {
return this.getDiagnosticsWorker(args, (project, file) => project.getLanguageService().getSyntacticDiagnostics(file), args.includeLinePosition);
return this.getDiagnosticsWorker(args, /*isSemantic*/ false, (project, file) => project.getLanguageService().getSyntacticDiagnostics(file), args.includeLinePosition);
}
private getSemanticDiagnosticsSync(args: protocol.SemanticDiagnosticsSyncRequestArgs): protocol.Diagnostic[] | protocol.DiagnosticWithLinePosition[] {
return this.getDiagnosticsWorker(args, (project, file) => project.getLanguageService().getSemanticDiagnostics(file), args.includeLinePosition);
return this.getDiagnosticsWorker(args, /*isSemantic*/ true, (project, file) => project.getLanguageService().getSemanticDiagnostics(file), args.includeLinePosition);
}
private getDocumentHighlights(args: protocol.DocumentHighlightsRequestArgs, simplifiedResult: boolean): protocol.DocumentHighlightsItem[] | DocumentHighlights[] {
@ -807,7 +807,7 @@ namespace ts.server {
private getIndentation(args: protocol.IndentationRequestArgs) {
const { file, project } = this.getFileAndProjectWithoutRefreshingInferredProjects(args);
const position = this.getPosition(args, project.getScriptInfoForNormalizedPath(file));
const options = args.options || this.projectService.getFormatCodeOptions(file);
const options = args.options ? convertFormatOptions(args.options) : this.projectService.getFormatCodeOptions(file);
const indentation = project.getLanguageService(/*ensureSynchronized*/ false).getIndentationAtPosition(file, position, options);
return { position, indentation };
}
@ -874,19 +874,19 @@ namespace ts.server {
private getFormattingEditsForRangeFull(args: protocol.FormatRequestArgs) {
const { file, project } = this.getFileAndProjectWithoutRefreshingInferredProjects(args);
const options = args.options || this.projectService.getFormatCodeOptions(file);
const options = args.options ? convertFormatOptions(args.options) : this.projectService.getFormatCodeOptions(file);
return project.getLanguageService(/*ensureSynchronized*/ false).getFormattingEditsForRange(file, args.position, args.endPosition, options);
}
private getFormattingEditsForDocumentFull(args: protocol.FormatRequestArgs) {
const { file, project } = this.getFileAndProjectWithoutRefreshingInferredProjects(args);
const options = args.options || this.projectService.getFormatCodeOptions(file);
const options = args.options ? convertFormatOptions(args.options) : this.projectService.getFormatCodeOptions(file);
return project.getLanguageService(/*ensureSynchronized*/ false).getFormattingEditsForDocument(file, options);
}
private getFormattingEditsAfterKeystrokeFull(args: protocol.FormatOnKeyRequestArgs) {
const { file, project } = this.getFileAndProjectWithoutRefreshingInferredProjects(args);
const options = args.options || this.projectService.getFormatCodeOptions(file);
const options = args.options ? convertFormatOptions(args.options) : this.projectService.getFormatCodeOptions(file);
return project.getLanguageService(/*ensureSynchronized*/ false).getFormattingEditsAfterKeystroke(file, args.position, args.key, options);
}
@ -1076,11 +1076,12 @@ namespace ts.server {
private reload(args: protocol.ReloadRequestArgs, reqSeq: number) {
const file = toNormalizedPath(args.file);
const tempFileName = args.tmpfile && toNormalizedPath(args.tmpfile);
const project = this.projectService.getDefaultProjectForFile(file, /*refreshInferredProjects*/ true);
if (project) {
this.changeSeq++;
// make sure no changes happen before this one is finished
if (project.reloadScript(file)) {
if (project.reloadScript(file, tempFileName)) {
this.output(undefined, CommandNames.Reload, reqSeq);
}
}
@ -1299,7 +1300,7 @@ namespace ts.server {
}
// No need to analyze lib.d.ts
let fileNamesInProject = fileNames.filter((value, index, array) => value.indexOf("lib.d.ts") < 0);
let fileNamesInProject = fileNames.filter(value => value.indexOf("lib.d.ts") < 0);
// Sort the file name list to make the recently touched files come first
const highPriorityFiles: NormalizedPath[] = [];
@ -1426,24 +1427,8 @@ namespace ts.server {
[CommandNames.RenameInfoFull]: (request: protocol.FileLocationRequest) => {
return this.requiredResponse(this.getRenameInfo(request.arguments));
},
[CommandNames.Open]: (request: protocol.Request) => {
const openArgs = <protocol.OpenRequestArgs>request.arguments;
let scriptKind: ScriptKind;
switch (openArgs.scriptKindName) {
case "TS":
scriptKind = ScriptKind.TS;
break;
case "JS":
scriptKind = ScriptKind.JS;
break;
case "TSX":
scriptKind = ScriptKind.TSX;
break;
case "JSX":
scriptKind = ScriptKind.JSX;
break;
}
this.openClientFile(toNormalizedPath(openArgs.file), openArgs.fileContent, scriptKind);
[CommandNames.Open]: (request: protocol.OpenRequest) => {
this.openClientFile(toNormalizedPath(request.arguments.file), request.arguments.fileContent, convertScriptKindName(request.arguments.scriptKindName));
return this.notRequired();
},
[CommandNames.Quickinfo]: (request: protocol.QuickInfoRequest) => {
@ -1515,7 +1500,7 @@ namespace ts.server {
[CommandNames.EncodedSemanticClassificationsFull]: (request: protocol.EncodedSemanticClassificationsRequest) => {
return this.requiredResponse(this.getEncodedSemanticClassifications(request.arguments));
},
[CommandNames.Cleanup]: (request: protocol.Request) => {
[CommandNames.Cleanup]: () => {
this.cleanup();
return this.requiredResponse(true);
},
@ -1596,7 +1581,7 @@ namespace ts.server {
[CommandNames.ProjectInfo]: (request: protocol.ProjectInfoRequest) => {
return this.requiredResponse(this.getProjectInfo(request.arguments));
},
[CommandNames.ReloadProjects]: (request: protocol.ReloadProjectsRequest) => {
[CommandNames.ReloadProjects]: () => {
this.projectService.reloadProjects();
return this.notRequired();
},
@ -1606,7 +1591,7 @@ namespace ts.server {
[CommandNames.GetCodeFixesFull]: (request: protocol.CodeFixRequest) => {
return this.requiredResponse(this.getCodeFixes(request.arguments, /*simplifiedResult*/ false));
},
[CommandNames.GetSupportedCodeFixes]: (request: protocol.Request) => {
[CommandNames.GetSupportedCodeFixes]: () => {
return this.requiredResponse(this.getSupportedCodeFixes());
}
});

View file

@ -10,7 +10,10 @@
"stripInternal": true,
"types": [
"node"
]
],
"target": "es5",
"noUnusedLocals": true,
"noUnusedParameters": true
},
"files": [
"../services/shims.ts",

View file

@ -7,7 +7,10 @@
"sourceMap": true,
"stripInternal": true,
"declaration": true,
"types": []
"types": [],
"target": "es5",
"noUnusedLocals": true,
"noUnusedParameters": true
},
"files": [
"../services/shims.ts",

View file

@ -9,9 +9,9 @@ namespace ts.server {
}
export const nullTypingsInstaller: ITypingsInstaller = {
enqueueInstallTypingsRequest: () => {},
attach: (projectService: ProjectService) => {},
onProjectClosed: (p: Project) => {},
enqueueInstallTypingsRequest: noop,
attach: noop,
onProjectClosed: noop,
globalTypingsCacheLocation: undefined
};

View file

@ -126,7 +126,7 @@ namespace ts.server.typingsInstaller {
case NpmInstallRequest: {
const command = `${this.npmPath} install ${args.join(" ")} --save-dev`;
const start = Date.now();
this.exec(command, { cwd }, (err, stdout, stderr) => {
this.exec(command, { cwd }, (_err, stdout, stderr) => {
if (this.log.isEnabled()) {
this.log.writeLine(`${requestKind} #${requestId} took: ${Date.now() - start} ms${sys.newLine}stdout: ${stdout}${sys.newLine}stderr: ${stderr}`);
}

View file

@ -10,7 +10,10 @@
"stripInternal": true,
"types": [
"node"
]
],
"target": "es5",
"noUnusedLocals": true,
"noUnusedParameters": true
},
"files": [
"../types.d.ts",

View file

@ -15,7 +15,7 @@ namespace ts.server.typingsInstaller {
const nullLog: Log = {
isEnabled: () => false,
writeLine: () => {}
writeLine: noop
};
function typingToFileName(cachePath: string, packageName: string, installTypingHost: InstallTypingHost): string {
@ -35,7 +35,7 @@ namespace ts.server.typingsInstaller {
export const MaxPackageNameLength = 214;
/**
* Validates package name using rules defined at https://docs.npmjs.com/files/package.json
* Validates package name using rules defined at https://docs.npmjs.com/files/package.json
*/
export function validatePackageName(packageName: string): PackageNameValidationResult {
Debug.assert(!!packageName, "Package name is not specified");
@ -131,7 +131,7 @@ namespace ts.server.typingsInstaller {
this.log.writeLine(`Got install request ${JSON.stringify(req)}`);
}
// load existing typing information from the cache
// load existing typing information from the cache
if (req.cachePath) {
if (this.log.isEnabled()) {
this.log.writeLine(`Request specifies cache path '${req.cachePath}', loading cached information...`);
@ -145,8 +145,7 @@ namespace ts.server.typingsInstaller {
req.projectRootPath,
this.safeListPath,
this.packageNameToTypingLocation,
req.typingOptions,
req.compilerOptions);
req.typingOptions);
if (this.log.isEnabled()) {
this.log.writeLine(`Finished typings discovery: ${JSON.stringify(discoverTypingsResult)}`);

View file

@ -1,3 +1,5 @@
/// <reference path='../compiler/utilities.ts' />
/* @internal */
namespace ts.Completions {
export function getCompletionsAtPosition(host: LanguageServiceHost, typeChecker: TypeChecker, log: (message: string) => void, compilerOptions: CompilerOptions, sourceFile: SourceFile, position: number): CompletionInfo {
@ -177,7 +179,7 @@ namespace ts.Completions {
// Get string literal completions from specialized signatures of the target
// i.e. declare function f(a: 'A');
// f("/*completion position*/")
return getStringLiteralCompletionEntriesFromCallExpression(argumentInfo, node);
return getStringLiteralCompletionEntriesFromCallExpression(argumentInfo);
}
// Get completion for string literal from string literal type
@ -197,7 +199,7 @@ namespace ts.Completions {
}
}
function getStringLiteralCompletionEntriesFromCallExpression(argumentInfo: SignatureHelp.ArgumentListInfo, location: Node) {
function getStringLiteralCompletionEntriesFromCallExpression(argumentInfo: SignatureHelp.ArgumentListInfo) {
const candidates: Signature[] = [];
const entries: CompletionEntry[] = [];
@ -359,7 +361,7 @@ namespace ts.Completions {
/**
* Multiple file entries might map to the same truncated name once we remove extensions
* (happens iff includeExtensions === false)so we use a set-like data structure. Eg:
*
*
* both foo.ts and foo.tsx become foo
*/
const foundFiles = createMap<boolean>();
@ -615,7 +617,7 @@ namespace ts.Completions {
if (typeRoots) {
for (const root of typeRoots) {
getCompletionEntriesFromDirectories(host, options, root, span, result);
getCompletionEntriesFromDirectories(host, root, span, result);
}
}
}
@ -624,14 +626,14 @@ namespace ts.Completions {
// Also get all @types typings installed in visible node_modules directories
for (const packageJson of findPackageJsons(scriptPath)) {
const typesDir = combinePaths(getDirectoryPath(packageJson), "node_modules/@types");
getCompletionEntriesFromDirectories(host, options, typesDir, span, result);
getCompletionEntriesFromDirectories(host, typesDir, span, result);
}
}
return result;
}
function getCompletionEntriesFromDirectories(host: LanguageServiceHost, options: CompilerOptions, directory: string, span: TextSpan, result: CompletionEntry[]) {
function getCompletionEntriesFromDirectories(host: LanguageServiceHost, directory: string, span: TextSpan, result: CompletionEntry[]) {
if (host.getDirectories && tryDirectoryExists(host, directory)) {
const directories = tryGetDirectories(host, directory);
if (directories) {
@ -951,7 +953,6 @@ namespace ts.Completions {
if (!tryGetGlobalSymbols()) {
return undefined;
}
isGlobalCompletion = true;
}
log("getCompletionData: Semantic work: " + (timestamp() - semanticStart));
@ -1030,7 +1031,6 @@ namespace ts.Completions {
if ((jsxContainer.kind === SyntaxKind.JsxSelfClosingElement) || (jsxContainer.kind === SyntaxKind.JsxOpeningElement)) {
// Cursor is inside a JSX self-closing element or opening element
attrsType = typeChecker.getJsxElementAttributesType(<JsxOpeningLikeElement>jsxContainer);
isGlobalCompletion = false;
if (attrsType) {
symbols = filterJsxAttributes(typeChecker.getPropertiesOfType(attrsType), (<JsxOpeningLikeElement>jsxContainer).attributes);
@ -1038,7 +1038,6 @@ namespace ts.Completions {
isNewIdentifierLocation = false;
return true;
}
}
}
@ -1079,6 +1078,13 @@ namespace ts.Completions {
position;
const scopeNode = getScopeNode(contextToken, adjustedPosition, sourceFile) || sourceFile;
if (scopeNode) {
isGlobalCompletion =
scopeNode.kind === SyntaxKind.SourceFile ||
scopeNode.kind === SyntaxKind.TemplateExpression ||
scopeNode.kind === SyntaxKind.JsxExpression ||
isStatement(scopeNode);
}
/// TODO filter meaning based on the current context
const symbolMeanings = SymbolFlags.Type | SymbolFlags.Value | SymbolFlags.Namespace | SymbolFlags.Alias;
@ -1702,11 +1708,11 @@ namespace ts.Completions {
* to determine if the caret is currently within the string literal and capture the literal fragment
* for completions.
* For example, this matches
*
*
* /// <reference path="fragment
*
*
* but not
*
*
* /// <reference path="fragment"
*/
const tripleSlashDirectiveFragmentRegex = /^(\/\/\/\s*<reference\s+(path|types)\s*=\s*(?:'|"))([^\3"]*)$/;

View file

@ -90,7 +90,7 @@ namespace ts.FindAllReferences {
getReferencesInNode(scope, symbol, declaredName, node, searchMeaning, findInStrings, findInComments, result, symbolToIndex);
}
else {
const internedName = getInternedName(symbol, node, declarations);
const internedName = getInternedName(symbol, node);
for (const sourceFile of sourceFiles) {
cancellationToken.throwIfCancellationRequested();
@ -175,7 +175,7 @@ namespace ts.FindAllReferences {
return undefined;
}
function getInternedName(symbol: Symbol, location: Node, declarations: Declaration[]): string {
function getInternedName(symbol: Symbol, location: Node): string {
// If this is an export or import specifier it could have been renamed using the 'as' syntax.
// If so we want to search for whatever under the cursor.
if (isImportOrExportSpecifierName(location)) {

View file

@ -248,7 +248,7 @@ namespace ts.formatting {
}
};
function rangeHasNoErrors(r: TextRange): boolean {
function rangeHasNoErrors(): boolean {
return false;
}
}
@ -624,10 +624,11 @@ namespace ts.formatting {
return inheritedIndentation;
}
if (isToken(child)) {
// JSX text shouldn't affect indenting
if (isToken(child) && child.kind !== SyntaxKind.JsxText) {
// if child node is a token, it does not impact indentation, proceed it using parent indentation scope rules
const tokenInfo = formattingScanner.readTokenInfo(child);
Debug.assert(tokenInfo.token.end === child.end);
Debug.assert(tokenInfo.token.end === child.end, "Token end is child end");
consumeTokenAndAdvanceScanner(tokenInfo, node, parentDynamicIndentation, child);
return inheritedIndentation;
}

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