mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Merge branch 'master' into this-function-types
This commit is contained in:
+5
-4
@@ -652,7 +652,7 @@ function deleteTemporaryProjectOutput() {
|
||||
}
|
||||
}
|
||||
|
||||
function runConsoleTests(defaultReporter, defaultSubsets, postLint) {
|
||||
function runConsoleTests(defaultReporter, defaultSubsets) {
|
||||
cleanTestDirs();
|
||||
var debug = process.env.debug || process.env.d;
|
||||
tests = process.env.test || process.env.tests || process.env.t;
|
||||
@@ -685,13 +685,13 @@ function runConsoleTests(defaultReporter, defaultSubsets, postLint) {
|
||||
subsetRegexes = subsets.map(function (sub) { return "^" + sub + ".*$"; });
|
||||
subsetRegexes.push("^(?!" + subsets.join("|") + ").*$");
|
||||
}
|
||||
subsetRegexes.forEach(function (subsetRegex) {
|
||||
subsetRegexes.forEach(function (subsetRegex, i) {
|
||||
tests = subsetRegex ? ' -g "' + subsetRegex + '"' : '';
|
||||
var cmd = "mocha" + (debug ? " --debug-brk" : "") + " -R " + reporter + tests + colors + ' -t ' + testTimeout + ' ' + run;
|
||||
console.log(cmd);
|
||||
exec(cmd, function () {
|
||||
deleteTemporaryProjectOutput();
|
||||
if (postLint) {
|
||||
if (i === 0) {
|
||||
var lint = jake.Task['lint'];
|
||||
lint.addListener('complete', function () {
|
||||
complete();
|
||||
@@ -713,7 +713,7 @@ task("runtests-parallel", ["build-rules", "tests", builtLocalDirectory], functio
|
||||
|
||||
desc("Runs the tests using the built run.js file. Optional arguments are: t[ests]=regex r[eporter]=[list|spec|json|<more>] d[ebug]=true color[s]=false.");
|
||||
task("runtests", ["build-rules", "tests", builtLocalDirectory], function() {
|
||||
runConsoleTests('mocha-fivemat-progress-reporter', [], /*postLint*/ true);
|
||||
runConsoleTests('mocha-fivemat-progress-reporter', []);
|
||||
}, {async: true});
|
||||
|
||||
desc("Generates code coverage data via instanbul");
|
||||
@@ -927,6 +927,7 @@ var servicesLintTargets = [
|
||||
"patternMatcher.ts",
|
||||
"services.ts",
|
||||
"shims.ts",
|
||||
"jsTyping.ts"
|
||||
].map(function (s) {
|
||||
return path.join(servicesDirectory, s);
|
||||
});
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
<!--
|
||||
Thank you for contributing to TypeScript! Please review this checklist
|
||||
before submitting your issue.
|
||||
[ ] Many common issues and suggestions are addressed in the FAQ
|
||||
https://github.com/Microsoft/TypeScript/wiki/FAQ
|
||||
[ ] Search for duplicates before logging new issues
|
||||
https://github.com/Microsoft/TypeScript/issues?utf8=%E2%9C%93&q=is%3Aissue
|
||||
[ ] Questions are best asked and answered at Stack Overflow
|
||||
http://stackoverflow.com/questions/tagged/typescript
|
||||
|
||||
For bug reports, please include the information below.
|
||||
__________________________________________________________ -->
|
||||
|
||||
**TypeScript Version:**
|
||||
|
||||
1.7.5 / 1.8.0-beta / nightly (1.9.0-dev.20160217)
|
||||
|
||||
**Code**
|
||||
|
||||
```ts
|
||||
// A self-contained demonstration of the problem follows...
|
||||
|
||||
```
|
||||
|
||||
**Expected behavior:**
|
||||
|
||||
**Actual behavior:**
|
||||
Vendored
+239
-156
File diff suppressed because it is too large
Load Diff
Vendored
+287
-204
File diff suppressed because it is too large
Load Diff
Vendored
+5344
File diff suppressed because it is too large
Load Diff
Vendored
+251
-162
File diff suppressed because it is too large
Load Diff
Vendored
+12
-6
@@ -595,6 +595,8 @@ interface AudioNode extends EventTarget {
|
||||
numberOfOutputs: number;
|
||||
connect(destination: AudioNode, output?: number, input?: number): void;
|
||||
disconnect(output?: number): void;
|
||||
disconnect(destination: AudioNode, output?: number, input?: number): void;
|
||||
disconnect(destination: AudioParam, output?: number): void;
|
||||
}
|
||||
|
||||
declare var AudioNode: {
|
||||
@@ -7111,7 +7113,7 @@ interface IDBCursor {
|
||||
direction: string;
|
||||
key: any;
|
||||
primaryKey: any;
|
||||
source: any;
|
||||
source: IDBObjectStore | IDBIndex;
|
||||
advance(count: number): void;
|
||||
continue(key?: any): void;
|
||||
delete(): IDBRequest;
|
||||
@@ -7149,7 +7151,7 @@ interface IDBDatabase extends EventTarget {
|
||||
close(): void;
|
||||
createObjectStore(name: string, optionalParameters?: IDBObjectStoreParameters): IDBObjectStore;
|
||||
deleteObjectStore(name: string): void;
|
||||
transaction(storeNames: any, mode?: string): IDBTransaction;
|
||||
transaction(storeNames: string | string[], mode?: string): IDBTransaction;
|
||||
addEventListener(type: "abort", listener: (ev: Event) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void;
|
||||
@@ -7207,9 +7209,10 @@ declare var IDBKeyRange: {
|
||||
|
||||
interface IDBObjectStore {
|
||||
indexNames: DOMStringList;
|
||||
keyPath: string;
|
||||
keyPath: string | string[];
|
||||
name: string;
|
||||
transaction: IDBTransaction;
|
||||
autoIncrement: boolean;
|
||||
add(value: any, key?: any): IDBRequest;
|
||||
clear(): IDBRequest;
|
||||
count(key?: any): IDBRequest;
|
||||
@@ -7248,7 +7251,7 @@ interface IDBRequest extends EventTarget {
|
||||
onsuccess: (ev: Event) => any;
|
||||
readyState: string;
|
||||
result: any;
|
||||
source: any;
|
||||
source: IDBObjectStore | IDBIndex | IDBCursor;
|
||||
transaction: IDBTransaction;
|
||||
addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: "success", listener: (ev: Event) => any, useCapture?: boolean): void;
|
||||
@@ -10435,11 +10438,14 @@ declare var SVGViewElement: {
|
||||
}
|
||||
|
||||
interface SVGZoomAndPan {
|
||||
zoomAndPan: number;
|
||||
}
|
||||
|
||||
declare var SVGZoomAndPan: {
|
||||
SVG_ZOOMANDPAN_DISABLE: number;
|
||||
SVG_ZOOMANDPAN_MAGNIFY: number;
|
||||
SVG_ZOOMANDPAN_UNKNOWN: number;
|
||||
}
|
||||
declare var SVGZoomAndPan: SVGZoomAndPan;
|
||||
|
||||
interface SVGZoomEvent extends UIEvent {
|
||||
newScale: number;
|
||||
@@ -12902,7 +12908,7 @@ interface DecodeSuccessCallback {
|
||||
(decodedData: AudioBuffer): void;
|
||||
}
|
||||
interface DecodeErrorCallback {
|
||||
(): void;
|
||||
(error: DOMException): void;
|
||||
}
|
||||
interface FunctionStringCallback {
|
||||
(data: string): void;
|
||||
|
||||
Vendored
+299
-210
File diff suppressed because it is too large
Load Diff
Vendored
+18829
File diff suppressed because it is too large
Load Diff
Vendored
+6
-5
@@ -492,7 +492,7 @@ interface IDBCursor {
|
||||
direction: string;
|
||||
key: any;
|
||||
primaryKey: any;
|
||||
source: any;
|
||||
source: IDBObjectStore | IDBIndex;
|
||||
advance(count: number): void;
|
||||
continue(key?: any): void;
|
||||
delete(): IDBRequest;
|
||||
@@ -530,7 +530,7 @@ interface IDBDatabase extends EventTarget {
|
||||
close(): void;
|
||||
createObjectStore(name: string, optionalParameters?: IDBObjectStoreParameters): IDBObjectStore;
|
||||
deleteObjectStore(name: string): void;
|
||||
transaction(storeNames: any, mode?: string): IDBTransaction;
|
||||
transaction(storeNames: string | string[], mode?: string): IDBTransaction;
|
||||
addEventListener(type: "abort", listener: (ev: Event) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void;
|
||||
@@ -588,9 +588,10 @@ declare var IDBKeyRange: {
|
||||
|
||||
interface IDBObjectStore {
|
||||
indexNames: DOMStringList;
|
||||
keyPath: string;
|
||||
keyPath: string | string[];
|
||||
name: string;
|
||||
transaction: IDBTransaction;
|
||||
autoIncrement: boolean;
|
||||
add(value: any, key?: any): IDBRequest;
|
||||
clear(): IDBRequest;
|
||||
count(key?: any): IDBRequest;
|
||||
@@ -629,7 +630,7 @@ interface IDBRequest extends EventTarget {
|
||||
onsuccess: (ev: Event) => any;
|
||||
readyState: string;
|
||||
result: any;
|
||||
source: any;
|
||||
source: IDBObjectStore | IDBIndex | IDBCursor;
|
||||
transaction: IDBTransaction;
|
||||
addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: "success", listener: (ev: Event) => any, useCapture?: boolean): void;
|
||||
@@ -1176,7 +1177,7 @@ interface DecodeSuccessCallback {
|
||||
(decodedData: AudioBuffer): void;
|
||||
}
|
||||
interface DecodeErrorCallback {
|
||||
(): void;
|
||||
(error: DOMException): void;
|
||||
}
|
||||
interface FunctionStringCallback {
|
||||
(data: string): void;
|
||||
|
||||
+4924
-3754
File diff suppressed because it is too large
Load Diff
+6098
-4896
File diff suppressed because it is too large
Load Diff
Vendored
+232
-203
@@ -160,169 +160,170 @@ declare namespace ts {
|
||||
IsKeyword = 124,
|
||||
ModuleKeyword = 125,
|
||||
NamespaceKeyword = 126,
|
||||
RequireKeyword = 127,
|
||||
NumberKeyword = 128,
|
||||
SetKeyword = 129,
|
||||
StringKeyword = 130,
|
||||
SymbolKeyword = 131,
|
||||
TypeKeyword = 132,
|
||||
FromKeyword = 133,
|
||||
GlobalKeyword = 134,
|
||||
OfKeyword = 135,
|
||||
QualifiedName = 136,
|
||||
ComputedPropertyName = 137,
|
||||
TypeParameter = 138,
|
||||
Parameter = 139,
|
||||
Decorator = 140,
|
||||
PropertySignature = 141,
|
||||
PropertyDeclaration = 142,
|
||||
MethodSignature = 143,
|
||||
MethodDeclaration = 144,
|
||||
Constructor = 145,
|
||||
GetAccessor = 146,
|
||||
SetAccessor = 147,
|
||||
CallSignature = 148,
|
||||
ConstructSignature = 149,
|
||||
IndexSignature = 150,
|
||||
TypePredicate = 151,
|
||||
TypeReference = 152,
|
||||
FunctionType = 153,
|
||||
ConstructorType = 154,
|
||||
TypeQuery = 155,
|
||||
TypeLiteral = 156,
|
||||
ArrayType = 157,
|
||||
TupleType = 158,
|
||||
UnionType = 159,
|
||||
IntersectionType = 160,
|
||||
ParenthesizedType = 161,
|
||||
ThisType = 162,
|
||||
StringLiteralType = 163,
|
||||
ObjectBindingPattern = 164,
|
||||
ArrayBindingPattern = 165,
|
||||
BindingElement = 166,
|
||||
ArrayLiteralExpression = 167,
|
||||
ObjectLiteralExpression = 168,
|
||||
PropertyAccessExpression = 169,
|
||||
ElementAccessExpression = 170,
|
||||
CallExpression = 171,
|
||||
NewExpression = 172,
|
||||
TaggedTemplateExpression = 173,
|
||||
TypeAssertionExpression = 174,
|
||||
ParenthesizedExpression = 175,
|
||||
FunctionExpression = 176,
|
||||
ArrowFunction = 177,
|
||||
DeleteExpression = 178,
|
||||
TypeOfExpression = 179,
|
||||
VoidExpression = 180,
|
||||
AwaitExpression = 181,
|
||||
PrefixUnaryExpression = 182,
|
||||
PostfixUnaryExpression = 183,
|
||||
BinaryExpression = 184,
|
||||
ConditionalExpression = 185,
|
||||
TemplateExpression = 186,
|
||||
YieldExpression = 187,
|
||||
SpreadElementExpression = 188,
|
||||
ClassExpression = 189,
|
||||
OmittedExpression = 190,
|
||||
ExpressionWithTypeArguments = 191,
|
||||
AsExpression = 192,
|
||||
TemplateSpan = 193,
|
||||
SemicolonClassElement = 194,
|
||||
Block = 195,
|
||||
VariableStatement = 196,
|
||||
EmptyStatement = 197,
|
||||
ExpressionStatement = 198,
|
||||
IfStatement = 199,
|
||||
DoStatement = 200,
|
||||
WhileStatement = 201,
|
||||
ForStatement = 202,
|
||||
ForInStatement = 203,
|
||||
ForOfStatement = 204,
|
||||
ContinueStatement = 205,
|
||||
BreakStatement = 206,
|
||||
ReturnStatement = 207,
|
||||
WithStatement = 208,
|
||||
SwitchStatement = 209,
|
||||
LabeledStatement = 210,
|
||||
ThrowStatement = 211,
|
||||
TryStatement = 212,
|
||||
DebuggerStatement = 213,
|
||||
VariableDeclaration = 214,
|
||||
VariableDeclarationList = 215,
|
||||
FunctionDeclaration = 216,
|
||||
ClassDeclaration = 217,
|
||||
InterfaceDeclaration = 218,
|
||||
TypeAliasDeclaration = 219,
|
||||
EnumDeclaration = 220,
|
||||
ModuleDeclaration = 221,
|
||||
ModuleBlock = 222,
|
||||
CaseBlock = 223,
|
||||
ImportEqualsDeclaration = 224,
|
||||
ImportDeclaration = 225,
|
||||
ImportClause = 226,
|
||||
NamespaceImport = 227,
|
||||
NamedImports = 228,
|
||||
ImportSpecifier = 229,
|
||||
ExportAssignment = 230,
|
||||
ExportDeclaration = 231,
|
||||
NamedExports = 232,
|
||||
ExportSpecifier = 233,
|
||||
MissingDeclaration = 234,
|
||||
ExternalModuleReference = 235,
|
||||
JsxElement = 236,
|
||||
JsxSelfClosingElement = 237,
|
||||
JsxOpeningElement = 238,
|
||||
JsxText = 239,
|
||||
JsxClosingElement = 240,
|
||||
JsxAttribute = 241,
|
||||
JsxSpreadAttribute = 242,
|
||||
JsxExpression = 243,
|
||||
CaseClause = 244,
|
||||
DefaultClause = 245,
|
||||
HeritageClause = 246,
|
||||
CatchClause = 247,
|
||||
PropertyAssignment = 248,
|
||||
ShorthandPropertyAssignment = 249,
|
||||
EnumMember = 250,
|
||||
SourceFile = 251,
|
||||
JSDocTypeExpression = 252,
|
||||
JSDocAllType = 253,
|
||||
JSDocUnknownType = 254,
|
||||
JSDocArrayType = 255,
|
||||
JSDocUnionType = 256,
|
||||
JSDocTupleType = 257,
|
||||
JSDocNullableType = 258,
|
||||
JSDocNonNullableType = 259,
|
||||
JSDocRecordType = 260,
|
||||
JSDocRecordMember = 261,
|
||||
JSDocTypeReference = 262,
|
||||
JSDocOptionalType = 263,
|
||||
JSDocFunctionType = 264,
|
||||
JSDocVariadicType = 265,
|
||||
JSDocConstructorType = 266,
|
||||
JSDocThisType = 267,
|
||||
JSDocComment = 268,
|
||||
JSDocTag = 269,
|
||||
JSDocParameterTag = 270,
|
||||
JSDocReturnTag = 271,
|
||||
JSDocTypeTag = 272,
|
||||
JSDocTemplateTag = 273,
|
||||
SyntaxList = 274,
|
||||
Count = 275,
|
||||
ReadonlyKeyword = 127,
|
||||
RequireKeyword = 128,
|
||||
NumberKeyword = 129,
|
||||
SetKeyword = 130,
|
||||
StringKeyword = 131,
|
||||
SymbolKeyword = 132,
|
||||
TypeKeyword = 133,
|
||||
FromKeyword = 134,
|
||||
GlobalKeyword = 135,
|
||||
OfKeyword = 136,
|
||||
QualifiedName = 137,
|
||||
ComputedPropertyName = 138,
|
||||
TypeParameter = 139,
|
||||
Parameter = 140,
|
||||
Decorator = 141,
|
||||
PropertySignature = 142,
|
||||
PropertyDeclaration = 143,
|
||||
MethodSignature = 144,
|
||||
MethodDeclaration = 145,
|
||||
Constructor = 146,
|
||||
GetAccessor = 147,
|
||||
SetAccessor = 148,
|
||||
CallSignature = 149,
|
||||
ConstructSignature = 150,
|
||||
IndexSignature = 151,
|
||||
TypePredicate = 152,
|
||||
TypeReference = 153,
|
||||
FunctionType = 154,
|
||||
ConstructorType = 155,
|
||||
TypeQuery = 156,
|
||||
TypeLiteral = 157,
|
||||
ArrayType = 158,
|
||||
TupleType = 159,
|
||||
UnionType = 160,
|
||||
IntersectionType = 161,
|
||||
ParenthesizedType = 162,
|
||||
ThisType = 163,
|
||||
StringLiteralType = 164,
|
||||
ObjectBindingPattern = 165,
|
||||
ArrayBindingPattern = 166,
|
||||
BindingElement = 167,
|
||||
ArrayLiteralExpression = 168,
|
||||
ObjectLiteralExpression = 169,
|
||||
PropertyAccessExpression = 170,
|
||||
ElementAccessExpression = 171,
|
||||
CallExpression = 172,
|
||||
NewExpression = 173,
|
||||
TaggedTemplateExpression = 174,
|
||||
TypeAssertionExpression = 175,
|
||||
ParenthesizedExpression = 176,
|
||||
FunctionExpression = 177,
|
||||
ArrowFunction = 178,
|
||||
DeleteExpression = 179,
|
||||
TypeOfExpression = 180,
|
||||
VoidExpression = 181,
|
||||
AwaitExpression = 182,
|
||||
PrefixUnaryExpression = 183,
|
||||
PostfixUnaryExpression = 184,
|
||||
BinaryExpression = 185,
|
||||
ConditionalExpression = 186,
|
||||
TemplateExpression = 187,
|
||||
YieldExpression = 188,
|
||||
SpreadElementExpression = 189,
|
||||
ClassExpression = 190,
|
||||
OmittedExpression = 191,
|
||||
ExpressionWithTypeArguments = 192,
|
||||
AsExpression = 193,
|
||||
TemplateSpan = 194,
|
||||
SemicolonClassElement = 195,
|
||||
Block = 196,
|
||||
VariableStatement = 197,
|
||||
EmptyStatement = 198,
|
||||
ExpressionStatement = 199,
|
||||
IfStatement = 200,
|
||||
DoStatement = 201,
|
||||
WhileStatement = 202,
|
||||
ForStatement = 203,
|
||||
ForInStatement = 204,
|
||||
ForOfStatement = 205,
|
||||
ContinueStatement = 206,
|
||||
BreakStatement = 207,
|
||||
ReturnStatement = 208,
|
||||
WithStatement = 209,
|
||||
SwitchStatement = 210,
|
||||
LabeledStatement = 211,
|
||||
ThrowStatement = 212,
|
||||
TryStatement = 213,
|
||||
DebuggerStatement = 214,
|
||||
VariableDeclaration = 215,
|
||||
VariableDeclarationList = 216,
|
||||
FunctionDeclaration = 217,
|
||||
ClassDeclaration = 218,
|
||||
InterfaceDeclaration = 219,
|
||||
TypeAliasDeclaration = 220,
|
||||
EnumDeclaration = 221,
|
||||
ModuleDeclaration = 222,
|
||||
ModuleBlock = 223,
|
||||
CaseBlock = 224,
|
||||
ImportEqualsDeclaration = 225,
|
||||
ImportDeclaration = 226,
|
||||
ImportClause = 227,
|
||||
NamespaceImport = 228,
|
||||
NamedImports = 229,
|
||||
ImportSpecifier = 230,
|
||||
ExportAssignment = 231,
|
||||
ExportDeclaration = 232,
|
||||
NamedExports = 233,
|
||||
ExportSpecifier = 234,
|
||||
MissingDeclaration = 235,
|
||||
ExternalModuleReference = 236,
|
||||
JsxElement = 237,
|
||||
JsxSelfClosingElement = 238,
|
||||
JsxOpeningElement = 239,
|
||||
JsxText = 240,
|
||||
JsxClosingElement = 241,
|
||||
JsxAttribute = 242,
|
||||
JsxSpreadAttribute = 243,
|
||||
JsxExpression = 244,
|
||||
CaseClause = 245,
|
||||
DefaultClause = 246,
|
||||
HeritageClause = 247,
|
||||
CatchClause = 248,
|
||||
PropertyAssignment = 249,
|
||||
ShorthandPropertyAssignment = 250,
|
||||
EnumMember = 251,
|
||||
SourceFile = 252,
|
||||
JSDocTypeExpression = 253,
|
||||
JSDocAllType = 254,
|
||||
JSDocUnknownType = 255,
|
||||
JSDocArrayType = 256,
|
||||
JSDocUnionType = 257,
|
||||
JSDocTupleType = 258,
|
||||
JSDocNullableType = 259,
|
||||
JSDocNonNullableType = 260,
|
||||
JSDocRecordType = 261,
|
||||
JSDocRecordMember = 262,
|
||||
JSDocTypeReference = 263,
|
||||
JSDocOptionalType = 264,
|
||||
JSDocFunctionType = 265,
|
||||
JSDocVariadicType = 266,
|
||||
JSDocConstructorType = 267,
|
||||
JSDocThisType = 268,
|
||||
JSDocComment = 269,
|
||||
JSDocTag = 270,
|
||||
JSDocParameterTag = 271,
|
||||
JSDocReturnTag = 272,
|
||||
JSDocTypeTag = 273,
|
||||
JSDocTemplateTag = 274,
|
||||
SyntaxList = 275,
|
||||
Count = 276,
|
||||
FirstAssignment = 56,
|
||||
LastAssignment = 68,
|
||||
FirstReservedWord = 70,
|
||||
LastReservedWord = 105,
|
||||
FirstKeyword = 70,
|
||||
LastKeyword = 135,
|
||||
LastKeyword = 136,
|
||||
FirstFutureReservedWord = 106,
|
||||
LastFutureReservedWord = 114,
|
||||
FirstTypeNode = 151,
|
||||
LastTypeNode = 163,
|
||||
FirstTypeNode = 152,
|
||||
LastTypeNode = 164,
|
||||
FirstPunctuation = 15,
|
||||
LastPunctuation = 68,
|
||||
FirstToken = 0,
|
||||
LastToken = 135,
|
||||
LastToken = 136,
|
||||
FirstTriviaToken = 2,
|
||||
LastTriviaToken = 7,
|
||||
FirstLiteralToken = 8,
|
||||
@@ -331,40 +332,47 @@ declare namespace ts {
|
||||
LastTemplateToken = 14,
|
||||
FirstBinaryOperator = 25,
|
||||
LastBinaryOperator = 68,
|
||||
FirstNode = 136,
|
||||
FirstNode = 137,
|
||||
}
|
||||
enum NodeFlags {
|
||||
None = 0,
|
||||
Export = 2,
|
||||
Ambient = 4,
|
||||
Public = 8,
|
||||
Private = 16,
|
||||
Protected = 32,
|
||||
Static = 64,
|
||||
Export = 1,
|
||||
Ambient = 2,
|
||||
Public = 4,
|
||||
Private = 8,
|
||||
Protected = 16,
|
||||
Static = 32,
|
||||
Readonly = 64,
|
||||
Abstract = 128,
|
||||
Async = 256,
|
||||
Default = 512,
|
||||
MultiLine = 1024,
|
||||
Synthetic = 2048,
|
||||
DeclarationFile = 4096,
|
||||
Let = 8192,
|
||||
Const = 16384,
|
||||
OctalLiteral = 32768,
|
||||
Namespace = 65536,
|
||||
ExportContext = 131072,
|
||||
ContainsThis = 262144,
|
||||
HasImplicitReturn = 524288,
|
||||
HasExplicitReturn = 1048576,
|
||||
GlobalAugmentation = 2097152,
|
||||
HasClassExtends = 4194304,
|
||||
HasDecorators = 8388608,
|
||||
HasParamDecorators = 16777216,
|
||||
HasAsyncFunctions = 33554432,
|
||||
Modifier = 1022,
|
||||
AccessibilityModifier = 56,
|
||||
BlockScoped = 24576,
|
||||
ReachabilityCheckFlags = 1572864,
|
||||
EmitHelperFlags = 62914560,
|
||||
Let = 1024,
|
||||
Const = 2048,
|
||||
Namespace = 4096,
|
||||
ExportContext = 8192,
|
||||
ContainsThis = 16384,
|
||||
HasImplicitReturn = 32768,
|
||||
HasExplicitReturn = 65536,
|
||||
GlobalAugmentation = 131072,
|
||||
HasClassExtends = 262144,
|
||||
HasDecorators = 524288,
|
||||
HasParamDecorators = 1048576,
|
||||
HasAsyncFunctions = 2097152,
|
||||
DisallowInContext = 4194304,
|
||||
YieldContext = 8388608,
|
||||
DecoratorContext = 16777216,
|
||||
AwaitContext = 33554432,
|
||||
ThisNodeHasError = 67108864,
|
||||
JavaScriptFile = 134217728,
|
||||
ThisNodeOrAnySubNodesHasError = 268435456,
|
||||
HasAggregatedChildData = 536870912,
|
||||
Modifier = 959,
|
||||
AccessibilityModifier = 28,
|
||||
BlockScoped = 3072,
|
||||
ReachabilityCheckFlags = 98304,
|
||||
EmitHelperFlags = 3932160,
|
||||
ContextFlags = 62914560,
|
||||
TypeExcludesFlags = 41943040,
|
||||
}
|
||||
enum JsxFlags {
|
||||
None = 0,
|
||||
@@ -372,10 +380,6 @@ declare namespace ts {
|
||||
IntrinsicNamedElement = 1,
|
||||
/** An element inferred from the string index signature of the JSX.IntrinsicElements interface */
|
||||
IntrinsicIndexedElement = 2,
|
||||
/** An element backed by a class, class-like, or function value */
|
||||
ValueElement = 4,
|
||||
/** Element resolution failed */
|
||||
UnknownElement = 16,
|
||||
IntrinsicElement = 3,
|
||||
}
|
||||
interface Node extends TextRange {
|
||||
@@ -702,7 +706,7 @@ declare namespace ts {
|
||||
expression: LeftHandSideExpression;
|
||||
argumentExpression?: Expression;
|
||||
}
|
||||
interface CallExpression extends LeftHandSideExpression {
|
||||
interface CallExpression extends LeftHandSideExpression, Declaration {
|
||||
expression: LeftHandSideExpression;
|
||||
typeArguments?: NodeArray<TypeNode>;
|
||||
arguments: NodeArray<Expression>;
|
||||
@@ -1000,6 +1004,7 @@ declare namespace ts {
|
||||
interface JSDocThisType extends JSDocType {
|
||||
type: JSDocType;
|
||||
}
|
||||
type JSDocTypeReferencingNode = JSDocThisType | JSDocConstructorType | JSDocVariadicType | JSDocOptionalType | JSDocNullableType | JSDocNonNullableType;
|
||||
interface JSDocRecordMember extends PropertySignature {
|
||||
name: Identifier | LiteralExpression;
|
||||
type?: JSDocType;
|
||||
@@ -1040,6 +1045,7 @@ declare namespace ts {
|
||||
moduleName: string;
|
||||
referencedFiles: FileReference[];
|
||||
languageVariant: LanguageVariant;
|
||||
isDeclarationFile: boolean;
|
||||
/**
|
||||
* lib.d.ts should have a reference comment like
|
||||
*
|
||||
@@ -1133,6 +1139,7 @@ declare namespace ts {
|
||||
}
|
||||
interface EmitResult {
|
||||
emitSkipped: boolean;
|
||||
/** Contains declaration emit diagnostics */
|
||||
diagnostics: Diagnostic[];
|
||||
}
|
||||
interface TypeChecker {
|
||||
@@ -1177,7 +1184,8 @@ declare namespace ts {
|
||||
buildSignatureDisplay(signatures: Signature, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags, kind?: SignatureKind): void;
|
||||
buildParameterDisplay(parameter: Symbol, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void;
|
||||
buildTypeParameterDisplay(tp: TypeParameter, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void;
|
||||
buildTypeParameterDisplayFromSymbol(symbol: Symbol, writer: SymbolWriter, enclosingDeclaraiton?: Node, flags?: TypeFormatFlags): void;
|
||||
buildTypePredicateDisplay(predicate: TypePredicate, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void;
|
||||
buildTypeParameterDisplayFromSymbol(symbol: Symbol, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void;
|
||||
buildDisplayForParametersAndDelimiters(parameters: Symbol[], writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void;
|
||||
buildDisplayForTypeParametersAndDelimiters(typeParameters: TypeParameter[], writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void;
|
||||
buildReturnTypeDisplay(signature: Signature, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void;
|
||||
@@ -1217,17 +1225,18 @@ declare namespace ts {
|
||||
This = 0,
|
||||
Identifier = 1,
|
||||
}
|
||||
interface TypePredicate {
|
||||
interface TypePredicateBase {
|
||||
kind: TypePredicateKind;
|
||||
type: Type;
|
||||
}
|
||||
interface ThisTypePredicate extends TypePredicate {
|
||||
interface ThisTypePredicate extends TypePredicateBase {
|
||||
_thisTypePredicateBrand: any;
|
||||
}
|
||||
interface IdentifierTypePredicate extends TypePredicate {
|
||||
interface IdentifierTypePredicate extends TypePredicateBase {
|
||||
parameterName: string;
|
||||
parameterIndex: number;
|
||||
}
|
||||
type TypePredicate = IdentifierTypePredicate | ThisTypePredicate;
|
||||
enum SymbolFlags {
|
||||
None = 0,
|
||||
FunctionScopedVariable = 1,
|
||||
@@ -1328,7 +1337,6 @@ declare namespace ts {
|
||||
ESSymbol = 16777216,
|
||||
ThisType = 33554432,
|
||||
ObjectLiteralPatternWithComputedProperties = 67108864,
|
||||
PredicateType = 134217728,
|
||||
StringLike = 258,
|
||||
NumberLike = 132,
|
||||
ObjectType = 80896,
|
||||
@@ -1341,9 +1349,6 @@ declare namespace ts {
|
||||
symbol?: Symbol;
|
||||
pattern?: DestructuringPattern;
|
||||
}
|
||||
interface PredicateType extends Type {
|
||||
predicate: ThisTypePredicate | IdentifierTypePredicate;
|
||||
}
|
||||
interface StringLiteralType extends Type {
|
||||
text: string;
|
||||
}
|
||||
@@ -1359,8 +1364,8 @@ declare namespace ts {
|
||||
declaredProperties: Symbol[];
|
||||
declaredCallSignatures: Signature[];
|
||||
declaredConstructSignatures: Signature[];
|
||||
declaredStringIndexType: Type;
|
||||
declaredNumberIndexType: Type;
|
||||
declaredStringIndexInfo: IndexInfo;
|
||||
declaredNumberIndexInfo: IndexInfo;
|
||||
}
|
||||
interface TypeReference extends ObjectType {
|
||||
target: GenericType;
|
||||
@@ -1394,6 +1399,11 @@ declare namespace ts {
|
||||
String = 0,
|
||||
Number = 1,
|
||||
}
|
||||
interface IndexInfo {
|
||||
type: Type;
|
||||
isReadonly: boolean;
|
||||
declaration?: SignatureDeclaration;
|
||||
}
|
||||
interface DiagnosticMessage {
|
||||
key: string;
|
||||
category: DiagnosticCategory;
|
||||
@@ -1429,6 +1439,9 @@ declare namespace ts {
|
||||
Classic = 1,
|
||||
NodeJs = 2,
|
||||
}
|
||||
type RootPaths = string[];
|
||||
type PathSubstitutions = Map<string[]>;
|
||||
type TsConfigOnlyOptions = RootPaths | PathSubstitutions;
|
||||
interface CompilerOptions {
|
||||
allowNonTsExtensions?: boolean;
|
||||
charset?: string;
|
||||
@@ -1476,9 +1489,14 @@ declare namespace ts {
|
||||
noImplicitReturns?: boolean;
|
||||
noFallthroughCasesInSwitch?: boolean;
|
||||
forceConsistentCasingInFileNames?: boolean;
|
||||
baseUrl?: string;
|
||||
paths?: PathSubstitutions;
|
||||
rootDirs?: RootPaths;
|
||||
traceModuleResolution?: boolean;
|
||||
allowSyntheticDefaultImports?: boolean;
|
||||
allowJs?: boolean;
|
||||
[option: string]: string | number | boolean;
|
||||
noImplicitUseStrict?: boolean;
|
||||
[option: string]: string | number | boolean | TsConfigOnlyOptions;
|
||||
}
|
||||
enum ModuleKind {
|
||||
None = 0,
|
||||
@@ -1502,6 +1520,13 @@ declare namespace ts {
|
||||
line: number;
|
||||
character: number;
|
||||
}
|
||||
enum ScriptKind {
|
||||
Unknown = 0,
|
||||
JS = 1,
|
||||
JSX = 2,
|
||||
TS = 3,
|
||||
TSX = 4,
|
||||
}
|
||||
enum ScriptTarget {
|
||||
ES3 = 0,
|
||||
ES5 = 1,
|
||||
@@ -1521,6 +1546,7 @@ declare namespace ts {
|
||||
interface ModuleResolutionHost {
|
||||
fileExists(fileName: string): boolean;
|
||||
readFile(fileName: string): string;
|
||||
trace?(s: string): void;
|
||||
directoryExists?(directoryName: string): boolean;
|
||||
}
|
||||
interface ResolvedModule {
|
||||
@@ -1604,6 +1630,7 @@ declare namespace ts {
|
||||
scanJsxIdentifier(): SyntaxKind;
|
||||
reScanJsxToken(): SyntaxKind;
|
||||
scanJsxToken(): SyntaxKind;
|
||||
scanJSDocToken(): SyntaxKind;
|
||||
scan(): SyntaxKind;
|
||||
setText(text: string, start?: number, length?: number): void;
|
||||
setOnError(onError: ErrorCallback): void;
|
||||
@@ -1611,6 +1638,7 @@ declare namespace ts {
|
||||
setLanguageVariant(variant: LanguageVariant): void;
|
||||
setTextPos(textPos: number): void;
|
||||
lookAhead<T>(callback: () => T): T;
|
||||
scanRange<T>(start: number, length: number, callback: () => T): T;
|
||||
tryScan<T>(callback: () => T): T;
|
||||
}
|
||||
function tokenToString(t: SyntaxKind): string;
|
||||
@@ -1661,7 +1689,7 @@ declare namespace ts {
|
||||
declare namespace ts {
|
||||
function createNode(kind: SyntaxKind, pos?: number, end?: number): Node;
|
||||
function forEachChild<T>(node: Node, cbNode: (node: Node) => T, cbNodeArray?: (nodes: Node[]) => T): T;
|
||||
function createSourceFile(fileName: string, sourceText: string, languageVersion: ScriptTarget, setParentNodes?: boolean): SourceFile;
|
||||
function createSourceFile(fileName: string, sourceText: string, languageVersion: ScriptTarget, setParentNodes?: boolean, scriptKind?: ScriptKind): SourceFile;
|
||||
function updateSourceFile(sourceFile: SourceFile, newText: string, textChangeRange: TextChangeRange, aggressiveChecks?: boolean): SourceFile;
|
||||
}
|
||||
declare namespace ts {
|
||||
@@ -1702,8 +1730,8 @@ declare namespace ts {
|
||||
* @param basePath A root directory to resolve relative path entries in the config
|
||||
* file to. e.g. outDir
|
||||
*/
|
||||
function parseJsonConfigFileContent(json: any, host: ParseConfigHost, basePath: string, existingOptions?: CompilerOptions): ParsedCommandLine;
|
||||
function convertCompilerOptionsFromJson(jsonOptions: any, basePath: string): {
|
||||
function parseJsonConfigFileContent(json: any, host: ParseConfigHost, basePath: string, existingOptions?: CompilerOptions, configFileName?: string): ParsedCommandLine;
|
||||
function convertCompilerOptionsFromJson(jsonOptions: any, basePath: string, configFileName?: string): {
|
||||
options: CompilerOptions;
|
||||
errors: Diagnostic[];
|
||||
};
|
||||
@@ -1796,6 +1824,7 @@ declare namespace ts {
|
||||
getNewLine?(): string;
|
||||
getProjectVersion?(): string;
|
||||
getScriptFileNames(): string[];
|
||||
getScriptKind?(fileName: string): ScriptKind;
|
||||
getScriptVersion(fileName: string): string;
|
||||
getScriptSnapshot(fileName: string): IScriptSnapshot;
|
||||
getLocalizedDiagnosticMessages?(): any;
|
||||
@@ -2164,7 +2193,7 @@ declare namespace ts {
|
||||
* @parm version Current version of the file. Only used if the file was not found
|
||||
* in the registry and a new one was created.
|
||||
*/
|
||||
acquireDocument(fileName: string, compilationSettings: CompilerOptions, scriptSnapshot: IScriptSnapshot, version: string): SourceFile;
|
||||
acquireDocument(fileName: string, compilationSettings: CompilerOptions, scriptSnapshot: IScriptSnapshot, version: string, scriptKind?: ScriptKind): SourceFile;
|
||||
/**
|
||||
* Request an updated version of an already existing SourceFile with a given fileName
|
||||
* and compilationSettings. The update will in-turn call updateLanguageServiceSourceFile
|
||||
@@ -2177,7 +2206,7 @@ declare namespace ts {
|
||||
* @param scriptSnapshot Text of the file.
|
||||
* @param version Current version of the file.
|
||||
*/
|
||||
updateDocument(fileName: string, compilationSettings: CompilerOptions, scriptSnapshot: IScriptSnapshot, version: string): SourceFile;
|
||||
updateDocument(fileName: string, compilationSettings: CompilerOptions, scriptSnapshot: IScriptSnapshot, version: string, scriptKind?: ScriptKind): SourceFile;
|
||||
/**
|
||||
* Informs the DocumentRegistry that a file is not needed any longer.
|
||||
*
|
||||
@@ -2301,7 +2330,7 @@ declare namespace ts {
|
||||
}
|
||||
function transpileModule(input: string, transpileOptions: TranspileOptions): TranspileOutput;
|
||||
function transpile(input: string, compilerOptions?: CompilerOptions, fileName?: string, diagnostics?: Diagnostic[], moduleName?: string): string;
|
||||
function createLanguageServiceSourceFile(fileName: string, scriptSnapshot: IScriptSnapshot, scriptTarget: ScriptTarget, version: string, setNodeParents: boolean): SourceFile;
|
||||
function createLanguageServiceSourceFile(fileName: string, scriptSnapshot: IScriptSnapshot, scriptTarget: ScriptTarget, version: string, setNodeParents: boolean, scriptKind?: ScriptKind): SourceFile;
|
||||
let disableIncrementalParsing: boolean;
|
||||
function updateLanguageServiceSourceFile(sourceFile: SourceFile, scriptSnapshot: IScriptSnapshot, version: string, textChangeRange: TextChangeRange, aggressiveChecks?: boolean): SourceFile;
|
||||
function createDocumentRegistry(useCaseSensitiveFileNames?: boolean, currentDirectory?: string): DocumentRegistry;
|
||||
|
||||
+7071
-5624
File diff suppressed because it is too large
Load Diff
Vendored
+232
-203
@@ -160,169 +160,170 @@ declare namespace ts {
|
||||
IsKeyword = 124,
|
||||
ModuleKeyword = 125,
|
||||
NamespaceKeyword = 126,
|
||||
RequireKeyword = 127,
|
||||
NumberKeyword = 128,
|
||||
SetKeyword = 129,
|
||||
StringKeyword = 130,
|
||||
SymbolKeyword = 131,
|
||||
TypeKeyword = 132,
|
||||
FromKeyword = 133,
|
||||
GlobalKeyword = 134,
|
||||
OfKeyword = 135,
|
||||
QualifiedName = 136,
|
||||
ComputedPropertyName = 137,
|
||||
TypeParameter = 138,
|
||||
Parameter = 139,
|
||||
Decorator = 140,
|
||||
PropertySignature = 141,
|
||||
PropertyDeclaration = 142,
|
||||
MethodSignature = 143,
|
||||
MethodDeclaration = 144,
|
||||
Constructor = 145,
|
||||
GetAccessor = 146,
|
||||
SetAccessor = 147,
|
||||
CallSignature = 148,
|
||||
ConstructSignature = 149,
|
||||
IndexSignature = 150,
|
||||
TypePredicate = 151,
|
||||
TypeReference = 152,
|
||||
FunctionType = 153,
|
||||
ConstructorType = 154,
|
||||
TypeQuery = 155,
|
||||
TypeLiteral = 156,
|
||||
ArrayType = 157,
|
||||
TupleType = 158,
|
||||
UnionType = 159,
|
||||
IntersectionType = 160,
|
||||
ParenthesizedType = 161,
|
||||
ThisType = 162,
|
||||
StringLiteralType = 163,
|
||||
ObjectBindingPattern = 164,
|
||||
ArrayBindingPattern = 165,
|
||||
BindingElement = 166,
|
||||
ArrayLiteralExpression = 167,
|
||||
ObjectLiteralExpression = 168,
|
||||
PropertyAccessExpression = 169,
|
||||
ElementAccessExpression = 170,
|
||||
CallExpression = 171,
|
||||
NewExpression = 172,
|
||||
TaggedTemplateExpression = 173,
|
||||
TypeAssertionExpression = 174,
|
||||
ParenthesizedExpression = 175,
|
||||
FunctionExpression = 176,
|
||||
ArrowFunction = 177,
|
||||
DeleteExpression = 178,
|
||||
TypeOfExpression = 179,
|
||||
VoidExpression = 180,
|
||||
AwaitExpression = 181,
|
||||
PrefixUnaryExpression = 182,
|
||||
PostfixUnaryExpression = 183,
|
||||
BinaryExpression = 184,
|
||||
ConditionalExpression = 185,
|
||||
TemplateExpression = 186,
|
||||
YieldExpression = 187,
|
||||
SpreadElementExpression = 188,
|
||||
ClassExpression = 189,
|
||||
OmittedExpression = 190,
|
||||
ExpressionWithTypeArguments = 191,
|
||||
AsExpression = 192,
|
||||
TemplateSpan = 193,
|
||||
SemicolonClassElement = 194,
|
||||
Block = 195,
|
||||
VariableStatement = 196,
|
||||
EmptyStatement = 197,
|
||||
ExpressionStatement = 198,
|
||||
IfStatement = 199,
|
||||
DoStatement = 200,
|
||||
WhileStatement = 201,
|
||||
ForStatement = 202,
|
||||
ForInStatement = 203,
|
||||
ForOfStatement = 204,
|
||||
ContinueStatement = 205,
|
||||
BreakStatement = 206,
|
||||
ReturnStatement = 207,
|
||||
WithStatement = 208,
|
||||
SwitchStatement = 209,
|
||||
LabeledStatement = 210,
|
||||
ThrowStatement = 211,
|
||||
TryStatement = 212,
|
||||
DebuggerStatement = 213,
|
||||
VariableDeclaration = 214,
|
||||
VariableDeclarationList = 215,
|
||||
FunctionDeclaration = 216,
|
||||
ClassDeclaration = 217,
|
||||
InterfaceDeclaration = 218,
|
||||
TypeAliasDeclaration = 219,
|
||||
EnumDeclaration = 220,
|
||||
ModuleDeclaration = 221,
|
||||
ModuleBlock = 222,
|
||||
CaseBlock = 223,
|
||||
ImportEqualsDeclaration = 224,
|
||||
ImportDeclaration = 225,
|
||||
ImportClause = 226,
|
||||
NamespaceImport = 227,
|
||||
NamedImports = 228,
|
||||
ImportSpecifier = 229,
|
||||
ExportAssignment = 230,
|
||||
ExportDeclaration = 231,
|
||||
NamedExports = 232,
|
||||
ExportSpecifier = 233,
|
||||
MissingDeclaration = 234,
|
||||
ExternalModuleReference = 235,
|
||||
JsxElement = 236,
|
||||
JsxSelfClosingElement = 237,
|
||||
JsxOpeningElement = 238,
|
||||
JsxText = 239,
|
||||
JsxClosingElement = 240,
|
||||
JsxAttribute = 241,
|
||||
JsxSpreadAttribute = 242,
|
||||
JsxExpression = 243,
|
||||
CaseClause = 244,
|
||||
DefaultClause = 245,
|
||||
HeritageClause = 246,
|
||||
CatchClause = 247,
|
||||
PropertyAssignment = 248,
|
||||
ShorthandPropertyAssignment = 249,
|
||||
EnumMember = 250,
|
||||
SourceFile = 251,
|
||||
JSDocTypeExpression = 252,
|
||||
JSDocAllType = 253,
|
||||
JSDocUnknownType = 254,
|
||||
JSDocArrayType = 255,
|
||||
JSDocUnionType = 256,
|
||||
JSDocTupleType = 257,
|
||||
JSDocNullableType = 258,
|
||||
JSDocNonNullableType = 259,
|
||||
JSDocRecordType = 260,
|
||||
JSDocRecordMember = 261,
|
||||
JSDocTypeReference = 262,
|
||||
JSDocOptionalType = 263,
|
||||
JSDocFunctionType = 264,
|
||||
JSDocVariadicType = 265,
|
||||
JSDocConstructorType = 266,
|
||||
JSDocThisType = 267,
|
||||
JSDocComment = 268,
|
||||
JSDocTag = 269,
|
||||
JSDocParameterTag = 270,
|
||||
JSDocReturnTag = 271,
|
||||
JSDocTypeTag = 272,
|
||||
JSDocTemplateTag = 273,
|
||||
SyntaxList = 274,
|
||||
Count = 275,
|
||||
ReadonlyKeyword = 127,
|
||||
RequireKeyword = 128,
|
||||
NumberKeyword = 129,
|
||||
SetKeyword = 130,
|
||||
StringKeyword = 131,
|
||||
SymbolKeyword = 132,
|
||||
TypeKeyword = 133,
|
||||
FromKeyword = 134,
|
||||
GlobalKeyword = 135,
|
||||
OfKeyword = 136,
|
||||
QualifiedName = 137,
|
||||
ComputedPropertyName = 138,
|
||||
TypeParameter = 139,
|
||||
Parameter = 140,
|
||||
Decorator = 141,
|
||||
PropertySignature = 142,
|
||||
PropertyDeclaration = 143,
|
||||
MethodSignature = 144,
|
||||
MethodDeclaration = 145,
|
||||
Constructor = 146,
|
||||
GetAccessor = 147,
|
||||
SetAccessor = 148,
|
||||
CallSignature = 149,
|
||||
ConstructSignature = 150,
|
||||
IndexSignature = 151,
|
||||
TypePredicate = 152,
|
||||
TypeReference = 153,
|
||||
FunctionType = 154,
|
||||
ConstructorType = 155,
|
||||
TypeQuery = 156,
|
||||
TypeLiteral = 157,
|
||||
ArrayType = 158,
|
||||
TupleType = 159,
|
||||
UnionType = 160,
|
||||
IntersectionType = 161,
|
||||
ParenthesizedType = 162,
|
||||
ThisType = 163,
|
||||
StringLiteralType = 164,
|
||||
ObjectBindingPattern = 165,
|
||||
ArrayBindingPattern = 166,
|
||||
BindingElement = 167,
|
||||
ArrayLiteralExpression = 168,
|
||||
ObjectLiteralExpression = 169,
|
||||
PropertyAccessExpression = 170,
|
||||
ElementAccessExpression = 171,
|
||||
CallExpression = 172,
|
||||
NewExpression = 173,
|
||||
TaggedTemplateExpression = 174,
|
||||
TypeAssertionExpression = 175,
|
||||
ParenthesizedExpression = 176,
|
||||
FunctionExpression = 177,
|
||||
ArrowFunction = 178,
|
||||
DeleteExpression = 179,
|
||||
TypeOfExpression = 180,
|
||||
VoidExpression = 181,
|
||||
AwaitExpression = 182,
|
||||
PrefixUnaryExpression = 183,
|
||||
PostfixUnaryExpression = 184,
|
||||
BinaryExpression = 185,
|
||||
ConditionalExpression = 186,
|
||||
TemplateExpression = 187,
|
||||
YieldExpression = 188,
|
||||
SpreadElementExpression = 189,
|
||||
ClassExpression = 190,
|
||||
OmittedExpression = 191,
|
||||
ExpressionWithTypeArguments = 192,
|
||||
AsExpression = 193,
|
||||
TemplateSpan = 194,
|
||||
SemicolonClassElement = 195,
|
||||
Block = 196,
|
||||
VariableStatement = 197,
|
||||
EmptyStatement = 198,
|
||||
ExpressionStatement = 199,
|
||||
IfStatement = 200,
|
||||
DoStatement = 201,
|
||||
WhileStatement = 202,
|
||||
ForStatement = 203,
|
||||
ForInStatement = 204,
|
||||
ForOfStatement = 205,
|
||||
ContinueStatement = 206,
|
||||
BreakStatement = 207,
|
||||
ReturnStatement = 208,
|
||||
WithStatement = 209,
|
||||
SwitchStatement = 210,
|
||||
LabeledStatement = 211,
|
||||
ThrowStatement = 212,
|
||||
TryStatement = 213,
|
||||
DebuggerStatement = 214,
|
||||
VariableDeclaration = 215,
|
||||
VariableDeclarationList = 216,
|
||||
FunctionDeclaration = 217,
|
||||
ClassDeclaration = 218,
|
||||
InterfaceDeclaration = 219,
|
||||
TypeAliasDeclaration = 220,
|
||||
EnumDeclaration = 221,
|
||||
ModuleDeclaration = 222,
|
||||
ModuleBlock = 223,
|
||||
CaseBlock = 224,
|
||||
ImportEqualsDeclaration = 225,
|
||||
ImportDeclaration = 226,
|
||||
ImportClause = 227,
|
||||
NamespaceImport = 228,
|
||||
NamedImports = 229,
|
||||
ImportSpecifier = 230,
|
||||
ExportAssignment = 231,
|
||||
ExportDeclaration = 232,
|
||||
NamedExports = 233,
|
||||
ExportSpecifier = 234,
|
||||
MissingDeclaration = 235,
|
||||
ExternalModuleReference = 236,
|
||||
JsxElement = 237,
|
||||
JsxSelfClosingElement = 238,
|
||||
JsxOpeningElement = 239,
|
||||
JsxText = 240,
|
||||
JsxClosingElement = 241,
|
||||
JsxAttribute = 242,
|
||||
JsxSpreadAttribute = 243,
|
||||
JsxExpression = 244,
|
||||
CaseClause = 245,
|
||||
DefaultClause = 246,
|
||||
HeritageClause = 247,
|
||||
CatchClause = 248,
|
||||
PropertyAssignment = 249,
|
||||
ShorthandPropertyAssignment = 250,
|
||||
EnumMember = 251,
|
||||
SourceFile = 252,
|
||||
JSDocTypeExpression = 253,
|
||||
JSDocAllType = 254,
|
||||
JSDocUnknownType = 255,
|
||||
JSDocArrayType = 256,
|
||||
JSDocUnionType = 257,
|
||||
JSDocTupleType = 258,
|
||||
JSDocNullableType = 259,
|
||||
JSDocNonNullableType = 260,
|
||||
JSDocRecordType = 261,
|
||||
JSDocRecordMember = 262,
|
||||
JSDocTypeReference = 263,
|
||||
JSDocOptionalType = 264,
|
||||
JSDocFunctionType = 265,
|
||||
JSDocVariadicType = 266,
|
||||
JSDocConstructorType = 267,
|
||||
JSDocThisType = 268,
|
||||
JSDocComment = 269,
|
||||
JSDocTag = 270,
|
||||
JSDocParameterTag = 271,
|
||||
JSDocReturnTag = 272,
|
||||
JSDocTypeTag = 273,
|
||||
JSDocTemplateTag = 274,
|
||||
SyntaxList = 275,
|
||||
Count = 276,
|
||||
FirstAssignment = 56,
|
||||
LastAssignment = 68,
|
||||
FirstReservedWord = 70,
|
||||
LastReservedWord = 105,
|
||||
FirstKeyword = 70,
|
||||
LastKeyword = 135,
|
||||
LastKeyword = 136,
|
||||
FirstFutureReservedWord = 106,
|
||||
LastFutureReservedWord = 114,
|
||||
FirstTypeNode = 151,
|
||||
LastTypeNode = 163,
|
||||
FirstTypeNode = 152,
|
||||
LastTypeNode = 164,
|
||||
FirstPunctuation = 15,
|
||||
LastPunctuation = 68,
|
||||
FirstToken = 0,
|
||||
LastToken = 135,
|
||||
LastToken = 136,
|
||||
FirstTriviaToken = 2,
|
||||
LastTriviaToken = 7,
|
||||
FirstLiteralToken = 8,
|
||||
@@ -331,40 +332,47 @@ declare namespace ts {
|
||||
LastTemplateToken = 14,
|
||||
FirstBinaryOperator = 25,
|
||||
LastBinaryOperator = 68,
|
||||
FirstNode = 136,
|
||||
FirstNode = 137,
|
||||
}
|
||||
enum NodeFlags {
|
||||
None = 0,
|
||||
Export = 2,
|
||||
Ambient = 4,
|
||||
Public = 8,
|
||||
Private = 16,
|
||||
Protected = 32,
|
||||
Static = 64,
|
||||
Export = 1,
|
||||
Ambient = 2,
|
||||
Public = 4,
|
||||
Private = 8,
|
||||
Protected = 16,
|
||||
Static = 32,
|
||||
Readonly = 64,
|
||||
Abstract = 128,
|
||||
Async = 256,
|
||||
Default = 512,
|
||||
MultiLine = 1024,
|
||||
Synthetic = 2048,
|
||||
DeclarationFile = 4096,
|
||||
Let = 8192,
|
||||
Const = 16384,
|
||||
OctalLiteral = 32768,
|
||||
Namespace = 65536,
|
||||
ExportContext = 131072,
|
||||
ContainsThis = 262144,
|
||||
HasImplicitReturn = 524288,
|
||||
HasExplicitReturn = 1048576,
|
||||
GlobalAugmentation = 2097152,
|
||||
HasClassExtends = 4194304,
|
||||
HasDecorators = 8388608,
|
||||
HasParamDecorators = 16777216,
|
||||
HasAsyncFunctions = 33554432,
|
||||
Modifier = 1022,
|
||||
AccessibilityModifier = 56,
|
||||
BlockScoped = 24576,
|
||||
ReachabilityCheckFlags = 1572864,
|
||||
EmitHelperFlags = 62914560,
|
||||
Let = 1024,
|
||||
Const = 2048,
|
||||
Namespace = 4096,
|
||||
ExportContext = 8192,
|
||||
ContainsThis = 16384,
|
||||
HasImplicitReturn = 32768,
|
||||
HasExplicitReturn = 65536,
|
||||
GlobalAugmentation = 131072,
|
||||
HasClassExtends = 262144,
|
||||
HasDecorators = 524288,
|
||||
HasParamDecorators = 1048576,
|
||||
HasAsyncFunctions = 2097152,
|
||||
DisallowInContext = 4194304,
|
||||
YieldContext = 8388608,
|
||||
DecoratorContext = 16777216,
|
||||
AwaitContext = 33554432,
|
||||
ThisNodeHasError = 67108864,
|
||||
JavaScriptFile = 134217728,
|
||||
ThisNodeOrAnySubNodesHasError = 268435456,
|
||||
HasAggregatedChildData = 536870912,
|
||||
Modifier = 959,
|
||||
AccessibilityModifier = 28,
|
||||
BlockScoped = 3072,
|
||||
ReachabilityCheckFlags = 98304,
|
||||
EmitHelperFlags = 3932160,
|
||||
ContextFlags = 62914560,
|
||||
TypeExcludesFlags = 41943040,
|
||||
}
|
||||
enum JsxFlags {
|
||||
None = 0,
|
||||
@@ -372,10 +380,6 @@ declare namespace ts {
|
||||
IntrinsicNamedElement = 1,
|
||||
/** An element inferred from the string index signature of the JSX.IntrinsicElements interface */
|
||||
IntrinsicIndexedElement = 2,
|
||||
/** An element backed by a class, class-like, or function value */
|
||||
ValueElement = 4,
|
||||
/** Element resolution failed */
|
||||
UnknownElement = 16,
|
||||
IntrinsicElement = 3,
|
||||
}
|
||||
interface Node extends TextRange {
|
||||
@@ -702,7 +706,7 @@ declare namespace ts {
|
||||
expression: LeftHandSideExpression;
|
||||
argumentExpression?: Expression;
|
||||
}
|
||||
interface CallExpression extends LeftHandSideExpression {
|
||||
interface CallExpression extends LeftHandSideExpression, Declaration {
|
||||
expression: LeftHandSideExpression;
|
||||
typeArguments?: NodeArray<TypeNode>;
|
||||
arguments: NodeArray<Expression>;
|
||||
@@ -1000,6 +1004,7 @@ declare namespace ts {
|
||||
interface JSDocThisType extends JSDocType {
|
||||
type: JSDocType;
|
||||
}
|
||||
type JSDocTypeReferencingNode = JSDocThisType | JSDocConstructorType | JSDocVariadicType | JSDocOptionalType | JSDocNullableType | JSDocNonNullableType;
|
||||
interface JSDocRecordMember extends PropertySignature {
|
||||
name: Identifier | LiteralExpression;
|
||||
type?: JSDocType;
|
||||
@@ -1040,6 +1045,7 @@ declare namespace ts {
|
||||
moduleName: string;
|
||||
referencedFiles: FileReference[];
|
||||
languageVariant: LanguageVariant;
|
||||
isDeclarationFile: boolean;
|
||||
/**
|
||||
* lib.d.ts should have a reference comment like
|
||||
*
|
||||
@@ -1133,6 +1139,7 @@ declare namespace ts {
|
||||
}
|
||||
interface EmitResult {
|
||||
emitSkipped: boolean;
|
||||
/** Contains declaration emit diagnostics */
|
||||
diagnostics: Diagnostic[];
|
||||
}
|
||||
interface TypeChecker {
|
||||
@@ -1177,7 +1184,8 @@ declare namespace ts {
|
||||
buildSignatureDisplay(signatures: Signature, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags, kind?: SignatureKind): void;
|
||||
buildParameterDisplay(parameter: Symbol, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void;
|
||||
buildTypeParameterDisplay(tp: TypeParameter, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void;
|
||||
buildTypeParameterDisplayFromSymbol(symbol: Symbol, writer: SymbolWriter, enclosingDeclaraiton?: Node, flags?: TypeFormatFlags): void;
|
||||
buildTypePredicateDisplay(predicate: TypePredicate, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void;
|
||||
buildTypeParameterDisplayFromSymbol(symbol: Symbol, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void;
|
||||
buildDisplayForParametersAndDelimiters(parameters: Symbol[], writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void;
|
||||
buildDisplayForTypeParametersAndDelimiters(typeParameters: TypeParameter[], writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void;
|
||||
buildReturnTypeDisplay(signature: Signature, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void;
|
||||
@@ -1217,17 +1225,18 @@ declare namespace ts {
|
||||
This = 0,
|
||||
Identifier = 1,
|
||||
}
|
||||
interface TypePredicate {
|
||||
interface TypePredicateBase {
|
||||
kind: TypePredicateKind;
|
||||
type: Type;
|
||||
}
|
||||
interface ThisTypePredicate extends TypePredicate {
|
||||
interface ThisTypePredicate extends TypePredicateBase {
|
||||
_thisTypePredicateBrand: any;
|
||||
}
|
||||
interface IdentifierTypePredicate extends TypePredicate {
|
||||
interface IdentifierTypePredicate extends TypePredicateBase {
|
||||
parameterName: string;
|
||||
parameterIndex: number;
|
||||
}
|
||||
type TypePredicate = IdentifierTypePredicate | ThisTypePredicate;
|
||||
enum SymbolFlags {
|
||||
None = 0,
|
||||
FunctionScopedVariable = 1,
|
||||
@@ -1328,7 +1337,6 @@ declare namespace ts {
|
||||
ESSymbol = 16777216,
|
||||
ThisType = 33554432,
|
||||
ObjectLiteralPatternWithComputedProperties = 67108864,
|
||||
PredicateType = 134217728,
|
||||
StringLike = 258,
|
||||
NumberLike = 132,
|
||||
ObjectType = 80896,
|
||||
@@ -1341,9 +1349,6 @@ declare namespace ts {
|
||||
symbol?: Symbol;
|
||||
pattern?: DestructuringPattern;
|
||||
}
|
||||
interface PredicateType extends Type {
|
||||
predicate: ThisTypePredicate | IdentifierTypePredicate;
|
||||
}
|
||||
interface StringLiteralType extends Type {
|
||||
text: string;
|
||||
}
|
||||
@@ -1359,8 +1364,8 @@ declare namespace ts {
|
||||
declaredProperties: Symbol[];
|
||||
declaredCallSignatures: Signature[];
|
||||
declaredConstructSignatures: Signature[];
|
||||
declaredStringIndexType: Type;
|
||||
declaredNumberIndexType: Type;
|
||||
declaredStringIndexInfo: IndexInfo;
|
||||
declaredNumberIndexInfo: IndexInfo;
|
||||
}
|
||||
interface TypeReference extends ObjectType {
|
||||
target: GenericType;
|
||||
@@ -1394,6 +1399,11 @@ declare namespace ts {
|
||||
String = 0,
|
||||
Number = 1,
|
||||
}
|
||||
interface IndexInfo {
|
||||
type: Type;
|
||||
isReadonly: boolean;
|
||||
declaration?: SignatureDeclaration;
|
||||
}
|
||||
interface DiagnosticMessage {
|
||||
key: string;
|
||||
category: DiagnosticCategory;
|
||||
@@ -1429,6 +1439,9 @@ declare namespace ts {
|
||||
Classic = 1,
|
||||
NodeJs = 2,
|
||||
}
|
||||
type RootPaths = string[];
|
||||
type PathSubstitutions = Map<string[]>;
|
||||
type TsConfigOnlyOptions = RootPaths | PathSubstitutions;
|
||||
interface CompilerOptions {
|
||||
allowNonTsExtensions?: boolean;
|
||||
charset?: string;
|
||||
@@ -1476,9 +1489,14 @@ declare namespace ts {
|
||||
noImplicitReturns?: boolean;
|
||||
noFallthroughCasesInSwitch?: boolean;
|
||||
forceConsistentCasingInFileNames?: boolean;
|
||||
baseUrl?: string;
|
||||
paths?: PathSubstitutions;
|
||||
rootDirs?: RootPaths;
|
||||
traceModuleResolution?: boolean;
|
||||
allowSyntheticDefaultImports?: boolean;
|
||||
allowJs?: boolean;
|
||||
[option: string]: string | number | boolean;
|
||||
noImplicitUseStrict?: boolean;
|
||||
[option: string]: string | number | boolean | TsConfigOnlyOptions;
|
||||
}
|
||||
enum ModuleKind {
|
||||
None = 0,
|
||||
@@ -1502,6 +1520,13 @@ declare namespace ts {
|
||||
line: number;
|
||||
character: number;
|
||||
}
|
||||
enum ScriptKind {
|
||||
Unknown = 0,
|
||||
JS = 1,
|
||||
JSX = 2,
|
||||
TS = 3,
|
||||
TSX = 4,
|
||||
}
|
||||
enum ScriptTarget {
|
||||
ES3 = 0,
|
||||
ES5 = 1,
|
||||
@@ -1521,6 +1546,7 @@ declare namespace ts {
|
||||
interface ModuleResolutionHost {
|
||||
fileExists(fileName: string): boolean;
|
||||
readFile(fileName: string): string;
|
||||
trace?(s: string): void;
|
||||
directoryExists?(directoryName: string): boolean;
|
||||
}
|
||||
interface ResolvedModule {
|
||||
@@ -1604,6 +1630,7 @@ declare namespace ts {
|
||||
scanJsxIdentifier(): SyntaxKind;
|
||||
reScanJsxToken(): SyntaxKind;
|
||||
scanJsxToken(): SyntaxKind;
|
||||
scanJSDocToken(): SyntaxKind;
|
||||
scan(): SyntaxKind;
|
||||
setText(text: string, start?: number, length?: number): void;
|
||||
setOnError(onError: ErrorCallback): void;
|
||||
@@ -1611,6 +1638,7 @@ declare namespace ts {
|
||||
setLanguageVariant(variant: LanguageVariant): void;
|
||||
setTextPos(textPos: number): void;
|
||||
lookAhead<T>(callback: () => T): T;
|
||||
scanRange<T>(start: number, length: number, callback: () => T): T;
|
||||
tryScan<T>(callback: () => T): T;
|
||||
}
|
||||
function tokenToString(t: SyntaxKind): string;
|
||||
@@ -1661,7 +1689,7 @@ declare namespace ts {
|
||||
declare namespace ts {
|
||||
function createNode(kind: SyntaxKind, pos?: number, end?: number): Node;
|
||||
function forEachChild<T>(node: Node, cbNode: (node: Node) => T, cbNodeArray?: (nodes: Node[]) => T): T;
|
||||
function createSourceFile(fileName: string, sourceText: string, languageVersion: ScriptTarget, setParentNodes?: boolean): SourceFile;
|
||||
function createSourceFile(fileName: string, sourceText: string, languageVersion: ScriptTarget, setParentNodes?: boolean, scriptKind?: ScriptKind): SourceFile;
|
||||
function updateSourceFile(sourceFile: SourceFile, newText: string, textChangeRange: TextChangeRange, aggressiveChecks?: boolean): SourceFile;
|
||||
}
|
||||
declare namespace ts {
|
||||
@@ -1702,8 +1730,8 @@ declare namespace ts {
|
||||
* @param basePath A root directory to resolve relative path entries in the config
|
||||
* file to. e.g. outDir
|
||||
*/
|
||||
function parseJsonConfigFileContent(json: any, host: ParseConfigHost, basePath: string, existingOptions?: CompilerOptions): ParsedCommandLine;
|
||||
function convertCompilerOptionsFromJson(jsonOptions: any, basePath: string): {
|
||||
function parseJsonConfigFileContent(json: any, host: ParseConfigHost, basePath: string, existingOptions?: CompilerOptions, configFileName?: string): ParsedCommandLine;
|
||||
function convertCompilerOptionsFromJson(jsonOptions: any, basePath: string, configFileName?: string): {
|
||||
options: CompilerOptions;
|
||||
errors: Diagnostic[];
|
||||
};
|
||||
@@ -1796,6 +1824,7 @@ declare namespace ts {
|
||||
getNewLine?(): string;
|
||||
getProjectVersion?(): string;
|
||||
getScriptFileNames(): string[];
|
||||
getScriptKind?(fileName: string): ScriptKind;
|
||||
getScriptVersion(fileName: string): string;
|
||||
getScriptSnapshot(fileName: string): IScriptSnapshot;
|
||||
getLocalizedDiagnosticMessages?(): any;
|
||||
@@ -2164,7 +2193,7 @@ declare namespace ts {
|
||||
* @parm version Current version of the file. Only used if the file was not found
|
||||
* in the registry and a new one was created.
|
||||
*/
|
||||
acquireDocument(fileName: string, compilationSettings: CompilerOptions, scriptSnapshot: IScriptSnapshot, version: string): SourceFile;
|
||||
acquireDocument(fileName: string, compilationSettings: CompilerOptions, scriptSnapshot: IScriptSnapshot, version: string, scriptKind?: ScriptKind): SourceFile;
|
||||
/**
|
||||
* Request an updated version of an already existing SourceFile with a given fileName
|
||||
* and compilationSettings. The update will in-turn call updateLanguageServiceSourceFile
|
||||
@@ -2177,7 +2206,7 @@ declare namespace ts {
|
||||
* @param scriptSnapshot Text of the file.
|
||||
* @param version Current version of the file.
|
||||
*/
|
||||
updateDocument(fileName: string, compilationSettings: CompilerOptions, scriptSnapshot: IScriptSnapshot, version: string): SourceFile;
|
||||
updateDocument(fileName: string, compilationSettings: CompilerOptions, scriptSnapshot: IScriptSnapshot, version: string, scriptKind?: ScriptKind): SourceFile;
|
||||
/**
|
||||
* Informs the DocumentRegistry that a file is not needed any longer.
|
||||
*
|
||||
@@ -2301,7 +2330,7 @@ declare namespace ts {
|
||||
}
|
||||
function transpileModule(input: string, transpileOptions: TranspileOptions): TranspileOutput;
|
||||
function transpile(input: string, compilerOptions?: CompilerOptions, fileName?: string, diagnostics?: Diagnostic[], moduleName?: string): string;
|
||||
function createLanguageServiceSourceFile(fileName: string, scriptSnapshot: IScriptSnapshot, scriptTarget: ScriptTarget, version: string, setNodeParents: boolean): SourceFile;
|
||||
function createLanguageServiceSourceFile(fileName: string, scriptSnapshot: IScriptSnapshot, scriptTarget: ScriptTarget, version: string, setNodeParents: boolean, scriptKind?: ScriptKind): SourceFile;
|
||||
let disableIncrementalParsing: boolean;
|
||||
function updateLanguageServiceSourceFile(sourceFile: SourceFile, scriptSnapshot: IScriptSnapshot, version: string, textChangeRange: TextChangeRange, aggressiveChecks?: boolean): SourceFile;
|
||||
function createDocumentRegistry(useCaseSensitiveFileNames?: boolean, currentDirectory?: string): DocumentRegistry;
|
||||
|
||||
+7071
-5624
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,16 @@
|
||||
<!--
|
||||
Thank you for submitting a pull request!
|
||||
|
||||
Here's a checklist you might find useful.
|
||||
[ ] There is an associated issue that is labelled
|
||||
'Bug' or 'Accepting PRs' or is in the Community milestone
|
||||
[ ] Code is up-to-date with the `master` branch
|
||||
[ ] You've successfully run `jake runtests` locally
|
||||
[ ] You've signed the CLA
|
||||
[ ] There are new or updated unit tests validating the change
|
||||
|
||||
Refer to CONTRIBUTING.MD for more details.
|
||||
https://github.com/Microsoft/TypeScript/blob/master/CONTRIBUTING.md
|
||||
-->
|
||||
|
||||
Fixes #
|
||||
+15
-5
@@ -685,7 +685,7 @@ namespace ts {
|
||||
// post catch/finally state is reachable if
|
||||
// - post try state is reachable - control flow can fall out of try block
|
||||
// - post catch state is reachable - control flow can fall out of catch block
|
||||
currentReachabilityState = or(postTryState, postCatchState);
|
||||
currentReachabilityState = n.catchClause ? or(postTryState, postCatchState) : postTryState;
|
||||
}
|
||||
|
||||
function bindSwitchStatement(n: SwitchStatement): void {
|
||||
@@ -708,10 +708,14 @@ namespace ts {
|
||||
function bindCaseBlock(n: CaseBlock): void {
|
||||
const startState = currentReachabilityState;
|
||||
|
||||
for (const clause of n.clauses) {
|
||||
for (let i = 0; i < n.clauses.length; i++) {
|
||||
const clause = n.clauses[i];
|
||||
currentReachabilityState = startState;
|
||||
bind(clause);
|
||||
if (clause.statements.length && currentReachabilityState === Reachability.Reachable && options.noFallthroughCasesInSwitch) {
|
||||
if (clause.statements.length &&
|
||||
i !== n.clauses.length - 1 && // allow fallthrough from the last case
|
||||
currentReachabilityState === Reachability.Reachable &&
|
||||
options.noFallthroughCasesInSwitch) {
|
||||
errorOnFirstToken(clause, Diagnostics.Fallthrough_case_in_switch);
|
||||
}
|
||||
}
|
||||
@@ -749,6 +753,7 @@ namespace ts {
|
||||
case SyntaxKind.GetAccessor:
|
||||
case SyntaxKind.SetAccessor:
|
||||
case SyntaxKind.FunctionType:
|
||||
case SyntaxKind.JSDocFunctionType:
|
||||
case SyntaxKind.ConstructorType:
|
||||
case SyntaxKind.FunctionExpression:
|
||||
case SyntaxKind.ArrowFunction:
|
||||
@@ -896,7 +901,12 @@ namespace ts {
|
||||
if (node.flags & NodeFlags.Export) {
|
||||
errorOnFirstToken(node, Diagnostics.export_modifier_cannot_be_applied_to_ambient_modules_and_module_augmentations_since_they_are_always_visible);
|
||||
}
|
||||
declareSymbolAndAddToSymbolTable(node, SymbolFlags.ValueModule, SymbolFlags.ValueModuleExcludes);
|
||||
if (isExternalModuleAugmentation(node)) {
|
||||
declareSymbolAndAddToSymbolTable(node, SymbolFlags.NamespaceModule, SymbolFlags.NamespaceModuleExcludes);
|
||||
}
|
||||
else {
|
||||
declareSymbolAndAddToSymbolTable(node, SymbolFlags.ValueModule, SymbolFlags.ValueModuleExcludes);
|
||||
}
|
||||
}
|
||||
else {
|
||||
const state = getModuleInstanceState(node);
|
||||
@@ -1221,7 +1231,7 @@ namespace ts {
|
||||
|
||||
// Note: the node text must be exactly "use strict" or 'use strict'. It is not ok for the
|
||||
// string to contain unicode escapes (as per ES5).
|
||||
return nodeText === "\"use strict\"" || nodeText === "'use strict'";
|
||||
return nodeText === '"use strict"' || nodeText === "'use strict'";
|
||||
}
|
||||
|
||||
function bindWorker(node: Node) {
|
||||
|
||||
+547
-231
File diff suppressed because it is too large
Load Diff
@@ -17,6 +17,12 @@ namespace ts {
|
||||
type: "boolean",
|
||||
description: Diagnostics.Generates_corresponding_d_ts_file,
|
||||
},
|
||||
{
|
||||
name: "declarationDir",
|
||||
type: "string",
|
||||
isFilePath: true,
|
||||
paramType: Diagnostics.DIRECTORY,
|
||||
},
|
||||
{
|
||||
name: "diagnostics",
|
||||
type: "boolean",
|
||||
@@ -541,6 +547,7 @@ namespace ts {
|
||||
return {
|
||||
options,
|
||||
fileNames: getFileNames(),
|
||||
typingOptions: getTypingOptions(),
|
||||
errors
|
||||
};
|
||||
|
||||
@@ -605,6 +612,35 @@ namespace ts {
|
||||
}
|
||||
return fileNames;
|
||||
}
|
||||
|
||||
function getTypingOptions(): TypingOptions {
|
||||
const options: TypingOptions = getBaseFileName(configFileName) === "jsconfig.json"
|
||||
? { enableAutoDiscovery: true, include: [], exclude: [] }
|
||||
: { enableAutoDiscovery: false, include: [], exclude: [] };
|
||||
const jsonTypingOptions = json["typingOptions"];
|
||||
if (jsonTypingOptions) {
|
||||
for (const id in jsonTypingOptions) {
|
||||
if (id === "enableAutoDiscovery") {
|
||||
if (typeof jsonTypingOptions[id] === "boolean") {
|
||||
options.enableAutoDiscovery = jsonTypingOptions[id];
|
||||
}
|
||||
else {
|
||||
errors.push(createCompilerDiagnostic(Diagnostics.Unknown_typing_option_0, id));
|
||||
}
|
||||
}
|
||||
else if (id === "include") {
|
||||
options.include = convertJsonOptionToStringArray(id, jsonTypingOptions[id], errors);
|
||||
}
|
||||
else if (id === "exclude") {
|
||||
options.exclude = convertJsonOptionToStringArray(id, jsonTypingOptions[id], errors);
|
||||
}
|
||||
else {
|
||||
errors.push(createCompilerDiagnostic(Diagnostics.Unknown_typing_option_0, id));
|
||||
}
|
||||
}
|
||||
}
|
||||
return options;
|
||||
}
|
||||
}
|
||||
|
||||
export function convertCompilerOptionsFromJson(jsonOptions: any, basePath: string, configFileName?: string): { options: CompilerOptions, errors: Diagnostic[] } {
|
||||
@@ -645,28 +681,7 @@ namespace ts {
|
||||
break;
|
||||
case "object":
|
||||
// "object" options with 'isFilePath' = true expected to be string arrays
|
||||
let paths: string[] = [];
|
||||
let invalidOptionType = false;
|
||||
if (!isArray(value)) {
|
||||
invalidOptionType = true;
|
||||
}
|
||||
else {
|
||||
for (const element of <any[]>value) {
|
||||
if (typeof element === "string") {
|
||||
paths.push(normalizePath(combinePaths(basePath, element)));
|
||||
}
|
||||
else {
|
||||
invalidOptionType = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (invalidOptionType) {
|
||||
errors.push(createCompilerDiagnostic(Diagnostics.Option_0_should_have_array_of_strings_as_a_value, opt.name));
|
||||
}
|
||||
else {
|
||||
value = paths;
|
||||
}
|
||||
value = convertJsonOptionToStringArray(opt.name, value, errors, (element) => normalizePath(combinePaths(basePath, element)));
|
||||
break;
|
||||
}
|
||||
if (value === "") {
|
||||
@@ -686,4 +701,28 @@ namespace ts {
|
||||
|
||||
return { options, errors };
|
||||
}
|
||||
|
||||
function convertJsonOptionToStringArray(optionName: string, optionJson: any, errors: Diagnostic[], func?: (element: string) => string): string[] {
|
||||
const items: string[] = [];
|
||||
let invalidOptionType = false;
|
||||
if (!isArray(optionJson)) {
|
||||
invalidOptionType = true;
|
||||
}
|
||||
else {
|
||||
for (const element of <any[]>optionJson) {
|
||||
if (typeof element === "string") {
|
||||
const item = func ? func(element) : element;
|
||||
items.push(item);
|
||||
}
|
||||
else {
|
||||
invalidOptionType = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (invalidOptionType) {
|
||||
errors.push(createCompilerDiagnostic(Diagnostics.Option_0_should_have_array_of_strings_as_a_value, optionName));
|
||||
}
|
||||
return items;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -278,6 +278,14 @@ namespace ts {
|
||||
return hasOwnProperty.call(map, key);
|
||||
}
|
||||
|
||||
export function getKeys<T>(map: Map<T>): string[] {
|
||||
const keys: string[] = [];
|
||||
for (const key in map) {
|
||||
keys.push(key);
|
||||
}
|
||||
return keys;
|
||||
}
|
||||
|
||||
export function getProperty<T>(map: Map<T>, key: string): T {
|
||||
return hasOwnProperty.call(map, key) ? map[key] : undefined;
|
||||
}
|
||||
@@ -778,6 +786,32 @@ namespace ts {
|
||||
return pathLen > extLen && path.substr(pathLen - extLen, extLen) === extension;
|
||||
}
|
||||
|
||||
export function ensureScriptKind(fileName: string, scriptKind?: ScriptKind): ScriptKind {
|
||||
// Using scriptKind as a condition handles both:
|
||||
// - 'scriptKind' is unspecified and thus it is `undefined`
|
||||
// - 'scriptKind' is set and it is `Unknown` (0)
|
||||
// If the 'scriptKind' is 'undefined' or 'Unknown' then we attempt
|
||||
// to get the ScriptKind from the file name. If it cannot be resolved
|
||||
// from the file name then the default 'TS' script kind is returned.
|
||||
return (scriptKind || getScriptKindFromFileName(fileName)) || ScriptKind.TS;
|
||||
}
|
||||
|
||||
export function getScriptKindFromFileName(fileName: string): ScriptKind {
|
||||
const ext = fileName.substr(fileName.lastIndexOf("."));
|
||||
switch (ext.toLowerCase()) {
|
||||
case ".js":
|
||||
return ScriptKind.JS;
|
||||
case ".jsx":
|
||||
return ScriptKind.JSX;
|
||||
case ".ts":
|
||||
return ScriptKind.TS;
|
||||
case ".tsx":
|
||||
return ScriptKind.TSX;
|
||||
default:
|
||||
return ScriptKind.Unknown;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* List of supported extensions in order of file resolution precedence.
|
||||
*/
|
||||
|
||||
@@ -33,7 +33,7 @@ namespace ts {
|
||||
export function getDeclarationDiagnostics(host: EmitHost, resolver: EmitResolver, targetSourceFile: SourceFile): Diagnostic[] {
|
||||
const declarationDiagnostics = createDiagnosticCollection();
|
||||
forEachExpectedEmitFile(host, getDeclarationDiagnosticsFromFile, targetSourceFile);
|
||||
return declarationDiagnostics.getDiagnostics(targetSourceFile.fileName);
|
||||
return declarationDiagnostics.getDiagnostics(targetSourceFile ? targetSourceFile.fileName : undefined);
|
||||
|
||||
function getDeclarationDiagnosticsFromFile({ declarationFilePath }, sources: SourceFile[], isBundledEmit: boolean) {
|
||||
emitDeclarations(host, resolver, declarationDiagnostics, declarationFilePath, sources, isBundledEmit);
|
||||
@@ -753,9 +753,9 @@ namespace ts {
|
||||
if (moduleSpecifier.kind === SyntaxKind.StringLiteral && isBundledEmit && (compilerOptions.out || compilerOptions.outFile)) {
|
||||
const moduleName = getExternalModuleNameFromDeclaration(host, resolver, parent);
|
||||
if (moduleName) {
|
||||
write("\"");
|
||||
write('"');
|
||||
write(moduleName);
|
||||
write("\"");
|
||||
write('"');
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -987,6 +987,10 @@ namespace ts {
|
||||
else if (!isImplementsList && node.expression.kind === SyntaxKind.NullKeyword) {
|
||||
write("null");
|
||||
}
|
||||
else {
|
||||
writer.getSymbolAccessibilityDiagnostic = getHeritageClauseVisibilityError;
|
||||
resolver.writeBaseConstructorTypeOfClass(<ClassLikeDeclaration>enclosingDeclaration, enclosingDeclaration, TypeFormatFlags.UseTypeOfFunction, writer);
|
||||
}
|
||||
|
||||
function getHeritageClauseVisibilityError(symbolAccessibilityResult: SymbolAccessibilityResult): SymbolAccessibilityDiagnostic {
|
||||
let diagnosticMessage: DiagnosticMessage;
|
||||
@@ -1313,7 +1317,7 @@ namespace ts {
|
||||
if (node.kind === SyntaxKind.FunctionDeclaration) {
|
||||
emitModuleElementDeclarationFlags(node);
|
||||
}
|
||||
else if (node.kind === SyntaxKind.MethodDeclaration) {
|
||||
else if (node.kind === SyntaxKind.MethodDeclaration || node.kind === SyntaxKind.Constructor) {
|
||||
emitClassMemberDeclarationFlags(node.flags);
|
||||
}
|
||||
if (node.kind === SyntaxKind.FunctionDeclaration) {
|
||||
@@ -1679,7 +1683,7 @@ namespace ts {
|
||||
host.getCanonicalFileName,
|
||||
/*isAbsolutePathAnUrl*/ false);
|
||||
|
||||
referencePathsOutput += "/// <reference path=\"" + declFileName + "\" />" + newLine;
|
||||
referencePathsOutput += '/// <reference path="' + declFileName + '" />' + newLine;
|
||||
}
|
||||
return addedBundledEmitReference;
|
||||
|
||||
|
||||
@@ -779,7 +779,7 @@
|
||||
"category": "Error",
|
||||
"code": 1241
|
||||
},
|
||||
"'abstract' modifier can only appear on a class or method declaration.": {
|
||||
"'abstract' modifier can only appear on a class, method, or property declaration.": {
|
||||
"category": "Error",
|
||||
"code": 1242
|
||||
},
|
||||
@@ -1151,7 +1151,7 @@
|
||||
"category": "Error",
|
||||
"code": 2382
|
||||
},
|
||||
"Overload signatures must all be exported or not exported.": {
|
||||
"Overload signatures must all be exported or non-exported.": {
|
||||
"category": "Error",
|
||||
"code": 2383
|
||||
},
|
||||
@@ -1311,7 +1311,7 @@
|
||||
"category": "Error",
|
||||
"code": 2427
|
||||
},
|
||||
"All declarations of an interface must have identical type parameters.": {
|
||||
"All declarations of '{0}' must have identical type parameters.": {
|
||||
"category": "Error",
|
||||
"code": 2428
|
||||
},
|
||||
@@ -1635,7 +1635,7 @@
|
||||
"category": "Error",
|
||||
"code": 2511
|
||||
},
|
||||
"Overload signatures must all be abstract or not abstract.": {
|
||||
"Overload signatures must all be abstract or non-abstract.": {
|
||||
"category": "Error",
|
||||
"code": 2512
|
||||
},
|
||||
@@ -1703,6 +1703,10 @@
|
||||
"category": "Error",
|
||||
"code": 2529
|
||||
},
|
||||
"Property '{0}' is incompatible with index signature.": {
|
||||
"category": "Error",
|
||||
"code": 2530
|
||||
},
|
||||
"JSX element attributes type '{0}' may not be a union type.": {
|
||||
"category": "Error",
|
||||
"code": 2600
|
||||
@@ -1823,18 +1827,42 @@
|
||||
"category": "Error",
|
||||
"code": 2671
|
||||
},
|
||||
"A function that is called with the 'new' keyword cannot have a 'this' type that is void.": {
|
||||
"Cannot assign a '{0}' constructor type to a '{1}' constructor type.": {
|
||||
"category": "Error",
|
||||
"code": 2672
|
||||
},
|
||||
"'this' parameter must be the first parameter.": {
|
||||
"Constructor of class '{0}' is private and only accessible within the class declaration.": {
|
||||
"category": "Error",
|
||||
"code": 2673
|
||||
},
|
||||
"A constructor cannot have a 'this' parameter.": {
|
||||
"Constructor of class '{0}' is protected and only accessible within the class declaration.": {
|
||||
"category": "Error",
|
||||
"code": 2674
|
||||
},
|
||||
"Cannot extend a class '{0}'. Class constructor is marked as private.": {
|
||||
"category": "Error",
|
||||
"code": 2675
|
||||
},
|
||||
"Accessors must both be abstract or non-abstract.": {
|
||||
"category": "Error",
|
||||
"code": 2676
|
||||
},
|
||||
"A type predicate's type must be assignable to its parameter's type.": {
|
||||
"category": "Error",
|
||||
"code": 2677
|
||||
},
|
||||
"A function that is called with the 'new' keyword cannot have a 'this' type that is void.": {
|
||||
"category": "Error",
|
||||
"code": 2678
|
||||
},
|
||||
"'this' parameter must be the first parameter.": {
|
||||
"category": "Error",
|
||||
"code": 2679
|
||||
},
|
||||
"A constructor cannot have a 'this' parameter.": {
|
||||
"category": "Error",
|
||||
"code": 2680
|
||||
},
|
||||
"Import declaration '{0}' is using private name '{1}'.": {
|
||||
"category": "Error",
|
||||
"code": 4000
|
||||
@@ -2792,5 +2820,9 @@
|
||||
"'super' must be called before accessing 'this' in the constructor of a derived class.": {
|
||||
"category": "Error",
|
||||
"code": 17009
|
||||
},
|
||||
"Unknown typing option '{0}'.": {
|
||||
"category": "Error",
|
||||
"code": 17010
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+52
-37
@@ -296,11 +296,11 @@ namespace ts {
|
||||
* If loop contains block scoped binding captured in some function then loop body is converted to a function.
|
||||
* Lexical bindings declared in loop initializer will be passed into the loop body function as parameters,
|
||||
* however if this binding is modified inside the body - this new value should be propagated back to the original binding.
|
||||
* This is done by declaring new variable (out parameter holder) outside of the loop for every binding that is reassigned inside the body.
|
||||
* This is done by declaring new variable (out parameter holder) outside of the loop for every binding that is reassigned inside the body.
|
||||
* On every iteration this variable is initialized with value of corresponding binding.
|
||||
* At every point where control flow leaves the loop either explicitly (break/continue) or implicitly (at the end of loop body)
|
||||
* we copy the value inside the loop to the out parameter holder.
|
||||
*
|
||||
*
|
||||
* for (let x;;) {
|
||||
* let a = 1;
|
||||
* let b = () => a;
|
||||
@@ -308,9 +308,9 @@ namespace ts {
|
||||
* if (...) break;
|
||||
* ...
|
||||
* }
|
||||
*
|
||||
*
|
||||
* will be converted to
|
||||
*
|
||||
*
|
||||
* var out_x;
|
||||
* var loop = function(x) {
|
||||
* var a = 1;
|
||||
@@ -326,7 +326,7 @@ namespace ts {
|
||||
* x = out_x;
|
||||
* if (state === "break") break;
|
||||
* }
|
||||
*
|
||||
*
|
||||
* NOTE: values to out parameters are not copies if loop is abrupted with 'return' - in this case this will end the entire enclosing function
|
||||
* so nobody can observe this new value.
|
||||
*/
|
||||
@@ -966,7 +966,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
||||
// Any template literal or string literal with an extended escape
|
||||
// (e.g. "\u{0067}") will need to be downleveled as a escaped string literal.
|
||||
if (languageVersion < ScriptTarget.ES6 && (isTemplateLiteralKind(node.kind) || node.hasExtendedUnicodeEscape)) {
|
||||
return getQuotedEscapedLiteralText("\"", node.text, "\"");
|
||||
return getQuotedEscapedLiteralText('"', node.text, '"');
|
||||
}
|
||||
|
||||
// If we don't need to downlevel and we can reach the original source text using
|
||||
@@ -979,7 +979,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
||||
// or an escaped quoted form of the original text if it's string-like.
|
||||
switch (node.kind) {
|
||||
case SyntaxKind.StringLiteral:
|
||||
return getQuotedEscapedLiteralText("\"", node.text, "\"");
|
||||
return getQuotedEscapedLiteralText('"', node.text, '"');
|
||||
case SyntaxKind.NoSubstitutionTemplateLiteral:
|
||||
return getQuotedEscapedLiteralText("`", node.text, "`");
|
||||
case SyntaxKind.TemplateHead:
|
||||
@@ -1205,9 +1205,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
||||
/// 'Div' for upper-cased or dotted names
|
||||
function emitTagName(name: Identifier | QualifiedName) {
|
||||
if (name.kind === SyntaxKind.Identifier && isIntrinsicJsxName((<Identifier>name).text)) {
|
||||
write("\"");
|
||||
write('"');
|
||||
emit(name);
|
||||
write("\"");
|
||||
write('"');
|
||||
}
|
||||
else {
|
||||
emit(name);
|
||||
@@ -1222,9 +1222,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
||||
emit(name);
|
||||
}
|
||||
else {
|
||||
write("\"");
|
||||
write('"');
|
||||
emit(name);
|
||||
write("\"");
|
||||
write('"');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1493,7 +1493,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
||||
emit((<ComputedPropertyName>node).expression);
|
||||
}
|
||||
else {
|
||||
write("\"");
|
||||
write('"');
|
||||
|
||||
if (node.kind === SyntaxKind.NumericLiteral) {
|
||||
write((<LiteralExpression>node).text);
|
||||
@@ -1502,7 +1502,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
||||
writeTextOfNode(currentText, node);
|
||||
}
|
||||
|
||||
write("\"");
|
||||
write('"');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1592,7 +1592,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
||||
if (declaration.kind === SyntaxKind.ImportClause) {
|
||||
// Identifier references default import
|
||||
write(getGeneratedNameForNode(<ImportDeclaration>declaration.parent));
|
||||
write(languageVersion === ScriptTarget.ES3 ? "[\"default\"]" : ".default");
|
||||
write(languageVersion === ScriptTarget.ES3 ? '["default"]' : ".default");
|
||||
return;
|
||||
}
|
||||
else if (declaration.kind === SyntaxKind.ImportSpecifier) {
|
||||
@@ -1601,7 +1601,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
||||
const name = (<ImportSpecifier>declaration).propertyName || (<ImportSpecifier>declaration).name;
|
||||
const identifier = getTextOfNodeFromSourceText(currentText, name);
|
||||
if (languageVersion === ScriptTarget.ES3 && identifier === "default") {
|
||||
write(`["default"]`);
|
||||
write('["default"]');
|
||||
}
|
||||
else {
|
||||
write(".");
|
||||
@@ -2138,6 +2138,12 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
||||
return container && container.kind !== SyntaxKind.SourceFile;
|
||||
}
|
||||
|
||||
// Return true if identifier resolves to an imported identifier
|
||||
function isImportedReference(node: Identifier) {
|
||||
const declaration = resolver.getReferencedImportDeclaration(node);
|
||||
return declaration && (declaration.kind === SyntaxKind.ImportClause || declaration.kind === SyntaxKind.ImportSpecifier);
|
||||
}
|
||||
|
||||
function emitShorthandPropertyAssignment(node: ShorthandPropertyAssignment) {
|
||||
// The name property of a short-hand property assignment is considered an expression position, so here
|
||||
// we manually emit the identifier to avoid rewriting.
|
||||
@@ -2151,7 +2157,18 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
||||
// let obj = { y };
|
||||
// }
|
||||
// Here we need to emit obj = { y : m.y } regardless of the output target.
|
||||
if (modulekind !== ModuleKind.ES6 || isNamespaceExportReference(node.name)) {
|
||||
// The same rules apply for imported identifiers when targeting module formats with indirect access to
|
||||
// the imported identifiers. For example, when targeting CommonJS:
|
||||
//
|
||||
// import {foo} from './foo';
|
||||
// export const baz = { foo };
|
||||
//
|
||||
// Must be transformed into:
|
||||
//
|
||||
// const foo_1 = require('./foo');
|
||||
// exports.baz = { foo: foo_1.foo };
|
||||
//
|
||||
if (languageVersion < ScriptTarget.ES6 || (modulekind !== ModuleKind.ES6 && isImportedReference(node.name)) || isNamespaceExportReference(node.name) ) {
|
||||
// Emit identifier as an identifier
|
||||
write(": ");
|
||||
emit(node.name);
|
||||
@@ -3073,7 +3090,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
||||
}
|
||||
|
||||
writeLine();
|
||||
// end of loop body -> copy out parameter
|
||||
// end of loop body -> copy out parameter
|
||||
copyLoopOutParameters(convertedLoopState, CopyDirection.ToOutParameter, /*emitAsStatements*/true);
|
||||
|
||||
decreaseIndent();
|
||||
@@ -3232,8 +3249,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
||||
|
||||
// loop is considered simple if it does not have any return statements or break\continue that transfer control outside of the loop
|
||||
// simple loops are emitted as just 'loop()';
|
||||
// NOTE: if loop uses only 'continue' it still will be emitted as simple loop
|
||||
const isSimpleLoop =
|
||||
!loop.state.nonLocalJumps &&
|
||||
!(loop.state.nonLocalJumps & ~Jump.Continue) &&
|
||||
!loop.state.labeledNonLocalBreaks &&
|
||||
!loop.state.labeledNonLocalContinues;
|
||||
|
||||
@@ -3274,13 +3292,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
||||
writeLine();
|
||||
}
|
||||
|
||||
if (loop.state.nonLocalJumps & Jump.Continue) {
|
||||
write(`if (${loopResult} === "continue") continue;`);
|
||||
writeLine();
|
||||
}
|
||||
|
||||
// in case of labeled breaks emit code that either breaks to some known label inside outer loop or delegates jump decision to outer loop
|
||||
emitDispatchTableForLabeledJumps(loopResult, loop.state, convertedLoopState);
|
||||
// in case of 'continue' we'll just fallthough here
|
||||
}
|
||||
|
||||
if (emitAsBlock) {
|
||||
@@ -3575,6 +3589,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
||||
}
|
||||
else {
|
||||
convertedLoopState.nonLocalJumps |= Jump.Continue;
|
||||
// note: return value is emitted only to simplify debugging, call to converted loop body does not do any dispatching on it.
|
||||
write(`"continue";`);
|
||||
}
|
||||
}
|
||||
@@ -3792,7 +3807,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
||||
if (!isEs6Module) {
|
||||
if (languageVersion !== ScriptTarget.ES3) {
|
||||
// default value of configurable, enumerable, writable are `false`.
|
||||
write("Object.defineProperty(exports, \"__esModule\", { value: true });");
|
||||
write('Object.defineProperty(exports, "__esModule", { value: true });');
|
||||
writeLine();
|
||||
}
|
||||
else {
|
||||
@@ -3828,7 +3843,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
||||
if (node.flags & NodeFlags.Default) {
|
||||
emitEs6ExportDefaultCompat(node);
|
||||
if (languageVersion === ScriptTarget.ES3) {
|
||||
write("exports[\"default\"]");
|
||||
write('exports["default"]');
|
||||
}
|
||||
else {
|
||||
write("exports.default");
|
||||
@@ -6601,7 +6616,7 @@ const _super = (function (geti, seti) {
|
||||
emitEs6ExportDefaultCompat(node);
|
||||
emitContainingModuleName(node);
|
||||
if (languageVersion === ScriptTarget.ES3) {
|
||||
write("[\"default\"] = ");
|
||||
write('["default"] = ');
|
||||
}
|
||||
else {
|
||||
write(".default = ");
|
||||
@@ -7270,7 +7285,7 @@ const _super = (function (geti, seti) {
|
||||
}
|
||||
|
||||
// text should be quoted string
|
||||
// for deduplication purposes in key remove leading and trailing quotes so 'a' and "a" will be considered the same
|
||||
// for deduplication purposes in key remove leading and trailing quotes so 'a' and "a" will be considered the same
|
||||
const key = text.substr(1, text.length - 2);
|
||||
|
||||
if (hasProperty(groupIndices, key)) {
|
||||
@@ -7323,11 +7338,11 @@ const _super = (function (geti, seti) {
|
||||
// Fill in amd-dependency tags
|
||||
for (const amdDependency of node.amdDependencies) {
|
||||
if (amdDependency.name) {
|
||||
aliasedModuleNames.push("\"" + amdDependency.path + "\"");
|
||||
aliasedModuleNames.push('"' + amdDependency.path + '"');
|
||||
importAliasNames.push(amdDependency.name);
|
||||
}
|
||||
else {
|
||||
unaliasedModuleNames.push("\"" + amdDependency.path + "\"");
|
||||
unaliasedModuleNames.push('"' + amdDependency.path + '"');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7369,7 +7384,7 @@ const _super = (function (geti, seti) {
|
||||
}
|
||||
|
||||
function emitAMDDependencyList({ aliasedModuleNames, unaliasedModuleNames }: AMDDependencyNames) {
|
||||
write("[\"require\", \"exports\"");
|
||||
write('["require", "exports"');
|
||||
if (aliasedModuleNames.length) {
|
||||
write(", ");
|
||||
write(aliasedModuleNames.join(", "));
|
||||
@@ -7403,8 +7418,8 @@ const _super = (function (geti, seti) {
|
||||
emitExportStarHelper();
|
||||
emitCaptureThisForNodeIfNecessary(node);
|
||||
emitLinesStartingAt(node.statements, startIndex);
|
||||
emitTempDeclarations(/*newLine*/ true);
|
||||
emitExportEquals(/*emitAsReturn*/ true);
|
||||
emitTempDeclarations(/*newLine*/ true);
|
||||
decreaseIndent();
|
||||
writeLine();
|
||||
write("});");
|
||||
@@ -7417,8 +7432,8 @@ const _super = (function (geti, seti) {
|
||||
emitExportStarHelper();
|
||||
emitCaptureThisForNodeIfNecessary(node);
|
||||
emitLinesStartingAt(node.statements, startIndex);
|
||||
emitTempDeclarations(/*newLine*/ true);
|
||||
emitExportEquals(/*emitAsReturn*/ false);
|
||||
emitTempDeclarations(/*newLine*/ true);
|
||||
}
|
||||
|
||||
function emitUMDModule(node: SourceFile) {
|
||||
@@ -7444,8 +7459,8 @@ const _super = (function (geti, seti) {
|
||||
emitExportStarHelper();
|
||||
emitCaptureThisForNodeIfNecessary(node);
|
||||
emitLinesStartingAt(node.statements, startIndex);
|
||||
emitTempDeclarations(/*newLine*/ true);
|
||||
emitExportEquals(/*emitAsReturn*/ true);
|
||||
emitTempDeclarations(/*newLine*/ true);
|
||||
decreaseIndent();
|
||||
writeLine();
|
||||
write("});");
|
||||
@@ -7503,7 +7518,7 @@ const _super = (function (geti, seti) {
|
||||
if (isLineBreak(c)) {
|
||||
if (firstNonWhitespace !== -1 && (lastNonWhitespace - firstNonWhitespace + 1 > 0)) {
|
||||
const part = text.substr(firstNonWhitespace, lastNonWhitespace - firstNonWhitespace + 1);
|
||||
result = (result ? result + "\" + ' ' + \"" : "") + escapeString(part);
|
||||
result = (result ? result + `" + ' ' + "` : "") + escapeString(part);
|
||||
}
|
||||
firstNonWhitespace = -1;
|
||||
}
|
||||
@@ -7526,7 +7541,7 @@ const _super = (function (geti, seti) {
|
||||
if (entities[m] !== undefined) {
|
||||
const ch = String.fromCharCode(entities[m]);
|
||||
// " needs to be escaped
|
||||
return ch === "\"" ? "\\\"" : ch;
|
||||
return ch === '"' ? "\\\"" : ch;
|
||||
}
|
||||
else {
|
||||
return s;
|
||||
@@ -7570,9 +7585,9 @@ const _super = (function (geti, seti) {
|
||||
function emitJsxText(node: JsxText) {
|
||||
switch (compilerOptions.jsx) {
|
||||
case JsxEmit.React:
|
||||
write("\"");
|
||||
write('"');
|
||||
write(trimReactWhitespaceAndApplyEntities(node));
|
||||
write("\"");
|
||||
write('"');
|
||||
break;
|
||||
|
||||
case JsxEmit.Preserve:
|
||||
|
||||
+26
-20
@@ -399,14 +399,18 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
export function createSourceFile(fileName: string, sourceText: string, languageVersion: ScriptTarget, setParentNodes = false): SourceFile {
|
||||
export function createSourceFile(fileName: string, sourceText: string, languageVersion: ScriptTarget, setParentNodes = false, scriptKind?: ScriptKind): SourceFile {
|
||||
const start = new Date().getTime();
|
||||
const result = Parser.parseSourceFile(fileName, sourceText, languageVersion, /*syntaxCursor*/ undefined, setParentNodes);
|
||||
const result = Parser.parseSourceFile(fileName, sourceText, languageVersion, /*syntaxCursor*/ undefined, setParentNodes, scriptKind);
|
||||
|
||||
parseTime += new Date().getTime() - start;
|
||||
return result;
|
||||
}
|
||||
|
||||
export function isExternalModule(file: SourceFile): boolean {
|
||||
return file.externalModuleIndicator !== undefined;
|
||||
}
|
||||
|
||||
// Produces a new SourceFile for the 'newText' provided. The 'textChangeRange' parameter
|
||||
// indicates what changed between the 'text' that this SourceFile has and the 'newText'.
|
||||
// The SourceFile will be created with the compiler attempting to reuse as many nodes from
|
||||
@@ -533,23 +537,24 @@ namespace ts {
|
||||
// attached to the EOF token.
|
||||
let parseErrorBeforeNextFinishedNode = false;
|
||||
|
||||
export function parseSourceFile(fileName: string, _sourceText: string, languageVersion: ScriptTarget, _syntaxCursor: IncrementalParser.SyntaxCursor, setParentNodes?: boolean): SourceFile {
|
||||
const isJavaScriptFile = hasJavaScriptFileExtension(fileName) || _sourceText.lastIndexOf("// @language=javascript", 0) === 0;
|
||||
initializeState(fileName, _sourceText, languageVersion, isJavaScriptFile, _syntaxCursor);
|
||||
export function parseSourceFile(fileName: string, _sourceText: string, languageVersion: ScriptTarget, _syntaxCursor: IncrementalParser.SyntaxCursor, setParentNodes?: boolean, scriptKind?: ScriptKind): SourceFile {
|
||||
scriptKind = ensureScriptKind(fileName, scriptKind);
|
||||
|
||||
const result = parseSourceFileWorker(fileName, languageVersion, setParentNodes);
|
||||
initializeState(fileName, _sourceText, languageVersion, _syntaxCursor, scriptKind);
|
||||
|
||||
const result = parseSourceFileWorker(fileName, languageVersion, setParentNodes, scriptKind);
|
||||
|
||||
clearState();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
function getLanguageVariant(fileName: string) {
|
||||
function getLanguageVariant(scriptKind: ScriptKind) {
|
||||
// .tsx and .jsx files are treated as jsx language variant.
|
||||
return fileExtensionIs(fileName, ".tsx") || fileExtensionIs(fileName, ".jsx") || fileExtensionIs(fileName, ".js") ? LanguageVariant.JSX : LanguageVariant.Standard;
|
||||
return scriptKind === ScriptKind.TSX || scriptKind === ScriptKind.JSX || scriptKind === ScriptKind.JS ? LanguageVariant.JSX : LanguageVariant.Standard;
|
||||
}
|
||||
|
||||
function initializeState(fileName: string, _sourceText: string, languageVersion: ScriptTarget, isJavaScriptFile: boolean, _syntaxCursor: IncrementalParser.SyntaxCursor) {
|
||||
function initializeState(fileName: string, _sourceText: string, languageVersion: ScriptTarget, _syntaxCursor: IncrementalParser.SyntaxCursor, scriptKind: ScriptKind) {
|
||||
NodeConstructor = objectAllocator.getNodeConstructor();
|
||||
SourceFileConstructor = objectAllocator.getSourceFileConstructor();
|
||||
|
||||
@@ -562,14 +567,14 @@ namespace ts {
|
||||
identifierCount = 0;
|
||||
nodeCount = 0;
|
||||
|
||||
contextFlags = isJavaScriptFile ? NodeFlags.JavaScriptFile : NodeFlags.None;
|
||||
contextFlags = scriptKind === ScriptKind.JS || scriptKind === ScriptKind.JSX ? NodeFlags.JavaScriptFile : NodeFlags.None;
|
||||
parseErrorBeforeNextFinishedNode = false;
|
||||
|
||||
// Initialize and prime the scanner before parsing the source elements.
|
||||
scanner.setText(sourceText);
|
||||
scanner.setOnError(scanError);
|
||||
scanner.setScriptTarget(languageVersion);
|
||||
scanner.setLanguageVariant(getLanguageVariant(fileName));
|
||||
scanner.setLanguageVariant(getLanguageVariant(scriptKind));
|
||||
}
|
||||
|
||||
function clearState() {
|
||||
@@ -585,8 +590,8 @@ namespace ts {
|
||||
sourceText = undefined;
|
||||
}
|
||||
|
||||
function parseSourceFileWorker(fileName: string, languageVersion: ScriptTarget, setParentNodes: boolean): SourceFile {
|
||||
sourceFile = createSourceFile(fileName, languageVersion);
|
||||
function parseSourceFileWorker(fileName: string, languageVersion: ScriptTarget, setParentNodes: boolean, scriptKind: ScriptKind): SourceFile {
|
||||
sourceFile = createSourceFile(fileName, languageVersion, scriptKind);
|
||||
sourceFile.flags = contextFlags;
|
||||
|
||||
// Prime the scanner.
|
||||
@@ -653,7 +658,7 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
function createSourceFile(fileName: string, languageVersion: ScriptTarget): SourceFile {
|
||||
function createSourceFile(fileName: string, languageVersion: ScriptTarget, scriptKind: ScriptKind): SourceFile {
|
||||
// code from createNode is inlined here so createNode won't have to deal with special case of creating source files
|
||||
// this is quite rare comparing to other nodes and createNode should be as fast as possible
|
||||
const sourceFile = <SourceFile>new SourceFileConstructor(SyntaxKind.SourceFile, /*pos*/ 0, /* end */ sourceText.length);
|
||||
@@ -663,8 +668,9 @@ namespace ts {
|
||||
sourceFile.bindDiagnostics = [];
|
||||
sourceFile.languageVersion = languageVersion;
|
||||
sourceFile.fileName = normalizePath(fileName);
|
||||
sourceFile.languageVariant = getLanguageVariant(sourceFile.fileName);
|
||||
sourceFile.languageVariant = getLanguageVariant(scriptKind);
|
||||
sourceFile.isDeclarationFile = fileExtensionIs(sourceFile.fileName, ".d.ts");
|
||||
sourceFile.scriptKind = scriptKind;
|
||||
|
||||
return sourceFile;
|
||||
}
|
||||
@@ -3934,7 +3940,7 @@ namespace ts {
|
||||
|
||||
function tryParseAccessorDeclaration(fullStart: number, decorators: NodeArray<Decorator>, modifiers: ModifiersArray): AccessorDeclaration {
|
||||
if (parseContextualModifier(SyntaxKind.GetKeyword)) {
|
||||
return parseAccessorDeclaration(SyntaxKind.GetAccessor, fullStart, decorators, modifiers);
|
||||
return addJSDocComment(parseAccessorDeclaration(SyntaxKind.GetAccessor, fullStart, decorators, modifiers));
|
||||
}
|
||||
else if (parseContextualModifier(SyntaxKind.SetKeyword)) {
|
||||
return parseAccessorDeclaration(SyntaxKind.SetAccessor, fullStart, decorators, modifiers);
|
||||
@@ -5593,7 +5599,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
export function parseJSDocTypeExpressionForTests(content: string, start: number, length: number) {
|
||||
initializeState("file.js", content, ScriptTarget.Latest, /*isJavaScriptFile*/ true, /*_syntaxCursor:*/ undefined);
|
||||
initializeState("file.js", content, ScriptTarget.Latest, /*_syntaxCursor:*/ undefined, ScriptKind.JS);
|
||||
scanner.setText(content, start, length);
|
||||
token = scanner.scan();
|
||||
const jsDocTypeExpression = parseJSDocTypeExpression();
|
||||
@@ -5912,7 +5918,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
export function parseIsolatedJSDocComment(content: string, start: number, length: number) {
|
||||
initializeState("file.js", content, ScriptTarget.Latest, /*isJavaScriptFile*/ true, /*_syntaxCursor:*/ undefined);
|
||||
initializeState("file.js", content, ScriptTarget.Latest, /*_syntaxCursor:*/ undefined, ScriptKind.JS);
|
||||
sourceFile = <SourceFile>{ languageVariant: LanguageVariant.Standard, text: content };
|
||||
const jsDocComment = parseJSDocCommentWorker(start, length);
|
||||
const diagnostics = parseDiagnostics;
|
||||
@@ -6238,7 +6244,7 @@ namespace ts {
|
||||
if (sourceFile.statements.length === 0) {
|
||||
// If we don't have any statements in the current source file, then there's no real
|
||||
// way to incrementally parse. So just do a full parse instead.
|
||||
return Parser.parseSourceFile(sourceFile.fileName, newText, sourceFile.languageVersion, /*syntaxCursor*/ undefined, /*setParentNodes*/ true);
|
||||
return Parser.parseSourceFile(sourceFile.fileName, newText, sourceFile.languageVersion, /*syntaxCursor*/ undefined, /*setParentNodes*/ true, sourceFile.scriptKind);
|
||||
}
|
||||
|
||||
// Make sure we're not trying to incrementally update a source file more than once. Once
|
||||
@@ -6302,7 +6308,7 @@ namespace ts {
|
||||
// inconsistent tree. Setting the parents on the new tree should be very fast. We
|
||||
// will immediately bail out of walking any subtrees when we can see that their parents
|
||||
// are already correct.
|
||||
const result = Parser.parseSourceFile(sourceFile.fileName, newText, sourceFile.languageVersion, syntaxCursor, /*setParentNodes*/ true);
|
||||
const result = Parser.parseSourceFile(sourceFile.fileName, newText, sourceFile.languageVersion, syntaxCursor, /*setParentNodes*/ true, sourceFile.scriptKind);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
+47
-11
@@ -953,13 +953,31 @@ namespace ts {
|
||||
}
|
||||
|
||||
function emitWorker(program: Program, sourceFile: SourceFile, writeFileCallback: WriteFileCallback, cancellationToken: CancellationToken): EmitResult {
|
||||
let declarationDiagnostics: Diagnostic[] = [];
|
||||
|
||||
if (options.noEmit) {
|
||||
return { diagnostics: declarationDiagnostics, sourceMaps: undefined, emitSkipped: true };
|
||||
}
|
||||
|
||||
// If the noEmitOnError flag is set, then check if we have any errors so far. If so,
|
||||
// immediately bail out. Note that we pass 'undefined' for 'sourceFile' so that we
|
||||
// get any preEmit diagnostics, not just the ones
|
||||
if (options.noEmitOnError) {
|
||||
const preEmitDiagnostics = getPreEmitDiagnostics(program, /*sourceFile:*/ undefined, cancellationToken);
|
||||
if (preEmitDiagnostics.length > 0) {
|
||||
return { diagnostics: preEmitDiagnostics, sourceMaps: undefined, emitSkipped: true };
|
||||
const diagnostics = program.getOptionsDiagnostics(cancellationToken).concat(
|
||||
program.getSyntacticDiagnostics(sourceFile, cancellationToken),
|
||||
program.getGlobalDiagnostics(cancellationToken),
|
||||
program.getSemanticDiagnostics(sourceFile, cancellationToken));
|
||||
|
||||
if (diagnostics.length === 0 && program.getCompilerOptions().declaration) {
|
||||
declarationDiagnostics = program.getDeclarationDiagnostics(/*sourceFile*/ undefined, cancellationToken);
|
||||
}
|
||||
|
||||
if (diagnostics.length > 0 || declarationDiagnostics.length > 0) {
|
||||
return {
|
||||
diagnostics: concatenate(diagnostics, declarationDiagnostics),
|
||||
sourceMaps: undefined,
|
||||
emitSkipped: true
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1016,7 +1034,14 @@ namespace ts {
|
||||
}
|
||||
|
||||
function getDeclarationDiagnostics(sourceFile: SourceFile, cancellationToken: CancellationToken): Diagnostic[] {
|
||||
return getDiagnosticsHelper(sourceFile, getDeclarationDiagnosticsForFile, cancellationToken);
|
||||
const options = program.getCompilerOptions();
|
||||
// collect diagnostics from the program only once if either no source file was specified or out/outFile is set (bundled emit)
|
||||
if (!sourceFile || options.out || options.outFile) {
|
||||
return getDeclarationDiagnosticsWorker(sourceFile, cancellationToken);
|
||||
}
|
||||
else {
|
||||
return getDiagnosticsHelper(sourceFile, getDeclarationDiagnosticsForFile, cancellationToken);
|
||||
}
|
||||
}
|
||||
|
||||
function getSyntacticDiagnosticsForFile(sourceFile: SourceFile, cancellationToken: CancellationToken): Diagnostic[] {
|
||||
@@ -1230,17 +1255,19 @@ namespace ts {
|
||||
});
|
||||
}
|
||||
|
||||
function getDeclarationDiagnosticsForFile(sourceFile: SourceFile, cancellationToken: CancellationToken): Diagnostic[] {
|
||||
function getDeclarationDiagnosticsWorker(sourceFile: SourceFile, cancellationToken: CancellationToken): Diagnostic[] {
|
||||
return runWithCancellationToken(() => {
|
||||
if (!isDeclarationFile(sourceFile)) {
|
||||
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);
|
||||
}
|
||||
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);
|
||||
});
|
||||
}
|
||||
|
||||
function getDeclarationDiagnosticsForFile(sourceFile: SourceFile, cancellationToken: CancellationToken): Diagnostic[] {
|
||||
return isDeclarationFile(sourceFile) ? [] : getDeclarationDiagnosticsWorker(sourceFile, cancellationToken);
|
||||
}
|
||||
|
||||
function getOptionsDiagnostics(): Diagnostic[] {
|
||||
const allDiagnostics: Diagnostic[] = [];
|
||||
addRange(allDiagnostics, fileProcessingDiagnostics.getGlobalDiagnostics());
|
||||
@@ -1656,6 +1683,15 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
if (options.declarationDir) {
|
||||
if (!options.declaration) {
|
||||
programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "declarationDir", "declaration"));
|
||||
}
|
||||
if (options.out || options.outFile) {
|
||||
programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_cannot_be_specified_with_option_1, "declarationDir", options.out ? "out" : "outFile"));
|
||||
}
|
||||
}
|
||||
|
||||
const languageVersion = options.target || ScriptTarget.ES3;
|
||||
const outFile = options.outFile || options.out;
|
||||
|
||||
|
||||
+27
-23
@@ -240,6 +240,11 @@ namespace ts {
|
||||
return typeof JSON === "object" && typeof JSON.parse === "function";
|
||||
}
|
||||
|
||||
function isWatchSet(options: CompilerOptions) {
|
||||
// Firefox has Object.prototype.watch
|
||||
return options.watch && options.hasOwnProperty("watch");
|
||||
}
|
||||
|
||||
export function executeCommandLine(args: string[]): void {
|
||||
const commandLine = parseCommandLine(args);
|
||||
let configFileName: string; // Configuration file name (if any)
|
||||
@@ -327,8 +332,7 @@ namespace ts {
|
||||
return sys.exit(ExitStatus.Success);
|
||||
}
|
||||
|
||||
// Firefox has Object.prototype.watch
|
||||
if (commandLine.options.watch && commandLine.options.hasOwnProperty("watch")) {
|
||||
if (isWatchSet(commandLine.options)) {
|
||||
if (!sys.watchFile) {
|
||||
reportDiagnostic(createCompilerDiagnostic(Diagnostics.The_current_host_does_not_support_the_0_option, "--watch"), /* compilerHost */ undefined);
|
||||
return sys.exit(ExitStatus.DiagnosticsPresent_OutputsSkipped);
|
||||
@@ -382,6 +386,10 @@ namespace ts {
|
||||
sys.exit(ExitStatus.DiagnosticsPresent_OutputsSkipped);
|
||||
return;
|
||||
}
|
||||
if (isWatchSet(configParseResult.options) && !sys.watchFile) {
|
||||
reportDiagnostic(createCompilerDiagnostic(Diagnostics.The_current_host_does_not_support_the_0_option, "--watch"), /* compilerHost */ undefined);
|
||||
sys.exit(ExitStatus.DiagnosticsPresent_OutputsSkipped);
|
||||
}
|
||||
return configParseResult;
|
||||
}
|
||||
|
||||
@@ -415,7 +423,7 @@ namespace ts {
|
||||
|
||||
const compileResult = compile(rootFileNames, compilerOptions, compilerHost);
|
||||
|
||||
if (!compilerOptions.watch) {
|
||||
if (!isWatchSet(compilerOptions)) {
|
||||
return sys.exit(compileResult.exitStatus);
|
||||
}
|
||||
|
||||
@@ -441,7 +449,7 @@ namespace ts {
|
||||
}
|
||||
// Use default host function
|
||||
const sourceFile = hostGetSourceFile(fileName, languageVersion, onError);
|
||||
if (sourceFile && compilerOptions.watch) {
|
||||
if (sourceFile && isWatchSet(compilerOptions) && sys.watchFile) {
|
||||
// Attach a file watcher
|
||||
const filePath = toPath(sourceFile.fileName, sys.getCurrentDirectory(), createGetCanonicalFileName(sys.useCaseSensitiveFileNames));
|
||||
sourceFile.fileWatcher = sys.watchFile(filePath, (fileName: string, removed?: boolean) => sourceFileChanged(sourceFile, removed));
|
||||
@@ -590,30 +598,21 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
reportDiagnostics(diagnostics, compilerHost);
|
||||
|
||||
// If the user doesn't want us to emit, then we're done at this point.
|
||||
if (compilerOptions.noEmit) {
|
||||
return diagnostics.length
|
||||
? ExitStatus.DiagnosticsPresent_OutputsSkipped
|
||||
: ExitStatus.Success;
|
||||
}
|
||||
|
||||
// Otherwise, emit and report any errors we ran into.
|
||||
const emitOutput = program.emit();
|
||||
reportDiagnostics(emitOutput.diagnostics, compilerHost);
|
||||
diagnostics = diagnostics.concat(emitOutput.diagnostics);
|
||||
|
||||
// If the emitter didn't emit anything, then pass that value along.
|
||||
if (emitOutput.emitSkipped) {
|
||||
reportDiagnostics(sortAndDeduplicateDiagnostics(diagnostics), compilerHost);
|
||||
|
||||
if (emitOutput.emitSkipped && diagnostics.length > 0) {
|
||||
// If the emitter didn't emit anything, then pass that value along.
|
||||
return ExitStatus.DiagnosticsPresent_OutputsSkipped;
|
||||
}
|
||||
|
||||
// The emitter emitted something, inform the caller if that happened in the presence
|
||||
// of diagnostics or not.
|
||||
if (diagnostics.length > 0 || emitOutput.diagnostics.length > 0) {
|
||||
else if (diagnostics.length > 0) {
|
||||
// The emitter emitted something, inform the caller if that happened in the presence
|
||||
// of diagnostics or not.
|
||||
return ExitStatus.DiagnosticsPresent_OutputsGenerated;
|
||||
}
|
||||
|
||||
return ExitStatus.Success;
|
||||
}
|
||||
}
|
||||
@@ -719,14 +718,19 @@ namespace ts {
|
||||
else {
|
||||
const compilerOptions = extend(options, defaultInitCompilerOptions);
|
||||
const configurations: any = {
|
||||
compilerOptions: serializeCompilerOptions(compilerOptions),
|
||||
exclude: ["node_modules"]
|
||||
compilerOptions: serializeCompilerOptions(compilerOptions)
|
||||
};
|
||||
|
||||
if (fileNames && fileNames.length) {
|
||||
// only set the files property if we have at least one file
|
||||
configurations.files = fileNames;
|
||||
}
|
||||
else {
|
||||
configurations.exclude = ["node_modules"];
|
||||
if (compilerOptions.outDir) {
|
||||
configurations.exclude.push(compilerOptions.outDir);
|
||||
}
|
||||
}
|
||||
|
||||
sys.writeFile(file, JSON.stringify(configurations, undefined, 4));
|
||||
reportDiagnostic(createCompilerDiagnostic(Diagnostics.Successfully_created_a_tsconfig_json_file), /* compilerHost */ undefined);
|
||||
|
||||
+34
-1
@@ -1,3 +1,4 @@
|
||||
|
||||
namespace ts {
|
||||
export interface Map<T> {
|
||||
[index: string]: T;
|
||||
@@ -410,7 +411,7 @@ namespace ts {
|
||||
EmitHelperFlags = HasClassExtends | HasDecorators | HasParamDecorators | HasAsyncFunctions,
|
||||
|
||||
// Parsing context flags
|
||||
ContextFlags = DisallowInContext | YieldContext | DecoratorContext | AwaitContext,
|
||||
ContextFlags = DisallowInContext | YieldContext | DecoratorContext | AwaitContext | JavaScriptFile,
|
||||
|
||||
// Exclude these flags when parsing a Type
|
||||
TypeExcludesFlags = YieldContext | AwaitContext,
|
||||
@@ -1207,6 +1208,8 @@ namespace ts {
|
||||
block: Block;
|
||||
}
|
||||
|
||||
export type DeclarationWithTypeParameters = SignatureDeclaration | ClassLikeDeclaration | InterfaceDeclaration | TypeAliasDeclaration;
|
||||
|
||||
export interface ClassLikeDeclaration extends Declaration {
|
||||
name?: Identifier;
|
||||
typeParameters?: NodeArray<TypeParameterDeclaration>;
|
||||
@@ -1530,6 +1533,7 @@ namespace ts {
|
||||
hasNoDefaultLib: boolean;
|
||||
|
||||
languageVersion: ScriptTarget;
|
||||
/* @internal */ scriptKind: ScriptKind;
|
||||
|
||||
// The first node that causes this file to be an external module
|
||||
/* @internal */ externalModuleIndicator: Node;
|
||||
@@ -1680,6 +1684,7 @@ namespace ts {
|
||||
|
||||
export interface EmitResult {
|
||||
emitSkipped: boolean;
|
||||
/** Contains declaration emit diagnostics */
|
||||
diagnostics: Diagnostic[];
|
||||
/* @internal */ sourceMaps: SourceMapData[]; // Array of sourceMapData if compiler emitted sourcemaps
|
||||
}
|
||||
@@ -1886,6 +1891,7 @@ namespace ts {
|
||||
writeTypeOfDeclaration(declaration: AccessorDeclaration | VariableLikeDeclaration, enclosingDeclaration: Node, flags: TypeFormatFlags, writer: SymbolWriter): void;
|
||||
writeReturnTypeOfSignatureDeclaration(signatureDeclaration: SignatureDeclaration, enclosingDeclaration: Node, flags: TypeFormatFlags, writer: SymbolWriter): void;
|
||||
writeTypeOfExpression(expr: Expression, enclosingDeclaration: Node, flags: TypeFormatFlags, writer: SymbolWriter): void;
|
||||
writeBaseConstructorTypeOfClass(node: ClassLikeDeclaration, enclosingDeclaration: Node, flags: TypeFormatFlags, writer: SymbolWriter): void;
|
||||
isSymbolAccessible(symbol: Symbol, enclosingDeclaration: Node, meaning: SymbolFlags): SymbolAccessibilityResult;
|
||||
isEntityNameVisible(entityName: EntityName | Expression, enclosingDeclaration: Node): SymbolVisibilityResult;
|
||||
// Returns the constant value this property access resolves to, or 'undefined' for a non-constant
|
||||
@@ -2283,6 +2289,7 @@ namespace ts {
|
||||
/* @internal */
|
||||
export interface TypeMapper {
|
||||
(t: TypeParameter): Type;
|
||||
mappedTypes?: Type[]; // Types mapped by this mapper
|
||||
instantiations?: Type[]; // Cache of instantiations created using this type mapper.
|
||||
context?: InferenceContext; // The inference context this mapper was created from.
|
||||
// Only inference mappers have this set (in createInferenceMapper).
|
||||
@@ -2369,6 +2376,7 @@ namespace ts {
|
||||
allowNonTsExtensions?: boolean;
|
||||
charset?: string;
|
||||
declaration?: boolean;
|
||||
declarationDir?: string;
|
||||
diagnostics?: boolean;
|
||||
emitBOM?: boolean;
|
||||
help?: boolean;
|
||||
@@ -2431,6 +2439,22 @@ namespace ts {
|
||||
[option: string]: string | number | boolean | TsConfigOnlyOptions;
|
||||
}
|
||||
|
||||
export interface TypingOptions {
|
||||
enableAutoDiscovery?: boolean;
|
||||
include?: string[];
|
||||
exclude?: string[];
|
||||
[option: string]: string[] | boolean;
|
||||
}
|
||||
|
||||
export interface DiscoverTypingsInfo {
|
||||
fileNames: string[]; // The file names that belong to the same project.
|
||||
projectRootPath: string; // The path to the project root directory
|
||||
safeListPath: string; // The path used to retrieve the safe list
|
||||
packageNameToTypingLocation: Map<string>; // The map of package names to their cached typing locations
|
||||
typingOptions: TypingOptions; // Used to customize the typing inference process
|
||||
compilerOptions: CompilerOptions; // Used as a source for typing inference
|
||||
}
|
||||
|
||||
export enum ModuleKind {
|
||||
None = 0,
|
||||
CommonJS = 1,
|
||||
@@ -2460,6 +2484,14 @@ namespace ts {
|
||||
character: number;
|
||||
}
|
||||
|
||||
export const enum ScriptKind {
|
||||
Unknown = 0,
|
||||
JS = 1,
|
||||
JSX = 2,
|
||||
TS = 3,
|
||||
TSX = 4
|
||||
}
|
||||
|
||||
export const enum ScriptTarget {
|
||||
ES3 = 0,
|
||||
ES5 = 1,
|
||||
@@ -2481,6 +2513,7 @@ namespace ts {
|
||||
|
||||
export interface ParsedCommandLine {
|
||||
options: CompilerOptions;
|
||||
typingOptions?: TypingOptions;
|
||||
fileNames: string[];
|
||||
errors: Diagnostic[];
|
||||
}
|
||||
|
||||
+18
-14
@@ -407,10 +407,6 @@ namespace ts {
|
||||
return createTextSpanFromBounds(pos, errorNode.end);
|
||||
}
|
||||
|
||||
export function isExternalModule(file: SourceFile): boolean {
|
||||
return file.externalModuleIndicator !== undefined;
|
||||
}
|
||||
|
||||
export function isExternalOrCommonJsModule(file: SourceFile): boolean {
|
||||
return (file.externalModuleIndicator || file.commonJsModuleIndicator) !== undefined;
|
||||
}
|
||||
@@ -2012,6 +2008,18 @@ namespace ts {
|
||||
return emitOutputFilePathWithoutExtension + extension;
|
||||
}
|
||||
|
||||
export function getDeclarationEmitOutputFilePath(sourceFile: SourceFile, host: EmitHost) {
|
||||
const options = host.getCompilerOptions();
|
||||
const outputDir = options.declarationDir || options.outDir; // Prefer declaration folder if specified
|
||||
|
||||
if (options.declaration) {
|
||||
const path = outputDir
|
||||
? getSourceFilePathInNewDir(sourceFile, host, outputDir)
|
||||
: sourceFile.fileName;
|
||||
return removeFileExtension(path) + ".d.ts";
|
||||
}
|
||||
}
|
||||
|
||||
export function getEmitScriptTarget(compilerOptions: CompilerOptions) {
|
||||
return compilerOptions.target || ScriptTarget.ES3;
|
||||
}
|
||||
@@ -2065,23 +2073,23 @@ namespace ts {
|
||||
const emitFileNames: EmitFileNames = {
|
||||
jsFilePath,
|
||||
sourceMapFilePath: getSourceMapFilePath(jsFilePath, options),
|
||||
declarationFilePath: !isSourceFileJavaScript(sourceFile) ? getDeclarationEmitFilePath(jsFilePath, options) : undefined
|
||||
declarationFilePath: !isSourceFileJavaScript(sourceFile) ? getDeclarationEmitOutputFilePath(sourceFile, host) : undefined
|
||||
};
|
||||
action(emitFileNames, [sourceFile], /*isBundledEmit*/false);
|
||||
}
|
||||
|
||||
function onBundledEmit(host: EmitHost) {
|
||||
// Can emit only sources that are not declaration file and are either non module code or module with --module or --target es6 specified
|
||||
const bundledSources = filter(host.getSourceFiles(),
|
||||
sourceFile => !isDeclarationFile(sourceFile) && // Not a declaration file
|
||||
(!isExternalModule(sourceFile) || // non module file
|
||||
(getEmitModuleKind(options) && isExternalModule(sourceFile)))); // module that can emit - note falsy value from getEmitModuleKind means the module kind that shouldn't be emitted
|
||||
const bundledSources = filter(host.getSourceFiles(), sourceFile =>
|
||||
!isDeclarationFile(sourceFile) // Not a declaration file
|
||||
&& (!isExternalModule(sourceFile) || !!getEmitModuleKind(options))); // and not a module, unless module emit enabled
|
||||
|
||||
if (bundledSources.length) {
|
||||
const jsFilePath = options.outFile || options.out;
|
||||
const emitFileNames: EmitFileNames = {
|
||||
jsFilePath,
|
||||
sourceMapFilePath: getSourceMapFilePath(jsFilePath, options),
|
||||
declarationFilePath: getDeclarationEmitFilePath(jsFilePath, options)
|
||||
declarationFilePath: options.declaration ? removeFileExtension(jsFilePath) + ".d.ts" : undefined
|
||||
};
|
||||
action(emitFileNames, bundledSources, /*isBundledEmit*/true);
|
||||
}
|
||||
@@ -2090,10 +2098,6 @@ namespace ts {
|
||||
function getSourceMapFilePath(jsFilePath: string, options: CompilerOptions) {
|
||||
return options.sourceMap ? jsFilePath + ".map" : undefined;
|
||||
}
|
||||
|
||||
function getDeclarationEmitFilePath(jsFilePath: string, options: CompilerOptions) {
|
||||
return options.declaration ? removeFileExtension(jsFilePath) + ".d.ts" : undefined;
|
||||
}
|
||||
}
|
||||
|
||||
export function getSourceFilePathInNewDir(sourceFile: SourceFile, host: EmitHost, newDirPath: string) {
|
||||
|
||||
@@ -262,8 +262,8 @@ class CompilerBaselineRunner extends RunnerBase {
|
||||
// different order with 'pull' operations, and thus can produce slightly differing
|
||||
// output.
|
||||
//
|
||||
// For example, with a full type check, we may see a type outputed as: number | string
|
||||
// But with a pull type check, we may see it as: string | number
|
||||
// For example, with a full type check, we may see a type displayed as: number | string
|
||||
// But with a pull type check, we may see it as: string | number
|
||||
//
|
||||
// These types are equivalent, but depend on what order the compiler observed
|
||||
// certain parts of the program.
|
||||
|
||||
Vendored
+2
-2
@@ -1073,7 +1073,7 @@ declare module "crypto" {
|
||||
update(data: any): void;
|
||||
sign(private_key: string, output_format: string): string;
|
||||
}
|
||||
export function createVerify(algorith: string): Verify;
|
||||
export function createVerify(algorithm: string): Verify;
|
||||
interface Verify {
|
||||
update(data: any): void;
|
||||
verify(object: string, signature: string, signature_format?: string): boolean;
|
||||
@@ -1237,7 +1237,7 @@ declare module "assert" {
|
||||
export function equal(actual: any, expected: any, message?: string): void;
|
||||
export function notEqual(actual: any, expected: any, message?: string): void;
|
||||
export function deepEqual(actual: any, expected: any, message?: string): void;
|
||||
export function notDeepEqual(acutal: any, expected: any, message?: string): void;
|
||||
export function notDeepEqual(actual: any, expected: any, message?: string): void;
|
||||
export function strictEqual(actual: any, expected: any, message?: string): void;
|
||||
export function notStrictEqual(actual: any, expected: any, message?: string): void;
|
||||
export var throws: {
|
||||
|
||||
@@ -231,13 +231,13 @@ namespace FourSlash {
|
||||
private getLanguageServiceAdapter(testType: FourSlashTestType, cancellationToken: TestCancellationToken, compilationOptions: ts.CompilerOptions): Harness.LanguageService.LanguageServiceAdapter {
|
||||
switch (testType) {
|
||||
case FourSlashTestType.Native:
|
||||
return new Harness.LanguageService.NativeLanugageServiceAdapter(cancellationToken, compilationOptions);
|
||||
return new Harness.LanguageService.NativeLanguageServiceAdapter(cancellationToken, compilationOptions);
|
||||
case FourSlashTestType.Shims:
|
||||
return new Harness.LanguageService.ShimLanugageServiceAdapter(/*preprocessToResolve*/ false, cancellationToken, compilationOptions);
|
||||
return new Harness.LanguageService.ShimLanguageServiceAdapter(/*preprocessToResolve*/ false, cancellationToken, compilationOptions);
|
||||
case FourSlashTestType.ShimsWithPreprocess:
|
||||
return new Harness.LanguageService.ShimLanugageServiceAdapter(/*preprocessToResolve*/ true, cancellationToken, compilationOptions);
|
||||
return new Harness.LanguageService.ShimLanguageServiceAdapter(/*preprocessToResolve*/ true, cancellationToken, compilationOptions);
|
||||
case FourSlashTestType.Server:
|
||||
return new Harness.LanguageService.ServerLanugageServiceAdapter(cancellationToken, compilationOptions);
|
||||
return new Harness.LanguageService.ServerLanguageServiceAdapter(cancellationToken, compilationOptions);
|
||||
default:
|
||||
throw new Error("Unknown FourSlash test type: ");
|
||||
}
|
||||
@@ -1279,7 +1279,7 @@ namespace FourSlash {
|
||||
const edits = this.languageService.getFormattingEditsAfterKeystroke(this.activeFile.fileName, offset, ch, this.formatCodeOptions);
|
||||
if (edits.length) {
|
||||
offset += this.applyEdits(this.activeFile.fileName, edits, /*isFormattingEdit*/ true);
|
||||
// this.checkPostEditInletiants();
|
||||
// this.checkPostEditInvariants();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1370,7 +1370,7 @@ namespace FourSlash {
|
||||
const edits = this.languageService.getFormattingEditsAfterKeystroke(this.activeFile.fileName, offset, ch, this.formatCodeOptions);
|
||||
if (edits.length) {
|
||||
offset += this.applyEdits(this.activeFile.fileName, edits, /*isFormattingEdit*/ true);
|
||||
// this.checkPostEditInletiants();
|
||||
// this.checkPostEditInvariants();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2771,12 +2771,12 @@ namespace FourSlashInterface {
|
||||
|
||||
// Verifies the member list contains the specified symbol. The
|
||||
// member list is brought up if necessary
|
||||
public memberListContains(symbol: string, text?: string, documenation?: string, kind?: string) {
|
||||
public memberListContains(symbol: string, text?: string, documentation?: string, kind?: string) {
|
||||
if (this.negative) {
|
||||
this.state.verifyMemberListDoesNotContain(symbol);
|
||||
}
|
||||
else {
|
||||
this.state.verifyMemberListContains(symbol, text, documenation, kind);
|
||||
this.state.verifyMemberListContains(symbol, text, documentation, kind);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1330,7 +1330,7 @@ namespace Harness {
|
||||
|
||||
public getSourceMapRecord() {
|
||||
if (this.sourceMapData) {
|
||||
return Harness.SourceMapRecoder.getSourceMapRecord(this.sourceMapData, this.program, this.files);
|
||||
return Harness.SourceMapRecorder.getSourceMapRecord(this.sourceMapData, this.program, this.files);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -183,6 +183,7 @@ namespace Harness.LanguageService {
|
||||
const script = this.getScriptInfo(fileName);
|
||||
return script ? new ScriptSnapshot(script) : undefined;
|
||||
}
|
||||
getScriptKind(fileName: string): ts.ScriptKind { return ts.ScriptKind.Unknown; }
|
||||
getScriptVersion(fileName: string): string {
|
||||
const script = this.getScriptInfo(fileName);
|
||||
return script ? script.version.toString() : undefined;
|
||||
@@ -193,7 +194,7 @@ namespace Harness.LanguageService {
|
||||
error(s: string): void { }
|
||||
}
|
||||
|
||||
export class NativeLanugageServiceAdapter implements LanguageServiceAdapter {
|
||||
export class NativeLanguageServiceAdapter implements LanguageServiceAdapter {
|
||||
private host: NativeLanguageServiceHost;
|
||||
constructor(cancellationToken?: ts.HostCancellationToken, options?: ts.CompilerOptions) {
|
||||
this.host = new NativeLanguageServiceHost(cancellationToken, options);
|
||||
@@ -253,6 +254,7 @@ namespace Harness.LanguageService {
|
||||
const nativeScriptSnapshot = this.nativeHost.getScriptSnapshot(fileName);
|
||||
return nativeScriptSnapshot && new ScriptSnapshotProxy(nativeScriptSnapshot);
|
||||
}
|
||||
getScriptKind(fileName: string): ts.ScriptKind { return this.nativeHost.getScriptKind(fileName); }
|
||||
getScriptVersion(fileName: string): string { return this.nativeHost.getScriptVersion(fileName); }
|
||||
getLocalizedDiagnosticMessages(): string { return JSON.stringify({}); }
|
||||
|
||||
@@ -427,7 +429,7 @@ namespace Harness.LanguageService {
|
||||
dispose(): void { this.shim.dispose({}); }
|
||||
}
|
||||
|
||||
export class ShimLanugageServiceAdapter implements LanguageServiceAdapter {
|
||||
export class ShimLanguageServiceAdapter implements LanguageServiceAdapter {
|
||||
private host: ShimLanguageServiceHost;
|
||||
private factory: ts.TypeScriptServicesFactory;
|
||||
constructor(preprocessToResolve: boolean, cancellationToken?: ts.HostCancellationToken, options?: ts.CompilerOptions) {
|
||||
@@ -609,7 +611,7 @@ namespace Harness.LanguageService {
|
||||
}
|
||||
}
|
||||
|
||||
export class ServerLanugageServiceAdapter implements LanguageServiceAdapter {
|
||||
export class ServerLanguageServiceAdapter implements LanguageServiceAdapter {
|
||||
private host: SessionClientHost;
|
||||
private client: ts.server.SessionClient;
|
||||
constructor(cancellationToken?: ts.HostCancellationToken, options?: ts.CompilerOptions) {
|
||||
|
||||
@@ -136,7 +136,7 @@ namespace Playback {
|
||||
};
|
||||
wrapper.startReplayFromData = log => {
|
||||
replayLog = log;
|
||||
// Remove non-found files from the log (shouldn't really need them, but we still record them for diganostic purposes)
|
||||
// Remove non-found files from the log (shouldn't really need them, but we still record them for diagnostic purposes)
|
||||
replayLog.filesRead = replayLog.filesRead.filter(f => f.result.contents !== undefined);
|
||||
};
|
||||
|
||||
|
||||
@@ -370,14 +370,14 @@ class ProjectRunner extends RunnerBase {
|
||||
}
|
||||
|
||||
const outputDtsFileName = emitOutputFilePathWithoutExtension + ".d.ts";
|
||||
const file = findOutpuDtsFile(outputDtsFileName);
|
||||
const file = findOutputDtsFile(outputDtsFileName);
|
||||
if (file) {
|
||||
allInputFiles.unshift(file);
|
||||
}
|
||||
}
|
||||
else {
|
||||
const outputDtsFileName = ts.removeFileExtension(compilerOptions.outFile || compilerOptions.out) + ".d.ts";
|
||||
const outputDtsFile = findOutpuDtsFile(outputDtsFileName);
|
||||
const outputDtsFile = findOutputDtsFile(outputDtsFileName);
|
||||
if (!ts.contains(allInputFiles, outputDtsFile)) {
|
||||
allInputFiles.unshift(outputDtsFile);
|
||||
}
|
||||
@@ -387,7 +387,7 @@ class ProjectRunner extends RunnerBase {
|
||||
// Dont allow config files since we are compiling existing source options
|
||||
return compileProjectFiles(compilerResult.moduleKind, getInputFiles, getSourceFileText, writeFile, compilerResult.compilerOptions);
|
||||
|
||||
function findOutpuDtsFile(fileName: string) {
|
||||
function findOutputDtsFile(fileName: string) {
|
||||
return ts.forEach(compilerResult.outputFiles, outputFile => outputFile.emittedFileName === fileName ? outputFile : undefined);
|
||||
}
|
||||
function getInputFiles() {
|
||||
@@ -484,7 +484,7 @@ class ProjectRunner extends RunnerBase {
|
||||
it("SourceMapRecord for (" + moduleNameToString(moduleKind) + "): " + testCaseFileName, () => {
|
||||
if (compilerResult.sourceMapData) {
|
||||
Harness.Baseline.runBaseline("SourceMapRecord for (" + moduleNameToString(compilerResult.moduleKind) + "): " + testCaseFileName, getBaselineFolder(compilerResult.moduleKind) + testCaseJustName + ".sourcemap.txt", () => {
|
||||
return Harness.SourceMapRecoder.getSourceMapRecord(compilerResult.sourceMapData, compilerResult.program,
|
||||
return Harness.SourceMapRecorder.getSourceMapRecord(compilerResult.sourceMapData, compilerResult.program,
|
||||
ts.filter(compilerResult.outputFiles, outputFile => Harness.Compiler.isJS(outputFile.emittedFileName)));
|
||||
});
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
|
||||
///<reference path="harness.ts"/>
|
||||
|
||||
namespace Harness.SourceMapRecoder {
|
||||
namespace Harness.SourceMapRecorder {
|
||||
|
||||
interface SourceMapSpanWithDecodeErrors {
|
||||
sourceMapSpan: ts.SourceMapSpan;
|
||||
@@ -202,7 +202,7 @@ namespace Harness.SourceMapRecoder {
|
||||
}
|
||||
|
||||
namespace SourceMapSpanWriter {
|
||||
let sourceMapRecoder: Compiler.WriterAggregator;
|
||||
let sourceMapRecorder: Compiler.WriterAggregator;
|
||||
let sourceMapSources: string[];
|
||||
let sourceMapNames: string[];
|
||||
|
||||
@@ -216,8 +216,8 @@ namespace Harness.SourceMapRecoder {
|
||||
let prevWrittenJsLine: number;
|
||||
let spanMarkerContinues: boolean;
|
||||
|
||||
export function intializeSourceMapSpanWriter(sourceMapRecordWriter: Compiler.WriterAggregator, sourceMapData: ts.SourceMapData, currentJsFile: Compiler.GeneratedFile) {
|
||||
sourceMapRecoder = sourceMapRecordWriter;
|
||||
export function initializeSourceMapSpanWriter(sourceMapRecordWriter: Compiler.WriterAggregator, sourceMapData: ts.SourceMapData, currentJsFile: Compiler.GeneratedFile) {
|
||||
sourceMapRecorder = sourceMapRecordWriter;
|
||||
sourceMapSources = sourceMapData.sourceMapSources;
|
||||
sourceMapNames = sourceMapData.sourceMapNames;
|
||||
|
||||
@@ -231,15 +231,15 @@ namespace Harness.SourceMapRecoder {
|
||||
|
||||
SourceMapDecoder.initializeSourceMapDecoding(sourceMapData);
|
||||
|
||||
sourceMapRecoder.WriteLine("===================================================================");
|
||||
sourceMapRecoder.WriteLine("JsFile: " + sourceMapData.sourceMapFile);
|
||||
sourceMapRecoder.WriteLine("mapUrl: " + sourceMapData.jsSourceMappingURL);
|
||||
sourceMapRecoder.WriteLine("sourceRoot: " + sourceMapData.sourceMapSourceRoot);
|
||||
sourceMapRecoder.WriteLine("sources: " + sourceMapData.sourceMapSources);
|
||||
sourceMapRecorder.WriteLine("===================================================================");
|
||||
sourceMapRecorder.WriteLine("JsFile: " + sourceMapData.sourceMapFile);
|
||||
sourceMapRecorder.WriteLine("mapUrl: " + sourceMapData.jsSourceMappingURL);
|
||||
sourceMapRecorder.WriteLine("sourceRoot: " + sourceMapData.sourceMapSourceRoot);
|
||||
sourceMapRecorder.WriteLine("sources: " + sourceMapData.sourceMapSources);
|
||||
if (sourceMapData.sourceMapSourcesContent) {
|
||||
sourceMapRecoder.WriteLine("sourcesContent: " + JSON.stringify(sourceMapData.sourceMapSourcesContent));
|
||||
sourceMapRecorder.WriteLine("sourcesContent: " + JSON.stringify(sourceMapData.sourceMapSourcesContent));
|
||||
}
|
||||
sourceMapRecoder.WriteLine("===================================================================");
|
||||
sourceMapRecorder.WriteLine("===================================================================");
|
||||
}
|
||||
|
||||
function getSourceMapSpanString(mapEntry: ts.SourceMapSpan, getAbsentNameIndex?: boolean) {
|
||||
@@ -291,10 +291,10 @@ namespace Harness.SourceMapRecoder {
|
||||
recordSourceMapSpan(sourceMapSpan);
|
||||
|
||||
assert.isTrue(spansOnSingleLine.length === 1);
|
||||
sourceMapRecoder.WriteLine("-------------------------------------------------------------------");
|
||||
sourceMapRecoder.WriteLine("emittedFile:" + jsFile.fileName);
|
||||
sourceMapRecoder.WriteLine("sourceFile:" + sourceMapSources[spansOnSingleLine[0].sourceMapSpan.sourceIndex]);
|
||||
sourceMapRecoder.WriteLine("-------------------------------------------------------------------");
|
||||
sourceMapRecorder.WriteLine("-------------------------------------------------------------------");
|
||||
sourceMapRecorder.WriteLine("emittedFile:" + jsFile.fileName);
|
||||
sourceMapRecorder.WriteLine("sourceFile:" + sourceMapSources[spansOnSingleLine[0].sourceMapSpan.sourceIndex]);
|
||||
sourceMapRecorder.WriteLine("-------------------------------------------------------------------");
|
||||
|
||||
tsLineMap = ts.computeLineStarts(newSourceFileCode);
|
||||
tsCode = newSourceFileCode;
|
||||
@@ -306,8 +306,8 @@ namespace Harness.SourceMapRecoder {
|
||||
writeRecordedSpans();
|
||||
|
||||
if (!SourceMapDecoder.hasCompletedDecoding()) {
|
||||
sourceMapRecoder.WriteLine("!!!! **** There are more source map entries in the sourceMap's mapping than what was encoded");
|
||||
sourceMapRecoder.WriteLine("!!!! **** Remaining decoded string: " + SourceMapDecoder.getRemainingDecodeString());
|
||||
sourceMapRecorder.WriteLine("!!!! **** There are more source map entries in the sourceMap's mapping than what was encoded");
|
||||
sourceMapRecorder.WriteLine("!!!! **** Remaining decoded string: " + SourceMapDecoder.getRemainingDecodeString());
|
||||
|
||||
}
|
||||
|
||||
@@ -323,7 +323,7 @@ namespace Harness.SourceMapRecoder {
|
||||
|
||||
function writeJsFileLines(endJsLine: number) {
|
||||
for (; prevWrittenJsLine < endJsLine; prevWrittenJsLine++) {
|
||||
sourceMapRecoder.Write(">>>" + getTextOfLine(prevWrittenJsLine, jsLineMap, jsFile.code));
|
||||
sourceMapRecorder.Write(">>>" + getTextOfLine(prevWrittenJsLine, jsLineMap, jsFile.code));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -356,9 +356,9 @@ namespace Harness.SourceMapRecoder {
|
||||
}
|
||||
|
||||
function writeSourceMapIndent(indentLength: number, indentPrefix: string) {
|
||||
sourceMapRecoder.Write(indentPrefix);
|
||||
sourceMapRecorder.Write(indentPrefix);
|
||||
for (let i = 1; i < indentLength; i++) {
|
||||
sourceMapRecoder.Write(" ");
|
||||
sourceMapRecorder.Write(" ");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -369,12 +369,12 @@ namespace Harness.SourceMapRecoder {
|
||||
writeSourceMapIndent(prevEmittedCol, markerId);
|
||||
|
||||
for (let i = prevEmittedCol; i < endColumn; i++) {
|
||||
sourceMapRecoder.Write("^");
|
||||
sourceMapRecorder.Write("^");
|
||||
}
|
||||
if (endContinues) {
|
||||
sourceMapRecoder.Write("->");
|
||||
sourceMapRecorder.Write("->");
|
||||
}
|
||||
sourceMapRecoder.WriteLine("");
|
||||
sourceMapRecorder.WriteLine("");
|
||||
spanMarkerContinues = endContinues;
|
||||
}
|
||||
|
||||
@@ -390,16 +390,16 @@ namespace Harness.SourceMapRecoder {
|
||||
// If there are decode errors, write
|
||||
for (let i = 0; i < currentSpan.decodeErrors.length; i++) {
|
||||
writeSourceMapIndent(prevEmittedCol, markerIds[index]);
|
||||
sourceMapRecoder.WriteLine(currentSpan.decodeErrors[i]);
|
||||
sourceMapRecorder.WriteLine(currentSpan.decodeErrors[i]);
|
||||
}
|
||||
}
|
||||
|
||||
const tsCodeLineMap = ts.computeLineStarts(sourceText);
|
||||
for (let i = 0; i < tsCodeLineMap.length; i++) {
|
||||
writeSourceMapIndent(prevEmittedCol, i === 0 ? markerIds[index] : " >");
|
||||
sourceMapRecoder.Write(getTextOfLine(i, tsCodeLineMap, sourceText));
|
||||
sourceMapRecorder.Write(getTextOfLine(i, tsCodeLineMap, sourceText));
|
||||
if (i === tsCodeLineMap.length - 1) {
|
||||
sourceMapRecoder.WriteLine("");
|
||||
sourceMapRecorder.WriteLine("");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -407,7 +407,7 @@ namespace Harness.SourceMapRecoder {
|
||||
}
|
||||
|
||||
function writeSpanDetails(currentSpan: SourceMapSpanWithDecodeErrors, index: number) {
|
||||
sourceMapRecoder.WriteLine(markerIds[index] + getSourceMapSpanString(currentSpan.sourceMapSpan));
|
||||
sourceMapRecorder.WriteLine(markerIds[index] + getSourceMapSpanString(currentSpan.sourceMapSpan));
|
||||
}
|
||||
|
||||
if (spansOnSingleLine.length) {
|
||||
@@ -431,19 +431,19 @@ namespace Harness.SourceMapRecoder {
|
||||
// Emit column number etc
|
||||
iterateSpans(writeSpanDetails);
|
||||
|
||||
sourceMapRecoder.WriteLine("---");
|
||||
sourceMapRecorder.WriteLine("---");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export function getSourceMapRecord(sourceMapDataList: ts.SourceMapData[], program: ts.Program, jsFiles: Compiler.GeneratedFile[]) {
|
||||
const sourceMapRecoder = new Compiler.WriterAggregator();
|
||||
const sourceMapRecorder = new Compiler.WriterAggregator();
|
||||
|
||||
for (let i = 0; i < sourceMapDataList.length; i++) {
|
||||
const sourceMapData = sourceMapDataList[i];
|
||||
let prevSourceFile: ts.SourceFile;
|
||||
|
||||
SourceMapSpanWriter.intializeSourceMapSpanWriter(sourceMapRecoder, sourceMapData, jsFiles[i]);
|
||||
SourceMapSpanWriter.initializeSourceMapSpanWriter(sourceMapRecorder, sourceMapData, jsFiles[i]);
|
||||
for (let j = 0; j < sourceMapData.sourceMapDecodedMappings.length; j++) {
|
||||
const decodedSourceMapping = sourceMapData.sourceMapDecodedMappings[j];
|
||||
const currentSourceFile = program.getSourceFile(sourceMapData.inputSourceFileNames[decodedSourceMapping.sourceIndex]);
|
||||
@@ -457,7 +457,7 @@ namespace Harness.SourceMapRecoder {
|
||||
}
|
||||
SourceMapSpanWriter.close(); // If the last spans werent emitted, emit them
|
||||
}
|
||||
sourceMapRecoder.Close();
|
||||
return sourceMapRecoder.lines.join("\r\n");
|
||||
sourceMapRecorder.Close();
|
||||
return sourceMapRecorder.lines.join("\r\n");
|
||||
}
|
||||
}
|
||||
|
||||
Vendored
+1
-1
@@ -222,7 +222,7 @@ interface NumberConstructor {
|
||||
|
||||
/**
|
||||
* Returns true if passed value is finite.
|
||||
* Unlike the global isFininte, Number.isFinite doesn't forcibly convert the parameter to a
|
||||
* Unlike the global isFinite, Number.isFinite doesn't forcibly convert the parameter to a
|
||||
* number. Only finite values of the type number, result in true.
|
||||
* @param number A numeric value.
|
||||
*/
|
||||
|
||||
@@ -83,7 +83,7 @@ namespace ts.server {
|
||||
|
||||
private processResponse<T extends protocol.Response>(request: protocol.Request): T {
|
||||
var lastMessage = this.messages.shift();
|
||||
Debug.assert(!!lastMessage, "Did not recieve any responses.");
|
||||
Debug.assert(!!lastMessage, "Did not receive any responses.");
|
||||
|
||||
// Read the content length
|
||||
var contentLengthPrefix = "Content-Length: ";
|
||||
@@ -108,7 +108,7 @@ namespace ts.server {
|
||||
}
|
||||
|
||||
// verify the sequence numbers
|
||||
Debug.assert(response.request_seq === request.seq, "Malformed response: response sequance number did not match request sequence number.");
|
||||
Debug.assert(response.request_seq === request.seq, "Malformed response: response sequence number did not match request sequence number.");
|
||||
|
||||
// unmarshal errors
|
||||
if (!response.success) {
|
||||
|
||||
@@ -192,6 +192,10 @@ namespace ts.server {
|
||||
return this.roots.map(root => root.fileName);
|
||||
}
|
||||
|
||||
getScriptKind() {
|
||||
return ScriptKind.Unknown;
|
||||
}
|
||||
|
||||
getScriptVersion(filename: string) {
|
||||
return this.getScriptInfo(filename).svc.latestVersion().toString();
|
||||
}
|
||||
|
||||
Vendored
+6
-6
@@ -444,7 +444,7 @@ declare namespace ts.server.protocol {
|
||||
/** Defines space handling after a comma delimiter. Default value is true. */
|
||||
insertSpaceAfterCommaDelimiter?: boolean;
|
||||
|
||||
/** Defines space handling after a semicolon in a for statemen. Default value is true */
|
||||
/** Defines space handling after a semicolon in a for statement. Default value is true */
|
||||
insertSpaceAfterSemicolonInForStatements?: boolean;
|
||||
|
||||
/** Defines space handling after a binary operator. Default value is true. */
|
||||
@@ -469,7 +469,7 @@ declare namespace ts.server.protocol {
|
||||
placeOpenBraceOnNewLineForControlBlocks?: boolean;
|
||||
|
||||
/** Index operator */
|
||||
[key: string] : string | number | boolean;
|
||||
[key: string]: string | number | boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -835,7 +835,7 @@ declare namespace ts.server.protocol {
|
||||
prefixDisplayParts: SymbolDisplayPart[];
|
||||
|
||||
/**
|
||||
* The suffix disaply parts.
|
||||
* The suffix display parts.
|
||||
*/
|
||||
suffixDisplayParts: SymbolDisplayPart[];
|
||||
|
||||
@@ -903,7 +903,7 @@ declare namespace ts.server.protocol {
|
||||
}
|
||||
|
||||
/**
|
||||
* Repsonse object for a SignatureHelpRequest.
|
||||
* Response object for a SignatureHelpRequest.
|
||||
*/
|
||||
export interface SignatureHelpResponse extends Response {
|
||||
body?: SignatureHelpItems;
|
||||
@@ -970,7 +970,7 @@ declare namespace ts.server.protocol {
|
||||
*/
|
||||
export interface Diagnostic {
|
||||
/**
|
||||
* Starting file location at which text appies.
|
||||
* Starting file location at which text applies.
|
||||
*/
|
||||
start: Location;
|
||||
|
||||
@@ -1179,7 +1179,7 @@ declare namespace ts.server.protocol {
|
||||
}
|
||||
|
||||
/**
|
||||
* NavBar itesm request; value of command field is "navbar".
|
||||
* NavBar items request; value of command field is "navbar".
|
||||
* Return response giving the list of navigation bar entries
|
||||
* extracted from the requested file.
|
||||
*/
|
||||
|
||||
@@ -603,7 +603,7 @@ namespace ts.server {
|
||||
// Check whether we should auto-indent. This will be when
|
||||
// the position is on a line containing only whitespace.
|
||||
// This should leave the edits returned from
|
||||
// getFormattingEditsAfterKeytroke either empty or pertaining
|
||||
// getFormattingEditsAfterKeystroke either empty or pertaining
|
||||
// only to the previous line. If all this is true, then
|
||||
// add edits necessary to properly indent the current line.
|
||||
if ((key == "\n") && ((!edits) || (edits.length === 0) || allEditsBeforePos(edits, position))) {
|
||||
|
||||
@@ -490,17 +490,17 @@ namespace ts.BreakpointResolver {
|
||||
return spanInNode(block.statements[0]);
|
||||
}
|
||||
|
||||
function spanInInitializerOfForLike(forLikeStaement: ForStatement | ForOfStatement | ForInStatement): TextSpan {
|
||||
if (forLikeStaement.initializer.kind === SyntaxKind.VariableDeclarationList) {
|
||||
function spanInInitializerOfForLike(forLikeStatement: ForStatement | ForOfStatement | ForInStatement): TextSpan {
|
||||
if (forLikeStatement.initializer.kind === SyntaxKind.VariableDeclarationList) {
|
||||
// declaration list, set breakpoint in first declaration
|
||||
let variableDeclarationList = <VariableDeclarationList>forLikeStaement.initializer;
|
||||
let variableDeclarationList = <VariableDeclarationList>forLikeStatement.initializer;
|
||||
if (variableDeclarationList.declarations.length > 0) {
|
||||
return spanInNode(variableDeclarationList.declarations[0]);
|
||||
}
|
||||
}
|
||||
else {
|
||||
// Expression - set breakpoint in it
|
||||
return spanInNode(forLikeStaement.initializer);
|
||||
return spanInNode(forLikeStatement.initializer);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -256,7 +256,7 @@ namespace ts.formatting {
|
||||
return enclosingNode.pos;
|
||||
}
|
||||
|
||||
// preceding token ends after the start of original range (i.e when originaRange.pos falls in the middle of literal)
|
||||
// preceding token ends after the start of original range (i.e when originalRange.pos falls in the middle of literal)
|
||||
// start from the beginning of enclosingNode to handle the entire 'originalRange'
|
||||
if (precedingToken.end >= originalRange.pos) {
|
||||
return enclosingNode.pos;
|
||||
|
||||
@@ -181,7 +181,7 @@ namespace ts.formatting {
|
||||
// readTokenInfo was called before with the same expected scan action.
|
||||
// No need to re-scan text, return existing 'lastTokenInfo'
|
||||
// it is ok to call fixTokenKind here since it does not affect
|
||||
// what portion of text is consumed. In opposize rescanning can change it,
|
||||
// what portion of text is consumed. In contrast rescanning can change it,
|
||||
// i.e. for '>=' when originally scanner eats just one character
|
||||
// and rescanning forces it to consume more.
|
||||
return fixTokenKind(lastTokenInfo, n);
|
||||
|
||||
@@ -235,29 +235,29 @@ namespace ts.formatting {
|
||||
this.IgnoreAfterLineComment = new Rule(RuleDescriptor.create3(SyntaxKind.SingleLineCommentTrivia, Shared.TokenRange.Any), RuleOperation.create1(RuleAction.Ignore));
|
||||
|
||||
// Space after keyword but not before ; or : or ?
|
||||
this.NoSpaceBeforeSemicolon = new Rule(RuleDescriptor.create2(Shared.TokenRange.Any, SyntaxKind.SemicolonToken), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Delete));
|
||||
this.NoSpaceBeforeColon = new Rule(RuleDescriptor.create2(Shared.TokenRange.Any, SyntaxKind.ColonToken), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), RuleAction.Delete));
|
||||
this.NoSpaceBeforeQuestionMark = new Rule(RuleDescriptor.create2(Shared.TokenRange.Any, SyntaxKind.QuestionToken), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), RuleAction.Delete));
|
||||
this.SpaceAfterColon = new Rule(RuleDescriptor.create3(SyntaxKind.ColonToken, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), RuleAction.Space));
|
||||
this.SpaceAfterQuestionMarkInConditionalOperator = new Rule(RuleDescriptor.create3(SyntaxKind.QuestionToken, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsConditionalOperatorContext), RuleAction.Space));
|
||||
this.NoSpaceAfterQuestionMark = new Rule(RuleDescriptor.create3(SyntaxKind.QuestionToken, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Delete));
|
||||
this.SpaceAfterSemicolon = new Rule(RuleDescriptor.create3(SyntaxKind.SemicolonToken, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Space));
|
||||
this.NoSpaceBeforeSemicolon = new Rule(RuleDescriptor.create2(Shared.TokenRange.Any, SyntaxKind.SemicolonToken), RuleOperation.create2(new RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), RuleAction.Delete));
|
||||
this.NoSpaceBeforeColon = new Rule(RuleDescriptor.create2(Shared.TokenRange.Any, SyntaxKind.ColonToken), RuleOperation.create2(new RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNotBinaryOpContext), RuleAction.Delete));
|
||||
this.NoSpaceBeforeQuestionMark = new Rule(RuleDescriptor.create2(Shared.TokenRange.Any, SyntaxKind.QuestionToken), RuleOperation.create2(new RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNotBinaryOpContext), RuleAction.Delete));
|
||||
this.SpaceAfterColon = new Rule(RuleDescriptor.create3(SyntaxKind.ColonToken, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNotBinaryOpContext), RuleAction.Space));
|
||||
this.SpaceAfterQuestionMarkInConditionalOperator = new Rule(RuleDescriptor.create3(SyntaxKind.QuestionToken, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsConditionalOperatorContext), RuleAction.Space));
|
||||
this.NoSpaceAfterQuestionMark = new Rule(RuleDescriptor.create3(SyntaxKind.QuestionToken, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), RuleAction.Delete));
|
||||
this.SpaceAfterSemicolon = new Rule(RuleDescriptor.create3(SyntaxKind.SemicolonToken, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), RuleAction.Space));
|
||||
|
||||
// Space after }.
|
||||
this.SpaceAfterCloseBrace = new Rule(RuleDescriptor.create3(SyntaxKind.CloseBraceToken, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsAfterCodeBlockContext), RuleAction.Space));
|
||||
this.SpaceAfterCloseBrace = new Rule(RuleDescriptor.create3(SyntaxKind.CloseBraceToken, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsAfterCodeBlockContext), RuleAction.Space));
|
||||
|
||||
// Special case for (}, else) and (}, while) since else & while tokens are not part of the tree which makes SpaceAfterCloseBrace rule not applied
|
||||
this.SpaceBetweenCloseBraceAndElse = new Rule(RuleDescriptor.create1(SyntaxKind.CloseBraceToken, SyntaxKind.ElseKeyword), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Space));
|
||||
this.SpaceBetweenCloseBraceAndWhile = new Rule(RuleDescriptor.create1(SyntaxKind.CloseBraceToken, SyntaxKind.WhileKeyword), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Space));
|
||||
this.NoSpaceAfterCloseBrace = new Rule(RuleDescriptor.create3(SyntaxKind.CloseBraceToken, Shared.TokenRange.FromTokens([SyntaxKind.CloseParenToken, SyntaxKind.CloseBracketToken, SyntaxKind.CommaToken, SyntaxKind.SemicolonToken])), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Delete));
|
||||
this.SpaceBetweenCloseBraceAndElse = new Rule(RuleDescriptor.create1(SyntaxKind.CloseBraceToken, SyntaxKind.ElseKeyword), RuleOperation.create2(new RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), RuleAction.Space));
|
||||
this.SpaceBetweenCloseBraceAndWhile = new Rule(RuleDescriptor.create1(SyntaxKind.CloseBraceToken, SyntaxKind.WhileKeyword), RuleOperation.create2(new RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), RuleAction.Space));
|
||||
this.NoSpaceAfterCloseBrace = new Rule(RuleDescriptor.create3(SyntaxKind.CloseBraceToken, Shared.TokenRange.FromTokens([SyntaxKind.CloseParenToken, SyntaxKind.CloseBracketToken, SyntaxKind.CommaToken, SyntaxKind.SemicolonToken])), RuleOperation.create2(new RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), RuleAction.Delete));
|
||||
|
||||
// No space for dot
|
||||
this.NoSpaceBeforeDot = new Rule(RuleDescriptor.create2(Shared.TokenRange.Any, SyntaxKind.DotToken), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Delete));
|
||||
this.NoSpaceAfterDot = new Rule(RuleDescriptor.create3(SyntaxKind.DotToken, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Delete));
|
||||
this.NoSpaceBeforeDot = new Rule(RuleDescriptor.create2(Shared.TokenRange.Any, SyntaxKind.DotToken), RuleOperation.create2(new RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), RuleAction.Delete));
|
||||
this.NoSpaceAfterDot = new Rule(RuleDescriptor.create3(SyntaxKind.DotToken, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), RuleAction.Delete));
|
||||
|
||||
// No space before and after indexer
|
||||
this.NoSpaceBeforeOpenBracket = new Rule(RuleDescriptor.create2(Shared.TokenRange.Any, SyntaxKind.OpenBracketToken), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Delete));
|
||||
this.NoSpaceAfterCloseBracket = new Rule(RuleDescriptor.create3(SyntaxKind.CloseBracketToken, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBeforeBlockInFunctionDeclarationContext), RuleAction.Delete));
|
||||
this.NoSpaceBeforeOpenBracket = new Rule(RuleDescriptor.create2(Shared.TokenRange.Any, SyntaxKind.OpenBracketToken), RuleOperation.create2(new RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), RuleAction.Delete));
|
||||
this.NoSpaceAfterCloseBracket = new Rule(RuleDescriptor.create3(SyntaxKind.CloseBracketToken, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNotBeforeBlockInFunctionDeclarationContext), RuleAction.Delete));
|
||||
|
||||
// Place a space before open brace in a function declaration
|
||||
this.FunctionOpenBraceLeftTokenRange = Shared.TokenRange.AnyIncludingMultilineComments;
|
||||
@@ -274,7 +274,7 @@ namespace ts.formatting {
|
||||
// Insert a space after { and before } in single-line contexts, but remove space from empty object literals {}.
|
||||
this.SpaceAfterOpenBrace = new Rule(RuleDescriptor.create3(SyntaxKind.OpenBraceToken, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsSingleLineBlockContext), RuleAction.Space));
|
||||
this.SpaceBeforeCloseBrace = new Rule(RuleDescriptor.create2(Shared.TokenRange.Any, SyntaxKind.CloseBraceToken), RuleOperation.create2(new RuleOperationContext(Rules.IsSingleLineBlockContext), RuleAction.Space));
|
||||
this.NoSpaceBetweenEmptyBraceBrackets = new Rule(RuleDescriptor.create1(SyntaxKind.OpenBraceToken, SyntaxKind.CloseBraceToken), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsObjectContext), RuleAction.Delete));
|
||||
this.NoSpaceBetweenEmptyBraceBrackets = new Rule(RuleDescriptor.create1(SyntaxKind.OpenBraceToken, SyntaxKind.CloseBraceToken), RuleOperation.create2(new RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsObjectContext), RuleAction.Delete));
|
||||
|
||||
// Insert new line after { and before } in multi-line contexts.
|
||||
this.NewLineAfterOpenBraceInBlockContext = new Rule(RuleDescriptor.create3(SyntaxKind.OpenBraceToken, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsMultilineBlockContext), RuleAction.NewLine));
|
||||
@@ -285,100 +285,100 @@ namespace ts.formatting {
|
||||
// Special handling of unary operators.
|
||||
// Prefix operators generally shouldn't have a space between
|
||||
// them and their target unary expression.
|
||||
this.NoSpaceAfterUnaryPrefixOperator = new Rule(RuleDescriptor.create4(Shared.TokenRange.UnaryPrefixOperators, Shared.TokenRange.UnaryPrefixExpressions), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), RuleAction.Delete));
|
||||
this.NoSpaceAfterUnaryPreincrementOperator = new Rule(RuleDescriptor.create3(SyntaxKind.PlusPlusToken, Shared.TokenRange.UnaryPreincrementExpressions), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Delete));
|
||||
this.NoSpaceAfterUnaryPredecrementOperator = new Rule(RuleDescriptor.create3(SyntaxKind.MinusMinusToken, Shared.TokenRange.UnaryPredecrementExpressions), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Delete));
|
||||
this.NoSpaceBeforeUnaryPostincrementOperator = new Rule(RuleDescriptor.create2(Shared.TokenRange.UnaryPostincrementExpressions, SyntaxKind.PlusPlusToken), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Delete));
|
||||
this.NoSpaceBeforeUnaryPostdecrementOperator = new Rule(RuleDescriptor.create2(Shared.TokenRange.UnaryPostdecrementExpressions, SyntaxKind.MinusMinusToken), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Delete));
|
||||
this.NoSpaceAfterUnaryPrefixOperator = new Rule(RuleDescriptor.create4(Shared.TokenRange.UnaryPrefixOperators, Shared.TokenRange.UnaryPrefixExpressions), RuleOperation.create2(new RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNotBinaryOpContext), RuleAction.Delete));
|
||||
this.NoSpaceAfterUnaryPreincrementOperator = new Rule(RuleDescriptor.create3(SyntaxKind.PlusPlusToken, Shared.TokenRange.UnaryPreincrementExpressions), RuleOperation.create2(new RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), RuleAction.Delete));
|
||||
this.NoSpaceAfterUnaryPredecrementOperator = new Rule(RuleDescriptor.create3(SyntaxKind.MinusMinusToken, Shared.TokenRange.UnaryPredecrementExpressions), RuleOperation.create2(new RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), RuleAction.Delete));
|
||||
this.NoSpaceBeforeUnaryPostincrementOperator = new Rule(RuleDescriptor.create2(Shared.TokenRange.UnaryPostincrementExpressions, SyntaxKind.PlusPlusToken), RuleOperation.create2(new RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), RuleAction.Delete));
|
||||
this.NoSpaceBeforeUnaryPostdecrementOperator = new Rule(RuleDescriptor.create2(Shared.TokenRange.UnaryPostdecrementExpressions, SyntaxKind.MinusMinusToken), RuleOperation.create2(new RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), RuleAction.Delete));
|
||||
|
||||
// More unary operator special-casing.
|
||||
// DevDiv 181814: Be careful when removing leading whitespace
|
||||
// around unary operators. Examples:
|
||||
// 1 - -2 --X--> 1--2
|
||||
// a + ++b --X--> a+++b
|
||||
this.SpaceAfterPostincrementWhenFollowedByAdd = new Rule(RuleDescriptor.create1(SyntaxKind.PlusPlusToken, SyntaxKind.PlusToken), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), RuleAction.Space));
|
||||
this.SpaceAfterAddWhenFollowedByUnaryPlus = new Rule(RuleDescriptor.create1(SyntaxKind.PlusToken, SyntaxKind.PlusToken), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), RuleAction.Space));
|
||||
this.SpaceAfterAddWhenFollowedByPreincrement = new Rule(RuleDescriptor.create1(SyntaxKind.PlusToken, SyntaxKind.PlusPlusToken), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), RuleAction.Space));
|
||||
this.SpaceAfterPostdecrementWhenFollowedBySubtract = new Rule(RuleDescriptor.create1(SyntaxKind.MinusMinusToken, SyntaxKind.MinusToken), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), RuleAction.Space));
|
||||
this.SpaceAfterSubtractWhenFollowedByUnaryMinus = new Rule(RuleDescriptor.create1(SyntaxKind.MinusToken, SyntaxKind.MinusToken), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), RuleAction.Space));
|
||||
this.SpaceAfterSubtractWhenFollowedByPredecrement = new Rule(RuleDescriptor.create1(SyntaxKind.MinusToken, SyntaxKind.MinusMinusToken), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), RuleAction.Space));
|
||||
this.SpaceAfterPostincrementWhenFollowedByAdd = new Rule(RuleDescriptor.create1(SyntaxKind.PlusPlusToken, SyntaxKind.PlusToken), RuleOperation.create2(new RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), RuleAction.Space));
|
||||
this.SpaceAfterAddWhenFollowedByUnaryPlus = new Rule(RuleDescriptor.create1(SyntaxKind.PlusToken, SyntaxKind.PlusToken), RuleOperation.create2(new RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), RuleAction.Space));
|
||||
this.SpaceAfterAddWhenFollowedByPreincrement = new Rule(RuleDescriptor.create1(SyntaxKind.PlusToken, SyntaxKind.PlusPlusToken), RuleOperation.create2(new RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), RuleAction.Space));
|
||||
this.SpaceAfterPostdecrementWhenFollowedBySubtract = new Rule(RuleDescriptor.create1(SyntaxKind.MinusMinusToken, SyntaxKind.MinusToken), RuleOperation.create2(new RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), RuleAction.Space));
|
||||
this.SpaceAfterSubtractWhenFollowedByUnaryMinus = new Rule(RuleDescriptor.create1(SyntaxKind.MinusToken, SyntaxKind.MinusToken), RuleOperation.create2(new RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), RuleAction.Space));
|
||||
this.SpaceAfterSubtractWhenFollowedByPredecrement = new Rule(RuleDescriptor.create1(SyntaxKind.MinusToken, SyntaxKind.MinusMinusToken), RuleOperation.create2(new RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), RuleAction.Space));
|
||||
|
||||
this.NoSpaceBeforeComma = new Rule(RuleDescriptor.create2(Shared.TokenRange.Any, SyntaxKind.CommaToken), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Delete));
|
||||
this.NoSpaceBeforeComma = new Rule(RuleDescriptor.create2(Shared.TokenRange.Any, SyntaxKind.CommaToken), RuleOperation.create2(new RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), RuleAction.Delete));
|
||||
|
||||
this.SpaceAfterCertainKeywords = new Rule(RuleDescriptor.create4(Shared.TokenRange.FromTokens([SyntaxKind.VarKeyword, SyntaxKind.ThrowKeyword, SyntaxKind.NewKeyword, SyntaxKind.DeleteKeyword, SyntaxKind.ReturnKeyword, SyntaxKind.TypeOfKeyword, SyntaxKind.AwaitKeyword]), Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Space));
|
||||
this.SpaceAfterLetConstInVariableDeclaration = new Rule(RuleDescriptor.create4(Shared.TokenRange.FromTokens([SyntaxKind.LetKeyword, SyntaxKind.ConstKeyword]), Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsStartOfVariableDeclarationList), RuleAction.Space));
|
||||
this.NoSpaceBeforeOpenParenInFuncCall = new Rule(RuleDescriptor.create2(Shared.TokenRange.Any, SyntaxKind.OpenParenToken), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsFunctionCallOrNewContext, Rules.IsPreviousTokenNotComma), RuleAction.Delete));
|
||||
this.SpaceAfterCertainKeywords = new Rule(RuleDescriptor.create4(Shared.TokenRange.FromTokens([SyntaxKind.VarKeyword, SyntaxKind.ThrowKeyword, SyntaxKind.NewKeyword, SyntaxKind.DeleteKeyword, SyntaxKind.ReturnKeyword, SyntaxKind.TypeOfKeyword, SyntaxKind.AwaitKeyword]), Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), RuleAction.Space));
|
||||
this.SpaceAfterLetConstInVariableDeclaration = new Rule(RuleDescriptor.create4(Shared.TokenRange.FromTokens([SyntaxKind.LetKeyword, SyntaxKind.ConstKeyword]), Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsStartOfVariableDeclarationList), RuleAction.Space));
|
||||
this.NoSpaceBeforeOpenParenInFuncCall = new Rule(RuleDescriptor.create2(Shared.TokenRange.Any, SyntaxKind.OpenParenToken), RuleOperation.create2(new RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsFunctionCallOrNewContext, Rules.IsPreviousTokenNotComma), RuleAction.Delete));
|
||||
this.SpaceAfterFunctionInFuncDecl = new Rule(RuleDescriptor.create3(SyntaxKind.FunctionKeyword, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsFunctionDeclContext), RuleAction.Space));
|
||||
this.NoSpaceBeforeOpenParenInFuncDecl = new Rule(RuleDescriptor.create2(Shared.TokenRange.Any, SyntaxKind.OpenParenToken), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsFunctionDeclContext), RuleAction.Delete));
|
||||
this.SpaceAfterVoidOperator = new Rule(RuleDescriptor.create3(SyntaxKind.VoidKeyword, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsVoidOpContext), RuleAction.Space));
|
||||
this.NoSpaceBeforeOpenParenInFuncDecl = new Rule(RuleDescriptor.create2(Shared.TokenRange.Any, SyntaxKind.OpenParenToken), RuleOperation.create2(new RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsFunctionDeclContext), RuleAction.Delete));
|
||||
this.SpaceAfterVoidOperator = new Rule(RuleDescriptor.create3(SyntaxKind.VoidKeyword, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsVoidOpContext), RuleAction.Space));
|
||||
|
||||
this.NoSpaceBetweenReturnAndSemicolon = new Rule(RuleDescriptor.create1(SyntaxKind.ReturnKeyword, SyntaxKind.SemicolonToken), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Delete));
|
||||
this.NoSpaceBetweenReturnAndSemicolon = new Rule(RuleDescriptor.create1(SyntaxKind.ReturnKeyword, SyntaxKind.SemicolonToken), RuleOperation.create2(new RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), RuleAction.Delete));
|
||||
|
||||
// Add a space between statements. All keywords except (do,else,case) has open/close parens after them.
|
||||
// So, we have a rule to add a space for [),Any], [do,Any], [else,Any], and [case,Any]
|
||||
this.SpaceBetweenStatements = new Rule(RuleDescriptor.create4(Shared.TokenRange.FromTokens([SyntaxKind.CloseParenToken, SyntaxKind.DoKeyword, SyntaxKind.ElseKeyword, SyntaxKind.CaseKeyword]), Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotForContext), RuleAction.Space));
|
||||
this.SpaceBetweenStatements = new Rule(RuleDescriptor.create4(Shared.TokenRange.FromTokens([SyntaxKind.CloseParenToken, SyntaxKind.DoKeyword, SyntaxKind.ElseKeyword, SyntaxKind.CaseKeyword]), Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNotForContext), RuleAction.Space));
|
||||
|
||||
// This low-pri rule takes care of "try {" and "finally {" in case the rule SpaceBeforeOpenBraceInControl didn't execute on FormatOnEnter.
|
||||
this.SpaceAfterTryFinally = new Rule(RuleDescriptor.create2(Shared.TokenRange.FromTokens([SyntaxKind.TryKeyword, SyntaxKind.FinallyKeyword]), SyntaxKind.OpenBraceToken), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Space));
|
||||
this.SpaceAfterTryFinally = new Rule(RuleDescriptor.create2(Shared.TokenRange.FromTokens([SyntaxKind.TryKeyword, SyntaxKind.FinallyKeyword]), SyntaxKind.OpenBraceToken), RuleOperation.create2(new RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), RuleAction.Space));
|
||||
|
||||
// get x() {}
|
||||
// set x(val) {}
|
||||
this.SpaceAfterGetSetInMember = new Rule(RuleDescriptor.create2(Shared.TokenRange.FromTokens([SyntaxKind.GetKeyword, SyntaxKind.SetKeyword]), SyntaxKind.Identifier), RuleOperation.create2(new RuleOperationContext(Rules.IsFunctionDeclContext), RuleAction.Space));
|
||||
|
||||
// Special case for binary operators (that are keywords). For these we have to add a space and shouldn't follow any user options.
|
||||
this.SpaceBeforeBinaryKeywordOperator = new Rule(RuleDescriptor.create4(Shared.TokenRange.Any, Shared.TokenRange.BinaryKeywordOperators), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), RuleAction.Space));
|
||||
this.SpaceAfterBinaryKeywordOperator = new Rule(RuleDescriptor.create4(Shared.TokenRange.BinaryKeywordOperators, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), RuleAction.Space));
|
||||
this.SpaceBeforeBinaryKeywordOperator = new Rule(RuleDescriptor.create4(Shared.TokenRange.Any, Shared.TokenRange.BinaryKeywordOperators), RuleOperation.create2(new RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), RuleAction.Space));
|
||||
this.SpaceAfterBinaryKeywordOperator = new Rule(RuleDescriptor.create4(Shared.TokenRange.BinaryKeywordOperators, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), RuleAction.Space));
|
||||
|
||||
// TypeScript-specific higher priority rules
|
||||
|
||||
// Treat constructor as an identifier in a function declaration, and remove spaces between constructor and following left parentheses
|
||||
this.NoSpaceAfterConstructor = new Rule(RuleDescriptor.create1(SyntaxKind.ConstructorKeyword, SyntaxKind.OpenParenToken), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Delete));
|
||||
this.NoSpaceAfterConstructor = new Rule(RuleDescriptor.create1(SyntaxKind.ConstructorKeyword, SyntaxKind.OpenParenToken), RuleOperation.create2(new RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), RuleAction.Delete));
|
||||
|
||||
// Use of module as a function call. e.g.: import m2 = module("m2");
|
||||
this.NoSpaceAfterModuleImport = new Rule(RuleDescriptor.create2(Shared.TokenRange.FromTokens([SyntaxKind.ModuleKeyword, SyntaxKind.RequireKeyword]), SyntaxKind.OpenParenToken), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Delete));
|
||||
this.NoSpaceAfterModuleImport = new Rule(RuleDescriptor.create2(Shared.TokenRange.FromTokens([SyntaxKind.ModuleKeyword, SyntaxKind.RequireKeyword]), SyntaxKind.OpenParenToken), RuleOperation.create2(new RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), RuleAction.Delete));
|
||||
|
||||
// Add a space around certain TypeScript keywords
|
||||
this.SpaceAfterCertainTypeScriptKeywords = new Rule(RuleDescriptor.create4(Shared.TokenRange.FromTokens([SyntaxKind.AbstractKeyword, SyntaxKind.ClassKeyword, SyntaxKind.DeclareKeyword, SyntaxKind.DefaultKeyword, SyntaxKind.EnumKeyword, SyntaxKind.ExportKeyword, SyntaxKind.ExtendsKeyword, SyntaxKind.GetKeyword, SyntaxKind.ImplementsKeyword, SyntaxKind.ImportKeyword, SyntaxKind.InterfaceKeyword, SyntaxKind.ModuleKeyword, SyntaxKind.NamespaceKeyword, SyntaxKind.PrivateKeyword, SyntaxKind.PublicKeyword, SyntaxKind.ProtectedKeyword, SyntaxKind.SetKeyword, SyntaxKind.StaticKeyword, SyntaxKind.TypeKeyword]), Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Space));
|
||||
this.SpaceBeforeCertainTypeScriptKeywords = new Rule(RuleDescriptor.create4(Shared.TokenRange.Any, Shared.TokenRange.FromTokens([SyntaxKind.ExtendsKeyword, SyntaxKind.ImplementsKeyword])), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Space));
|
||||
this.SpaceAfterCertainTypeScriptKeywords = new Rule(RuleDescriptor.create4(Shared.TokenRange.FromTokens([SyntaxKind.AbstractKeyword, SyntaxKind.ClassKeyword, SyntaxKind.DeclareKeyword, SyntaxKind.DefaultKeyword, SyntaxKind.EnumKeyword, SyntaxKind.ExportKeyword, SyntaxKind.ExtendsKeyword, SyntaxKind.GetKeyword, SyntaxKind.ImplementsKeyword, SyntaxKind.ImportKeyword, SyntaxKind.InterfaceKeyword, SyntaxKind.ModuleKeyword, SyntaxKind.NamespaceKeyword, SyntaxKind.PrivateKeyword, SyntaxKind.PublicKeyword, SyntaxKind.ProtectedKeyword, SyntaxKind.SetKeyword, SyntaxKind.StaticKeyword, SyntaxKind.TypeKeyword]), Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), RuleAction.Space));
|
||||
this.SpaceBeforeCertainTypeScriptKeywords = new Rule(RuleDescriptor.create4(Shared.TokenRange.Any, Shared.TokenRange.FromTokens([SyntaxKind.ExtendsKeyword, SyntaxKind.ImplementsKeyword])), RuleOperation.create2(new RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), RuleAction.Space));
|
||||
|
||||
// Treat string literals in module names as identifiers, and add a space between the literal and the opening Brace braces, e.g.: module "m2" {
|
||||
this.SpaceAfterModuleName = new Rule(RuleDescriptor.create1(SyntaxKind.StringLiteral, SyntaxKind.OpenBraceToken), RuleOperation.create2(new RuleOperationContext(Rules.IsModuleDeclContext), RuleAction.Space));
|
||||
|
||||
// Lambda expressions
|
||||
this.SpaceBeforeArrow = new Rule(RuleDescriptor.create2(Shared.TokenRange.Any, SyntaxKind.EqualsGreaterThanToken), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Space));
|
||||
this.SpaceAfterArrow = new Rule(RuleDescriptor.create3(SyntaxKind.EqualsGreaterThanToken, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Space));
|
||||
this.SpaceBeforeArrow = new Rule(RuleDescriptor.create2(Shared.TokenRange.Any, SyntaxKind.EqualsGreaterThanToken), RuleOperation.create2(new RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), RuleAction.Space));
|
||||
this.SpaceAfterArrow = new Rule(RuleDescriptor.create3(SyntaxKind.EqualsGreaterThanToken, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), RuleAction.Space));
|
||||
|
||||
// Optional parameters and let args
|
||||
this.NoSpaceAfterEllipsis = new Rule(RuleDescriptor.create1(SyntaxKind.DotDotDotToken, SyntaxKind.Identifier), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Delete));
|
||||
this.NoSpaceAfterOptionalParameters = new Rule(RuleDescriptor.create3(SyntaxKind.QuestionToken, Shared.TokenRange.FromTokens([SyntaxKind.CloseParenToken, SyntaxKind.CommaToken])), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), RuleAction.Delete));
|
||||
this.NoSpaceAfterEllipsis = new Rule(RuleDescriptor.create1(SyntaxKind.DotDotDotToken, SyntaxKind.Identifier), RuleOperation.create2(new RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), RuleAction.Delete));
|
||||
this.NoSpaceAfterOptionalParameters = new Rule(RuleDescriptor.create3(SyntaxKind.QuestionToken, Shared.TokenRange.FromTokens([SyntaxKind.CloseParenToken, SyntaxKind.CommaToken])), RuleOperation.create2(new RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNotBinaryOpContext), RuleAction.Delete));
|
||||
|
||||
// generics and type assertions
|
||||
this.NoSpaceBeforeOpenAngularBracket = new Rule(RuleDescriptor.create2(Shared.TokenRange.TypeNames, SyntaxKind.LessThanToken), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsTypeArgumentOrParameterOrAssertionContext), RuleAction.Delete));
|
||||
this.NoSpaceBetweenCloseParenAndAngularBracket = new Rule(RuleDescriptor.create1(SyntaxKind.CloseParenToken, SyntaxKind.LessThanToken), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsTypeArgumentOrParameterOrAssertionContext), RuleAction.Delete));
|
||||
this.NoSpaceAfterOpenAngularBracket = new Rule(RuleDescriptor.create3(SyntaxKind.LessThanToken, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsTypeArgumentOrParameterOrAssertionContext), RuleAction.Delete));
|
||||
this.NoSpaceBeforeCloseAngularBracket = new Rule(RuleDescriptor.create2(Shared.TokenRange.Any, SyntaxKind.GreaterThanToken), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsTypeArgumentOrParameterOrAssertionContext), RuleAction.Delete));
|
||||
this.NoSpaceAfterCloseAngularBracket = new Rule(RuleDescriptor.create3(SyntaxKind.GreaterThanToken, Shared.TokenRange.FromTokens([SyntaxKind.OpenParenToken, SyntaxKind.OpenBracketToken, SyntaxKind.GreaterThanToken, SyntaxKind.CommaToken])), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsTypeArgumentOrParameterOrAssertionContext), RuleAction.Delete));
|
||||
this.NoSpaceAfterTypeAssertion = new Rule(RuleDescriptor.create3(SyntaxKind.GreaterThanToken, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsTypeAssertionContext), RuleAction.Delete));
|
||||
this.NoSpaceBeforeOpenAngularBracket = new Rule(RuleDescriptor.create2(Shared.TokenRange.TypeNames, SyntaxKind.LessThanToken), RuleOperation.create2(new RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsTypeArgumentOrParameterOrAssertionContext), RuleAction.Delete));
|
||||
this.NoSpaceBetweenCloseParenAndAngularBracket = new Rule(RuleDescriptor.create1(SyntaxKind.CloseParenToken, SyntaxKind.LessThanToken), RuleOperation.create2(new RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsTypeArgumentOrParameterOrAssertionContext), RuleAction.Delete));
|
||||
this.NoSpaceAfterOpenAngularBracket = new Rule(RuleDescriptor.create3(SyntaxKind.LessThanToken, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsTypeArgumentOrParameterOrAssertionContext), RuleAction.Delete));
|
||||
this.NoSpaceBeforeCloseAngularBracket = new Rule(RuleDescriptor.create2(Shared.TokenRange.Any, SyntaxKind.GreaterThanToken), RuleOperation.create2(new RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsTypeArgumentOrParameterOrAssertionContext), RuleAction.Delete));
|
||||
this.NoSpaceAfterCloseAngularBracket = new Rule(RuleDescriptor.create3(SyntaxKind.GreaterThanToken, Shared.TokenRange.FromTokens([SyntaxKind.OpenParenToken, SyntaxKind.OpenBracketToken, SyntaxKind.GreaterThanToken, SyntaxKind.CommaToken])), RuleOperation.create2(new RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsTypeArgumentOrParameterOrAssertionContext), RuleAction.Delete));
|
||||
this.NoSpaceAfterTypeAssertion = new Rule(RuleDescriptor.create3(SyntaxKind.GreaterThanToken, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsTypeAssertionContext), RuleAction.Delete));
|
||||
|
||||
// Remove spaces in empty interface literals. e.g.: x: {}
|
||||
this.NoSpaceBetweenEmptyInterfaceBraceBrackets = new Rule(RuleDescriptor.create1(SyntaxKind.OpenBraceToken, SyntaxKind.CloseBraceToken), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsObjectTypeContext), RuleAction.Delete));
|
||||
this.NoSpaceBetweenEmptyInterfaceBraceBrackets = new Rule(RuleDescriptor.create1(SyntaxKind.OpenBraceToken, SyntaxKind.CloseBraceToken), RuleOperation.create2(new RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsObjectTypeContext), RuleAction.Delete));
|
||||
|
||||
// decorators
|
||||
this.SpaceBeforeAt = new Rule(RuleDescriptor.create2(Shared.TokenRange.Any, SyntaxKind.AtToken), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Space));
|
||||
this.NoSpaceAfterAt = new Rule(RuleDescriptor.create3(SyntaxKind.AtToken, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Delete));
|
||||
this.SpaceBeforeAt = new Rule(RuleDescriptor.create2(Shared.TokenRange.Any, SyntaxKind.AtToken), RuleOperation.create2(new RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), RuleAction.Space));
|
||||
this.NoSpaceAfterAt = new Rule(RuleDescriptor.create3(SyntaxKind.AtToken, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), RuleAction.Delete));
|
||||
this.SpaceAfterDecorator = new Rule(RuleDescriptor.create4(Shared.TokenRange.Any, Shared.TokenRange.FromTokens([SyntaxKind.AbstractKeyword, SyntaxKind.Identifier, SyntaxKind.ExportKeyword, SyntaxKind.DefaultKeyword, SyntaxKind.ClassKeyword, SyntaxKind.StaticKeyword, SyntaxKind.PublicKeyword, SyntaxKind.PrivateKeyword, SyntaxKind.ProtectedKeyword, SyntaxKind.GetKeyword, SyntaxKind.SetKeyword, SyntaxKind.OpenBracketToken, SyntaxKind.AsteriskToken])), RuleOperation.create2(new RuleOperationContext(Rules.IsEndOfDecoratorContextOnSameLine), RuleAction.Space));
|
||||
|
||||
this.NoSpaceBetweenFunctionKeywordAndStar = new Rule(RuleDescriptor.create1(SyntaxKind.FunctionKeyword, SyntaxKind.AsteriskToken), RuleOperation.create2(new RuleOperationContext(Rules.IsFunctionDeclarationOrFunctionExpressionContext), RuleAction.Delete));
|
||||
this.SpaceAfterStarInGeneratorDeclaration = new Rule(RuleDescriptor.create3(SyntaxKind.AsteriskToken, Shared.TokenRange.FromTokens([SyntaxKind.Identifier, SyntaxKind.OpenParenToken])), RuleOperation.create2(new RuleOperationContext(Rules.IsFunctionDeclarationOrFunctionExpressionContext), RuleAction.Space));
|
||||
this.NoSpaceBetweenYieldKeywordAndStar = new Rule(RuleDescriptor.create1(SyntaxKind.YieldKeyword, SyntaxKind.AsteriskToken), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsYieldOrYieldStarWithOperand), RuleAction.Delete));
|
||||
this.SpaceBetweenYieldOrYieldStarAndOperand = new Rule(RuleDescriptor.create4(Shared.TokenRange.FromTokens([SyntaxKind.YieldKeyword, SyntaxKind.AsteriskToken]), Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsYieldOrYieldStarWithOperand), RuleAction.Space));
|
||||
this.NoSpaceBetweenYieldKeywordAndStar = new Rule(RuleDescriptor.create1(SyntaxKind.YieldKeyword, SyntaxKind.AsteriskToken), RuleOperation.create2(new RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsYieldOrYieldStarWithOperand), RuleAction.Delete));
|
||||
this.SpaceBetweenYieldOrYieldStarAndOperand = new Rule(RuleDescriptor.create4(Shared.TokenRange.FromTokens([SyntaxKind.YieldKeyword, SyntaxKind.AsteriskToken]), Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsYieldOrYieldStarWithOperand), RuleAction.Space));
|
||||
|
||||
// Async-await
|
||||
this.SpaceBetweenAsyncAndOpenParen = new Rule(RuleDescriptor.create1(SyntaxKind.AsyncKeyword, SyntaxKind.OpenParenToken), RuleOperation.create2(new RuleOperationContext(Rules.IsArrowFunctionContext, Rules.IsSameLineTokenContext), RuleAction.Space));
|
||||
this.SpaceBetweenAsyncAndFunctionKeyword = new Rule(RuleDescriptor.create1(SyntaxKind.AsyncKeyword, SyntaxKind.FunctionKeyword), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Space));
|
||||
this.SpaceBetweenAsyncAndOpenParen = new Rule(RuleDescriptor.create1(SyntaxKind.AsyncKeyword, SyntaxKind.OpenParenToken), RuleOperation.create2(new RuleOperationContext(Rules.IsArrowFunctionContext, Rules.IsNonJsxSameLineTokenContext), RuleAction.Space));
|
||||
this.SpaceBetweenAsyncAndFunctionKeyword = new Rule(RuleDescriptor.create1(SyntaxKind.AsyncKeyword, SyntaxKind.FunctionKeyword), RuleOperation.create2(new RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), RuleAction.Space));
|
||||
|
||||
// template string
|
||||
this.NoSpaceBetweenTagAndTemplateString = new Rule(RuleDescriptor.create3(SyntaxKind.Identifier, Shared.TokenRange.FromTokens([SyntaxKind.NoSubstitutionTemplateLiteral, SyntaxKind.TemplateHead])), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Delete));
|
||||
this.NoSpaceBetweenTagAndTemplateString = new Rule(RuleDescriptor.create3(SyntaxKind.Identifier, Shared.TokenRange.FromTokens([SyntaxKind.NoSubstitutionTemplateLiteral, SyntaxKind.TemplateHead])), RuleOperation.create2(new RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), RuleAction.Delete));
|
||||
|
||||
// These rules are higher in priority than user-configurable rules.
|
||||
this.HighPriorityCommonRules = [
|
||||
@@ -444,14 +444,14 @@ namespace ts.formatting {
|
||||
///
|
||||
|
||||
// Insert space after comma delimiter
|
||||
this.SpaceAfterComma = new Rule(RuleDescriptor.create3(SyntaxKind.CommaToken, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNextTokenNotCloseBracket), RuleAction.Space));
|
||||
this.NoSpaceAfterComma = new Rule(RuleDescriptor.create3(SyntaxKind.CommaToken, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Delete));
|
||||
this.SpaceAfterComma = new Rule(RuleDescriptor.create3(SyntaxKind.CommaToken, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNextTokenNotCloseBracket), RuleAction.Space));
|
||||
this.NoSpaceAfterComma = new Rule(RuleDescriptor.create3(SyntaxKind.CommaToken, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), RuleAction.Delete));
|
||||
|
||||
// Insert space before and after binary operators
|
||||
this.SpaceBeforeBinaryOperator = new Rule(RuleDescriptor.create4(Shared.TokenRange.Any, Shared.TokenRange.BinaryOperators), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), RuleAction.Space));
|
||||
this.SpaceAfterBinaryOperator = new Rule(RuleDescriptor.create4(Shared.TokenRange.BinaryOperators, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), RuleAction.Space));
|
||||
this.NoSpaceBeforeBinaryOperator = new Rule(RuleDescriptor.create4(Shared.TokenRange.Any, Shared.TokenRange.BinaryOperators), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), RuleAction.Delete));
|
||||
this.NoSpaceAfterBinaryOperator = new Rule(RuleDescriptor.create4(Shared.TokenRange.BinaryOperators, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), RuleAction.Delete));
|
||||
this.SpaceBeforeBinaryOperator = new Rule(RuleDescriptor.create4(Shared.TokenRange.Any, Shared.TokenRange.BinaryOperators), RuleOperation.create2(new RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), RuleAction.Space));
|
||||
this.SpaceAfterBinaryOperator = new Rule(RuleDescriptor.create4(Shared.TokenRange.BinaryOperators, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), RuleAction.Space));
|
||||
this.NoSpaceBeforeBinaryOperator = new Rule(RuleDescriptor.create4(Shared.TokenRange.Any, Shared.TokenRange.BinaryOperators), RuleOperation.create2(new RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), RuleAction.Delete));
|
||||
this.NoSpaceAfterBinaryOperator = new Rule(RuleDescriptor.create4(Shared.TokenRange.BinaryOperators, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), RuleAction.Delete));
|
||||
|
||||
// Insert space after keywords in control flow statements
|
||||
this.SpaceAfterKeywordInControl = new Rule(RuleDescriptor.create2(Shared.TokenRange.Keywords, SyntaxKind.OpenParenToken), RuleOperation.create2(new RuleOperationContext(Rules.IsControlDeclContext), RuleAction.Space));
|
||||
@@ -468,28 +468,28 @@ namespace ts.formatting {
|
||||
this.NewLineBeforeOpenBraceInControl = new Rule(RuleDescriptor.create2(this.ControlOpenBraceLeftTokenRange, SyntaxKind.OpenBraceToken), RuleOperation.create2(new RuleOperationContext(Rules.IsControlDeclContext, Rules.IsBeforeMultilineBlockContext), RuleAction.NewLine), RuleFlags.CanDeleteNewLines);
|
||||
|
||||
// Insert space after semicolon in for statement
|
||||
this.SpaceAfterSemicolonInFor = new Rule(RuleDescriptor.create3(SyntaxKind.SemicolonToken, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsForContext), RuleAction.Space));
|
||||
this.NoSpaceAfterSemicolonInFor = new Rule(RuleDescriptor.create3(SyntaxKind.SemicolonToken, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsForContext), RuleAction.Delete));
|
||||
this.SpaceAfterSemicolonInFor = new Rule(RuleDescriptor.create3(SyntaxKind.SemicolonToken, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsForContext), RuleAction.Space));
|
||||
this.NoSpaceAfterSemicolonInFor = new Rule(RuleDescriptor.create3(SyntaxKind.SemicolonToken, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsForContext), RuleAction.Delete));
|
||||
|
||||
// Insert space after opening and before closing nonempty parenthesis
|
||||
this.SpaceAfterOpenParen = new Rule(RuleDescriptor.create3(SyntaxKind.OpenParenToken, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Space));
|
||||
this.SpaceBeforeCloseParen = new Rule(RuleDescriptor.create2(Shared.TokenRange.Any, SyntaxKind.CloseParenToken), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Space));
|
||||
this.NoSpaceBetweenParens = new Rule(RuleDescriptor.create1(SyntaxKind.OpenParenToken, SyntaxKind.CloseParenToken), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Delete));
|
||||
this.NoSpaceAfterOpenParen = new Rule(RuleDescriptor.create3(SyntaxKind.OpenParenToken, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Delete));
|
||||
this.NoSpaceBeforeCloseParen = new Rule(RuleDescriptor.create2(Shared.TokenRange.Any, SyntaxKind.CloseParenToken), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Delete));
|
||||
this.SpaceAfterOpenParen = new Rule(RuleDescriptor.create3(SyntaxKind.OpenParenToken, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), RuleAction.Space));
|
||||
this.SpaceBeforeCloseParen = new Rule(RuleDescriptor.create2(Shared.TokenRange.Any, SyntaxKind.CloseParenToken), RuleOperation.create2(new RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), RuleAction.Space));
|
||||
this.NoSpaceBetweenParens = new Rule(RuleDescriptor.create1(SyntaxKind.OpenParenToken, SyntaxKind.CloseParenToken), RuleOperation.create2(new RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), RuleAction.Delete));
|
||||
this.NoSpaceAfterOpenParen = new Rule(RuleDescriptor.create3(SyntaxKind.OpenParenToken, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), RuleAction.Delete));
|
||||
this.NoSpaceBeforeCloseParen = new Rule(RuleDescriptor.create2(Shared.TokenRange.Any, SyntaxKind.CloseParenToken), RuleOperation.create2(new RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), RuleAction.Delete));
|
||||
|
||||
// Insert space after opening and before closing nonempty brackets
|
||||
this.SpaceAfterOpenBracket = new Rule(RuleDescriptor.create3(SyntaxKind.OpenBracketToken, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Space));
|
||||
this.SpaceBeforeCloseBracket = new Rule(RuleDescriptor.create2(Shared.TokenRange.Any, SyntaxKind.CloseBracketToken), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Space));
|
||||
this.NoSpaceBetweenBrackets = new Rule(RuleDescriptor.create1(SyntaxKind.OpenBracketToken, SyntaxKind.CloseBracketToken), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Delete));
|
||||
this.NoSpaceAfterOpenBracket = new Rule(RuleDescriptor.create3(SyntaxKind.OpenBracketToken, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Delete));
|
||||
this.NoSpaceBeforeCloseBracket = new Rule(RuleDescriptor.create2(Shared.TokenRange.Any, SyntaxKind.CloseBracketToken), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Delete));
|
||||
this.SpaceAfterOpenBracket = new Rule(RuleDescriptor.create3(SyntaxKind.OpenBracketToken, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), RuleAction.Space));
|
||||
this.SpaceBeforeCloseBracket = new Rule(RuleDescriptor.create2(Shared.TokenRange.Any, SyntaxKind.CloseBracketToken), RuleOperation.create2(new RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), RuleAction.Space));
|
||||
this.NoSpaceBetweenBrackets = new Rule(RuleDescriptor.create1(SyntaxKind.OpenBracketToken, SyntaxKind.CloseBracketToken), RuleOperation.create2(new RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), RuleAction.Delete));
|
||||
this.NoSpaceAfterOpenBracket = new Rule(RuleDescriptor.create3(SyntaxKind.OpenBracketToken, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), RuleAction.Delete));
|
||||
this.NoSpaceBeforeCloseBracket = new Rule(RuleDescriptor.create2(Shared.TokenRange.Any, SyntaxKind.CloseBracketToken), RuleOperation.create2(new RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), RuleAction.Delete));
|
||||
|
||||
// Insert space after opening and before closing template string braces
|
||||
this.NoSpaceAfterTemplateHeadAndMiddle = new Rule(RuleDescriptor.create4(Shared.TokenRange.FromTokens([SyntaxKind.TemplateHead, SyntaxKind.TemplateMiddle]), Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Delete));
|
||||
this.SpaceAfterTemplateHeadAndMiddle = new Rule(RuleDescriptor.create4(Shared.TokenRange.FromTokens([SyntaxKind.TemplateHead, SyntaxKind.TemplateMiddle]), Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Space));
|
||||
this.NoSpaceBeforeTemplateMiddleAndTail = new Rule(RuleDescriptor.create4(Shared.TokenRange.Any, Shared.TokenRange.FromTokens([SyntaxKind.TemplateMiddle, SyntaxKind.TemplateTail])), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Delete));
|
||||
this.SpaceBeforeTemplateMiddleAndTail = new Rule(RuleDescriptor.create4(Shared.TokenRange.Any, Shared.TokenRange.FromTokens([SyntaxKind.TemplateMiddle, SyntaxKind.TemplateTail])), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Space));
|
||||
this.NoSpaceAfterTemplateHeadAndMiddle = new Rule(RuleDescriptor.create4(Shared.TokenRange.FromTokens([SyntaxKind.TemplateHead, SyntaxKind.TemplateMiddle]), Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), RuleAction.Delete));
|
||||
this.SpaceAfterTemplateHeadAndMiddle = new Rule(RuleDescriptor.create4(Shared.TokenRange.FromTokens([SyntaxKind.TemplateHead, SyntaxKind.TemplateMiddle]), Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), RuleAction.Space));
|
||||
this.NoSpaceBeforeTemplateMiddleAndTail = new Rule(RuleDescriptor.create4(Shared.TokenRange.Any, Shared.TokenRange.FromTokens([SyntaxKind.TemplateMiddle, SyntaxKind.TemplateTail])), RuleOperation.create2(new RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), RuleAction.Delete));
|
||||
this.SpaceBeforeTemplateMiddleAndTail = new Rule(RuleDescriptor.create4(Shared.TokenRange.Any, Shared.TokenRange.FromTokens([SyntaxKind.TemplateMiddle, SyntaxKind.TemplateTail])), RuleOperation.create2(new RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), RuleAction.Space));
|
||||
|
||||
// Insert space after function keyword for anonymous functions
|
||||
this.SpaceAfterAnonymousFunctionKeyword = new Rule(RuleDescriptor.create1(SyntaxKind.FunctionKeyword, SyntaxKind.OpenParenToken), RuleOperation.create2(new RuleOperationContext(Rules.IsFunctionDeclContext), RuleAction.Space));
|
||||
@@ -561,13 +561,13 @@ namespace ts.formatting {
|
||||
//// Ex:
|
||||
//// if (1)
|
||||
//// { ... }
|
||||
//// * ) and { are on differnet lines. We only need to format if the block is multiline context. So in this case we don't format.
|
||||
//// * ) and { are on different lines. We only need to format if the block is multiline context. So in this case we don't format.
|
||||
////
|
||||
//// Ex:
|
||||
//// if (1)
|
||||
//// { ...
|
||||
//// }
|
||||
//// * ) and { are on differnet lines. We only need to format if the block is multiline context. So in this case we format.
|
||||
//// * ) and { are on different lines. We only need to format if the block is multiline context. So in this case we format.
|
||||
|
||||
return context.TokensAreOnSameLine() || Rules.IsBeforeMultilineBlockContext(context);
|
||||
}
|
||||
@@ -719,8 +719,8 @@ namespace ts.formatting {
|
||||
return context.contextNode.kind === SyntaxKind.ArrowFunction;
|
||||
}
|
||||
|
||||
static IsSameLineTokenContext(context: FormattingContext): boolean {
|
||||
return context.TokensAreOnSameLine();
|
||||
static IsNonJsxSameLineTokenContext(context: FormattingContext): boolean {
|
||||
return context.TokensAreOnSameLine() && context.contextNode.kind !== SyntaxKind.JsxText;
|
||||
}
|
||||
|
||||
static IsNotBeforeBlockInFunctionDeclarationContext(context: FormattingContext): boolean {
|
||||
|
||||
@@ -0,0 +1,227 @@
|
||||
// Copyright (c) Microsoft. All rights reserved. Licensed under the Apache License, Version 2.0.
|
||||
// See LICENSE.txt in the project root for complete license information.
|
||||
|
||||
/// <reference path='services.ts' />
|
||||
|
||||
/* @internal */
|
||||
namespace ts.JsTyping {
|
||||
|
||||
export interface TypingResolutionHost {
|
||||
directoryExists: (path: string) => boolean;
|
||||
fileExists: (fileName: string) => boolean;
|
||||
readFile: (path: string, encoding?: string) => string;
|
||||
readDirectory: (path: string, extension?: string, exclude?: string[], depth?: number) => string[];
|
||||
};
|
||||
|
||||
interface PackageJson {
|
||||
_requiredBy?: string[];
|
||||
dependencies?: Map<string>;
|
||||
devDependencies?: Map<string>;
|
||||
name?: string;
|
||||
optionalDependencies?: Map<string>;
|
||||
peerDependencies?: Map<string>;
|
||||
typings?: string;
|
||||
};
|
||||
|
||||
// A map of loose file names to library names
|
||||
// that we are confident require typings
|
||||
let safeList: Map<string>;
|
||||
|
||||
/**
|
||||
* @param host is the object providing I/O related operations.
|
||||
* @param fileNames are the file names that belong to the same project
|
||||
* @param projectRootPath is the path to the project root directory
|
||||
* @param safeListPath is the path used to retrieve the safe list
|
||||
* @param packageNameToTypingLocation is the map of package names to their cached typing locations
|
||||
* @param typingOptions are used to customize the typing inference process
|
||||
* @param compilerOptions are used as a source for typing inference
|
||||
*/
|
||||
export function discoverTypings(
|
||||
host: TypingResolutionHost,
|
||||
fileNames: string[],
|
||||
projectRootPath: Path,
|
||||
safeListPath: Path,
|
||||
packageNameToTypingLocation: Map<string>,
|
||||
typingOptions: TypingOptions,
|
||||
compilerOptions: CompilerOptions):
|
||||
{ cachedTypingPaths: string[], newTypingNames: string[], filesToWatch: string[] } {
|
||||
|
||||
// A typing name to typing file path mapping
|
||||
const inferredTypings: Map<string> = {};
|
||||
|
||||
if (!typingOptions || !typingOptions.enableAutoDiscovery) {
|
||||
return { cachedTypingPaths: [], newTypingNames: [], filesToWatch: [] };
|
||||
}
|
||||
|
||||
// Only infer typings for .js and .jsx files
|
||||
fileNames = filter(map(fileNames, normalizePath), f => scriptKindIs(f, /*LanguageServiceHost*/ undefined, ScriptKind.JS, ScriptKind.JSX));
|
||||
|
||||
if (!safeList) {
|
||||
const result = readConfigFile(safeListPath, (path: string) => host.readFile(path));
|
||||
if (result.config) {
|
||||
safeList = result.config;
|
||||
}
|
||||
else {
|
||||
safeList = {};
|
||||
};
|
||||
}
|
||||
|
||||
const filesToWatch: string[] = [];
|
||||
// Directories to search for package.json, bower.json and other typing information
|
||||
let searchDirs: string[] = [];
|
||||
let exclude: string[] = [];
|
||||
|
||||
mergeTypings(typingOptions.include);
|
||||
exclude = typingOptions.exclude || [];
|
||||
|
||||
const possibleSearchDirs = map(fileNames, getDirectoryPath);
|
||||
if (projectRootPath !== undefined) {
|
||||
possibleSearchDirs.push(projectRootPath);
|
||||
}
|
||||
searchDirs = deduplicate(possibleSearchDirs);
|
||||
for (const searchDir of searchDirs) {
|
||||
const packageJsonPath = combinePaths(searchDir, "package.json");
|
||||
getTypingNamesFromJson(packageJsonPath, filesToWatch);
|
||||
|
||||
const bowerJsonPath = combinePaths(searchDir, "bower.json");
|
||||
getTypingNamesFromJson(bowerJsonPath, filesToWatch);
|
||||
|
||||
const nodeModulesPath = combinePaths(searchDir, "node_modules");
|
||||
getTypingNamesFromNodeModuleFolder(nodeModulesPath);
|
||||
}
|
||||
getTypingNamesFromSourceFileNames(fileNames);
|
||||
|
||||
// Add the cached typing locations for inferred typings that are already installed
|
||||
for (const name in packageNameToTypingLocation) {
|
||||
if (hasProperty(inferredTypings, name) && !inferredTypings[name]) {
|
||||
inferredTypings[name] = packageNameToTypingLocation[name];
|
||||
}
|
||||
}
|
||||
|
||||
// Remove typings that the user has added to the exclude list
|
||||
for (const excludeTypingName of exclude) {
|
||||
delete inferredTypings[excludeTypingName];
|
||||
}
|
||||
|
||||
const newTypingNames: string[] = [];
|
||||
const cachedTypingPaths: string[] = [];
|
||||
for (const typing in inferredTypings) {
|
||||
if (inferredTypings[typing] !== undefined) {
|
||||
cachedTypingPaths.push(inferredTypings[typing]);
|
||||
}
|
||||
else {
|
||||
newTypingNames.push(typing);
|
||||
}
|
||||
}
|
||||
return { cachedTypingPaths, newTypingNames, filesToWatch };
|
||||
|
||||
/**
|
||||
* Merge a given list of typingNames to the inferredTypings map
|
||||
*/
|
||||
function mergeTypings(typingNames: string[]) {
|
||||
if (!typingNames) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (const typing of typingNames) {
|
||||
if (!hasProperty(inferredTypings, typing)) {
|
||||
inferredTypings[typing] = undefined;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the typing info from common package manager json files like package.json or bower.json
|
||||
*/
|
||||
function getTypingNamesFromJson(jsonPath: string, filesToWatch: string[]) {
|
||||
const result = readConfigFile(jsonPath, (path: string) => host.readFile(path));
|
||||
if (result.config) {
|
||||
const jsonConfig: PackageJson = result.config;
|
||||
filesToWatch.push(jsonPath);
|
||||
if (jsonConfig.dependencies) {
|
||||
mergeTypings(getKeys(jsonConfig.dependencies));
|
||||
}
|
||||
if (jsonConfig.devDependencies) {
|
||||
mergeTypings(getKeys(jsonConfig.devDependencies));
|
||||
}
|
||||
if (jsonConfig.optionalDependencies) {
|
||||
mergeTypings(getKeys(jsonConfig.optionalDependencies));
|
||||
}
|
||||
if (jsonConfig.peerDependencies) {
|
||||
mergeTypings(getKeys(jsonConfig.peerDependencies));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Infer typing names from given file names. For example, the file name "jquery-min.2.3.4.js"
|
||||
* should be inferred to the 'jquery' typing name; and "angular-route.1.2.3.js" should be inferred
|
||||
* to the 'angular-route' typing name.
|
||||
* @param fileNames are the names for source files in the project
|
||||
*/
|
||||
function getTypingNamesFromSourceFileNames(fileNames: string[]) {
|
||||
const jsFileNames = filter(fileNames, hasJavaScriptFileExtension);
|
||||
const inferredTypingNames = map(jsFileNames, f => removeFileExtension(getBaseFileName(f.toLowerCase())));
|
||||
const cleanedTypingNames = map(inferredTypingNames, f => f.replace(/((?:\.|-)min(?=\.|$))|((?:-|\.)\d+)/g, ""));
|
||||
if (safeList === undefined) {
|
||||
mergeTypings(cleanedTypingNames);
|
||||
}
|
||||
else {
|
||||
mergeTypings(filter(cleanedTypingNames, f => hasProperty(safeList, f)));
|
||||
}
|
||||
|
||||
const hasJsxFile = forEach(fileNames, f => scriptKindIs(f, /*LanguageServiceHost*/ undefined, ScriptKind.JSX));
|
||||
if (hasJsxFile) {
|
||||
mergeTypings(["react"]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Infer typing names from node_module folder
|
||||
* @param nodeModulesPath is the path to the "node_modules" folder
|
||||
*/
|
||||
function getTypingNamesFromNodeModuleFolder(nodeModulesPath: string) {
|
||||
// Todo: add support for ModuleResolutionHost too
|
||||
if (!host.directoryExists(nodeModulesPath)) {
|
||||
return;
|
||||
}
|
||||
|
||||
const typingNames: string[] = [];
|
||||
const fileNames = host.readDirectory(nodeModulesPath, "*.json", /*exclude*/ undefined, /*depth*/ 2);
|
||||
for (const fileName of fileNames) {
|
||||
const normalizedFileName = normalizePath(fileName);
|
||||
if (getBaseFileName(normalizedFileName) !== "package.json") {
|
||||
continue;
|
||||
}
|
||||
const result = readConfigFile(normalizedFileName, (path: string) => host.readFile(path));
|
||||
if (!result.config) {
|
||||
continue;
|
||||
}
|
||||
const packageJson: PackageJson = result.config;
|
||||
|
||||
// npm 3's package.json contains a "_requiredBy" field
|
||||
// we should include all the top level module names for npm 2, and only module names whose
|
||||
// "_requiredBy" field starts with "#" or equals "/" for npm 3.
|
||||
if (packageJson._requiredBy &&
|
||||
filter(packageJson._requiredBy, (r: string) => r[0] === "#" || r === "/").length === 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// If the package has its own d.ts typings, those will take precedence. Otherwise the package name will be used
|
||||
// to download d.ts files from DefinitelyTyped
|
||||
if (!packageJson.name) {
|
||||
continue;
|
||||
}
|
||||
if (packageJson.typings) {
|
||||
const absolutePath = getNormalizedAbsolutePath(packageJson.typings, getDirectoryPath(normalizedFileName));
|
||||
inferredTypings[packageJson.name] = absolutePath;
|
||||
}
|
||||
else {
|
||||
typingNames.push(packageJson.name);
|
||||
}
|
||||
}
|
||||
mergeTypings(typingNames);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -374,7 +374,7 @@ namespace ts.NavigationBar {
|
||||
return createEnumItem(<EnumDeclaration>node);
|
||||
|
||||
case SyntaxKind.InterfaceDeclaration:
|
||||
return createIterfaceItem(<InterfaceDeclaration>node);
|
||||
return createInterfaceItem(<InterfaceDeclaration>node);
|
||||
|
||||
case SyntaxKind.ModuleDeclaration:
|
||||
return createModuleItem(<ModuleDeclaration>node);
|
||||
@@ -493,7 +493,7 @@ namespace ts.NavigationBar {
|
||||
getIndent(node));
|
||||
}
|
||||
|
||||
function createIterfaceItem(node: InterfaceDeclaration): ts.NavigationBarItem {
|
||||
function createInterfaceItem(node: InterfaceDeclaration): ts.NavigationBarItem {
|
||||
let childItems = getItemsWorker(sortNodes(removeDynamicallyNamedProperties(node)), createChildItem);
|
||||
return getNavigationBarItem(
|
||||
node.name.text,
|
||||
|
||||
@@ -100,7 +100,7 @@ namespace ts.OutliningElementsCollector {
|
||||
const closeBrace = findChildOfKind(n, SyntaxKind.CloseBraceToken, sourceFile);
|
||||
|
||||
// Check if the block is standalone, or 'attached' to some parent statement.
|
||||
// If the latter, we want to collaps the block, but consider its hint span
|
||||
// If the latter, we want to collapse the block, but consider its hint span
|
||||
// to be the entire span of the parent.
|
||||
if (parent.kind === SyntaxKind.DoStatement ||
|
||||
parent.kind === SyntaxKind.ForInStatement ||
|
||||
|
||||
+33
-18
@@ -7,6 +7,7 @@
|
||||
/// <reference path='patternMatcher.ts' />
|
||||
/// <reference path='signatureHelp.ts' />
|
||||
/// <reference path='utilities.ts' />
|
||||
/// <reference path='jsTyping.ts' />
|
||||
/// <reference path='formatting\formatting.ts' />
|
||||
/// <reference path='formatting\smartIndenter.ts' />
|
||||
|
||||
@@ -807,6 +808,7 @@ namespace ts {
|
||||
public identifierCount: number;
|
||||
public symbolCount: number;
|
||||
public version: string;
|
||||
public scriptKind: ScriptKind;
|
||||
public languageVersion: ScriptTarget;
|
||||
public languageVariant: LanguageVariant;
|
||||
public identifiers: Map<string>;
|
||||
@@ -1020,6 +1022,7 @@ namespace ts {
|
||||
getNewLine?(): string;
|
||||
getProjectVersion?(): string;
|
||||
getScriptFileNames(): string[];
|
||||
getScriptKind?(fileName: string): ScriptKind;
|
||||
getScriptVersion(fileName: string): string;
|
||||
getScriptSnapshot(fileName: string): IScriptSnapshot;
|
||||
getLocalizedDiagnosticMessages?(): any;
|
||||
@@ -1469,7 +1472,8 @@ namespace ts {
|
||||
fileName: string,
|
||||
compilationSettings: CompilerOptions,
|
||||
scriptSnapshot: IScriptSnapshot,
|
||||
version: string): SourceFile;
|
||||
version: string,
|
||||
scriptKind?: ScriptKind): SourceFile;
|
||||
|
||||
/**
|
||||
* Request an updated version of an already existing SourceFile with a given fileName
|
||||
@@ -1487,7 +1491,8 @@ namespace ts {
|
||||
fileName: string,
|
||||
compilationSettings: CompilerOptions,
|
||||
scriptSnapshot: IScriptSnapshot,
|
||||
version: string): SourceFile;
|
||||
version: string,
|
||||
scriptKind?: ScriptKind): SourceFile;
|
||||
|
||||
/**
|
||||
* Informs the DocumentRegistry that a file is not needed any longer.
|
||||
@@ -1658,6 +1663,7 @@ namespace ts {
|
||||
hostFileName: string;
|
||||
version: string;
|
||||
scriptSnapshot: IScriptSnapshot;
|
||||
scriptKind: ScriptKind;
|
||||
}
|
||||
|
||||
interface DocumentRegistryEntry {
|
||||
@@ -1752,7 +1758,8 @@ namespace ts {
|
||||
entry = {
|
||||
hostFileName: fileName,
|
||||
version: this.host.getScriptVersion(fileName),
|
||||
scriptSnapshot: scriptSnapshot
|
||||
scriptSnapshot: scriptSnapshot,
|
||||
scriptKind: getScriptKind(fileName, this.host)
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1818,12 +1825,13 @@ namespace ts {
|
||||
throw new Error("Could not find file: '" + fileName + "'.");
|
||||
}
|
||||
|
||||
const scriptKind = getScriptKind(fileName, this.host);
|
||||
const version = this.host.getScriptVersion(fileName);
|
||||
let sourceFile: SourceFile;
|
||||
|
||||
if (this.currentFileName !== fileName) {
|
||||
// This is a new file, just parse it
|
||||
sourceFile = createLanguageServiceSourceFile(fileName, scriptSnapshot, ScriptTarget.Latest, version, /*setNodeParents*/ true);
|
||||
sourceFile = createLanguageServiceSourceFile(fileName, scriptSnapshot, ScriptTarget.Latest, version, /*setNodeParents*/ true, scriptKind);
|
||||
}
|
||||
else if (this.currentFileVersion !== version) {
|
||||
// This is the same file, just a newer version. Incrementally parse the file.
|
||||
@@ -1954,9 +1962,9 @@ namespace ts {
|
||||
return output.outputText;
|
||||
}
|
||||
|
||||
export function createLanguageServiceSourceFile(fileName: string, scriptSnapshot: IScriptSnapshot, scriptTarget: ScriptTarget, version: string, setNodeParents: boolean): SourceFile {
|
||||
export function createLanguageServiceSourceFile(fileName: string, scriptSnapshot: IScriptSnapshot, scriptTarget: ScriptTarget, version: string, setNodeParents: boolean, scriptKind?: ScriptKind): SourceFile {
|
||||
const text = scriptSnapshot.getText(0, scriptSnapshot.getLength());
|
||||
const sourceFile = createSourceFile(fileName, text, scriptTarget, setNodeParents);
|
||||
const sourceFile = createSourceFile(fileName, text, scriptTarget, setNodeParents, scriptKind);
|
||||
setSourceFileFields(sourceFile, scriptSnapshot, version);
|
||||
return sourceFile;
|
||||
}
|
||||
@@ -2018,7 +2026,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
// Otherwise, just create a new source file.
|
||||
return createLanguageServiceSourceFile(sourceFile.fileName, scriptSnapshot, sourceFile.languageVersion, version, /*setNodeParents*/ true);
|
||||
return createLanguageServiceSourceFile(sourceFile.fileName, scriptSnapshot, sourceFile.languageVersion, version, /*setNodeParents*/ true, sourceFile.scriptKind);
|
||||
}
|
||||
|
||||
export function createDocumentRegistry(useCaseSensitiveFileNames?: boolean, currentDirectory = ""): DocumentRegistry {
|
||||
@@ -2060,12 +2068,12 @@ namespace ts {
|
||||
return JSON.stringify(bucketInfoArray, undefined, 2);
|
||||
}
|
||||
|
||||
function acquireDocument(fileName: string, compilationSettings: CompilerOptions, scriptSnapshot: IScriptSnapshot, version: string): SourceFile {
|
||||
return acquireOrUpdateDocument(fileName, compilationSettings, scriptSnapshot, version, /*acquiring*/ true);
|
||||
function acquireDocument(fileName: string, compilationSettings: CompilerOptions, scriptSnapshot: IScriptSnapshot, version: string, scriptKind?: ScriptKind): SourceFile {
|
||||
return acquireOrUpdateDocument(fileName, compilationSettings, scriptSnapshot, version, /*acquiring*/ true, scriptKind);
|
||||
}
|
||||
|
||||
function updateDocument(fileName: string, compilationSettings: CompilerOptions, scriptSnapshot: IScriptSnapshot, version: string): SourceFile {
|
||||
return acquireOrUpdateDocument(fileName, compilationSettings, scriptSnapshot, version, /*acquiring*/ false);
|
||||
function updateDocument(fileName: string, compilationSettings: CompilerOptions, scriptSnapshot: IScriptSnapshot, version: string, scriptKind?: ScriptKind): SourceFile {
|
||||
return acquireOrUpdateDocument(fileName, compilationSettings, scriptSnapshot, version, /*acquiring*/ false, scriptKind);
|
||||
}
|
||||
|
||||
function acquireOrUpdateDocument(
|
||||
@@ -2073,7 +2081,8 @@ namespace ts {
|
||||
compilationSettings: CompilerOptions,
|
||||
scriptSnapshot: IScriptSnapshot,
|
||||
version: string,
|
||||
acquiring: boolean): SourceFile {
|
||||
acquiring: boolean,
|
||||
scriptKind?: ScriptKind): SourceFile {
|
||||
|
||||
const bucket = getBucketForCompilationSettings(compilationSettings, /*createIfMissing*/ true);
|
||||
const path = toPath(fileName, currentDirectory, getCanonicalFileName);
|
||||
@@ -2082,7 +2091,7 @@ namespace ts {
|
||||
Debug.assert(acquiring, "How could we be trying to update a document that the registry doesn't have?");
|
||||
|
||||
// Have never seen this file with these settings. Create a new source file for it.
|
||||
const sourceFile = createLanguageServiceSourceFile(fileName, scriptSnapshot, compilationSettings.target, version, /*setNodeParents*/ false);
|
||||
const sourceFile = createLanguageServiceSourceFile(fileName, scriptSnapshot, compilationSettings.target, version, /*setNodeParents*/ false, scriptKind);
|
||||
|
||||
entry = {
|
||||
sourceFile: sourceFile,
|
||||
@@ -2830,7 +2839,7 @@ namespace ts {
|
||||
if (oldSourceFile) {
|
||||
// We already had a source file for this file name. Go to the registry to
|
||||
// ensure that we get the right up to date version of it. We need this to
|
||||
// address the following 'race'. Specifically, say we have the following:
|
||||
// address the following race-condition. Specifically, say we have the following:
|
||||
//
|
||||
// LS1
|
||||
// \
|
||||
@@ -2849,14 +2858,20 @@ namespace ts {
|
||||
// it's source file any more, and instead defers to DocumentRegistry to get
|
||||
// either version 1, version 2 (or some other version) depending on what the
|
||||
// host says should be used.
|
||||
return documentRegistry.updateDocument(fileName, newSettings, hostFileInformation.scriptSnapshot, hostFileInformation.version);
|
||||
|
||||
// We do not support the scenario where a host can modify a registered
|
||||
// file's script kind, i.e. in one project some file is treated as ".ts"
|
||||
// and in another as ".js"
|
||||
Debug.assert(hostFileInformation.scriptKind === oldSourceFile.scriptKind, "Registered script kind (" + oldSourceFile.scriptKind + ") should match new script kind (" + hostFileInformation.scriptKind + ") for file: " + fileName);
|
||||
|
||||
return documentRegistry.updateDocument(fileName, newSettings, hostFileInformation.scriptSnapshot, hostFileInformation.version, hostFileInformation.scriptKind);
|
||||
}
|
||||
|
||||
// We didn't already have the file. Fall through and acquire it from the registry.
|
||||
}
|
||||
|
||||
// Could not find this file in the old program, create a new SourceFile for it.
|
||||
return documentRegistry.acquireDocument(fileName, newSettings, hostFileInformation.scriptSnapshot, hostFileInformation.version);
|
||||
return documentRegistry.acquireDocument(fileName, newSettings, hostFileInformation.scriptSnapshot, hostFileInformation.version, hostFileInformation.scriptKind);
|
||||
}
|
||||
|
||||
function sourceFileUpToDate(sourceFile: SourceFile): boolean {
|
||||
@@ -3120,7 +3135,7 @@ namespace ts {
|
||||
else if (isRightOfOpenTag) {
|
||||
const tagSymbols = typeChecker.getJsxIntrinsicTagNames();
|
||||
if (tryGetGlobalSymbols()) {
|
||||
symbols = tagSymbols.concat(symbols.filter(s => !!(s.flags & SymbolFlags.Value)));
|
||||
symbols = tagSymbols.concat(symbols.filter(s => !!(s.flags & (SymbolFlags.Value | SymbolFlags.Alias))));
|
||||
}
|
||||
else {
|
||||
symbols = tagSymbols;
|
||||
@@ -4654,7 +4669,7 @@ namespace ts {
|
||||
|
||||
// Go to the original declaration for cases:
|
||||
//
|
||||
// (1) when the aliased symbol was declared in the location(parent).
|
||||
// (1) when the aliased symbol was declared in the location(parent).
|
||||
// (2) when the aliased symbol is originating from a named import.
|
||||
//
|
||||
if (node.kind === SyntaxKind.Identifier &&
|
||||
|
||||
+40
-4
@@ -55,6 +55,7 @@ namespace ts {
|
||||
|
||||
/** Returns a JSON-encoded value of the type: string[] */
|
||||
getScriptFileNames(): string;
|
||||
getScriptKind?(fileName: string): ScriptKind;
|
||||
getScriptVersion(fileName: string): string;
|
||||
getScriptSnapshot(fileName: string): ScriptSnapshotShim;
|
||||
getLocalizedDiagnosticMessages(): string;
|
||||
@@ -77,7 +78,7 @@ namespace ts {
|
||||
* @param exclude A JSON encoded string[] containing the paths to exclude
|
||||
* when enumerating the directory.
|
||||
*/
|
||||
readDirectory(rootDir: string, extension: string, exclude?: string): string;
|
||||
readDirectory(rootDir: string, extension: string, exclude?: string, depth?: number): string;
|
||||
|
||||
trace(s: string): void;
|
||||
}
|
||||
@@ -231,6 +232,7 @@ namespace ts {
|
||||
getPreProcessedFileInfo(fileName: string, sourceText: IScriptSnapshot): string;
|
||||
getTSConfigFileInfo(fileName: string, sourceText: IScriptSnapshot): string;
|
||||
getDefaultCompilationSettings(): string;
|
||||
discoverTypings(discoverTypingsJson: string): string;
|
||||
}
|
||||
|
||||
function logInternalError(logger: Logger, err: Error) {
|
||||
@@ -346,6 +348,15 @@ namespace ts {
|
||||
return scriptSnapshot && new ScriptSnapshotShimAdapter(scriptSnapshot);
|
||||
}
|
||||
|
||||
public getScriptKind(fileName: string): ScriptKind {
|
||||
if ("getScriptKind" in this.shimHost) {
|
||||
return this.shimHost.getScriptKind(fileName);
|
||||
}
|
||||
else {
|
||||
return ScriptKind.Unknown;
|
||||
}
|
||||
}
|
||||
|
||||
public getScriptVersion(fileName: string): string {
|
||||
return this.shimHost.getScriptVersion(fileName);
|
||||
}
|
||||
@@ -412,8 +423,16 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
public readDirectory(rootDir: string, extension: string, exclude: string[]): string[] {
|
||||
const encoded = this.shimHost.readDirectory(rootDir, extension, JSON.stringify(exclude));
|
||||
public readDirectory(rootDir: string, extension: string, exclude: string[], depth?: number): string[] {
|
||||
// Wrap the API changes for 2.0 release. This try/catch
|
||||
// should be removed once TypeScript 2.0 has shipped.
|
||||
let encoded: string;
|
||||
try {
|
||||
encoded = this.shimHost.readDirectory(rootDir, extension, JSON.stringify(exclude), depth);
|
||||
}
|
||||
catch (e) {
|
||||
encoded = this.shimHost.readDirectory(rootDir, extension, JSON.stringify(exclude));
|
||||
}
|
||||
return JSON.parse(encoded);
|
||||
}
|
||||
|
||||
@@ -744,7 +763,7 @@ namespace ts {
|
||||
`getDocumentHighlights('${fileName}', ${position})`,
|
||||
() => {
|
||||
const results = this.languageService.getDocumentHighlights(fileName, position, JSON.parse(filesToSearch));
|
||||
// workaround for VS document higlighting issue - keep only items from the initial file
|
||||
// workaround for VS document highlighting issue - keep only items from the initial file
|
||||
const normalizedName = normalizeSlashes(fileName).toLowerCase();
|
||||
return filter(results, r => normalizeSlashes(r.fileName).toLowerCase() === normalizedName);
|
||||
});
|
||||
@@ -943,6 +962,7 @@ namespace ts {
|
||||
if (result.error) {
|
||||
return {
|
||||
options: {},
|
||||
typingOptions: {},
|
||||
files: [],
|
||||
errors: [realizeDiagnostic(result.error, "\r\n")]
|
||||
};
|
||||
@@ -953,6 +973,7 @@ namespace ts {
|
||||
|
||||
return {
|
||||
options: configFile.options,
|
||||
typingOptions: configFile.typingOptions,
|
||||
files: configFile.fileNames,
|
||||
errors: realizeDiagnostics(configFile.errors, "\r\n")
|
||||
};
|
||||
@@ -965,6 +986,21 @@ namespace ts {
|
||||
() => getDefaultCompilerOptions()
|
||||
);
|
||||
}
|
||||
|
||||
public discoverTypings(discoverTypingsJson: string): string {
|
||||
const getCanonicalFileName = createGetCanonicalFileName(/*useCaseSensitivefileNames:*/ false);
|
||||
return this.forwardJSONCall("discoverTypings()", () => {
|
||||
const info = <DiscoverTypingsInfo>JSON.parse(discoverTypingsJson);
|
||||
return ts.JsTyping.discoverTypings(
|
||||
this.host,
|
||||
info.fileNames,
|
||||
toPath(info.projectRootPath, info.projectRootPath, getCanonicalFileName),
|
||||
toPath(info.safeListPath, info.safeListPath, getCanonicalFileName),
|
||||
info.packageNameToTypingLocation,
|
||||
info.typingOptions,
|
||||
info.compilerOptions);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export class TypeScriptServicesFactory implements ShimFactory {
|
||||
|
||||
@@ -50,7 +50,7 @@ namespace ts.SignatureHelp {
|
||||
// case TypeScript.SyntaxKind.GreaterThanGreaterThanGreaterThanToken:
|
||||
// stack++;
|
||||
|
||||
// // Intentaion fall through
|
||||
// // Intentional fall through
|
||||
// case TypeScript.SyntaxKind.GreaterThanToken:
|
||||
// stack++;
|
||||
// break;
|
||||
@@ -76,7 +76,7 @@ namespace ts.SignatureHelp {
|
||||
// break;
|
||||
|
||||
// case TypeScript.SyntaxKind.EqualsGreaterThanToken:
|
||||
// // This can be a function type or a constructor type. In either case, we want to skip the function defintion
|
||||
// // This can be a function type or a constructor type. In either case, we want to skip the function definition
|
||||
// token = previousToken(token, /*includeSkippedTokens*/ true);
|
||||
|
||||
// if (token && token.kind() === TypeScript.SyntaxKind.CloseParenToken) {
|
||||
@@ -99,7 +99,7 @@ namespace ts.SignatureHelp {
|
||||
// }
|
||||
// }
|
||||
// else {
|
||||
// // This is not a funtion type. exit the main loop
|
||||
// // This is not a function type. exit the main loop
|
||||
// break whileLoop;
|
||||
// }
|
||||
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
"shims.ts",
|
||||
"signatureHelp.ts",
|
||||
"utilities.ts",
|
||||
"jsTyping.ts",
|
||||
"formatting/formatting.ts",
|
||||
"formatting/formattingContext.ts",
|
||||
"formatting/formattingRequestKind.ts",
|
||||
|
||||
@@ -147,7 +147,7 @@ namespace ts {
|
||||
|
||||
case SyntaxKind.CaseClause:
|
||||
case SyntaxKind.DefaultClause:
|
||||
// there is no such thing as terminator token for CaseClause/DefaultClause so for simplicitly always consider them non-completed
|
||||
// there is no such thing as terminator token for CaseClause/DefaultClause so for simplicity always consider them non-completed
|
||||
return false;
|
||||
|
||||
case SyntaxKind.ForStatement:
|
||||
@@ -265,7 +265,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
/* Gets the token whose text has range [start, end) and position >= start
|
||||
* and (position < end or (position === end && token is keyword or identifier or numeric\string litera))
|
||||
* and (position < end or (position === end && token is keyword or identifier or numeric/string literal))
|
||||
*/
|
||||
export function getTouchingPropertyName(sourceFile: SourceFile, position: number): Node {
|
||||
return getTouchingToken(sourceFile, position, n => isPropertyName(n.kind));
|
||||
@@ -837,4 +837,19 @@ namespace ts {
|
||||
};
|
||||
return name;
|
||||
}
|
||||
|
||||
export function scriptKindIs(fileName: string, host: LanguageServiceHost, ...scriptKinds: ScriptKind[]): boolean {
|
||||
const scriptKind = getScriptKind(fileName, host);
|
||||
return forEach(scriptKinds, k => k === scriptKind);
|
||||
}
|
||||
|
||||
export function getScriptKind(fileName: string, host?: LanguageServiceHost): ScriptKind {
|
||||
// First check to see if the script kind can be determined from the file name
|
||||
var scriptKind = getScriptKindFromFileName(fileName);
|
||||
if (scriptKind === ScriptKind.Unknown && host && host.getScriptKind) {
|
||||
// Next check to see if the host can resolve the script kind
|
||||
scriptKind = host.getScriptKind(fileName);
|
||||
}
|
||||
return ensureScriptKind(fileName, scriptKind);
|
||||
}
|
||||
}
|
||||
@@ -16,7 +16,7 @@ export function compile(fileNames: string[], options: ts.CompilerOptions): void
|
||||
var program = ts.createProgram(fileNames, options);
|
||||
var emitResult = program.emit();
|
||||
|
||||
var allDiagnostics = ts.getPreEmitDiagnostics(program).concat(emitResult.diagnostics);
|
||||
var allDiagnostics = ts.getPreEmitDiagnostics(program);
|
||||
|
||||
allDiagnostics.forEach(diagnostic => {
|
||||
var { line, character } = diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start);
|
||||
@@ -45,7 +45,7 @@ var ts = require("typescript");
|
||||
function compile(fileNames, options) {
|
||||
var program = ts.createProgram(fileNames, options);
|
||||
var emitResult = program.emit();
|
||||
var allDiagnostics = ts.getPreEmitDiagnostics(program).concat(emitResult.diagnostics);
|
||||
var allDiagnostics = ts.getPreEmitDiagnostics(program);
|
||||
allDiagnostics.forEach(function (diagnostic) {
|
||||
var _a = diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start), line = _a.line, character = _a.character;
|
||||
var message = ts.flattenDiagnosticMessageText(diagnostic.messageText, '\n');
|
||||
|
||||
+2
-2
@@ -1,4 +1,4 @@
|
||||
tests/cases/conformance/internalModules/DeclarationMerging/ClassAndModuleThatMergeWithModulesExportedStaticFunctionUsingClassPrivateStatics.ts(11,16): error TS2341: Property 'sfn' is private and only accessible within class 'clodule<T>'.
|
||||
tests/cases/conformance/internalModules/DeclarationMerging/ClassAndModuleThatMergeWithModulesExportedStaticFunctionUsingClassPrivateStatics.ts(11,24): error TS2341: Property 'sfn' is private and only accessible within class 'clodule<T>'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/internalModules/DeclarationMerging/ClassAndModuleThatMergeWithModulesExportedStaticFunctionUsingClassPrivateStatics.ts (1 errors) ====
|
||||
@@ -13,7 +13,7 @@ tests/cases/conformance/internalModules/DeclarationMerging/ClassAndModuleThatMer
|
||||
// error: duplicate identifier expected
|
||||
export function fn<T>(x: T, y: T): number {
|
||||
return clodule.sfn('a');
|
||||
~~~~~~~~~~~
|
||||
~~~
|
||||
!!! error TS2341: Property 'sfn' is private and only accessible within class 'clodule<T>'.
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
tests/cases/conformance/parser/ecmascript5/Protected/Protected3.ts(2,3): error TS1089: 'protected' modifier cannot appear on a constructor declaration.
|
||||
|
||||
|
||||
==== tests/cases/conformance/parser/ecmascript5/Protected/Protected3.ts (1 errors) ====
|
||||
class C {
|
||||
protected constructor() { }
|
||||
~~~~~~~~~
|
||||
!!! error TS1089: 'protected' modifier cannot appear on a constructor declaration.
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
=== tests/cases/conformance/parser/ecmascript5/Protected/Protected3.ts ===
|
||||
class C {
|
||||
>C : Symbol(C, Decl(Protected3.ts, 0, 0))
|
||||
|
||||
protected constructor() { }
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
=== tests/cases/conformance/parser/ecmascript5/Protected/Protected3.ts ===
|
||||
class C {
|
||||
>C : C
|
||||
|
||||
protected constructor() { }
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
//// [VariableDeclaration12_es6.ts]
|
||||
|
||||
let
|
||||
x
|
||||
|
||||
//// [VariableDeclaration12_es6.js]
|
||||
let x;
|
||||
@@ -0,0 +1,6 @@
|
||||
=== tests/cases/conformance/es6/variableDeclarations/VariableDeclaration12_es6.ts ===
|
||||
|
||||
let
|
||||
x
|
||||
>x : Symbol(x, Decl(VariableDeclaration12_es6.ts, 1, 3))
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
=== tests/cases/conformance/es6/variableDeclarations/VariableDeclaration12_es6.ts ===
|
||||
|
||||
let
|
||||
x
|
||||
>x : any
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
tests/cases/conformance/es6/variableDeclarations/VariableDeclaration13_es6.ts(5,5): error TS1181: Array element destructuring pattern expected.
|
||||
tests/cases/conformance/es6/variableDeclarations/VariableDeclaration13_es6.ts(5,6): error TS1005: ',' expected.
|
||||
tests/cases/conformance/es6/variableDeclarations/VariableDeclaration13_es6.ts(5,8): error TS1134: Variable declaration expected.
|
||||
tests/cases/conformance/es6/variableDeclarations/VariableDeclaration13_es6.ts(5,10): error TS1134: Variable declaration expected.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/variableDeclarations/VariableDeclaration13_es6.ts (4 errors) ====
|
||||
|
||||
// An ExpressionStatement cannot start with the two token sequence `let [` because
|
||||
// that would make it ambiguous with a `let` LexicalDeclaration whose first LexicalBinding was an ArrayBindingPattern.
|
||||
var let: any;
|
||||
let[0] = 100;
|
||||
~
|
||||
!!! error TS1181: Array element destructuring pattern expected.
|
||||
~
|
||||
!!! error TS1005: ',' expected.
|
||||
~
|
||||
!!! error TS1134: Variable declaration expected.
|
||||
~~~
|
||||
!!! error TS1134: Variable declaration expected.
|
||||
@@ -0,0 +1,13 @@
|
||||
//// [VariableDeclaration13_es6.ts]
|
||||
|
||||
// An ExpressionStatement cannot start with the two token sequence `let [` because
|
||||
// that would make it ambiguous with a `let` LexicalDeclaration whose first LexicalBinding was an ArrayBindingPattern.
|
||||
var let: any;
|
||||
let[0] = 100;
|
||||
|
||||
//// [VariableDeclaration13_es6.js]
|
||||
// An ExpressionStatement cannot start with the two token sequence `let [` because
|
||||
// that would make it ambiguous with a `let` LexicalDeclaration whose first LexicalBinding was an ArrayBindingPattern.
|
||||
var let;
|
||||
let [] = 0;
|
||||
100;
|
||||
@@ -0,0 +1,56 @@
|
||||
//// [abstractProperty.ts]
|
||||
interface A {
|
||||
prop: string;
|
||||
raw: string;
|
||||
m(): void;
|
||||
}
|
||||
abstract class B implements A {
|
||||
abstract prop: string;
|
||||
abstract raw: string;
|
||||
abstract readonly ro: string;
|
||||
abstract get readonlyProp(): string;
|
||||
abstract set readonlyProp(val: string);
|
||||
abstract m(): void;
|
||||
}
|
||||
class C extends B {
|
||||
get prop() { return "foo"; }
|
||||
set prop(v) { }
|
||||
raw = "edge";
|
||||
readonly ro = "readonly please";
|
||||
readonlyProp: string; // don't have to give a value, in fact
|
||||
m() { }
|
||||
}
|
||||
|
||||
//// [abstractProperty.js]
|
||||
var __extends = (this && this.__extends) || function (d, b) {
|
||||
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
|
||||
function __() { this.constructor = d; }
|
||||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
||||
};
|
||||
var B = (function () {
|
||||
function B() {
|
||||
}
|
||||
Object.defineProperty(B.prototype, "readonlyProp", {
|
||||
get: function () { },
|
||||
set: function (val) { },
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
return B;
|
||||
}());
|
||||
var C = (function (_super) {
|
||||
__extends(C, _super);
|
||||
function C() {
|
||||
_super.apply(this, arguments);
|
||||
this.raw = "edge";
|
||||
this.ro = "readonly please";
|
||||
}
|
||||
Object.defineProperty(C.prototype, "prop", {
|
||||
get: function () { return "foo"; },
|
||||
set: function (v) { },
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
C.prototype.m = function () { };
|
||||
return C;
|
||||
}(B));
|
||||
@@ -0,0 +1,59 @@
|
||||
=== tests/cases/compiler/abstractProperty.ts ===
|
||||
interface A {
|
||||
>A : Symbol(A, Decl(abstractProperty.ts, 0, 0))
|
||||
|
||||
prop: string;
|
||||
>prop : Symbol(prop, Decl(abstractProperty.ts, 0, 13))
|
||||
|
||||
raw: string;
|
||||
>raw : Symbol(raw, Decl(abstractProperty.ts, 1, 17))
|
||||
|
||||
m(): void;
|
||||
>m : Symbol(m, Decl(abstractProperty.ts, 2, 16))
|
||||
}
|
||||
abstract class B implements A {
|
||||
>B : Symbol(B, Decl(abstractProperty.ts, 4, 1))
|
||||
>A : Symbol(A, Decl(abstractProperty.ts, 0, 0))
|
||||
|
||||
abstract prop: string;
|
||||
>prop : Symbol(prop, Decl(abstractProperty.ts, 5, 31))
|
||||
|
||||
abstract raw: string;
|
||||
>raw : Symbol(raw, Decl(abstractProperty.ts, 6, 26))
|
||||
|
||||
abstract readonly ro: string;
|
||||
>ro : Symbol(ro, Decl(abstractProperty.ts, 7, 25))
|
||||
|
||||
abstract get readonlyProp(): string;
|
||||
>readonlyProp : Symbol(readonlyProp, Decl(abstractProperty.ts, 8, 33), Decl(abstractProperty.ts, 9, 40))
|
||||
|
||||
abstract set readonlyProp(val: string);
|
||||
>readonlyProp : Symbol(readonlyProp, Decl(abstractProperty.ts, 8, 33), Decl(abstractProperty.ts, 9, 40))
|
||||
>val : Symbol(val, Decl(abstractProperty.ts, 10, 30))
|
||||
|
||||
abstract m(): void;
|
||||
>m : Symbol(m, Decl(abstractProperty.ts, 10, 43))
|
||||
}
|
||||
class C extends B {
|
||||
>C : Symbol(C, Decl(abstractProperty.ts, 12, 1))
|
||||
>B : Symbol(B, Decl(abstractProperty.ts, 4, 1))
|
||||
|
||||
get prop() { return "foo"; }
|
||||
>prop : Symbol(prop, Decl(abstractProperty.ts, 13, 19), Decl(abstractProperty.ts, 14, 32))
|
||||
|
||||
set prop(v) { }
|
||||
>prop : Symbol(prop, Decl(abstractProperty.ts, 13, 19), Decl(abstractProperty.ts, 14, 32))
|
||||
>v : Symbol(v, Decl(abstractProperty.ts, 15, 13))
|
||||
|
||||
raw = "edge";
|
||||
>raw : Symbol(raw, Decl(abstractProperty.ts, 15, 19))
|
||||
|
||||
readonly ro = "readonly please";
|
||||
>ro : Symbol(ro, Decl(abstractProperty.ts, 16, 17))
|
||||
|
||||
readonlyProp: string; // don't have to give a value, in fact
|
||||
>readonlyProp : Symbol(readonlyProp, Decl(abstractProperty.ts, 17, 36))
|
||||
|
||||
m() { }
|
||||
>m : Symbol(m, Decl(abstractProperty.ts, 18, 25))
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
=== tests/cases/compiler/abstractProperty.ts ===
|
||||
interface A {
|
||||
>A : A
|
||||
|
||||
prop: string;
|
||||
>prop : string
|
||||
|
||||
raw: string;
|
||||
>raw : string
|
||||
|
||||
m(): void;
|
||||
>m : () => void
|
||||
}
|
||||
abstract class B implements A {
|
||||
>B : B
|
||||
>A : A
|
||||
|
||||
abstract prop: string;
|
||||
>prop : string
|
||||
|
||||
abstract raw: string;
|
||||
>raw : string
|
||||
|
||||
abstract readonly ro: string;
|
||||
>ro : string
|
||||
|
||||
abstract get readonlyProp(): string;
|
||||
>readonlyProp : string
|
||||
|
||||
abstract set readonlyProp(val: string);
|
||||
>readonlyProp : string
|
||||
>val : string
|
||||
|
||||
abstract m(): void;
|
||||
>m : () => void
|
||||
}
|
||||
class C extends B {
|
||||
>C : C
|
||||
>B : B
|
||||
|
||||
get prop() { return "foo"; }
|
||||
>prop : string
|
||||
>"foo" : string
|
||||
|
||||
set prop(v) { }
|
||||
>prop : string
|
||||
>v : string
|
||||
|
||||
raw = "edge";
|
||||
>raw : string
|
||||
>"edge" : string
|
||||
|
||||
readonly ro = "readonly please";
|
||||
>ro : string
|
||||
>"readonly please" : string
|
||||
|
||||
readonlyProp: string; // don't have to give a value, in fact
|
||||
>readonlyProp : string
|
||||
|
||||
m() { }
|
||||
>m : () => void
|
||||
}
|
||||
@@ -0,0 +1,106 @@
|
||||
tests/cases/compiler/abstractPropertyNegative.ts(10,18): error TS2380: 'get' and 'set' accessor must have the same type.
|
||||
tests/cases/compiler/abstractPropertyNegative.ts(11,18): error TS2380: 'get' and 'set' accessor must have the same type.
|
||||
tests/cases/compiler/abstractPropertyNegative.ts(13,7): error TS2515: Non-abstract class 'C' does not implement inherited abstract member 'm' from class 'B'.
|
||||
tests/cases/compiler/abstractPropertyNegative.ts(13,7): error TS2515: Non-abstract class 'C' does not implement inherited abstract member 'mismatch' from class 'B'.
|
||||
tests/cases/compiler/abstractPropertyNegative.ts(13,7): error TS2515: Non-abstract class 'C' does not implement inherited abstract member 'prop' from class 'B'.
|
||||
tests/cases/compiler/abstractPropertyNegative.ts(13,7): error TS2515: Non-abstract class 'C' does not implement inherited abstract member 'readonlyProp' from class 'B'.
|
||||
tests/cases/compiler/abstractPropertyNegative.ts(15,5): error TS1244: Abstract methods can only appear within an abstract class.
|
||||
tests/cases/compiler/abstractPropertyNegative.ts(16,37): error TS1005: '{' expected.
|
||||
tests/cases/compiler/abstractPropertyNegative.ts(19,1): error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
|
||||
tests/cases/compiler/abstractPropertyNegative.ts(24,7): error TS2415: Class 'WrongTypePropertyImpl' incorrectly extends base class 'WrongTypeProperty'.
|
||||
Types of property 'num' are incompatible.
|
||||
Type 'string' is not assignable to type 'number'.
|
||||
tests/cases/compiler/abstractPropertyNegative.ts(30,7): error TS2415: Class 'WrongTypeAccessorImpl' incorrectly extends base class 'WrongTypeAccessor'.
|
||||
Types of property 'num' are incompatible.
|
||||
Type 'string' is not assignable to type 'number'.
|
||||
tests/cases/compiler/abstractPropertyNegative.ts(33,7): error TS2415: Class 'WrongTypeAccessorImpl2' incorrectly extends base class 'WrongTypeAccessor'.
|
||||
Types of property 'num' are incompatible.
|
||||
Type 'string' is not assignable to type 'number'.
|
||||
tests/cases/compiler/abstractPropertyNegative.ts(38,18): error TS2676: Accessors must both be abstract or non-abstract.
|
||||
tests/cases/compiler/abstractPropertyNegative.ts(39,9): error TS2676: Accessors must both be abstract or non-abstract.
|
||||
tests/cases/compiler/abstractPropertyNegative.ts(40,9): error TS2676: Accessors must both be abstract or non-abstract.
|
||||
tests/cases/compiler/abstractPropertyNegative.ts(41,18): error TS2676: Accessors must both be abstract or non-abstract.
|
||||
|
||||
|
||||
==== tests/cases/compiler/abstractPropertyNegative.ts (16 errors) ====
|
||||
interface A {
|
||||
prop: string;
|
||||
m(): string;
|
||||
}
|
||||
abstract class B implements A {
|
||||
abstract prop: string;
|
||||
public abstract readonly ro: string;
|
||||
abstract get readonlyProp(): string;
|
||||
abstract m(): string;
|
||||
abstract get mismatch(): string;
|
||||
~~~~~~~~
|
||||
!!! error TS2380: 'get' and 'set' accessor must have the same type.
|
||||
abstract set mismatch(val: number); // error, not same type
|
||||
~~~~~~~~
|
||||
!!! error TS2380: 'get' and 'set' accessor must have the same type.
|
||||
}
|
||||
class C extends B {
|
||||
~
|
||||
!!! error TS2515: Non-abstract class 'C' does not implement inherited abstract member 'm' from class 'B'.
|
||||
~
|
||||
!!! error TS2515: Non-abstract class 'C' does not implement inherited abstract member 'mismatch' from class 'B'.
|
||||
~
|
||||
!!! error TS2515: Non-abstract class 'C' does not implement inherited abstract member 'prop' from class 'B'.
|
||||
~
|
||||
!!! error TS2515: Non-abstract class 'C' does not implement inherited abstract member 'readonlyProp' from class 'B'.
|
||||
readonly ro = "readonly please";
|
||||
abstract notAllowed: string;
|
||||
~~~~~~~~
|
||||
!!! error TS1244: Abstract methods can only appear within an abstract class.
|
||||
get concreteWithNoBody(): string;
|
||||
~
|
||||
!!! error TS1005: '{' expected.
|
||||
}
|
||||
let c = new C();
|
||||
c.ro = "error: lhs of assignment can't be readonly";
|
||||
~~~~
|
||||
!!! error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
|
||||
|
||||
abstract class WrongTypeProperty {
|
||||
abstract num: number;
|
||||
}
|
||||
class WrongTypePropertyImpl extends WrongTypeProperty {
|
||||
~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2415: Class 'WrongTypePropertyImpl' incorrectly extends base class 'WrongTypeProperty'.
|
||||
!!! error TS2415: Types of property 'num' are incompatible.
|
||||
!!! error TS2415: Type 'string' is not assignable to type 'number'.
|
||||
num = "nope, wrong";
|
||||
}
|
||||
abstract class WrongTypeAccessor {
|
||||
abstract get num(): number;
|
||||
}
|
||||
class WrongTypeAccessorImpl extends WrongTypeAccessor {
|
||||
~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2415: Class 'WrongTypeAccessorImpl' incorrectly extends base class 'WrongTypeAccessor'.
|
||||
!!! error TS2415: Types of property 'num' are incompatible.
|
||||
!!! error TS2415: Type 'string' is not assignable to type 'number'.
|
||||
get num() { return "nope, wrong"; }
|
||||
}
|
||||
class WrongTypeAccessorImpl2 extends WrongTypeAccessor {
|
||||
~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2415: Class 'WrongTypeAccessorImpl2' incorrectly extends base class 'WrongTypeAccessor'.
|
||||
!!! error TS2415: Types of property 'num' are incompatible.
|
||||
!!! error TS2415: Type 'string' is not assignable to type 'number'.
|
||||
num = "nope, wrong";
|
||||
}
|
||||
|
||||
abstract class AbstractAccessorMismatch {
|
||||
abstract get p1(): string;
|
||||
~~
|
||||
!!! error TS2676: Accessors must both be abstract or non-abstract.
|
||||
set p1(val: string) { };
|
||||
~~
|
||||
!!! error TS2676: Accessors must both be abstract or non-abstract.
|
||||
get p2(): string { return "should work"; }
|
||||
~~
|
||||
!!! error TS2676: Accessors must both be abstract or non-abstract.
|
||||
abstract set p2(val: string);
|
||||
~~
|
||||
!!! error TS2676: Accessors must both be abstract or non-abstract.
|
||||
}
|
||||
|
||||
@@ -0,0 +1,144 @@
|
||||
//// [abstractPropertyNegative.ts]
|
||||
interface A {
|
||||
prop: string;
|
||||
m(): string;
|
||||
}
|
||||
abstract class B implements A {
|
||||
abstract prop: string;
|
||||
public abstract readonly ro: string;
|
||||
abstract get readonlyProp(): string;
|
||||
abstract m(): string;
|
||||
abstract get mismatch(): string;
|
||||
abstract set mismatch(val: number); // error, not same type
|
||||
}
|
||||
class C extends B {
|
||||
readonly ro = "readonly please";
|
||||
abstract notAllowed: string;
|
||||
get concreteWithNoBody(): string;
|
||||
}
|
||||
let c = new C();
|
||||
c.ro = "error: lhs of assignment can't be readonly";
|
||||
|
||||
abstract class WrongTypeProperty {
|
||||
abstract num: number;
|
||||
}
|
||||
class WrongTypePropertyImpl extends WrongTypeProperty {
|
||||
num = "nope, wrong";
|
||||
}
|
||||
abstract class WrongTypeAccessor {
|
||||
abstract get num(): number;
|
||||
}
|
||||
class WrongTypeAccessorImpl extends WrongTypeAccessor {
|
||||
get num() { return "nope, wrong"; }
|
||||
}
|
||||
class WrongTypeAccessorImpl2 extends WrongTypeAccessor {
|
||||
num = "nope, wrong";
|
||||
}
|
||||
|
||||
abstract class AbstractAccessorMismatch {
|
||||
abstract get p1(): string;
|
||||
set p1(val: string) { };
|
||||
get p2(): string { return "should work"; }
|
||||
abstract set p2(val: string);
|
||||
}
|
||||
|
||||
|
||||
//// [abstractPropertyNegative.js]
|
||||
var __extends = (this && this.__extends) || function (d, b) {
|
||||
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
|
||||
function __() { this.constructor = d; }
|
||||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
||||
};
|
||||
var B = (function () {
|
||||
function B() {
|
||||
}
|
||||
Object.defineProperty(B.prototype, "readonlyProp", {
|
||||
get: function () { },
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
Object.defineProperty(B.prototype, "mismatch", {
|
||||
get: function () { },
|
||||
set: function (val) { } // error, not same type
|
||||
,
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
return B;
|
||||
}());
|
||||
var C = (function (_super) {
|
||||
__extends(C, _super);
|
||||
function C() {
|
||||
_super.apply(this, arguments);
|
||||
this.ro = "readonly please";
|
||||
}
|
||||
Object.defineProperty(C.prototype, "concreteWithNoBody", {
|
||||
get: function () { },
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
return C;
|
||||
}(B));
|
||||
var c = new C();
|
||||
c.ro = "error: lhs of assignment can't be readonly";
|
||||
var WrongTypeProperty = (function () {
|
||||
function WrongTypeProperty() {
|
||||
}
|
||||
return WrongTypeProperty;
|
||||
}());
|
||||
var WrongTypePropertyImpl = (function (_super) {
|
||||
__extends(WrongTypePropertyImpl, _super);
|
||||
function WrongTypePropertyImpl() {
|
||||
_super.apply(this, arguments);
|
||||
this.num = "nope, wrong";
|
||||
}
|
||||
return WrongTypePropertyImpl;
|
||||
}(WrongTypeProperty));
|
||||
var WrongTypeAccessor = (function () {
|
||||
function WrongTypeAccessor() {
|
||||
}
|
||||
Object.defineProperty(WrongTypeAccessor.prototype, "num", {
|
||||
get: function () { },
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
return WrongTypeAccessor;
|
||||
}());
|
||||
var WrongTypeAccessorImpl = (function (_super) {
|
||||
__extends(WrongTypeAccessorImpl, _super);
|
||||
function WrongTypeAccessorImpl() {
|
||||
_super.apply(this, arguments);
|
||||
}
|
||||
Object.defineProperty(WrongTypeAccessorImpl.prototype, "num", {
|
||||
get: function () { return "nope, wrong"; },
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
return WrongTypeAccessorImpl;
|
||||
}(WrongTypeAccessor));
|
||||
var WrongTypeAccessorImpl2 = (function (_super) {
|
||||
__extends(WrongTypeAccessorImpl2, _super);
|
||||
function WrongTypeAccessorImpl2() {
|
||||
_super.apply(this, arguments);
|
||||
this.num = "nope, wrong";
|
||||
}
|
||||
return WrongTypeAccessorImpl2;
|
||||
}(WrongTypeAccessor));
|
||||
var AbstractAccessorMismatch = (function () {
|
||||
function AbstractAccessorMismatch() {
|
||||
}
|
||||
Object.defineProperty(AbstractAccessorMismatch.prototype, "p1", {
|
||||
get: function () { },
|
||||
set: function (val) { },
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
;
|
||||
Object.defineProperty(AbstractAccessorMismatch.prototype, "p2", {
|
||||
get: function () { return "should work"; },
|
||||
set: function (val) { },
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
return AbstractAccessorMismatch;
|
||||
}());
|
||||
@@ -25,7 +25,7 @@ var results: string[];
|
||||
|
||||
|
||||
function f([, a, , b, , , , s, , , ] = results) {
|
||||
>f : ([, a, , b, , , , s, , , ]?: string[]) => void
|
||||
>f : ([, a, , b, , , , s, , ,]?: string[]) => void
|
||||
> : undefined
|
||||
>a : string
|
||||
> : undefined
|
||||
|
||||
@@ -16,8 +16,8 @@ tests/cases/conformance/expressions/arrayLiterals/arrayLiterals3.ts(34,5): error
|
||||
Types of property 'push' are incompatible.
|
||||
Type '(...items: (number | string)[]) => number' is not assignable to type '(...items: Number[]) => number'.
|
||||
Types of parameters 'items' and 'items' are incompatible.
|
||||
Type 'number | string' is not assignable to type 'Number'.
|
||||
Type 'string' is not assignable to type 'Number'.
|
||||
Type 'Number' is not assignable to type 'number | string'.
|
||||
Type 'Number' is not assignable to type 'string'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/expressions/arrayLiterals/arrayLiterals3.ts (6 errors) ====
|
||||
@@ -79,6 +79,6 @@ tests/cases/conformance/expressions/arrayLiterals/arrayLiterals3.ts(34,5): error
|
||||
!!! error TS2322: Types of property 'push' are incompatible.
|
||||
!!! error TS2322: Type '(...items: (number | string)[]) => number' is not assignable to type '(...items: Number[]) => number'.
|
||||
!!! error TS2322: Types of parameters 'items' and 'items' are incompatible.
|
||||
!!! error TS2322: Type 'number | string' is not assignable to type 'Number'.
|
||||
!!! error TS2322: Type 'string' is not assignable to type 'Number'.
|
||||
!!! error TS2322: Type 'Number' is not assignable to type 'number | string'.
|
||||
!!! error TS2322: Type 'Number' is not assignable to type 'string'.
|
||||
|
||||
@@ -77,31 +77,31 @@ var p4 = ([, ...a]) => { };
|
||||
>a : any[]
|
||||
|
||||
var p5 = ([a = 1]) => { };
|
||||
>p5 : ([a = 1]: [number]) => void
|
||||
>([a = 1]) => { } : ([a = 1]: [number]) => void
|
||||
>p5 : ([a]: [number]) => void
|
||||
>([a = 1]) => { } : ([a]: [number]) => void
|
||||
>a : number
|
||||
>1 : number
|
||||
|
||||
var p6 = ({ a }) => { };
|
||||
>p6 : ({ a }: { a: any; }) => void
|
||||
>({ a }) => { } : ({ a }: { a: any; }) => void
|
||||
>p6 : ({a}: { a: any; }) => void
|
||||
>({ a }) => { } : ({a}: { a: any; }) => void
|
||||
>a : any
|
||||
|
||||
var p7 = ({ a: { b } }) => { };
|
||||
>p7 : ({ a: { b } }: { a: { b: any; }; }) => void
|
||||
>({ a: { b } }) => { } : ({ a: { b } }: { a: { b: any; }; }) => void
|
||||
>p7 : ({a: {b}}: { a: { b: any; }; }) => void
|
||||
>({ a: { b } }) => { } : ({a: {b}}: { a: { b: any; }; }) => void
|
||||
>a : any
|
||||
>b : any
|
||||
|
||||
var p8 = ({ a = 1 }) => { };
|
||||
>p8 : ({ a = 1 }: { a?: number; }) => void
|
||||
>({ a = 1 }) => { } : ({ a = 1 }: { a?: number; }) => void
|
||||
>p8 : ({a}: { a?: number; }) => void
|
||||
>({ a = 1 }) => { } : ({a}: { a?: number; }) => void
|
||||
>a : number
|
||||
>1 : number
|
||||
|
||||
var p9 = ({ a: { b = 1 } = { b: 1 } }) => { };
|
||||
>p9 : ({ a: { b = 1 } = { b: 1 } }: { a?: { b?: number; }; }) => void
|
||||
>({ a: { b = 1 } = { b: 1 } }) => { } : ({ a: { b = 1 } = { b: 1 } }: { a?: { b?: number; }; }) => void
|
||||
>p9 : ({a: {b}}: { a?: { b?: number; }; }) => void
|
||||
>({ a: { b = 1 } = { b: 1 } }) => { } : ({a: {b}}: { a?: { b?: number; }; }) => void
|
||||
>a : any
|
||||
>b : number
|
||||
>1 : number
|
||||
@@ -110,8 +110,8 @@ var p9 = ({ a: { b = 1 } = { b: 1 } }) => { };
|
||||
>1 : number
|
||||
|
||||
var p10 = ([{ value, done }]) => { };
|
||||
>p10 : ([{ value, done }]: [{ value: any; done: any; }]) => void
|
||||
>([{ value, done }]) => { } : ([{ value, done }]: [{ value: any; done: any; }]) => void
|
||||
>p10 : ([{value, done}]: [{ value: any; done: any; }]) => void
|
||||
>([{ value, done }]) => { } : ([{value, done}]: [{ value: any; done: any; }]) => void
|
||||
>value : any
|
||||
>done : any
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ tests/cases/compiler/assignmentCompatBug5.ts(5,6): error TS2345: Argument of typ
|
||||
Type 'string' is not assignable to type 'number'.
|
||||
tests/cases/compiler/assignmentCompatBug5.ts(8,6): error TS2345: Argument of type '(s: string) => void' is not assignable to parameter of type '(n: number) => number'.
|
||||
Types of parameters 's' and 'n' are incompatible.
|
||||
Type 'string' is not assignable to type 'number'.
|
||||
Type 'number' is not assignable to type 'string'.
|
||||
tests/cases/compiler/assignmentCompatBug5.ts(9,6): error TS2345: Argument of type '(n: number) => void' is not assignable to parameter of type '(n: number) => number'.
|
||||
Type 'void' is not assignable to type 'number'.
|
||||
|
||||
@@ -27,7 +27,7 @@ tests/cases/compiler/assignmentCompatBug5.ts(9,6): error TS2345: Argument of typ
|
||||
~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2345: Argument of type '(s: string) => void' is not assignable to parameter of type '(n: number) => number'.
|
||||
!!! error TS2345: Types of parameters 's' and 'n' are incompatible.
|
||||
!!! error TS2345: Type 'string' is not assignable to type 'number'.
|
||||
!!! error TS2345: Type 'number' is not assignable to type 'string'.
|
||||
foo3((n) => { return; });
|
||||
~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2345: Argument of type '(n: number) => void' is not assignable to parameter of type '(n: number) => number'.
|
||||
|
||||
@@ -1,27 +1,27 @@
|
||||
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures.ts(35,1): error TS2322: Type 'S2' is not assignable to type 'T'.
|
||||
Types of parameters 'x' and 'x' are incompatible.
|
||||
Type 'string' is not assignable to type 'number'.
|
||||
Type 'number' is not assignable to type 'string'.
|
||||
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures.ts(36,1): error TS2322: Type '(x: string) => void' is not assignable to type 'T'.
|
||||
Types of parameters 'x' and 'x' are incompatible.
|
||||
Type 'string' is not assignable to type 'number'.
|
||||
Type 'number' is not assignable to type 'string'.
|
||||
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures.ts(37,1): error TS2322: Type '(x: string) => number' is not assignable to type 'T'.
|
||||
Types of parameters 'x' and 'x' are incompatible.
|
||||
Type 'string' is not assignable to type 'number'.
|
||||
Type 'number' is not assignable to type 'string'.
|
||||
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures.ts(38,1): error TS2322: Type '(x: string) => string' is not assignable to type 'T'.
|
||||
Types of parameters 'x' and 'x' are incompatible.
|
||||
Type 'string' is not assignable to type 'number'.
|
||||
Type 'number' is not assignable to type 'string'.
|
||||
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures.ts(39,1): error TS2322: Type 'S2' is not assignable to type '(x: number) => void'.
|
||||
Types of parameters 'x' and 'x' are incompatible.
|
||||
Type 'string' is not assignable to type 'number'.
|
||||
Type 'number' is not assignable to type 'string'.
|
||||
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures.ts(40,1): error TS2322: Type '(x: string) => void' is not assignable to type '(x: number) => void'.
|
||||
Types of parameters 'x' and 'x' are incompatible.
|
||||
Type 'string' is not assignable to type 'number'.
|
||||
Type 'number' is not assignable to type 'string'.
|
||||
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures.ts(41,1): error TS2322: Type '(x: string) => number' is not assignable to type '(x: number) => void'.
|
||||
Types of parameters 'x' and 'x' are incompatible.
|
||||
Type 'string' is not assignable to type 'number'.
|
||||
Type 'number' is not assignable to type 'string'.
|
||||
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures.ts(42,1): error TS2322: Type '(x: string) => string' is not assignable to type '(x: number) => void'.
|
||||
Types of parameters 'x' and 'x' are incompatible.
|
||||
Type 'string' is not assignable to type 'number'.
|
||||
Type 'number' is not assignable to type 'string'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures.ts (8 errors) ====
|
||||
@@ -63,40 +63,40 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme
|
||||
~
|
||||
!!! error TS2322: Type 'S2' is not assignable to type 'T'.
|
||||
!!! error TS2322: Types of parameters 'x' and 'x' are incompatible.
|
||||
!!! error TS2322: Type 'string' is not assignable to type 'number'.
|
||||
!!! error TS2322: Type 'number' is not assignable to type 'string'.
|
||||
t = a3;
|
||||
~
|
||||
!!! error TS2322: Type '(x: string) => void' is not assignable to type 'T'.
|
||||
!!! error TS2322: Types of parameters 'x' and 'x' are incompatible.
|
||||
!!! error TS2322: Type 'string' is not assignable to type 'number'.
|
||||
!!! error TS2322: Type 'number' is not assignable to type 'string'.
|
||||
t = (x: string) => 1;
|
||||
~
|
||||
!!! error TS2322: Type '(x: string) => number' is not assignable to type 'T'.
|
||||
!!! error TS2322: Types of parameters 'x' and 'x' are incompatible.
|
||||
!!! error TS2322: Type 'string' is not assignable to type 'number'.
|
||||
!!! error TS2322: Type 'number' is not assignable to type 'string'.
|
||||
t = function (x: string) { return ''; }
|
||||
~
|
||||
!!! error TS2322: Type '(x: string) => string' is not assignable to type 'T'.
|
||||
!!! error TS2322: Types of parameters 'x' and 'x' are incompatible.
|
||||
!!! error TS2322: Type 'string' is not assignable to type 'number'.
|
||||
!!! error TS2322: Type 'number' is not assignable to type 'string'.
|
||||
a = s2;
|
||||
~
|
||||
!!! error TS2322: Type 'S2' is not assignable to type '(x: number) => void'.
|
||||
!!! error TS2322: Types of parameters 'x' and 'x' are incompatible.
|
||||
!!! error TS2322: Type 'string' is not assignable to type 'number'.
|
||||
!!! error TS2322: Type 'number' is not assignable to type 'string'.
|
||||
a = a3;
|
||||
~
|
||||
!!! error TS2322: Type '(x: string) => void' is not assignable to type '(x: number) => void'.
|
||||
!!! error TS2322: Types of parameters 'x' and 'x' are incompatible.
|
||||
!!! error TS2322: Type 'string' is not assignable to type 'number'.
|
||||
!!! error TS2322: Type 'number' is not assignable to type 'string'.
|
||||
a = (x: string) => 1;
|
||||
~
|
||||
!!! error TS2322: Type '(x: string) => number' is not assignable to type '(x: number) => void'.
|
||||
!!! error TS2322: Types of parameters 'x' and 'x' are incompatible.
|
||||
!!! error TS2322: Type 'string' is not assignable to type 'number'.
|
||||
!!! error TS2322: Type 'number' is not assignable to type 'string'.
|
||||
a = function (x: string) { return ''; }
|
||||
~
|
||||
!!! error TS2322: Type '(x: string) => string' is not assignable to type '(x: number) => void'.
|
||||
!!! error TS2322: Types of parameters 'x' and 'x' are incompatible.
|
||||
!!! error TS2322: Type 'string' is not assignable to type 'number'.
|
||||
!!! error TS2322: Type 'number' is not assignable to type 'string'.
|
||||
|
||||
@@ -10,12 +10,12 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme
|
||||
Types of property 'f' are incompatible.
|
||||
Type '(x: string) => void' is not assignable to type '(x: number) => void'.
|
||||
Types of parameters 'x' and 'x' are incompatible.
|
||||
Type 'string' is not assignable to type 'number'.
|
||||
Type 'number' is not assignable to type 'string'.
|
||||
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures2.ts(43,1): error TS2322: Type '{ f(x: string): void; }' is not assignable to type 'T'.
|
||||
Types of property 'f' are incompatible.
|
||||
Type '(x: string) => void' is not assignable to type '(x: number) => void'.
|
||||
Types of parameters 'x' and 'x' are incompatible.
|
||||
Type 'string' is not assignable to type 'number'.
|
||||
Type 'number' is not assignable to type 'string'.
|
||||
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures2.ts(44,1): error TS2322: Type '(x: string) => number' is not assignable to type 'T'.
|
||||
Property 'f' is missing in type '(x: string) => number'.
|
||||
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures2.ts(45,1): error TS2322: Type '(x: string) => string' is not assignable to type 'T'.
|
||||
@@ -24,12 +24,12 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme
|
||||
Types of property 'f' are incompatible.
|
||||
Type '(x: string) => void' is not assignable to type '(x: number) => void'.
|
||||
Types of parameters 'x' and 'x' are incompatible.
|
||||
Type 'string' is not assignable to type 'number'.
|
||||
Type 'number' is not assignable to type 'string'.
|
||||
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures2.ts(47,1): error TS2322: Type '{ f(x: string): void; }' is not assignable to type '{ f(x: number): void; }'.
|
||||
Types of property 'f' are incompatible.
|
||||
Type '(x: string) => void' is not assignable to type '(x: number) => void'.
|
||||
Types of parameters 'x' and 'x' are incompatible.
|
||||
Type 'string' is not assignable to type 'number'.
|
||||
Type 'number' is not assignable to type 'string'.
|
||||
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures2.ts(48,1): error TS2322: Type '(x: string) => number' is not assignable to type '{ f(x: number): void; }'.
|
||||
Property 'f' is missing in type '(x: string) => number'.
|
||||
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures2.ts(49,1): error TS2322: Type '(x: string) => string' is not assignable to type '{ f(x: number): void; }'.
|
||||
@@ -96,14 +96,14 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme
|
||||
!!! error TS2322: Types of property 'f' are incompatible.
|
||||
!!! error TS2322: Type '(x: string) => void' is not assignable to type '(x: number) => void'.
|
||||
!!! error TS2322: Types of parameters 'x' and 'x' are incompatible.
|
||||
!!! error TS2322: Type 'string' is not assignable to type 'number'.
|
||||
!!! error TS2322: Type 'number' is not assignable to type 'string'.
|
||||
t = a3;
|
||||
~
|
||||
!!! error TS2322: Type '{ f(x: string): void; }' is not assignable to type 'T'.
|
||||
!!! error TS2322: Types of property 'f' are incompatible.
|
||||
!!! error TS2322: Type '(x: string) => void' is not assignable to type '(x: number) => void'.
|
||||
!!! error TS2322: Types of parameters 'x' and 'x' are incompatible.
|
||||
!!! error TS2322: Type 'string' is not assignable to type 'number'.
|
||||
!!! error TS2322: Type 'number' is not assignable to type 'string'.
|
||||
t = (x: string) => 1;
|
||||
~
|
||||
!!! error TS2322: Type '(x: string) => number' is not assignable to type 'T'.
|
||||
@@ -118,14 +118,14 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme
|
||||
!!! error TS2322: Types of property 'f' are incompatible.
|
||||
!!! error TS2322: Type '(x: string) => void' is not assignable to type '(x: number) => void'.
|
||||
!!! error TS2322: Types of parameters 'x' and 'x' are incompatible.
|
||||
!!! error TS2322: Type 'string' is not assignable to type 'number'.
|
||||
!!! error TS2322: Type 'number' is not assignable to type 'string'.
|
||||
a = a3;
|
||||
~
|
||||
!!! error TS2322: Type '{ f(x: string): void; }' is not assignable to type '{ f(x: number): void; }'.
|
||||
!!! error TS2322: Types of property 'f' are incompatible.
|
||||
!!! error TS2322: Type '(x: string) => void' is not assignable to type '(x: number) => void'.
|
||||
!!! error TS2322: Types of parameters 'x' and 'x' are incompatible.
|
||||
!!! error TS2322: Type 'string' is not assignable to type 'number'.
|
||||
!!! error TS2322: Type 'number' is not assignable to type 'string'.
|
||||
a = (x: string) => 1;
|
||||
~
|
||||
!!! error TS2322: Type '(x: string) => number' is not assignable to type '{ f(x: number): void; }'.
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures4.ts(52,9): error TS2322: Type '<T extends Base, U extends Derived>(x: (arg: T) => U, y: (arg2: { foo: number; }) => U) => (r: T) => U' is not assignable to type '(x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived'.
|
||||
Types of parameters 'y' and 'y' are incompatible.
|
||||
Type '(arg2: { foo: number; }) => any' is not assignable to type '(arg2: Base) => Derived'.
|
||||
Type '(arg2: Base) => Derived' is not assignable to type '(arg2: { foo: number; }) => any'.
|
||||
Types of parameters 'arg2' and 'arg2' are incompatible.
|
||||
Type '{ foo: number; }' is not assignable to type 'Base'.
|
||||
Types of property 'foo' are incompatible.
|
||||
Type 'number' is not assignable to type 'string'.
|
||||
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures4.ts(53,9): error TS2322: Type '(x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived' is not assignable to type '<T extends Base, U extends Derived>(x: (arg: T) => U, y: (arg2: { foo: number; }) => U) => (r: T) => U'.
|
||||
Types of parameters 'y' and 'y' are incompatible.
|
||||
Type '(arg2: Base) => Derived' is not assignable to type '(arg2: { foo: number; }) => any'.
|
||||
Type '(arg2: { foo: number; }) => any' is not assignable to type '(arg2: Base) => Derived'.
|
||||
Types of parameters 'arg2' and 'arg2' are incompatible.
|
||||
Type 'Base' is not assignable to type '{ foo: number; }'.
|
||||
Types of property 'foo' are incompatible.
|
||||
@@ -70,7 +70,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme
|
||||
~~
|
||||
!!! error TS2322: Type '<T extends Base, U extends Derived>(x: (arg: T) => U, y: (arg2: { foo: number; }) => U) => (r: T) => U' is not assignable to type '(x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived'.
|
||||
!!! error TS2322: Types of parameters 'y' and 'y' are incompatible.
|
||||
!!! error TS2322: Type '(arg2: { foo: number; }) => any' is not assignable to type '(arg2: Base) => Derived'.
|
||||
!!! error TS2322: Type '(arg2: Base) => Derived' is not assignable to type '(arg2: { foo: number; }) => any'.
|
||||
!!! error TS2322: Types of parameters 'arg2' and 'arg2' are incompatible.
|
||||
!!! error TS2322: Type '{ foo: number; }' is not assignable to type 'Base'.
|
||||
!!! error TS2322: Types of property 'foo' are incompatible.
|
||||
@@ -79,7 +79,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme
|
||||
~~
|
||||
!!! error TS2322: Type '(x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived' is not assignable to type '<T extends Base, U extends Derived>(x: (arg: T) => U, y: (arg2: { foo: number; }) => U) => (r: T) => U'.
|
||||
!!! error TS2322: Types of parameters 'y' and 'y' are incompatible.
|
||||
!!! error TS2322: Type '(arg2: Base) => Derived' is not assignable to type '(arg2: { foo: number; }) => any'.
|
||||
!!! error TS2322: Type '(arg2: { foo: number; }) => any' is not assignable to type '(arg2: Base) => Derived'.
|
||||
!!! error TS2322: Types of parameters 'arg2' and 'arg2' are incompatible.
|
||||
!!! error TS2322: Type 'Base' is not assignable to type '{ foo: number; }'.
|
||||
!!! error TS2322: Types of property 'foo' are incompatible.
|
||||
|
||||
+18
-18
@@ -1,30 +1,30 @@
|
||||
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignaturesWithRestParameters.ts(13,5): error TS2322: Type '(...args: string[]) => number' is not assignable to type '(...args: number[]) => number'.
|
||||
Types of parameters 'args' and 'args' are incompatible.
|
||||
Type 'string' is not assignable to type 'number'.
|
||||
Type 'number' is not assignable to type 'string'.
|
||||
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignaturesWithRestParameters.ts(17,5): error TS2322: Type '(x?: string) => number' is not assignable to type '(...args: number[]) => number'.
|
||||
Types of parameters 'x' and 'args' are incompatible.
|
||||
Type 'string' is not assignable to type 'number'.
|
||||
Type 'number' is not assignable to type 'string'.
|
||||
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignaturesWithRestParameters.ts(26,5): error TS2322: Type '(x: number, ...args: string[]) => number' is not assignable to type '(x: number, ...z: number[]) => number'.
|
||||
Types of parameters 'args' and 'z' are incompatible.
|
||||
Type 'string' is not assignable to type 'number'.
|
||||
Type 'number' is not assignable to type 'string'.
|
||||
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignaturesWithRestParameters.ts(35,5): error TS2322: Type '(x: number, y?: number, z?: number) => number' is not assignable to type '(x: number, y?: string, ...z: number[]) => number'.
|
||||
Types of parameters 'y' and 'y' are incompatible.
|
||||
Type 'number' is not assignable to type 'string'.
|
||||
Type 'string' is not assignable to type 'number'.
|
||||
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignaturesWithRestParameters.ts(36,5): error TS2322: Type '(x: number, ...z: number[]) => number' is not assignable to type '(x: number, y?: string, ...z: number[]) => number'.
|
||||
Types of parameters 'z' and 'y' are incompatible.
|
||||
Type 'number' is not assignable to type 'string'.
|
||||
Type 'string' is not assignable to type 'number'.
|
||||
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignaturesWithRestParameters.ts(37,5): error TS2322: Type '(x: string, y?: string, z?: string) => number' is not assignable to type '(x: number, y?: string, ...z: number[]) => number'.
|
||||
Types of parameters 'x' and 'x' are incompatible.
|
||||
Type 'string' is not assignable to type 'number'.
|
||||
Type 'number' is not assignable to type 'string'.
|
||||
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignaturesWithRestParameters.ts(41,5): error TS2322: Type '(x?: number, y?: number) => number' is not assignable to type '(x?: number, y?: string, ...z: number[]) => number'.
|
||||
Types of parameters 'y' and 'y' are incompatible.
|
||||
Type 'number' is not assignable to type 'string'.
|
||||
Type 'string' is not assignable to type 'number'.
|
||||
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignaturesWithRestParameters.ts(43,5): error TS2322: Type '(x: number, y?: number) => number' is not assignable to type '(x?: number, y?: string, ...z: number[]) => number'.
|
||||
Types of parameters 'y' and 'y' are incompatible.
|
||||
Type 'number' is not assignable to type 'string'.
|
||||
Type 'string' is not assignable to type 'number'.
|
||||
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignaturesWithRestParameters.ts(45,5): error TS2322: Type '(x: number, ...args: string[]) => number' is not assignable to type '(x?: number, y?: string, ...z: number[]) => number'.
|
||||
Types of parameters 'args' and 'z' are incompatible.
|
||||
Type 'string' is not assignable to type 'number'.
|
||||
Type 'number' is not assignable to type 'string'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignaturesWithRestParameters.ts (9 errors) ====
|
||||
@@ -44,7 +44,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme
|
||||
~
|
||||
!!! error TS2322: Type '(...args: string[]) => number' is not assignable to type '(...args: number[]) => number'.
|
||||
!!! error TS2322: Types of parameters 'args' and 'args' are incompatible.
|
||||
!!! error TS2322: Type 'string' is not assignable to type 'number'.
|
||||
!!! error TS2322: Type 'number' is not assignable to type 'string'.
|
||||
a = (x?: number) => 1; // ok, same number of required params
|
||||
a = (x?: number, y?: number, z?: number) => 1; // ok, same number of required params
|
||||
a = (x: number) => 1; // ok, rest param corresponds to infinite number of params
|
||||
@@ -52,7 +52,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme
|
||||
~
|
||||
!!! error TS2322: Type '(x?: string) => number' is not assignable to type '(...args: number[]) => number'.
|
||||
!!! error TS2322: Types of parameters 'x' and 'args' are incompatible.
|
||||
!!! error TS2322: Type 'string' is not assignable to type 'number'.
|
||||
!!! error TS2322: Type 'number' is not assignable to type 'string'.
|
||||
|
||||
|
||||
var a2: (x: number, ...z: number[]) => number;
|
||||
@@ -65,7 +65,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme
|
||||
~~
|
||||
!!! error TS2322: Type '(x: number, ...args: string[]) => number' is not assignable to type '(x: number, ...z: number[]) => number'.
|
||||
!!! error TS2322: Types of parameters 'args' and 'z' are incompatible.
|
||||
!!! error TS2322: Type 'string' is not assignable to type 'number'.
|
||||
!!! error TS2322: Type 'number' is not assignable to type 'string'.
|
||||
a2 = (x: number, y: number) => 1; // ok, rest param corresponds to infinite number of params
|
||||
a2 = (x: number, y?: number) => 1; // ok, same number of required params
|
||||
|
||||
@@ -78,17 +78,17 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme
|
||||
~~
|
||||
!!! error TS2322: Type '(x: number, y?: number, z?: number) => number' is not assignable to type '(x: number, y?: string, ...z: number[]) => number'.
|
||||
!!! error TS2322: Types of parameters 'y' and 'y' are incompatible.
|
||||
!!! error TS2322: Type 'number' is not assignable to type 'string'.
|
||||
!!! error TS2322: Type 'string' is not assignable to type 'number'.
|
||||
a3 = (x: number, ...z: number[]) => 1; // error
|
||||
~~
|
||||
!!! error TS2322: Type '(x: number, ...z: number[]) => number' is not assignable to type '(x: number, y?: string, ...z: number[]) => number'.
|
||||
!!! error TS2322: Types of parameters 'z' and 'y' are incompatible.
|
||||
!!! error TS2322: Type 'number' is not assignable to type 'string'.
|
||||
!!! error TS2322: Type 'string' is not assignable to type 'number'.
|
||||
a3 = (x: string, y?: string, z?: string) => 1; // error
|
||||
~~
|
||||
!!! error TS2322: Type '(x: string, y?: string, z?: string) => number' is not assignable to type '(x: number, y?: string, ...z: number[]) => number'.
|
||||
!!! error TS2322: Types of parameters 'x' and 'x' are incompatible.
|
||||
!!! error TS2322: Type 'string' is not assignable to type 'number'.
|
||||
!!! error TS2322: Type 'number' is not assignable to type 'string'.
|
||||
|
||||
var a4: (x?: number, y?: string, ...z: number[]) => number;
|
||||
a4 = () => 1; // ok, fewer required params
|
||||
@@ -96,16 +96,16 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme
|
||||
~~
|
||||
!!! error TS2322: Type '(x?: number, y?: number) => number' is not assignable to type '(x?: number, y?: string, ...z: number[]) => number'.
|
||||
!!! error TS2322: Types of parameters 'y' and 'y' are incompatible.
|
||||
!!! error TS2322: Type 'number' is not assignable to type 'string'.
|
||||
!!! error TS2322: Type 'string' is not assignable to type 'number'.
|
||||
a4 = (x: number) => 1; // ok, all present params match
|
||||
a4 = (x: number, y?: number) => 1; // error, second param has type mismatch
|
||||
~~
|
||||
!!! error TS2322: Type '(x: number, y?: number) => number' is not assignable to type '(x?: number, y?: string, ...z: number[]) => number'.
|
||||
!!! error TS2322: Types of parameters 'y' and 'y' are incompatible.
|
||||
!!! error TS2322: Type 'number' is not assignable to type 'string'.
|
||||
!!! error TS2322: Type 'string' is not assignable to type 'number'.
|
||||
a4 = (x?: number, y?: string) => 1; // ok, same number of required params with matching types
|
||||
a4 = (x: number, ...args: string[]) => 1; // error, rest params have type mismatch
|
||||
~~
|
||||
!!! error TS2322: Type '(x: number, ...args: string[]) => number' is not assignable to type '(x?: number, y?: string, ...z: number[]) => number'.
|
||||
!!! error TS2322: Types of parameters 'args' and 'z' are incompatible.
|
||||
!!! error TS2322: Type 'string' is not assignable to type 'number'.
|
||||
!!! error TS2322: Type 'number' is not assignable to type 'string'.
|
||||
@@ -1,33 +1,33 @@
|
||||
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures4.ts(52,9): error TS2322: Type 'new <T extends Base, U extends Derived>(x: (arg: T) => U, y: (arg2: { foo: number; }) => U) => (r: T) => U' is not assignable to type 'new (x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived'.
|
||||
Types of parameters 'y' and 'y' are incompatible.
|
||||
Type '(arg2: { foo: number; }) => any' is not assignable to type '(arg2: Base) => Derived'.
|
||||
Type '(arg2: Base) => Derived' is not assignable to type '(arg2: { foo: number; }) => any'.
|
||||
Types of parameters 'arg2' and 'arg2' are incompatible.
|
||||
Type '{ foo: number; }' is not assignable to type 'Base'.
|
||||
Types of property 'foo' are incompatible.
|
||||
Type 'number' is not assignable to type 'string'.
|
||||
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures4.ts(53,9): error TS2322: Type 'new (x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived' is not assignable to type 'new <T extends Base, U extends Derived>(x: (arg: T) => U, y: (arg2: { foo: number; }) => U) => (r: T) => U'.
|
||||
Types of parameters 'y' and 'y' are incompatible.
|
||||
Type '(arg2: Base) => Derived' is not assignable to type '(arg2: { foo: number; }) => any'.
|
||||
Type '(arg2: { foo: number; }) => any' is not assignable to type '(arg2: Base) => Derived'.
|
||||
Types of parameters 'arg2' and 'arg2' are incompatible.
|
||||
Type 'Base' is not assignable to type '{ foo: number; }'.
|
||||
Types of property 'foo' are incompatible.
|
||||
Type 'string' is not assignable to type 'number'.
|
||||
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures4.ts(77,9): error TS2322: Type 'new <T>(x: (a: T) => T) => T[]' is not assignable to type '{ new (x: { new (a: number): number; new (a?: number): number; }): number[]; new (x: { new (a: boolean): boolean; new (a?: boolean): boolean; }): boolean[]; }'.
|
||||
Types of parameters 'x' and 'x' are incompatible.
|
||||
Type '(a: any) => any' is not assignable to type '{ new (a: number): number; new (a?: number): number; }'.
|
||||
Type '(a: any) => any' provides no match for the signature 'new (a: number): number'
|
||||
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures4.ts(78,9): error TS2322: Type '{ new (x: { new (a: number): number; new (a?: number): number; }): number[]; new (x: { new (a: boolean): boolean; new (a?: boolean): boolean; }): boolean[]; }' is not assignable to type 'new <T>(x: (a: T) => T) => T[]'.
|
||||
Types of parameters 'x' and 'x' are incompatible.
|
||||
Type '{ new (a: number): number; new (a?: number): number; }' is not assignable to type '(a: any) => any'.
|
||||
Type '{ new (a: number): number; new (a?: number): number; }' provides no match for the signature '(a: any): any'
|
||||
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures4.ts(81,9): error TS2322: Type 'new <T>(x: (a: T) => T) => any[]' is not assignable to type '{ new (x: { new <T extends Derived>(a: T): T; new <T extends Base>(a: T): T; }): any[]; new (x: { new <T extends Derived2>(a: T): T; new <T extends Base>(a: T): T; }): any[]; }'.
|
||||
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures4.ts(78,9): error TS2322: Type '{ new (x: { new (a: number): number; new (a?: number): number; }): number[]; new (x: { new (a: boolean): boolean; new (a?: boolean): boolean; }): boolean[]; }' is not assignable to type 'new <T>(x: (a: T) => T) => T[]'.
|
||||
Types of parameters 'x' and 'x' are incompatible.
|
||||
Type '(a: any) => any' is not assignable to type '{ new <T extends Derived>(a: T): T; new <T extends Base>(a: T): T; }'.
|
||||
Type '(a: any) => any' provides no match for the signature 'new <T extends Derived>(a: T): T'
|
||||
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures4.ts(82,9): error TS2322: Type '{ new (x: { new <T extends Derived>(a: T): T; new <T extends Base>(a: T): T; }): any[]; new (x: { new <T extends Derived2>(a: T): T; new <T extends Base>(a: T): T; }): any[]; }' is not assignable to type 'new <T>(x: (a: T) => T) => any[]'.
|
||||
Type '(a: any) => any' is not assignable to type '{ new (a: number): number; new (a?: number): number; }'.
|
||||
Type '(a: any) => any' provides no match for the signature 'new (a: number): number'
|
||||
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures4.ts(81,9): error TS2322: Type 'new <T>(x: (a: T) => T) => any[]' is not assignable to type '{ new (x: { new <T extends Derived>(a: T): T; new <T extends Base>(a: T): T; }): any[]; new (x: { new <T extends Derived2>(a: T): T; new <T extends Base>(a: T): T; }): any[]; }'.
|
||||
Types of parameters 'x' and 'x' are incompatible.
|
||||
Type '{ new <T extends Derived>(a: T): T; new <T extends Base>(a: T): T; }' is not assignable to type '(a: any) => any'.
|
||||
Type '{ new <T extends Derived>(a: T): T; new <T extends Base>(a: T): T; }' provides no match for the signature '(a: any): any'
|
||||
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures4.ts(82,9): error TS2322: Type '{ new (x: { new <T extends Derived>(a: T): T; new <T extends Base>(a: T): T; }): any[]; new (x: { new <T extends Derived2>(a: T): T; new <T extends Base>(a: T): T; }): any[]; }' is not assignable to type 'new <T>(x: (a: T) => T) => any[]'.
|
||||
Types of parameters 'x' and 'x' are incompatible.
|
||||
Type '(a: any) => any' is not assignable to type '{ new <T extends Derived>(a: T): T; new <T extends Base>(a: T): T; }'.
|
||||
Type '(a: any) => any' provides no match for the signature 'new <T extends Derived>(a: T): T'
|
||||
|
||||
|
||||
==== tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures4.ts (6 errors) ====
|
||||
@@ -86,7 +86,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme
|
||||
~~
|
||||
!!! error TS2322: Type 'new <T extends Base, U extends Derived>(x: (arg: T) => U, y: (arg2: { foo: number; }) => U) => (r: T) => U' is not assignable to type 'new (x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived'.
|
||||
!!! error TS2322: Types of parameters 'y' and 'y' are incompatible.
|
||||
!!! error TS2322: Type '(arg2: { foo: number; }) => any' is not assignable to type '(arg2: Base) => Derived'.
|
||||
!!! error TS2322: Type '(arg2: Base) => Derived' is not assignable to type '(arg2: { foo: number; }) => any'.
|
||||
!!! error TS2322: Types of parameters 'arg2' and 'arg2' are incompatible.
|
||||
!!! error TS2322: Type '{ foo: number; }' is not assignable to type 'Base'.
|
||||
!!! error TS2322: Types of property 'foo' are incompatible.
|
||||
@@ -95,7 +95,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme
|
||||
~~
|
||||
!!! error TS2322: Type 'new (x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived' is not assignable to type 'new <T extends Base, U extends Derived>(x: (arg: T) => U, y: (arg2: { foo: number; }) => U) => (r: T) => U'.
|
||||
!!! error TS2322: Types of parameters 'y' and 'y' are incompatible.
|
||||
!!! error TS2322: Type '(arg2: Base) => Derived' is not assignable to type '(arg2: { foo: number; }) => any'.
|
||||
!!! error TS2322: Type '(arg2: { foo: number; }) => any' is not assignable to type '(arg2: Base) => Derived'.
|
||||
!!! error TS2322: Types of parameters 'arg2' and 'arg2' are incompatible.
|
||||
!!! error TS2322: Type 'Base' is not assignable to type '{ foo: number; }'.
|
||||
!!! error TS2322: Types of property 'foo' are incompatible.
|
||||
@@ -127,28 +127,28 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme
|
||||
~~~
|
||||
!!! error TS2322: Type 'new <T>(x: (a: T) => T) => T[]' is not assignable to type '{ new (x: { new (a: number): number; new (a?: number): number; }): number[]; new (x: { new (a: boolean): boolean; new (a?: boolean): boolean; }): boolean[]; }'.
|
||||
!!! error TS2322: Types of parameters 'x' and 'x' are incompatible.
|
||||
!!! error TS2322: Type '(a: any) => any' is not assignable to type '{ new (a: number): number; new (a?: number): number; }'.
|
||||
!!! error TS2322: Type '(a: any) => any' provides no match for the signature 'new (a: number): number'
|
||||
!!! error TS2322: Type '{ new (a: number): number; new (a?: number): number; }' is not assignable to type '(a: any) => any'.
|
||||
!!! error TS2322: Type '{ new (a: number): number; new (a?: number): number; }' provides no match for the signature '(a: any): any'
|
||||
b16 = a16; // error
|
||||
~~~
|
||||
!!! error TS2322: Type '{ new (x: { new (a: number): number; new (a?: number): number; }): number[]; new (x: { new (a: boolean): boolean; new (a?: boolean): boolean; }): boolean[]; }' is not assignable to type 'new <T>(x: (a: T) => T) => T[]'.
|
||||
!!! error TS2322: Types of parameters 'x' and 'x' are incompatible.
|
||||
!!! error TS2322: Type '{ new (a: number): number; new (a?: number): number; }' is not assignable to type '(a: any) => any'.
|
||||
!!! error TS2322: Type '{ new (a: number): number; new (a?: number): number; }' provides no match for the signature '(a: any): any'
|
||||
!!! error TS2322: Type '(a: any) => any' is not assignable to type '{ new (a: number): number; new (a?: number): number; }'.
|
||||
!!! error TS2322: Type '(a: any) => any' provides no match for the signature 'new (a: number): number'
|
||||
|
||||
var b17: new <T>(x: (a: T) => T) => any[];
|
||||
a17 = b17; // error
|
||||
~~~
|
||||
!!! error TS2322: Type 'new <T>(x: (a: T) => T) => any[]' is not assignable to type '{ new (x: { new <T extends Derived>(a: T): T; new <T extends Base>(a: T): T; }): any[]; new (x: { new <T extends Derived2>(a: T): T; new <T extends Base>(a: T): T; }): any[]; }'.
|
||||
!!! error TS2322: Types of parameters 'x' and 'x' are incompatible.
|
||||
!!! error TS2322: Type '(a: any) => any' is not assignable to type '{ new <T extends Derived>(a: T): T; new <T extends Base>(a: T): T; }'.
|
||||
!!! error TS2322: Type '(a: any) => any' provides no match for the signature 'new <T extends Derived>(a: T): T'
|
||||
!!! error TS2322: Type '{ new <T extends Derived>(a: T): T; new <T extends Base>(a: T): T; }' is not assignable to type '(a: any) => any'.
|
||||
!!! error TS2322: Type '{ new <T extends Derived>(a: T): T; new <T extends Base>(a: T): T; }' provides no match for the signature '(a: any): any'
|
||||
b17 = a17; // error
|
||||
~~~
|
||||
!!! error TS2322: Type '{ new (x: { new <T extends Derived>(a: T): T; new <T extends Base>(a: T): T; }): any[]; new (x: { new <T extends Derived2>(a: T): T; new <T extends Base>(a: T): T; }): any[]; }' is not assignable to type 'new <T>(x: (a: T) => T) => any[]'.
|
||||
!!! error TS2322: Types of parameters 'x' and 'x' are incompatible.
|
||||
!!! error TS2322: Type '{ new <T extends Derived>(a: T): T; new <T extends Base>(a: T): T; }' is not assignable to type '(a: any) => any'.
|
||||
!!! error TS2322: Type '{ new <T extends Derived>(a: T): T; new <T extends Base>(a: T): T; }' provides no match for the signature '(a: any): any'
|
||||
!!! error TS2322: Type '(a: any) => any' is not assignable to type '{ new <T extends Derived>(a: T): T; new <T extends Base>(a: T): T; }'.
|
||||
!!! error TS2322: Type '(a: any) => any' provides no match for the signature 'new <T extends Derived>(a: T): T'
|
||||
}
|
||||
|
||||
module WithGenericSignaturesInBaseType {
|
||||
|
||||
@@ -2,12 +2,12 @@ tests/cases/compiler/assignmentCompatWithOverloads.ts(17,1): error TS2322: Type
|
||||
Type 'string' is not assignable to type 'number'.
|
||||
tests/cases/compiler/assignmentCompatWithOverloads.ts(19,1): error TS2322: Type '(x: number) => number' is not assignable to type '(s1: string) => number'.
|
||||
Types of parameters 'x' and 's1' are incompatible.
|
||||
Type 'number' is not assignable to type 'string'.
|
||||
Type 'string' is not assignable to type 'number'.
|
||||
tests/cases/compiler/assignmentCompatWithOverloads.ts(21,1): error TS2322: Type '{ (x: string): string; (x: number): number; }' is not assignable to type '(s1: string) => number'.
|
||||
Type 'string' is not assignable to type 'number'.
|
||||
tests/cases/compiler/assignmentCompatWithOverloads.ts(30,1): error TS2322: Type 'typeof C' is not assignable to type 'new (x: number) => void'.
|
||||
Types of parameters 'x' and 'x' are incompatible.
|
||||
Type 'string' is not assignable to type 'number'.
|
||||
Type 'number' is not assignable to type 'string'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/assignmentCompatWithOverloads.ts (4 errors) ====
|
||||
@@ -36,7 +36,7 @@ tests/cases/compiler/assignmentCompatWithOverloads.ts(30,1): error TS2322: Type
|
||||
~
|
||||
!!! error TS2322: Type '(x: number) => number' is not assignable to type '(s1: string) => number'.
|
||||
!!! error TS2322: Types of parameters 'x' and 's1' are incompatible.
|
||||
!!! error TS2322: Type 'number' is not assignable to type 'string'.
|
||||
!!! error TS2322: Type 'string' is not assignable to type 'number'.
|
||||
|
||||
g = f4; // Error
|
||||
~
|
||||
@@ -54,4 +54,4 @@ tests/cases/compiler/assignmentCompatWithOverloads.ts(30,1): error TS2322: Type
|
||||
~
|
||||
!!! error TS2322: Type 'typeof C' is not assignable to type 'new (x: number) => void'.
|
||||
!!! error TS2322: Types of parameters 'x' and 'x' are incompatible.
|
||||
!!! error TS2322: Type 'string' is not assignable to type 'number'.
|
||||
!!! error TS2322: Type 'number' is not assignable to type 'string'.
|
||||
@@ -1,10 +1,8 @@
|
||||
tests/cases/conformance/types/members/augmentedTypeAssignmentCompatIndexSignature.ts(15,5): error TS2322: Type '{}' is not assignable to type '{ [n: number]: Foo; }'.
|
||||
Index signature is missing in type '{}'.
|
||||
tests/cases/conformance/types/members/augmentedTypeAssignmentCompatIndexSignature.ts(19,5): error TS2322: Type '() => void' is not assignable to type '{ [n: number]: Bar; }'.
|
||||
Index signature is missing in type '() => void'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/types/members/augmentedTypeAssignmentCompatIndexSignature.ts (2 errors) ====
|
||||
==== tests/cases/conformance/types/members/augmentedTypeAssignmentCompatIndexSignature.ts (1 errors) ====
|
||||
interface Foo { a }
|
||||
interface Bar { b }
|
||||
|
||||
@@ -20,9 +18,6 @@ tests/cases/conformance/types/members/augmentedTypeAssignmentCompatIndexSignatur
|
||||
var f = () => { };
|
||||
|
||||
var v1: {
|
||||
~~
|
||||
!!! error TS2322: Type '{}' is not assignable to type '{ [n: number]: Foo; }'.
|
||||
!!! error TS2322: Index signature is missing in type '{}'.
|
||||
[n: number]: Foo
|
||||
} = o; // Should be allowed
|
||||
|
||||
|
||||
@@ -6,6 +6,6 @@ function method() {
|
||||
>dictionary : { [index: string]: string; }
|
||||
><{ [index: string]: string; }>{} : { [index: string]: string; }
|
||||
>index : string
|
||||
>{} : { [x: string]: undefined; }
|
||||
>{} : {}
|
||||
}
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ var obj: { [s: string]: Contextual } = { s: e }; // { s: Ellement; [s: string]:
|
||||
>obj : { [s: string]: Contextual; }
|
||||
>s : string
|
||||
>Contextual : Contextual
|
||||
>{ s: e } : { [x: string]: Ellement; s: Ellement; }
|
||||
>{ s: e } : { s: Ellement; }
|
||||
>s : Ellement
|
||||
>e : Ellement
|
||||
|
||||
|
||||
@@ -73,10 +73,9 @@ var _loop_2 = function(x, y) {
|
||||
};
|
||||
var out_x_2, out_y_2;
|
||||
for (var x = 1, y = 2; x < y; ++x, --y) {
|
||||
var state_2 = _loop_2(x, y);
|
||||
_loop_2(x, y);
|
||||
x = out_x_2;
|
||||
y = out_y_2;
|
||||
if (state_2 === "continue") continue;
|
||||
}
|
||||
var _loop_3 = function(x, y) {
|
||||
var a = function () { return x++ + y++; };
|
||||
|
||||
@@ -147,9 +147,8 @@ var _loop_3 = function(x, y) {
|
||||
};
|
||||
var out_a_2_1;
|
||||
for (var a_2 = 1; a_2 < 5; --a_2) {
|
||||
var state_3 = _loop_4(a_2);
|
||||
_loop_4(a_2);
|
||||
a_2 = out_a_2_1;
|
||||
if (state_3 === "continue") continue;
|
||||
}
|
||||
y = 5;
|
||||
}
|
||||
@@ -158,10 +157,9 @@ var _loop_3 = function(x, y) {
|
||||
};
|
||||
var out_x_2, out_y_2;
|
||||
for (var x = 1, y = 2; x < y; ++x, --y) {
|
||||
var state_4 = _loop_3(x, y);
|
||||
_loop_3(x, y);
|
||||
x = out_x_2;
|
||||
y = out_y_2;
|
||||
if (state_4 === "continue") continue;
|
||||
}
|
||||
var _loop_5 = function(x, y) {
|
||||
var a = function () { return x++ + y++; };
|
||||
|
||||
@@ -0,0 +1,164 @@
|
||||
tests/cases/compiler/bluebirdStaticThis.ts(5,15): error TS2420: Class 'Promise<R>' incorrectly implements interface 'Thenable<R>'.
|
||||
Property 'then' is missing in type 'Promise<R>'.
|
||||
tests/cases/compiler/bluebirdStaticThis.ts(22,51): error TS2305: Module 'Promise' has no exported member 'Resolver'.
|
||||
tests/cases/compiler/bluebirdStaticThis.ts(57,109): error TS2305: Module 'Promise' has no exported member 'Inspection'.
|
||||
tests/cases/compiler/bluebirdStaticThis.ts(58,91): error TS2305: Module 'Promise' has no exported member 'Inspection'.
|
||||
tests/cases/compiler/bluebirdStaticThis.ts(59,91): error TS2305: Module 'Promise' has no exported member 'Inspection'.
|
||||
tests/cases/compiler/bluebirdStaticThis.ts(60,73): error TS2305: Module 'Promise' has no exported member 'Inspection'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/bluebirdStaticThis.ts (6 errors) ====
|
||||
// This version is reduced from the full d.ts by removing almost all the tests
|
||||
// and all the comments.
|
||||
// Then it adds explicit `this` arguments to the static members.
|
||||
// Tests by: Bart van der Schoor <https://github.com/Bartvds>
|
||||
declare class Promise<R> implements Promise.Thenable<R> {
|
||||
~~~~~~~
|
||||
!!! error TS2420: Class 'Promise<R>' incorrectly implements interface 'Thenable<R>'.
|
||||
!!! error TS2420: Property 'then' is missing in type 'Promise<R>'.
|
||||
constructor(callback: (resolve: (thenableOrResult: R | Promise.Thenable<R>) => void, reject: (error: any) => void) => void);
|
||||
static try<R>(dit: typeof Promise, fn: () => Promise.Thenable<R>, args?: any[], ctx?: any): Promise<R>;
|
||||
static try<R>(dit: typeof Promise, fn: () => R, args?: any[], ctx?: any): Promise<R>;
|
||||
|
||||
static attempt<R>(dit: typeof Promise, fn: () => Promise.Thenable<R>, args?: any[], ctx?: any): Promise<R>;
|
||||
static attempt<R>(dit: typeof Promise, fn: () => R, args?: any[], ctx?: any): Promise<R>;
|
||||
|
||||
static method(dit: typeof Promise, fn: Function): Function;
|
||||
|
||||
static resolve(dit: typeof Promise): Promise<void>;
|
||||
static resolve<R>(dit: typeof Promise, value: Promise.Thenable<R>): Promise<R>;
|
||||
static resolve<R>(dit: typeof Promise, value: R): Promise<R>;
|
||||
|
||||
static reject(dit: typeof Promise, reason: any): Promise<any>;
|
||||
static reject<R>(dit: typeof Promise, reason: any): Promise<R>;
|
||||
|
||||
static defer<R>(dit: typeof Promise): Promise.Resolver<R>;
|
||||
~~~~~~~~
|
||||
!!! error TS2305: Module 'Promise' has no exported member 'Resolver'.
|
||||
|
||||
static cast<R>(dit: typeof Promise, value: Promise.Thenable<R>): Promise<R>;
|
||||
static cast<R>(dit: typeof Promise, value: R): Promise<R>;
|
||||
|
||||
static bind(dit: typeof Promise, thisArg: any): Promise<void>;
|
||||
|
||||
static is(dit: typeof Promise, value: any): boolean;
|
||||
|
||||
static longStackTraces(dit: typeof Promise): void;
|
||||
|
||||
static delay<R>(dit: typeof Promise, value: Promise.Thenable<R>, ms: number): Promise<R>;
|
||||
static delay<R>(dit: typeof Promise, value: R, ms: number): Promise<R>;
|
||||
static delay(dit: typeof Promise, ms: number): Promise<void>;
|
||||
|
||||
static promisify(dit: typeof Promise, nodeFunction: Function, receiver?: any): Function;
|
||||
|
||||
static promisifyAll(dit: typeof Promise, target: Object): Object;
|
||||
|
||||
static coroutine<R>(dit: typeof Promise, generatorFunction: Function): Function;
|
||||
|
||||
static spawn<R>(dit: typeof Promise, generatorFunction: Function): Promise<R>;
|
||||
|
||||
static noConflict(dit: typeof Promise): typeof Promise;
|
||||
|
||||
static onPossiblyUnhandledRejection(dit: typeof Promise, handler: (reason: any) => any): void;
|
||||
|
||||
static all<R>(dit: typeof Promise, values: Promise.Thenable<Promise.Thenable<R>[]>): Promise<R[]>;
|
||||
static all<R>(dit: typeof Promise, values: Promise.Thenable<R[]>): Promise<R[]>;
|
||||
static all<R>(dit: typeof Promise, values: Promise.Thenable<R>[]): Promise<R[]>;
|
||||
static all<R>(dit: typeof Promise, values: R[]): Promise<R[]>;
|
||||
|
||||
static props(dit: typeof Promise, object: Promise<Object>): Promise<Object>;
|
||||
static props(dit: typeof Promise, object: Object): Promise<Object>;
|
||||
|
||||
static settle<R>(dit: typeof Promise, values: Promise.Thenable<Promise.Thenable<R>[]>): Promise<Promise.Inspection<R>[]>;
|
||||
~~~~~~~~~~
|
||||
!!! error TS2305: Module 'Promise' has no exported member 'Inspection'.
|
||||
static settle<R>(dit: typeof Promise, values: Promise.Thenable<R[]>): Promise<Promise.Inspection<R>[]>;
|
||||
~~~~~~~~~~
|
||||
!!! error TS2305: Module 'Promise' has no exported member 'Inspection'.
|
||||
static settle<R>(dit: typeof Promise, values: Promise.Thenable<R>[]): Promise<Promise.Inspection<R>[]>;
|
||||
~~~~~~~~~~
|
||||
!!! error TS2305: Module 'Promise' has no exported member 'Inspection'.
|
||||
static settle<R>(dit: typeof Promise, values: R[]): Promise<Promise.Inspection<R>[]>;
|
||||
~~~~~~~~~~
|
||||
!!! error TS2305: Module 'Promise' has no exported member 'Inspection'.
|
||||
|
||||
static any<R>(dit: typeof Promise, values: Promise.Thenable<Promise.Thenable<R>[]>): Promise<R>;
|
||||
static any<R>(dit: typeof Promise, values: Promise.Thenable<R[]>): Promise<R>;
|
||||
static any<R>(dit: typeof Promise, values: Promise.Thenable<R>[]): Promise<R>;
|
||||
static any<R>(dit: typeof Promise, values: R[]): Promise<R>;
|
||||
|
||||
static race<R>(dit: typeof Promise, values: Promise.Thenable<Promise.Thenable<R>[]>): Promise<R>;
|
||||
static race<R>(dit: typeof Promise, values: Promise.Thenable<R[]>): Promise<R>;
|
||||
static race<R>(dit: typeof Promise, values: Promise.Thenable<R>[]): Promise<R>;
|
||||
static race<R>(dit: typeof Promise, values: R[]): Promise<R>;
|
||||
|
||||
static some<R>(dit: typeof Promise, values: Promise.Thenable<Promise.Thenable<R>[]>, count: number): Promise<R[]>;
|
||||
static some<R>(dit: typeof Promise, values: Promise.Thenable<R[]>, count: number): Promise<R[]>;
|
||||
static some<R>(dit: typeof Promise, values: Promise.Thenable<R>[], count: number): Promise<R[]>;
|
||||
static some<R>(dit: typeof Promise, values: R[], count: number): Promise<R[]>;
|
||||
|
||||
static join<R>(dit: typeof Promise, ...values: Promise.Thenable<R>[]): Promise<R[]>;
|
||||
static join<R>(dit: typeof Promise, ...values: R[]): Promise<R[]>;
|
||||
|
||||
static map<R, U>(dit: typeof Promise, values: Promise.Thenable<Promise.Thenable<R>[]>, mapper: (item: R, index: number, arrayLength: number) => Promise.Thenable<U>): Promise<U[]>;
|
||||
static map<R, U>(dit: typeof Promise, values: Promise.Thenable<Promise.Thenable<R>[]>, mapper: (item: R, index: number, arrayLength: number) => U): Promise<U[]>;
|
||||
static map<R, U>(dit: typeof Promise, values: Promise.Thenable<R[]>, mapper: (item: R, index: number, arrayLength: number) => Promise.Thenable<U>): Promise<U[]>;
|
||||
static map<R, U>(dit: typeof Promise, values: Promise.Thenable<R[]>, mapper: (item: R, index: number, arrayLength: number) => U): Promise<U[]>;
|
||||
static map<R, U>(dit: typeof Promise, values: Promise.Thenable<R>[], mapper: (item: R, index: number, arrayLength: number) => Promise.Thenable<U>): Promise<U[]>;
|
||||
static map<R, U>(dit: typeof Promise, values: Promise.Thenable<R>[], mapper: (item: R, index: number, arrayLength: number) => U): Promise<U[]>;
|
||||
static map<R, U>(dit: typeof Promise, values: R[], mapper: (item: R, index: number, arrayLength: number) => Promise.Thenable<U>): Promise<U[]>;
|
||||
static map<R, U>(dit: typeof Promise, values: R[], mapper: (item: R, index: number, arrayLength: number) => U): Promise<U[]>;
|
||||
|
||||
static reduce<R, U>(dit: typeof Promise, values: Promise.Thenable<Promise.Thenable<R>[]>, reducer: (total: U, current: R, index: number, arrayLength: number) => Promise.Thenable<U>, initialValue?: U): Promise<U>;
|
||||
static reduce<R, U>(dit: typeof Promise, values: Promise.Thenable<Promise.Thenable<R>[]>, reducer: (total: U, current: R, index: number, arrayLength: number) => U, initialValue?: U): Promise<U>;
|
||||
|
||||
static reduce<R, U>(dit: typeof Promise, values: Promise.Thenable<R[]>, reducer: (total: U, current: R, index: number, arrayLength: number) => Promise.Thenable<U>, initialValue?: U): Promise<U>;
|
||||
static reduce<R, U>(dit: typeof Promise, values: Promise.Thenable<R[]>, reducer: (total: U, current: R, index: number, arrayLength: number) => U, initialValue?: U): Promise<U>;
|
||||
|
||||
static reduce<R, U>(dit: typeof Promise, values: Promise.Thenable<R>[], reducer: (total: U, current: R, index: number, arrayLength: number) => Promise.Thenable<U>, initialValue?: U): Promise<U>;
|
||||
static reduce<R, U>(dit: typeof Promise, values: Promise.Thenable<R>[], reducer: (total: U, current: R, index: number, arrayLength: number) => U, initialValue?: U): Promise<U>;
|
||||
|
||||
static reduce<R, U>(dit: typeof Promise, values: R[], reducer: (total: U, current: R, index: number, arrayLength: number) => Promise.Thenable<U>, initialValue?: U): Promise<U>;
|
||||
static reduce<R, U>(dit: typeof Promise, values: R[], reducer: (total: U, current: R, index: number, arrayLength: number) => U, initialValue?: U): Promise<U>;
|
||||
|
||||
static filter<R>(dit: typeof Promise, values: Promise.Thenable<Promise.Thenable<R>[]>, filterer: (item: R, index: number, arrayLength: number) => Promise.Thenable<boolean>): Promise<R[]>;
|
||||
static filter<R>(dit: typeof Promise, values: Promise.Thenable<Promise.Thenable<R>[]>, filterer: (item: R, index: number, arrayLength: number) => boolean): Promise<R[]>;
|
||||
static filter<R>(dit: typeof Promise, values: Promise.Thenable<R[]>, filterer: (item: R, index: number, arrayLength: number) => Promise.Thenable<boolean>): Promise<R[]>;
|
||||
static filter<R>(dit: typeof Promise, values: Promise.Thenable<R[]>, filterer: (item: R, index: number, arrayLength: number) => boolean): Promise<R[]>;
|
||||
static filter<R>(dit: typeof Promise, values: Promise.Thenable<R>[], filterer: (item: R, index: number, arrayLength: number) => Promise.Thenable<boolean>): Promise<R[]>;
|
||||
static filter<R>(dit: typeof Promise, values: Promise.Thenable<R>[], filterer: (item: R, index: number, arrayLength: number) => boolean): Promise<R[]>;
|
||||
static filter<R>(dit: typeof Promise, values: R[], filterer: (item: R, index: number, arrayLength: number) => Promise.Thenable<boolean>): Promise<R[]>;
|
||||
static filter<R>(dit: typeof Promise, values: R[], filterer: (item: R, index: number, arrayLength: number) => boolean): Promise<R[]>;
|
||||
}
|
||||
|
||||
declare module Promise {
|
||||
export interface Thenable<R> {
|
||||
then<U>(onFulfilled: (value: R) => Thenable<U>, onRejected: (error: any) => Thenable<U>): Thenable<U>;
|
||||
then<U>(onFulfilled: (value: R) => Thenable<U>, onRejected?: (error: any) => U): Thenable<U>;
|
||||
then<U>(onFulfilled: (value: R) => U, onRejected: (error: any) => Thenable<U>): Thenable<U>;
|
||||
then<U>(onFulfilled?: (value: R) => U, onRejected?: (error: any) => U): Thenable<U>;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
declare module 'bluebird' {
|
||||
export = Promise;
|
||||
}
|
||||
interface Foo {
|
||||
a: number;
|
||||
b: string;
|
||||
}
|
||||
var x: any;
|
||||
var arr: any[];
|
||||
var foo: Foo;
|
||||
var fooProm: Promise<Foo>;
|
||||
|
||||
fooProm = Promise.try(Promise, () => {
|
||||
return foo;
|
||||
});
|
||||
fooProm = Promise.try(Promise, () => {
|
||||
return foo;
|
||||
}, arr);
|
||||
fooProm = Promise.try(Promise, () => {
|
||||
return foo;
|
||||
}, arr, x);
|
||||
@@ -0,0 +1,157 @@
|
||||
//// [bluebirdStaticThis.ts]
|
||||
// This version is reduced from the full d.ts by removing almost all the tests
|
||||
// and all the comments.
|
||||
// Then it adds explicit `this` arguments to the static members.
|
||||
// Tests by: Bart van der Schoor <https://github.com/Bartvds>
|
||||
declare class Promise<R> implements Promise.Thenable<R> {
|
||||
constructor(callback: (resolve: (thenableOrResult: R | Promise.Thenable<R>) => void, reject: (error: any) => void) => void);
|
||||
static try<R>(dit: typeof Promise, fn: () => Promise.Thenable<R>, args?: any[], ctx?: any): Promise<R>;
|
||||
static try<R>(dit: typeof Promise, fn: () => R, args?: any[], ctx?: any): Promise<R>;
|
||||
|
||||
static attempt<R>(dit: typeof Promise, fn: () => Promise.Thenable<R>, args?: any[], ctx?: any): Promise<R>;
|
||||
static attempt<R>(dit: typeof Promise, fn: () => R, args?: any[], ctx?: any): Promise<R>;
|
||||
|
||||
static method(dit: typeof Promise, fn: Function): Function;
|
||||
|
||||
static resolve(dit: typeof Promise): Promise<void>;
|
||||
static resolve<R>(dit: typeof Promise, value: Promise.Thenable<R>): Promise<R>;
|
||||
static resolve<R>(dit: typeof Promise, value: R): Promise<R>;
|
||||
|
||||
static reject(dit: typeof Promise, reason: any): Promise<any>;
|
||||
static reject<R>(dit: typeof Promise, reason: any): Promise<R>;
|
||||
|
||||
static defer<R>(dit: typeof Promise): Promise.Resolver<R>;
|
||||
|
||||
static cast<R>(dit: typeof Promise, value: Promise.Thenable<R>): Promise<R>;
|
||||
static cast<R>(dit: typeof Promise, value: R): Promise<R>;
|
||||
|
||||
static bind(dit: typeof Promise, thisArg: any): Promise<void>;
|
||||
|
||||
static is(dit: typeof Promise, value: any): boolean;
|
||||
|
||||
static longStackTraces(dit: typeof Promise): void;
|
||||
|
||||
static delay<R>(dit: typeof Promise, value: Promise.Thenable<R>, ms: number): Promise<R>;
|
||||
static delay<R>(dit: typeof Promise, value: R, ms: number): Promise<R>;
|
||||
static delay(dit: typeof Promise, ms: number): Promise<void>;
|
||||
|
||||
static promisify(dit: typeof Promise, nodeFunction: Function, receiver?: any): Function;
|
||||
|
||||
static promisifyAll(dit: typeof Promise, target: Object): Object;
|
||||
|
||||
static coroutine<R>(dit: typeof Promise, generatorFunction: Function): Function;
|
||||
|
||||
static spawn<R>(dit: typeof Promise, generatorFunction: Function): Promise<R>;
|
||||
|
||||
static noConflict(dit: typeof Promise): typeof Promise;
|
||||
|
||||
static onPossiblyUnhandledRejection(dit: typeof Promise, handler: (reason: any) => any): void;
|
||||
|
||||
static all<R>(dit: typeof Promise, values: Promise.Thenable<Promise.Thenable<R>[]>): Promise<R[]>;
|
||||
static all<R>(dit: typeof Promise, values: Promise.Thenable<R[]>): Promise<R[]>;
|
||||
static all<R>(dit: typeof Promise, values: Promise.Thenable<R>[]): Promise<R[]>;
|
||||
static all<R>(dit: typeof Promise, values: R[]): Promise<R[]>;
|
||||
|
||||
static props(dit: typeof Promise, object: Promise<Object>): Promise<Object>;
|
||||
static props(dit: typeof Promise, object: Object): Promise<Object>;
|
||||
|
||||
static settle<R>(dit: typeof Promise, values: Promise.Thenable<Promise.Thenable<R>[]>): Promise<Promise.Inspection<R>[]>;
|
||||
static settle<R>(dit: typeof Promise, values: Promise.Thenable<R[]>): Promise<Promise.Inspection<R>[]>;
|
||||
static settle<R>(dit: typeof Promise, values: Promise.Thenable<R>[]): Promise<Promise.Inspection<R>[]>;
|
||||
static settle<R>(dit: typeof Promise, values: R[]): Promise<Promise.Inspection<R>[]>;
|
||||
|
||||
static any<R>(dit: typeof Promise, values: Promise.Thenable<Promise.Thenable<R>[]>): Promise<R>;
|
||||
static any<R>(dit: typeof Promise, values: Promise.Thenable<R[]>): Promise<R>;
|
||||
static any<R>(dit: typeof Promise, values: Promise.Thenable<R>[]): Promise<R>;
|
||||
static any<R>(dit: typeof Promise, values: R[]): Promise<R>;
|
||||
|
||||
static race<R>(dit: typeof Promise, values: Promise.Thenable<Promise.Thenable<R>[]>): Promise<R>;
|
||||
static race<R>(dit: typeof Promise, values: Promise.Thenable<R[]>): Promise<R>;
|
||||
static race<R>(dit: typeof Promise, values: Promise.Thenable<R>[]): Promise<R>;
|
||||
static race<R>(dit: typeof Promise, values: R[]): Promise<R>;
|
||||
|
||||
static some<R>(dit: typeof Promise, values: Promise.Thenable<Promise.Thenable<R>[]>, count: number): Promise<R[]>;
|
||||
static some<R>(dit: typeof Promise, values: Promise.Thenable<R[]>, count: number): Promise<R[]>;
|
||||
static some<R>(dit: typeof Promise, values: Promise.Thenable<R>[], count: number): Promise<R[]>;
|
||||
static some<R>(dit: typeof Promise, values: R[], count: number): Promise<R[]>;
|
||||
|
||||
static join<R>(dit: typeof Promise, ...values: Promise.Thenable<R>[]): Promise<R[]>;
|
||||
static join<R>(dit: typeof Promise, ...values: R[]): Promise<R[]>;
|
||||
|
||||
static map<R, U>(dit: typeof Promise, values: Promise.Thenable<Promise.Thenable<R>[]>, mapper: (item: R, index: number, arrayLength: number) => Promise.Thenable<U>): Promise<U[]>;
|
||||
static map<R, U>(dit: typeof Promise, values: Promise.Thenable<Promise.Thenable<R>[]>, mapper: (item: R, index: number, arrayLength: number) => U): Promise<U[]>;
|
||||
static map<R, U>(dit: typeof Promise, values: Promise.Thenable<R[]>, mapper: (item: R, index: number, arrayLength: number) => Promise.Thenable<U>): Promise<U[]>;
|
||||
static map<R, U>(dit: typeof Promise, values: Promise.Thenable<R[]>, mapper: (item: R, index: number, arrayLength: number) => U): Promise<U[]>;
|
||||
static map<R, U>(dit: typeof Promise, values: Promise.Thenable<R>[], mapper: (item: R, index: number, arrayLength: number) => Promise.Thenable<U>): Promise<U[]>;
|
||||
static map<R, U>(dit: typeof Promise, values: Promise.Thenable<R>[], mapper: (item: R, index: number, arrayLength: number) => U): Promise<U[]>;
|
||||
static map<R, U>(dit: typeof Promise, values: R[], mapper: (item: R, index: number, arrayLength: number) => Promise.Thenable<U>): Promise<U[]>;
|
||||
static map<R, U>(dit: typeof Promise, values: R[], mapper: (item: R, index: number, arrayLength: number) => U): Promise<U[]>;
|
||||
|
||||
static reduce<R, U>(dit: typeof Promise, values: Promise.Thenable<Promise.Thenable<R>[]>, reducer: (total: U, current: R, index: number, arrayLength: number) => Promise.Thenable<U>, initialValue?: U): Promise<U>;
|
||||
static reduce<R, U>(dit: typeof Promise, values: Promise.Thenable<Promise.Thenable<R>[]>, reducer: (total: U, current: R, index: number, arrayLength: number) => U, initialValue?: U): Promise<U>;
|
||||
|
||||
static reduce<R, U>(dit: typeof Promise, values: Promise.Thenable<R[]>, reducer: (total: U, current: R, index: number, arrayLength: number) => Promise.Thenable<U>, initialValue?: U): Promise<U>;
|
||||
static reduce<R, U>(dit: typeof Promise, values: Promise.Thenable<R[]>, reducer: (total: U, current: R, index: number, arrayLength: number) => U, initialValue?: U): Promise<U>;
|
||||
|
||||
static reduce<R, U>(dit: typeof Promise, values: Promise.Thenable<R>[], reducer: (total: U, current: R, index: number, arrayLength: number) => Promise.Thenable<U>, initialValue?: U): Promise<U>;
|
||||
static reduce<R, U>(dit: typeof Promise, values: Promise.Thenable<R>[], reducer: (total: U, current: R, index: number, arrayLength: number) => U, initialValue?: U): Promise<U>;
|
||||
|
||||
static reduce<R, U>(dit: typeof Promise, values: R[], reducer: (total: U, current: R, index: number, arrayLength: number) => Promise.Thenable<U>, initialValue?: U): Promise<U>;
|
||||
static reduce<R, U>(dit: typeof Promise, values: R[], reducer: (total: U, current: R, index: number, arrayLength: number) => U, initialValue?: U): Promise<U>;
|
||||
|
||||
static filter<R>(dit: typeof Promise, values: Promise.Thenable<Promise.Thenable<R>[]>, filterer: (item: R, index: number, arrayLength: number) => Promise.Thenable<boolean>): Promise<R[]>;
|
||||
static filter<R>(dit: typeof Promise, values: Promise.Thenable<Promise.Thenable<R>[]>, filterer: (item: R, index: number, arrayLength: number) => boolean): Promise<R[]>;
|
||||
static filter<R>(dit: typeof Promise, values: Promise.Thenable<R[]>, filterer: (item: R, index: number, arrayLength: number) => Promise.Thenable<boolean>): Promise<R[]>;
|
||||
static filter<R>(dit: typeof Promise, values: Promise.Thenable<R[]>, filterer: (item: R, index: number, arrayLength: number) => boolean): Promise<R[]>;
|
||||
static filter<R>(dit: typeof Promise, values: Promise.Thenable<R>[], filterer: (item: R, index: number, arrayLength: number) => Promise.Thenable<boolean>): Promise<R[]>;
|
||||
static filter<R>(dit: typeof Promise, values: Promise.Thenable<R>[], filterer: (item: R, index: number, arrayLength: number) => boolean): Promise<R[]>;
|
||||
static filter<R>(dit: typeof Promise, values: R[], filterer: (item: R, index: number, arrayLength: number) => Promise.Thenable<boolean>): Promise<R[]>;
|
||||
static filter<R>(dit: typeof Promise, values: R[], filterer: (item: R, index: number, arrayLength: number) => boolean): Promise<R[]>;
|
||||
}
|
||||
|
||||
declare module Promise {
|
||||
export interface Thenable<R> {
|
||||
then<U>(onFulfilled: (value: R) => Thenable<U>, onRejected: (error: any) => Thenable<U>): Thenable<U>;
|
||||
then<U>(onFulfilled: (value: R) => Thenable<U>, onRejected?: (error: any) => U): Thenable<U>;
|
||||
then<U>(onFulfilled: (value: R) => U, onRejected: (error: any) => Thenable<U>): Thenable<U>;
|
||||
then<U>(onFulfilled?: (value: R) => U, onRejected?: (error: any) => U): Thenable<U>;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
declare module 'bluebird' {
|
||||
export = Promise;
|
||||
}
|
||||
interface Foo {
|
||||
a: number;
|
||||
b: string;
|
||||
}
|
||||
var x: any;
|
||||
var arr: any[];
|
||||
var foo: Foo;
|
||||
var fooProm: Promise<Foo>;
|
||||
|
||||
fooProm = Promise.try(Promise, () => {
|
||||
return foo;
|
||||
});
|
||||
fooProm = Promise.try(Promise, () => {
|
||||
return foo;
|
||||
}, arr);
|
||||
fooProm = Promise.try(Promise, () => {
|
||||
return foo;
|
||||
}, arr, x);
|
||||
|
||||
//// [bluebirdStaticThis.js]
|
||||
var x;
|
||||
var arr;
|
||||
var foo;
|
||||
var fooProm;
|
||||
fooProm = Promise.try(Promise, function () {
|
||||
return foo;
|
||||
});
|
||||
fooProm = Promise.try(Promise, function () {
|
||||
return foo;
|
||||
}, arr);
|
||||
fooProm = Promise.try(Promise, function () {
|
||||
return foo;
|
||||
}, arr, x);
|
||||
@@ -2,12 +2,12 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/callSign
|
||||
Types of property 'a2' are incompatible.
|
||||
Type '(x: T) => U[]' is not assignable to type '(x: number) => string[]'.
|
||||
Types of parameters 'x' and 'x' are incompatible.
|
||||
Type 'T' is not assignable to type 'number'.
|
||||
Type 'number' is not assignable to type 'T'.
|
||||
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/callSignatureAssignabilityInInheritance3.ts(60,19): error TS2430: Interface 'I4' incorrectly extends interface 'A'.
|
||||
Types of property 'a8' are incompatible.
|
||||
Type '<T extends Base, U extends Derived>(x: (arg: T) => U, y: (arg2: { foo: number; }) => U) => (r: T) => U' is not assignable to type '(x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived'.
|
||||
Types of parameters 'y' and 'y' are incompatible.
|
||||
Type '(arg2: { foo: number; }) => any' is not assignable to type '(arg2: Base) => Derived'.
|
||||
Type '(arg2: Base) => Derived' is not assignable to type '(arg2: { foo: number; }) => any'.
|
||||
Types of parameters 'arg2' and 'arg2' are incompatible.
|
||||
Type '{ foo: number; }' is not assignable to type 'Base'.
|
||||
Types of property 'foo' are incompatible.
|
||||
@@ -71,7 +71,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/callSign
|
||||
!!! error TS2430: Types of property 'a2' are incompatible.
|
||||
!!! error TS2430: Type '(x: T) => U[]' is not assignable to type '(x: number) => string[]'.
|
||||
!!! error TS2430: Types of parameters 'x' and 'x' are incompatible.
|
||||
!!! error TS2430: Type 'T' is not assignable to type 'number'.
|
||||
!!! error TS2430: Type 'number' is not assignable to type 'T'.
|
||||
a2: (x: T) => U[]; // error, no contextual signature instantiation since I2.a2 is not generic
|
||||
}
|
||||
|
||||
@@ -86,7 +86,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/callSign
|
||||
!!! error TS2430: Types of property 'a8' are incompatible.
|
||||
!!! error TS2430: Type '<T extends Base, U extends Derived>(x: (arg: T) => U, y: (arg2: { foo: number; }) => U) => (r: T) => U' is not assignable to type '(x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived'.
|
||||
!!! error TS2430: Types of parameters 'y' and 'y' are incompatible.
|
||||
!!! error TS2430: Type '(arg2: { foo: number; }) => any' is not assignable to type '(arg2: Base) => Derived'.
|
||||
!!! error TS2430: Type '(arg2: Base) => Derived' is not assignable to type '(arg2: { foo: number; }) => any'.
|
||||
!!! error TS2430: Types of parameters 'arg2' and 'arg2' are incompatible.
|
||||
!!! error TS2430: Type '{ foo: number; }' is not assignable to type 'Base'.
|
||||
!!! error TS2430: Types of property 'foo' are incompatible.
|
||||
|
||||
@@ -254,7 +254,6 @@ for (var _i = 0, _a = []; _i < _a.length; _i++) {
|
||||
var x = _a[_i];
|
||||
var state_1 = _loop_1(x);
|
||||
if (state_1 === "break") break;
|
||||
if (state_1 === "continue") continue;
|
||||
}
|
||||
var _loop_2 = function(x) {
|
||||
(function () { return x; });
|
||||
@@ -269,7 +268,6 @@ var _loop_2 = function(x) {
|
||||
for (var x in []) {
|
||||
var state_2 = _loop_2(x);
|
||||
if (state_2 === "break") break;
|
||||
if (state_2 === "continue") continue;
|
||||
}
|
||||
var _loop_3 = function(x) {
|
||||
(function () { return x; });
|
||||
@@ -284,7 +282,6 @@ var _loop_3 = function(x) {
|
||||
for (var x = 0; x < 1; ++x) {
|
||||
var state_3 = _loop_3(x);
|
||||
if (state_3 === "break") break;
|
||||
if (state_3 === "continue") continue;
|
||||
}
|
||||
var _loop_4 = function() {
|
||||
var x;
|
||||
@@ -300,7 +297,6 @@ var _loop_4 = function() {
|
||||
while (1 === 1) {
|
||||
var state_4 = _loop_4();
|
||||
if (state_4 === "break") break;
|
||||
if (state_4 === "continue") continue;
|
||||
}
|
||||
var _loop_5 = function() {
|
||||
var x;
|
||||
@@ -316,7 +312,6 @@ var _loop_5 = function() {
|
||||
do {
|
||||
var state_5 = _loop_5();
|
||||
if (state_5 === "break") break;
|
||||
if (state_5 === "continue") continue;
|
||||
} while (1 === 1);
|
||||
var _loop_6 = function(y) {
|
||||
var x = 1;
|
||||
@@ -332,7 +327,6 @@ var _loop_6 = function(y) {
|
||||
for (var y = 0; y < 1; ++y) {
|
||||
var state_6 = _loop_6(y);
|
||||
if (state_6 === "break") break;
|
||||
if (state_6 === "continue") continue;
|
||||
}
|
||||
var _loop_7 = function(x, y) {
|
||||
(function () { return x + y; });
|
||||
@@ -347,7 +341,6 @@ var _loop_7 = function(x, y) {
|
||||
for (var x = 0, y = 1; x < 1; ++x) {
|
||||
var state_7 = _loop_7(x, y);
|
||||
if (state_7 === "break") break;
|
||||
if (state_7 === "continue") continue;
|
||||
}
|
||||
var _loop_8 = function() {
|
||||
var x, y;
|
||||
@@ -363,7 +356,6 @@ var _loop_8 = function() {
|
||||
while (1 === 1) {
|
||||
var state_8 = _loop_8();
|
||||
if (state_8 === "break") break;
|
||||
if (state_8 === "continue") continue;
|
||||
}
|
||||
var _loop_9 = function() {
|
||||
var x, y;
|
||||
@@ -379,7 +371,6 @@ var _loop_9 = function() {
|
||||
do {
|
||||
var state_9 = _loop_9();
|
||||
if (state_9 === "break") break;
|
||||
if (state_9 === "continue") continue;
|
||||
} while (1 === 1);
|
||||
var _loop_10 = function(y) {
|
||||
var x = 1;
|
||||
@@ -395,7 +386,6 @@ var _loop_10 = function(y) {
|
||||
for (var y = 0; y < 1; ++y) {
|
||||
var state_10 = _loop_10(y);
|
||||
if (state_10 === "break") break;
|
||||
if (state_10 === "continue") continue;
|
||||
}
|
||||
// ====const
|
||||
var _loop_11 = function(x) {
|
||||
@@ -412,7 +402,6 @@ for (var _b = 0, _c = []; _b < _c.length; _b++) {
|
||||
var x = _c[_b];
|
||||
var state_11 = _loop_11(x);
|
||||
if (state_11 === "break") break;
|
||||
if (state_11 === "continue") continue;
|
||||
}
|
||||
var _loop_12 = function(x) {
|
||||
(function () { return x; });
|
||||
@@ -427,7 +416,6 @@ var _loop_12 = function(x) {
|
||||
for (var x in []) {
|
||||
var state_12 = _loop_12(x);
|
||||
if (state_12 === "break") break;
|
||||
if (state_12 === "continue") continue;
|
||||
}
|
||||
var _loop_13 = function(x) {
|
||||
(function () { return x; });
|
||||
@@ -442,7 +430,6 @@ var _loop_13 = function(x) {
|
||||
for (var x = 0; x < 1;) {
|
||||
var state_13 = _loop_13(x);
|
||||
if (state_13 === "break") break;
|
||||
if (state_13 === "continue") continue;
|
||||
}
|
||||
var _loop_14 = function() {
|
||||
var x = 1;
|
||||
@@ -458,7 +445,6 @@ var _loop_14 = function() {
|
||||
while (1 === 1) {
|
||||
var state_14 = _loop_14();
|
||||
if (state_14 === "break") break;
|
||||
if (state_14 === "continue") continue;
|
||||
}
|
||||
var _loop_15 = function() {
|
||||
var x = 1;
|
||||
@@ -474,7 +460,6 @@ var _loop_15 = function() {
|
||||
do {
|
||||
var state_15 = _loop_15();
|
||||
if (state_15 === "break") break;
|
||||
if (state_15 === "continue") continue;
|
||||
} while (1 === 1);
|
||||
var _loop_16 = function(y) {
|
||||
var x = 1;
|
||||
@@ -490,7 +475,6 @@ var _loop_16 = function(y) {
|
||||
for (var y = 0; y < 1;) {
|
||||
var state_16 = _loop_16(y);
|
||||
if (state_16 === "break") break;
|
||||
if (state_16 === "continue") continue;
|
||||
}
|
||||
var _loop_17 = function(x, y) {
|
||||
(function () { return x + y; });
|
||||
@@ -505,7 +489,6 @@ var _loop_17 = function(x, y) {
|
||||
for (var x = 0, y = 1; x < 1;) {
|
||||
var state_17 = _loop_17(x, y);
|
||||
if (state_17 === "break") break;
|
||||
if (state_17 === "continue") continue;
|
||||
}
|
||||
var _loop_18 = function() {
|
||||
var x = 1, y = 1;
|
||||
@@ -521,7 +504,6 @@ var _loop_18 = function() {
|
||||
while (1 === 1) {
|
||||
var state_18 = _loop_18();
|
||||
if (state_18 === "break") break;
|
||||
if (state_18 === "continue") continue;
|
||||
}
|
||||
var _loop_19 = function() {
|
||||
var x = 1, y = 1;
|
||||
@@ -537,7 +519,6 @@ var _loop_19 = function() {
|
||||
do {
|
||||
var state_19 = _loop_19();
|
||||
if (state_19 === "break") break;
|
||||
if (state_19 === "continue") continue;
|
||||
} while (1 === 1);
|
||||
var _loop_20 = function(y) {
|
||||
var x = 1;
|
||||
@@ -553,5 +534,4 @@ var _loop_20 = function(y) {
|
||||
for (var y = 0; y < 1;) {
|
||||
var state_20 = _loop_20(y);
|
||||
if (state_20 === "break") break;
|
||||
if (state_20 === "continue") continue;
|
||||
}
|
||||
|
||||
@@ -397,7 +397,6 @@ l0: for (var _i = 0, _a = []; _i < _a.length; _i++) {
|
||||
var x = _a[_i];
|
||||
var state_1 = _loop_1(x);
|
||||
if (state_1 === "break") break;
|
||||
if (state_1 === "continue") continue;
|
||||
switch(state_1) {
|
||||
case "break-l0": break l0;
|
||||
case "continue-l0": continue l0;
|
||||
@@ -422,7 +421,6 @@ var _loop_2 = function(x) {
|
||||
l00: for (var x in []) {
|
||||
var state_2 = _loop_2(x);
|
||||
if (state_2 === "break") break;
|
||||
if (state_2 === "continue") continue;
|
||||
switch(state_2) {
|
||||
case "break-l00": break l00;
|
||||
case "continue-l00": continue l00;
|
||||
@@ -447,7 +445,6 @@ var _loop_3 = function(x) {
|
||||
l1: for (var x = 0; x < 1; ++x) {
|
||||
var state_3 = _loop_3(x);
|
||||
if (state_3 === "break") break;
|
||||
if (state_3 === "continue") continue;
|
||||
switch(state_3) {
|
||||
case "break-l1": break l1;
|
||||
case "continue-l1": continue l1;
|
||||
@@ -473,7 +470,6 @@ var _loop_4 = function() {
|
||||
l2: while (1 === 1) {
|
||||
var state_4 = _loop_4();
|
||||
if (state_4 === "break") break;
|
||||
if (state_4 === "continue") continue;
|
||||
switch(state_4) {
|
||||
case "break-l2": break l2;
|
||||
case "continue-l2": continue l2;
|
||||
@@ -499,7 +495,6 @@ var _loop_5 = function() {
|
||||
l3: do {
|
||||
var state_5 = _loop_5();
|
||||
if (state_5 === "break") break;
|
||||
if (state_5 === "continue") continue;
|
||||
switch(state_5) {
|
||||
case "break-l3": break l3;
|
||||
case "continue-l3": continue l3;
|
||||
@@ -525,7 +520,6 @@ var _loop_6 = function(y) {
|
||||
l4: for (var y = 0; y < 1; ++y) {
|
||||
var state_6 = _loop_6(y);
|
||||
if (state_6 === "break") break;
|
||||
if (state_6 === "continue") continue;
|
||||
switch(state_6) {
|
||||
case "break-l4": break l4;
|
||||
case "continue-l4": continue l4;
|
||||
@@ -550,7 +544,6 @@ var _loop_7 = function(x, y) {
|
||||
l5: for (var x = 0, y = 1; x < 1; ++x) {
|
||||
var state_7 = _loop_7(x, y);
|
||||
if (state_7 === "break") break;
|
||||
if (state_7 === "continue") continue;
|
||||
switch(state_7) {
|
||||
case "break-l5": break l5;
|
||||
case "continue-l5": continue l5;
|
||||
@@ -576,7 +569,6 @@ var _loop_8 = function() {
|
||||
l6: while (1 === 1) {
|
||||
var state_8 = _loop_8();
|
||||
if (state_8 === "break") break;
|
||||
if (state_8 === "continue") continue;
|
||||
switch(state_8) {
|
||||
case "break-l6": break l6;
|
||||
case "continue-l6": continue l6;
|
||||
@@ -602,7 +594,6 @@ var _loop_9 = function() {
|
||||
l7: do {
|
||||
var state_9 = _loop_9();
|
||||
if (state_9 === "break") break;
|
||||
if (state_9 === "continue") continue;
|
||||
switch(state_9) {
|
||||
case "break-l7": break l7;
|
||||
case "continue-l7": continue l7;
|
||||
@@ -628,7 +619,6 @@ var _loop_10 = function(y) {
|
||||
l8: for (var y = 0; y < 1; ++y) {
|
||||
var state_10 = _loop_10(y);
|
||||
if (state_10 === "break") break;
|
||||
if (state_10 === "continue") continue;
|
||||
switch(state_10) {
|
||||
case "break-l8": break l8;
|
||||
case "continue-l8": continue l8;
|
||||
@@ -655,7 +645,6 @@ l0_c: for (var _b = 0, _c = []; _b < _c.length; _b++) {
|
||||
var x = _c[_b];
|
||||
var state_11 = _loop_11(x);
|
||||
if (state_11 === "break") break;
|
||||
if (state_11 === "continue") continue;
|
||||
switch(state_11) {
|
||||
case "break-l0_c": break l0_c;
|
||||
case "continue-l0_c": continue l0_c;
|
||||
@@ -680,7 +669,6 @@ var _loop_12 = function(x) {
|
||||
l00_c: for (var x in []) {
|
||||
var state_12 = _loop_12(x);
|
||||
if (state_12 === "break") break;
|
||||
if (state_12 === "continue") continue;
|
||||
switch(state_12) {
|
||||
case "break-l00_c": break l00_c;
|
||||
case "continue-l00_c": continue l00_c;
|
||||
@@ -705,7 +693,6 @@ var _loop_13 = function(x) {
|
||||
l1_c: for (var x = 0; x < 1;) {
|
||||
var state_13 = _loop_13(x);
|
||||
if (state_13 === "break") break;
|
||||
if (state_13 === "continue") continue;
|
||||
switch(state_13) {
|
||||
case "break-l1_c": break l1_c;
|
||||
case "continue-l1_c": continue l1_c;
|
||||
@@ -731,7 +718,6 @@ var _loop_14 = function() {
|
||||
l2_c: while (1 === 1) {
|
||||
var state_14 = _loop_14();
|
||||
if (state_14 === "break") break;
|
||||
if (state_14 === "continue") continue;
|
||||
switch(state_14) {
|
||||
case "break-l2_c": break l2_c;
|
||||
case "continue-l2_c": continue l2_c;
|
||||
@@ -757,7 +743,6 @@ var _loop_15 = function() {
|
||||
l3_c: do {
|
||||
var state_15 = _loop_15();
|
||||
if (state_15 === "break") break;
|
||||
if (state_15 === "continue") continue;
|
||||
switch(state_15) {
|
||||
case "break-l3_c": break l3_c;
|
||||
case "continue-l3_c": continue l3_c;
|
||||
@@ -783,7 +768,6 @@ var _loop_16 = function(y) {
|
||||
l4_c: for (var y = 0; y < 1;) {
|
||||
var state_16 = _loop_16(y);
|
||||
if (state_16 === "break") break;
|
||||
if (state_16 === "continue") continue;
|
||||
switch(state_16) {
|
||||
case "break-l4_c": break l4_c;
|
||||
case "continue-l4_c": continue l4_c;
|
||||
@@ -808,7 +792,6 @@ var _loop_17 = function(x, y) {
|
||||
l5_c: for (var x = 0, y = 1; x < 1;) {
|
||||
var state_17 = _loop_17(x, y);
|
||||
if (state_17 === "break") break;
|
||||
if (state_17 === "continue") continue;
|
||||
switch(state_17) {
|
||||
case "break-l5_c": break l5_c;
|
||||
case "continue-l5_c": continue l5_c;
|
||||
@@ -834,7 +817,6 @@ var _loop_18 = function() {
|
||||
l6_c: while (1 === 1) {
|
||||
var state_18 = _loop_18();
|
||||
if (state_18 === "break") break;
|
||||
if (state_18 === "continue") continue;
|
||||
switch(state_18) {
|
||||
case "break-l6_c": break l6_c;
|
||||
case "continue-l6_c": continue l6_c;
|
||||
@@ -860,7 +842,6 @@ var _loop_19 = function() {
|
||||
l7_c: do {
|
||||
var state_19 = _loop_19();
|
||||
if (state_19 === "break") break;
|
||||
if (state_19 === "continue") continue;
|
||||
switch(state_19) {
|
||||
case "break-l7_c": break l7_c;
|
||||
case "continue-l7_c": continue l7_c;
|
||||
@@ -886,7 +867,6 @@ var _loop_20 = function(y) {
|
||||
l8_c: for (var y = 0; y < 1;) {
|
||||
var state_20 = _loop_20(y);
|
||||
if (state_20 === "break") break;
|
||||
if (state_20 === "continue") continue;
|
||||
switch(state_20) {
|
||||
case "break-l8_c": break l8_c;
|
||||
case "continue-l8_c": continue l8_c;
|
||||
|
||||
@@ -165,7 +165,6 @@ function foo() {
|
||||
var state_1 = _loop_2(y);
|
||||
if (typeof state_1 === "object") return state_1;
|
||||
if (state_1 === "break") break;
|
||||
if (state_1 === "continue") continue;
|
||||
switch(state_1) {
|
||||
case "break-l1": return state_1;
|
||||
case "break-ll1": break ll1;
|
||||
@@ -200,7 +199,6 @@ function foo() {
|
||||
var state_2 = _loop_1(x);
|
||||
if (typeof state_2 === "object") return state_2.value;
|
||||
if (state_2 === "break") break;
|
||||
if (state_2 === "continue") continue;
|
||||
switch(state_2) {
|
||||
case "break-l1": break l1;
|
||||
case "continue-l0": continue l0;
|
||||
@@ -247,7 +245,6 @@ function foo_c() {
|
||||
var state_3 = _loop_4(y);
|
||||
if (typeof state_3 === "object") return state_3;
|
||||
if (state_3 === "break") break;
|
||||
if (state_3 === "continue") continue;
|
||||
switch(state_3) {
|
||||
case "break-l1": return state_3;
|
||||
case "break-ll1": break ll1;
|
||||
@@ -282,7 +279,6 @@ function foo_c() {
|
||||
var state_4 = _loop_3(x);
|
||||
if (typeof state_4 === "object") return state_4.value;
|
||||
if (state_4 === "break") break;
|
||||
if (state_4 === "continue") continue;
|
||||
switch(state_4) {
|
||||
case "break-l1": break l1;
|
||||
case "continue-l0": continue l0;
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractConstructor.ts(2,5): error TS1242: 'abstract' modifier can only appear on a class or method declaration.
|
||||
tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractConstructor.ts(2,5): error TS1242: 'abstract' modifier can only appear on a class, method, or property declaration.
|
||||
|
||||
|
||||
==== tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractConstructor.ts (1 errors) ====
|
||||
abstract class A {
|
||||
abstract constructor() {}
|
||||
~~~~~~~~
|
||||
!!! error TS1242: 'abstract' modifier can only appear on a class or method declaration.
|
||||
!!! error TS1242: 'abstract' modifier can only appear on a class, method, or property declaration.
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractDeclarations.d.ts(2,5): error TS1242: 'abstract' modifier can only appear on a class or method declaration.
|
||||
tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractDeclarations.d.ts(2,5): error TS1242: 'abstract' modifier can only appear on a class, method, or property declaration.
|
||||
tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractDeclarations.d.ts(2,28): error TS1183: An implementation cannot be declared in ambient contexts.
|
||||
tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractDeclarations.d.ts(11,15): error TS2515: Non-abstract class 'CC' does not implement inherited abstract member 'foo' from class 'AA'.
|
||||
tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractDeclarations.d.ts(13,15): error TS2515: Non-abstract class 'DD' does not implement inherited abstract member 'foo' from class 'BB'.
|
||||
@@ -9,7 +9,7 @@ tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbst
|
||||
declare abstract class A {
|
||||
abstract constructor() {}
|
||||
~~~~~~~~
|
||||
!!! error TS1242: 'abstract' modifier can only appear on a class or method declaration.
|
||||
!!! error TS1242: 'abstract' modifier can only appear on a class, method, or property declaration.
|
||||
~
|
||||
!!! error TS1183: An implementation cannot be declared in ambient contexts.
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbst
|
||||
tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations2.ts(21,1): error TS2511: Cannot create an instance of the abstract class 'B'.
|
||||
tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations2.ts(26,7): error TS2515: Non-abstract class 'C' does not implement inherited abstract member 'bar' from class 'B'.
|
||||
tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations2.ts(46,5): error TS2391: Function implementation is missing or not immediately following the declaration.
|
||||
tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations2.ts(46,5): error TS2512: Overload signatures must all be abstract or not abstract.
|
||||
tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations2.ts(46,5): error TS2512: Overload signatures must all be abstract or non-abstract.
|
||||
tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations2.ts(50,5): error TS1244: Abstract methods can only appear within an abstract class.
|
||||
|
||||
|
||||
@@ -70,7 +70,7 @@ tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbst
|
||||
~~~
|
||||
!!! error TS2391: Function implementation is missing or not immediately following the declaration.
|
||||
~~~
|
||||
!!! error TS2512: Overload signatures must all be abstract or not abstract.
|
||||
!!! error TS2512: Overload signatures must all be abstract or non-abstract.
|
||||
}
|
||||
|
||||
class H { // error -- not declared abstract
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractOverloads.ts(7,5): error TS2512: Overload signatures must all be abstract or not abstract.
|
||||
tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractOverloads.ts(10,14): error TS2512: Overload signatures must all be abstract or not abstract.
|
||||
tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractOverloads.ts(12,14): error TS2512: Overload signatures must all be abstract or not abstract.
|
||||
tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractOverloads.ts(7,5): error TS2512: Overload signatures must all be abstract or non-abstract.
|
||||
tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractOverloads.ts(10,14): error TS2512: Overload signatures must all be abstract or non-abstract.
|
||||
tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractOverloads.ts(12,14): error TS2512: Overload signatures must all be abstract or non-abstract.
|
||||
tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractOverloads.ts(15,5): error TS2391: Function implementation is missing or not immediately following the declaration.
|
||||
tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractOverloads.ts(20,14): error TS2516: All declarations of an abstract method must be consecutive.
|
||||
|
||||
@@ -14,16 +14,16 @@ tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbst
|
||||
abstract bar();
|
||||
bar();
|
||||
~~~
|
||||
!!! error TS2512: Overload signatures must all be abstract or not abstract.
|
||||
!!! error TS2512: Overload signatures must all be abstract or non-abstract.
|
||||
abstract bar();
|
||||
|
||||
abstract baz();
|
||||
~~~
|
||||
!!! error TS2512: Overload signatures must all be abstract or not abstract.
|
||||
!!! error TS2512: Overload signatures must all be abstract or non-abstract.
|
||||
baz();
|
||||
abstract baz();
|
||||
~~~
|
||||
!!! error TS2512: Overload signatures must all be abstract or not abstract.
|
||||
!!! error TS2512: Overload signatures must all be abstract or non-abstract.
|
||||
baz() {}
|
||||
|
||||
qux();
|
||||
|
||||
@@ -1,29 +1,17 @@
|
||||
tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractProperties.ts(2,5): error TS1242: 'abstract' modifier can only appear on a class or method declaration.
|
||||
tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractProperties.ts(3,12): error TS1242: 'abstract' modifier can only appear on a class or method declaration.
|
||||
tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractProperties.ts(4,15): error TS1242: 'abstract' modifier can only appear on a class or method declaration.
|
||||
tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractProperties.ts(5,13): error TS1242: 'abstract' modifier can only appear on a class or method declaration.
|
||||
tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractProperties.ts(7,5): error TS1242: 'abstract' modifier can only appear on a class or method declaration.
|
||||
tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractProperties.ts(5,13): error TS1243: 'private' modifier cannot be used with 'abstract' modifier.
|
||||
tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractProperties.ts(12,13): error TS1243: 'private' modifier cannot be used with 'abstract' modifier.
|
||||
|
||||
|
||||
==== tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractProperties.ts (6 errors) ====
|
||||
==== tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractProperties.ts (2 errors) ====
|
||||
abstract class A {
|
||||
abstract x : number;
|
||||
~~~~~~~~
|
||||
!!! error TS1242: 'abstract' modifier can only appear on a class or method declaration.
|
||||
public abstract y : number;
|
||||
~~~~~~~~
|
||||
!!! error TS1242: 'abstract' modifier can only appear on a class or method declaration.
|
||||
protected abstract z : number;
|
||||
~~~~~~~~
|
||||
!!! error TS1242: 'abstract' modifier can only appear on a class or method declaration.
|
||||
private abstract w : number;
|
||||
~~~~~~~~
|
||||
!!! error TS1242: 'abstract' modifier can only appear on a class or method declaration.
|
||||
!!! error TS1243: 'private' modifier cannot be used with 'abstract' modifier.
|
||||
|
||||
abstract m: () => void;
|
||||
~~~~~~~~
|
||||
!!! error TS1242: 'abstract' modifier can only appear on a class or method declaration.
|
||||
|
||||
abstract foo_x() : number;
|
||||
public abstract foo_y() : number;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractWithInterface.ts(1,1): error TS1242: 'abstract' modifier can only appear on a class or method declaration.
|
||||
tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractWithInterface.ts(1,1): error TS1242: 'abstract' modifier can only appear on a class, method, or property declaration.
|
||||
|
||||
|
||||
==== tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractWithInterface.ts (1 errors) ====
|
||||
abstract interface I {}
|
||||
~~~~~~~~
|
||||
!!! error TS1242: 'abstract' modifier can only appear on a class or method declaration.
|
||||
!!! error TS1242: 'abstract' modifier can only appear on a class, method, or property declaration.
|
||||
@@ -1,29 +1,30 @@
|
||||
tests/cases/conformance/classes/constructorDeclarations/classConstructorAccessibility.ts(6,5): error TS1089: 'private' modifier cannot appear on a constructor declaration.
|
||||
tests/cases/conformance/classes/constructorDeclarations/classConstructorAccessibility.ts(10,5): error TS1089: 'protected' modifier cannot appear on a constructor declaration.
|
||||
tests/cases/conformance/classes/constructorDeclarations/classConstructorAccessibility.ts(23,9): error TS1089: 'private' modifier cannot appear on a constructor declaration.
|
||||
tests/cases/conformance/classes/constructorDeclarations/classConstructorAccessibility.ts(27,9): error TS1089: 'protected' modifier cannot appear on a constructor declaration.
|
||||
tests/cases/conformance/classes/constructorDeclarations/classConstructorAccessibility.ts(15,9): error TS2673: Constructor of class 'D' is private and only accessible within the class declaration.
|
||||
tests/cases/conformance/classes/constructorDeclarations/classConstructorAccessibility.ts(16,9): error TS2674: Constructor of class 'E' is protected and only accessible within the class declaration.
|
||||
tests/cases/conformance/classes/constructorDeclarations/classConstructorAccessibility.ts(32,13): error TS2673: Constructor of class 'D<T>' is private and only accessible within the class declaration.
|
||||
tests/cases/conformance/classes/constructorDeclarations/classConstructorAccessibility.ts(33,13): error TS2674: Constructor of class 'E<T>' is protected and only accessible within the class declaration.
|
||||
|
||||
|
||||
==== tests/cases/conformance/classes/constructorDeclarations/classConstructorAccessibility.ts (4 errors) ====
|
||||
|
||||
class C {
|
||||
public constructor(public x: number) { }
|
||||
}
|
||||
|
||||
class D {
|
||||
private constructor(public x: number) { } // error
|
||||
~~~~~~~
|
||||
!!! error TS1089: 'private' modifier cannot appear on a constructor declaration.
|
||||
private constructor(public x: number) { }
|
||||
}
|
||||
|
||||
class E {
|
||||
protected constructor(public x: number) { } // error
|
||||
~~~~~~~~~
|
||||
!!! error TS1089: 'protected' modifier cannot appear on a constructor declaration.
|
||||
protected constructor(public x: number) { }
|
||||
}
|
||||
|
||||
var c = new C(1);
|
||||
var d = new D(1);
|
||||
var e = new E(1);
|
||||
var d = new D(1); // error
|
||||
~~~~~~~~
|
||||
!!! error TS2673: Constructor of class 'D' is private and only accessible within the class declaration.
|
||||
var e = new E(1); // error
|
||||
~~~~~~~~
|
||||
!!! error TS2674: Constructor of class 'E' is protected and only accessible within the class declaration.
|
||||
|
||||
module Generic {
|
||||
class C<T> {
|
||||
@@ -31,19 +32,19 @@ tests/cases/conformance/classes/constructorDeclarations/classConstructorAccessib
|
||||
}
|
||||
|
||||
class D<T> {
|
||||
private constructor(public x: T) { } // error
|
||||
~~~~~~~
|
||||
!!! error TS1089: 'private' modifier cannot appear on a constructor declaration.
|
||||
private constructor(public x: T) { }
|
||||
}
|
||||
|
||||
class E<T> {
|
||||
protected constructor(public x: T) { } // error
|
||||
~~~~~~~~~
|
||||
!!! error TS1089: 'protected' modifier cannot appear on a constructor declaration.
|
||||
protected constructor(public x: T) { }
|
||||
}
|
||||
|
||||
var c = new C(1);
|
||||
var d = new D(1);
|
||||
var e = new E(1);
|
||||
var d = new D(1); // error
|
||||
~~~~~~~~
|
||||
!!! error TS2673: Constructor of class 'D<T>' is private and only accessible within the class declaration.
|
||||
var e = new E(1); // error
|
||||
~~~~~~~~
|
||||
!!! error TS2674: Constructor of class 'E<T>' is protected and only accessible within the class declaration.
|
||||
}
|
||||
|
||||
@@ -1,19 +1,20 @@
|
||||
//// [classConstructorAccessibility.ts]
|
||||
|
||||
class C {
|
||||
public constructor(public x: number) { }
|
||||
}
|
||||
|
||||
class D {
|
||||
private constructor(public x: number) { } // error
|
||||
private constructor(public x: number) { }
|
||||
}
|
||||
|
||||
class E {
|
||||
protected constructor(public x: number) { } // error
|
||||
protected constructor(public x: number) { }
|
||||
}
|
||||
|
||||
var c = new C(1);
|
||||
var d = new D(1);
|
||||
var e = new E(1);
|
||||
var d = new D(1); // error
|
||||
var e = new E(1); // error
|
||||
|
||||
module Generic {
|
||||
class C<T> {
|
||||
@@ -21,16 +22,16 @@ module Generic {
|
||||
}
|
||||
|
||||
class D<T> {
|
||||
private constructor(public x: T) { } // error
|
||||
private constructor(public x: T) { }
|
||||
}
|
||||
|
||||
class E<T> {
|
||||
protected constructor(public x: T) { } // error
|
||||
protected constructor(public x: T) { }
|
||||
}
|
||||
|
||||
var c = new C(1);
|
||||
var d = new D(1);
|
||||
var e = new E(1);
|
||||
var d = new D(1); // error
|
||||
var e = new E(1); // error
|
||||
}
|
||||
|
||||
|
||||
@@ -44,18 +45,18 @@ var C = (function () {
|
||||
var D = (function () {
|
||||
function D(x) {
|
||||
this.x = x;
|
||||
} // error
|
||||
}
|
||||
return D;
|
||||
}());
|
||||
var E = (function () {
|
||||
function E(x) {
|
||||
this.x = x;
|
||||
} // error
|
||||
}
|
||||
return E;
|
||||
}());
|
||||
var c = new C(1);
|
||||
var d = new D(1);
|
||||
var e = new E(1);
|
||||
var d = new D(1); // error
|
||||
var e = new E(1); // error
|
||||
var Generic;
|
||||
(function (Generic) {
|
||||
var C = (function () {
|
||||
@@ -67,16 +68,36 @@ var Generic;
|
||||
var D = (function () {
|
||||
function D(x) {
|
||||
this.x = x;
|
||||
} // error
|
||||
}
|
||||
return D;
|
||||
}());
|
||||
var E = (function () {
|
||||
function E(x) {
|
||||
this.x = x;
|
||||
} // error
|
||||
}
|
||||
return E;
|
||||
}());
|
||||
var c = new C(1);
|
||||
var d = new D(1);
|
||||
var e = new E(1);
|
||||
var d = new D(1); // error
|
||||
var e = new E(1); // error
|
||||
})(Generic || (Generic = {}));
|
||||
|
||||
|
||||
//// [classConstructorAccessibility.d.ts]
|
||||
declare class C {
|
||||
x: number;
|
||||
constructor(x: number);
|
||||
}
|
||||
declare class D {
|
||||
x: number;
|
||||
private constructor(x);
|
||||
}
|
||||
declare class E {
|
||||
x: number;
|
||||
protected constructor(x: number);
|
||||
}
|
||||
declare var c: C;
|
||||
declare var d: any;
|
||||
declare var e: any;
|
||||
declare module Generic {
|
||||
}
|
||||
|
||||
@@ -0,0 +1,59 @@
|
||||
tests/cases/conformance/classes/constructorDeclarations/classConstructorAccessibility2.ts(26,28): error TS2674: Constructor of class 'BaseB' is protected and only accessible within the class declaration.
|
||||
tests/cases/conformance/classes/constructorDeclarations/classConstructorAccessibility2.ts(29,24): error TS2675: Cannot extend a class 'BaseC'. Class constructor is marked as private.
|
||||
tests/cases/conformance/classes/constructorDeclarations/classConstructorAccessibility2.ts(32,28): error TS2673: Constructor of class 'BaseC' is private and only accessible within the class declaration.
|
||||
tests/cases/conformance/classes/constructorDeclarations/classConstructorAccessibility2.ts(36,10): error TS2674: Constructor of class 'BaseB' is protected and only accessible within the class declaration.
|
||||
tests/cases/conformance/classes/constructorDeclarations/classConstructorAccessibility2.ts(37,10): error TS2673: Constructor of class 'BaseC' is private and only accessible within the class declaration.
|
||||
|
||||
|
||||
==== tests/cases/conformance/classes/constructorDeclarations/classConstructorAccessibility2.ts (5 errors) ====
|
||||
|
||||
class BaseA {
|
||||
public constructor(public x: number) { }
|
||||
createInstance() { new BaseA(1); }
|
||||
}
|
||||
|
||||
class BaseB {
|
||||
protected constructor(public x: number) { }
|
||||
createInstance() { new BaseB(1); }
|
||||
}
|
||||
|
||||
class BaseC {
|
||||
private constructor(public x: number) { }
|
||||
createInstance() { new BaseC(1); }
|
||||
}
|
||||
|
||||
class DerivedA extends BaseA {
|
||||
constructor(public x: number) { super(x); }
|
||||
createInstance() { new DerivedA(1); }
|
||||
createBaseInstance() { new BaseA(1); }
|
||||
}
|
||||
|
||||
class DerivedB extends BaseB {
|
||||
constructor(public x: number) { super(x); }
|
||||
createInstance() { new DerivedB(1); }
|
||||
createBaseInstance() { new BaseB(1); } // error
|
||||
~~~~~~~~~~~~
|
||||
!!! error TS2674: Constructor of class 'BaseB' is protected and only accessible within the class declaration.
|
||||
}
|
||||
|
||||
class DerivedC extends BaseC { // error
|
||||
~~~~~
|
||||
!!! error TS2675: Cannot extend a class 'BaseC'. Class constructor is marked as private.
|
||||
constructor(public x: number) { super(x); }
|
||||
createInstance() { new DerivedC(1); }
|
||||
createBaseInstance() { new BaseC(1); } // error
|
||||
~~~~~~~~~~~~
|
||||
!!! error TS2673: Constructor of class 'BaseC' is private and only accessible within the class declaration.
|
||||
}
|
||||
|
||||
var ba = new BaseA(1);
|
||||
var bb = new BaseB(1); // error
|
||||
~~~~~~~~~~~~
|
||||
!!! error TS2674: Constructor of class 'BaseB' is protected and only accessible within the class declaration.
|
||||
var bc = new BaseC(1); // error
|
||||
~~~~~~~~~~~~
|
||||
!!! error TS2673: Constructor of class 'BaseC' is private and only accessible within the class declaration.
|
||||
|
||||
var da = new DerivedA(1);
|
||||
var db = new DerivedB(1);
|
||||
var dc = new DerivedC(1);
|
||||
@@ -0,0 +1,148 @@
|
||||
//// [classConstructorAccessibility2.ts]
|
||||
|
||||
class BaseA {
|
||||
public constructor(public x: number) { }
|
||||
createInstance() { new BaseA(1); }
|
||||
}
|
||||
|
||||
class BaseB {
|
||||
protected constructor(public x: number) { }
|
||||
createInstance() { new BaseB(1); }
|
||||
}
|
||||
|
||||
class BaseC {
|
||||
private constructor(public x: number) { }
|
||||
createInstance() { new BaseC(1); }
|
||||
}
|
||||
|
||||
class DerivedA extends BaseA {
|
||||
constructor(public x: number) { super(x); }
|
||||
createInstance() { new DerivedA(1); }
|
||||
createBaseInstance() { new BaseA(1); }
|
||||
}
|
||||
|
||||
class DerivedB extends BaseB {
|
||||
constructor(public x: number) { super(x); }
|
||||
createInstance() { new DerivedB(1); }
|
||||
createBaseInstance() { new BaseB(1); } // error
|
||||
}
|
||||
|
||||
class DerivedC extends BaseC { // error
|
||||
constructor(public x: number) { super(x); }
|
||||
createInstance() { new DerivedC(1); }
|
||||
createBaseInstance() { new BaseC(1); } // error
|
||||
}
|
||||
|
||||
var ba = new BaseA(1);
|
||||
var bb = new BaseB(1); // error
|
||||
var bc = new BaseC(1); // error
|
||||
|
||||
var da = new DerivedA(1);
|
||||
var db = new DerivedB(1);
|
||||
var dc = new DerivedC(1);
|
||||
|
||||
//// [classConstructorAccessibility2.js]
|
||||
var __extends = (this && this.__extends) || function (d, b) {
|
||||
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
|
||||
function __() { this.constructor = d; }
|
||||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
||||
};
|
||||
var BaseA = (function () {
|
||||
function BaseA(x) {
|
||||
this.x = x;
|
||||
}
|
||||
BaseA.prototype.createInstance = function () { new BaseA(1); };
|
||||
return BaseA;
|
||||
}());
|
||||
var BaseB = (function () {
|
||||
function BaseB(x) {
|
||||
this.x = x;
|
||||
}
|
||||
BaseB.prototype.createInstance = function () { new BaseB(1); };
|
||||
return BaseB;
|
||||
}());
|
||||
var BaseC = (function () {
|
||||
function BaseC(x) {
|
||||
this.x = x;
|
||||
}
|
||||
BaseC.prototype.createInstance = function () { new BaseC(1); };
|
||||
return BaseC;
|
||||
}());
|
||||
var DerivedA = (function (_super) {
|
||||
__extends(DerivedA, _super);
|
||||
function DerivedA(x) {
|
||||
_super.call(this, x);
|
||||
this.x = x;
|
||||
}
|
||||
DerivedA.prototype.createInstance = function () { new DerivedA(1); };
|
||||
DerivedA.prototype.createBaseInstance = function () { new BaseA(1); };
|
||||
return DerivedA;
|
||||
}(BaseA));
|
||||
var DerivedB = (function (_super) {
|
||||
__extends(DerivedB, _super);
|
||||
function DerivedB(x) {
|
||||
_super.call(this, x);
|
||||
this.x = x;
|
||||
}
|
||||
DerivedB.prototype.createInstance = function () { new DerivedB(1); };
|
||||
DerivedB.prototype.createBaseInstance = function () { new BaseB(1); }; // error
|
||||
return DerivedB;
|
||||
}(BaseB));
|
||||
var DerivedC = (function (_super) {
|
||||
__extends(DerivedC, _super);
|
||||
function DerivedC(x) {
|
||||
_super.call(this, x);
|
||||
this.x = x;
|
||||
}
|
||||
DerivedC.prototype.createInstance = function () { new DerivedC(1); };
|
||||
DerivedC.prototype.createBaseInstance = function () { new BaseC(1); }; // error
|
||||
return DerivedC;
|
||||
}(BaseC));
|
||||
var ba = new BaseA(1);
|
||||
var bb = new BaseB(1); // error
|
||||
var bc = new BaseC(1); // error
|
||||
var da = new DerivedA(1);
|
||||
var db = new DerivedB(1);
|
||||
var dc = new DerivedC(1);
|
||||
|
||||
|
||||
//// [classConstructorAccessibility2.d.ts]
|
||||
declare class BaseA {
|
||||
x: number;
|
||||
constructor(x: number);
|
||||
createInstance(): void;
|
||||
}
|
||||
declare class BaseB {
|
||||
x: number;
|
||||
protected constructor(x: number);
|
||||
createInstance(): void;
|
||||
}
|
||||
declare class BaseC {
|
||||
x: number;
|
||||
private constructor(x);
|
||||
createInstance(): void;
|
||||
}
|
||||
declare class DerivedA extends BaseA {
|
||||
x: number;
|
||||
constructor(x: number);
|
||||
createInstance(): void;
|
||||
createBaseInstance(): void;
|
||||
}
|
||||
declare class DerivedB extends BaseB {
|
||||
x: number;
|
||||
constructor(x: number);
|
||||
createInstance(): void;
|
||||
createBaseInstance(): void;
|
||||
}
|
||||
declare class DerivedC extends BaseC {
|
||||
x: number;
|
||||
constructor(x: number);
|
||||
createInstance(): void;
|
||||
createBaseInstance(): void;
|
||||
}
|
||||
declare var ba: BaseA;
|
||||
declare var bb: any;
|
||||
declare var bc: any;
|
||||
declare var da: DerivedA;
|
||||
declare var db: DerivedB;
|
||||
declare var dc: DerivedC;
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user