Update with master

This commit is contained in:
Tingan Ho
2016-03-03 13:58:20 +08:00
286 changed files with 55086 additions and 22180 deletions
+1
View File
@@ -927,6 +927,7 @@ var servicesLintTargets = [
"patternMatcher.ts",
"services.ts",
"shims.ts",
"jsTyping.ts"
].map(function (s) {
return path.join(servicesDirectory, s);
});
+239 -156
View File
File diff suppressed because it is too large Load Diff
+287 -204
View File
File diff suppressed because it is too large Load Diff
+5344
View File
File diff suppressed because it is too large Load Diff
+251 -162
View File
File diff suppressed because it is too large Load Diff
+12 -6
View File
@@ -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;
+299 -210
View File
File diff suppressed because it is too large Load Diff
+18829
View File
File diff suppressed because it is too large Load Diff
+6 -5
View File
@@ -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
View File
File diff suppressed because it is too large Load Diff
+6098 -4896
View File
File diff suppressed because it is too large Load Diff
+232 -203
View File
@@ -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
View File
File diff suppressed because it is too large Load Diff
+232 -203
View File
@@ -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
View File
File diff suppressed because it is too large Load Diff
+8 -4
View File
@@ -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);
}
}
@@ -1221,7 +1225,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) {
+148 -44
View File
@@ -1159,7 +1159,7 @@ namespace ts {
const isRelative = isExternalModuleNameRelative(moduleName);
if (!isRelative) {
const symbol = getSymbol(globals, "\"" + moduleName + "\"", SymbolFlags.ValueModule);
const symbol = getSymbol(globals, '"' + moduleName + '"', SymbolFlags.ValueModule);
if (symbol) {
// merged symbol is module declaration symbol combined with all augmentations
return getMergedSymbol(symbol);
@@ -2176,7 +2176,12 @@ namespace ts {
if (isRestParameter(parameterNode)) {
writePunctuation(writer, SyntaxKind.DotDotDotToken);
}
appendSymbolNameOnly(p, writer);
if (isBindingPattern(parameterNode.name)) {
buildBindingPatternDisplay(<BindingPattern>parameterNode.name, writer, enclosingDeclaration, flags, symbolStack);
}
else {
appendSymbolNameOnly(p, writer);
}
if (isOptionalParameter(parameterNode)) {
writePunctuation(writer, SyntaxKind.QuestionToken);
}
@@ -2186,20 +2191,63 @@ namespace ts {
buildTypeDisplay(getTypeOfSymbol(p), writer, enclosingDeclaration, flags, symbolStack);
}
function buildBindingPatternDisplay(bindingPattern: BindingPattern, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags, symbolStack?: Symbol[]) {
// We have to explicitly emit square bracket and bracket because these tokens are not stored inside the node.
if (bindingPattern.kind === SyntaxKind.ObjectBindingPattern) {
writePunctuation(writer, SyntaxKind.OpenBraceToken);
buildDisplayForCommaSeparatedList(bindingPattern.elements, writer, e => buildBindingElementDisplay(e, writer, enclosingDeclaration, flags, symbolStack));
writePunctuation(writer, SyntaxKind.CloseBraceToken);
}
else if (bindingPattern.kind === SyntaxKind.ArrayBindingPattern) {
writePunctuation(writer, SyntaxKind.OpenBracketToken);
const elements = bindingPattern.elements;
buildDisplayForCommaSeparatedList(elements, writer, e => buildBindingElementDisplay(e, writer, enclosingDeclaration, flags, symbolStack));
if (elements && elements.hasTrailingComma) {
writePunctuation(writer, SyntaxKind.CommaToken);
}
writePunctuation(writer, SyntaxKind.CloseBracketToken);
}
}
function buildBindingElementDisplay(bindingElement: BindingElement, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags, symbolStack?: Symbol[]) {
if (bindingElement.kind === SyntaxKind.OmittedExpression) {
return;
}
Debug.assert(bindingElement.kind === SyntaxKind.BindingElement);
if (bindingElement.propertyName) {
writer.writeSymbol(getTextOfNode(bindingElement.propertyName), bindingElement.symbol);
writePunctuation(writer, SyntaxKind.ColonToken);
writeSpace(writer);
}
if (isBindingPattern(bindingElement.name)) {
buildBindingPatternDisplay(<BindingPattern>bindingElement.name, writer, enclosingDeclaration, flags, symbolStack);
}
else {
if (bindingElement.dotDotDotToken) {
writePunctuation(writer, SyntaxKind.DotDotDotToken);
}
appendSymbolNameOnly(bindingElement.symbol, writer);
}
}
function buildDisplayForTypeParametersAndDelimiters(typeParameters: TypeParameter[], writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags, symbolStack?: Symbol[]) {
if (typeParameters && typeParameters.length) {
writePunctuation(writer, SyntaxKind.LessThanToken);
for (let i = 0; i < typeParameters.length; i++) {
if (i > 0) {
writePunctuation(writer, SyntaxKind.CommaToken);
writeSpace(writer);
}
buildTypeParameterDisplay(typeParameters[i], writer, enclosingDeclaration, flags, symbolStack);
}
buildDisplayForCommaSeparatedList(typeParameters, writer, p => buildTypeParameterDisplay(p, writer, enclosingDeclaration, flags, symbolStack));
writePunctuation(writer, SyntaxKind.GreaterThanToken);
}
}
function buildDisplayForCommaSeparatedList<T>(list: T[], writer: SymbolWriter, action: (item: T) => void) {
for (let i = 0; i < list.length; i++) {
if (i > 0) {
writePunctuation(writer, SyntaxKind.CommaToken);
writeSpace(writer);
}
action(list[i]);
}
}
function buildDisplayForTypeArgumentsAndDelimiters(typeParameters: TypeParameter[], mapper: TypeMapper, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags, symbolStack?: Symbol[]) {
if (typeParameters && typeParameters.length) {
writePunctuation(writer, SyntaxKind.LessThanToken);
@@ -2556,7 +2604,7 @@ namespace ts {
return name.kind === SyntaxKind.ComputedPropertyName && !isStringOrNumericLiteral((<ComputedPropertyName>name).expression.kind);
}
// Return the inferred type for a binding element
/** Return the inferred type for a binding element */
function getTypeForBindingElement(declaration: BindingElement): Type {
const pattern = <BindingPattern>declaration.parent;
const parentType = getTypeForBindingElementParent(<VariableLikeDeclaration>pattern.parent);
@@ -2582,6 +2630,9 @@ namespace ts {
// computed properties with non-literal names are treated as 'any'
return anyType;
}
if (declaration.initializer) {
getContextualType(declaration.initializer);
}
// Use type of the specified property, or otherwise, for a numeric name, the type of the numeric index signature,
// or otherwise the type of the string index signature.
@@ -5286,7 +5337,7 @@ namespace ts {
for (let i = 0; i < checkCount; i++) {
const s = i < sourceMax ? getTypeOfSymbol(sourceParams[i]) : getRestTypeOfSignature(source);
const t = i < targetMax ? getTypeOfSymbol(targetParams[i]) : getRestTypeOfSignature(target);
const related = compareTypes(t, s, /*reportErrors*/ false) || compareTypes(s, t, reportErrors);
const related = compareTypes(s, t, /*reportErrors*/ false) || compareTypes(t, s, reportErrors);
if (!related) {
if (reportErrors) {
errorReporter(Diagnostics.Types_of_parameters_0_and_1_are_incompatible,
@@ -5521,8 +5572,20 @@ namespace ts {
// on either side that need to be prioritized. For example, A | B = (A | B) & (C | D) or
// A & B = (A & B) | (C & D).
if (source.flags & TypeFlags.Intersection) {
// If target is a union type the following check will report errors so we suppress them here
if (result = someTypeRelatedToType(<IntersectionType>source, target, reportErrors && !(target.flags & TypeFlags.Union))) {
// Check to see if any constituents of the intersection are immediately related to the target.
//
// Don't report errors though. Checking whether a constituent is related to the source is not actually
// useful and leads to some confusing error messages. Instead it is better to let the below checks
// take care of this, or to not elaborate at all. For instance,
//
// - For an object type (such as 'C = A & B'), users are usually more interested in structural errors.
//
// - For a union type (such as '(A | B) = (C & D)'), it's better to hold onto the whole intersection
// than to report that 'D' is not assignable to 'A' or 'B'.
//
// - For a primitive type or type parameter (such as 'number = A & B') there is no point in
// breaking the intersection apart.
if (result = someTypeRelatedToType(<IntersectionType>source, target, /*reportErrors*/ false)) {
return result;
}
}
@@ -6524,6 +6587,7 @@ namespace ts {
let targetStack: Type[];
let depth = 0;
let inferiority = 0;
const visited: Map<boolean> = {};
inferFromTypes(source, target);
function isInProcess(source: Type, target: Type) {
@@ -6653,6 +6717,12 @@ namespace ts {
return;
}
const key = source.id + "," + target.id;
if (hasProperty(visited, key)) {
return;
}
visited[key] = true;
if (depth === 0) {
sourceStack = [];
targetStack = [];
@@ -7758,11 +7828,14 @@ namespace ts {
return undefined;
}
// In a variable, parameter or property declaration with a type annotation, the contextual type of an initializer
// expression is the type of the variable, parameter or property. Otherwise, in a parameter declaration of a
// contextually typed function expression, the contextual type of an initializer expression is the contextual type
// of the parameter. Otherwise, in a variable or parameter declaration with a binding pattern name, the contextual
// type of an initializer expression is the type implied by the binding pattern.
// In a variable, parameter or property declaration with a type annotation,
// the contextual type of an initializer expression is the type of the variable, parameter or property.
// Otherwise, in a parameter declaration of a contextually typed function expression,
// the contextual type of an initializer expression is the contextual type of the parameter.
// Otherwise, in a variable or parameter declaration with a binding pattern name,
// the contextual type of an initializer expression is the type implied by the binding pattern.
// Otherwise, in a binding pattern inside a variable or parameter declaration,
// the contextual type of an initializer expression is the type annotation of the containing declaration, if present.
function getContextualTypeForInitializerExpression(node: Expression): Type {
const declaration = <VariableLikeDeclaration>node.parent;
if (node === declaration.initializer) {
@@ -7778,6 +7851,18 @@ namespace ts {
if (isBindingPattern(declaration.name)) {
return getTypeFromBindingPattern(<BindingPattern>declaration.name, /*includePatternInType*/ true);
}
if (isBindingPattern(declaration.parent)) {
const parentDeclaration = declaration.parent.parent;
const name = declaration.propertyName || declaration.name;
if (isVariableLike(parentDeclaration) &&
parentDeclaration.type &&
!isBindingPattern(name)) {
const text = getTextOfPropertyName(name);
if (text) {
return getTypeOfPropertyOfType(getTypeFromTypeNode(parentDeclaration.type), text);
}
}
}
}
return undefined;
}
@@ -8712,18 +8797,20 @@ namespace ts {
if (!elemClassType || !isTypeAssignableTo(elemInstanceType, elemClassType)) {
// Is this is a stateless function component? See if its single signature's return type is
// assignable to the JSX Element Type
const elemType = checkExpression(node.tagName);
const callSignatures = elemType && getSignaturesOfType(elemType, SignatureKind.Call);
const callSignature = callSignatures && callSignatures.length > 0 && callSignatures[0];
const callReturnType = callSignature && getReturnTypeOfSignature(callSignature);
let paramType = callReturnType && (callSignature.parameters.length === 0 ? emptyObjectType : getTypeOfSymbol(callSignature.parameters[0]));
if (callReturnType && isTypeAssignableTo(callReturnType, jsxElementType)) {
// Intersect in JSX.IntrinsicAttributes if it exists
const intrinsicAttributes = getJsxType(JsxNames.IntrinsicAttributes);
if (intrinsicAttributes !== unknownType) {
paramType = intersectTypes(intrinsicAttributes, paramType);
if (jsxElementType) {
const elemType = checkExpression(node.tagName);
const callSignatures = elemType && getSignaturesOfType(elemType, SignatureKind.Call);
const callSignature = callSignatures && callSignatures.length > 0 && callSignatures[0];
const callReturnType = callSignature && getReturnTypeOfSignature(callSignature);
let paramType = callReturnType && (callSignature.parameters.length === 0 ? emptyObjectType : getTypeOfSymbol(callSignature.parameters[0]));
if (callReturnType && isTypeAssignableTo(callReturnType, jsxElementType)) {
// Intersect in JSX.IntrinsicAttributes if it exists
const intrinsicAttributes = getJsxType(JsxNames.IntrinsicAttributes);
if (intrinsicAttributes !== unknownType) {
paramType = intersectTypes(intrinsicAttributes, paramType);
}
return links.resolvedJsxType = paramType;
}
return links.resolvedJsxType = paramType;
}
}
@@ -8904,15 +8991,13 @@ namespace ts {
* @param type The type of left.
* @param prop The symbol for the right hand side of the property access.
*/
function checkClassPropertyAccess(node: PropertyAccessExpression | QualifiedName, left: Expression | QualifiedName, type: Type, prop: Symbol): boolean {
function checkClassPropertyAccess(node: PropertyAccessExpression | QualifiedName | VariableLikeDeclaration, left: Expression | QualifiedName, type: Type, prop: Symbol): boolean {
const flags = getDeclarationFlagsFromSymbol(prop);
const declaringClass = <InterfaceType>getDeclaredTypeOfSymbol(getParentOfSymbol(prop));
const errorNode = node.kind === SyntaxKind.PropertyAccessExpression || node.kind === SyntaxKind.VariableDeclaration ?
(<PropertyAccessExpression | VariableDeclaration>node).name :
(<QualifiedName>node).right;
if (left.kind === SyntaxKind.SuperKeyword) {
const errorNode = node.kind === SyntaxKind.PropertyAccessExpression ?
(<PropertyAccessExpression>node).name :
(<QualifiedName>node).right;
// TS 1.0 spec (April 2014): 4.8.2
// - In a constructor, instance member function, instance member accessor, or
// instance member variable initializer where this references a derived class instance,
@@ -8953,7 +9038,7 @@ namespace ts {
// Private property is accessible if declaring and enclosing class are the same
if (flags & NodeFlags.Private) {
if (declaringClass !== enclosingClass) {
error(node, Diagnostics.Property_0_is_private_and_only_accessible_within_class_1, symbolToString(prop), typeToString(declaringClass));
error(errorNode, Diagnostics.Property_0_is_private_and_only_accessible_within_class_1, symbolToString(prop), typeToString(declaringClass));
return false;
}
return true;
@@ -8967,7 +9052,7 @@ namespace ts {
}
// A protected property is accessible in the declaring class and classes derived from it
if (!enclosingClass || !hasBaseType(enclosingClass, declaringClass)) {
error(node, Diagnostics.Property_0_is_protected_and_only_accessible_within_class_1_and_its_subclasses, symbolToString(prop), typeToString(declaringClass));
error(errorNode, Diagnostics.Property_0_is_protected_and_only_accessible_within_class_1_and_its_subclasses, symbolToString(prop), typeToString(declaringClass));
return false;
}
// No further restrictions for static properties
@@ -8982,7 +9067,7 @@ namespace ts {
// TODO: why is the first part of this check here?
if (!(getTargetType(type).flags & (TypeFlags.Class | TypeFlags.Interface) && hasBaseType(<InterfaceType>type, enclosingClass))) {
error(node, Diagnostics.Property_0_is_protected_and_only_accessible_through_an_instance_of_class_1, symbolToString(prop), typeToString(enclosingClass));
error(errorNode, Diagnostics.Property_0_is_protected_and_only_accessible_through_an_instance_of_class_1, symbolToString(prop), typeToString(enclosingClass));
return false;
}
return true;
@@ -10735,6 +10820,7 @@ namespace ts {
// The identityMapper object is used to indicate that function expressions are wildcards
if (contextualMapper === identityMapper && isContextSensitive(node)) {
checkNodeDeferred(node);
return anyFunctionType;
}
@@ -11729,9 +11815,12 @@ namespace ts {
Diagnostics.A_type_predicate_cannot_reference_a_rest_parameter);
}
else {
const leadingError = chainDiagnosticMessages(undefined, Diagnostics.A_type_predicate_s_type_must_be_assignable_to_its_parameter_s_type);
checkTypeAssignableTo(typePredicate.type,
getTypeOfNode(parent.parameters[typePredicate.parameterIndex]),
node.type);
node.type,
/*headMessage*/ undefined,
leadingError);
}
}
else if (parameterName) {
@@ -12051,6 +12140,9 @@ namespace ts {
if (((node.flags & NodeFlags.AccessibilityModifier) !== (otherAccessor.flags & NodeFlags.AccessibilityModifier))) {
error(node.name, Diagnostics.Getter_and_setter_accessors_do_not_agree_in_visibility);
}
if (((node.flags & NodeFlags.Abstract) !== (otherAccessor.flags & NodeFlags.Abstract))) {
error(node.name, Diagnostics.Accessors_must_both_be_abstract_or_non_abstract);
}
const currentAccessorType = getAnnotatedAccessorType(node);
const otherAccessorType = getAnnotatedAccessorType(otherAccessor);
@@ -12196,7 +12288,7 @@ namespace ts {
forEach(overloads, o => {
const deviation = getEffectiveDeclarationFlags(o, flagsToCheck) ^ canonicalFlags;
if (deviation & NodeFlags.Export) {
error(o.name, Diagnostics.Overload_signatures_must_all_be_exported_or_not_exported);
error(o.name, Diagnostics.Overload_signatures_must_all_be_exported_or_non_exported);
}
else if (deviation & NodeFlags.Ambient) {
error(o.name, Diagnostics.Overload_signatures_must_all_be_ambient_or_non_ambient);
@@ -12205,7 +12297,7 @@ namespace ts {
error(o.name || o, Diagnostics.Overload_signatures_must_all_be_public_private_or_protected);
}
else if (deviation & NodeFlags.Abstract) {
error(o.name, Diagnostics.Overload_signatures_must_all_be_abstract_or_not_abstract);
error(o.name, Diagnostics.Overload_signatures_must_all_be_abstract_or_non_abstract);
}
});
}
@@ -13239,6 +13331,15 @@ namespace ts {
if (node.propertyName && node.propertyName.kind === SyntaxKind.ComputedPropertyName) {
checkComputedPropertyName(<ComputedPropertyName>node.propertyName);
}
// check private/protected variable access
const parent = <VariableLikeDeclaration>(<BindingPattern>node.parent).parent;
const parentType = getTypeForBindingElementParent(parent);
const name = node.propertyName || <Identifier>node.name;
const property = getPropertyOfType(parentType, getTextOfPropertyName(name));
if (parent.initializer && property && getParentOfSymbol(property)) {
checkClassPropertyAccess(parent, parent.initializer, parentType, property);
}
}
// For a binding pattern, check contained binding elements
@@ -16498,8 +16599,11 @@ namespace ts {
return grammarErrorOnNode(modifier, Diagnostics._0_modifier_already_seen, "abstract");
}
if (node.kind !== SyntaxKind.ClassDeclaration) {
if (node.kind !== SyntaxKind.MethodDeclaration) {
return grammarErrorOnNode(modifier, Diagnostics.abstract_modifier_can_only_appear_on_a_class_or_method_declaration);
if (node.kind !== SyntaxKind.MethodDeclaration &&
node.kind !== SyntaxKind.PropertyDeclaration &&
node.kind !== SyntaxKind.GetAccessor &&
node.kind !== SyntaxKind.SetAccessor) {
return grammarErrorOnNode(modifier, Diagnostics.abstract_modifier_can_only_appear_on_a_class_method_or_property_declaration);
}
if (!(node.parent.kind === SyntaxKind.ClassDeclaration && node.parent.flags & NodeFlags.Abstract)) {
return grammarErrorOnNode(modifier, Diagnostics.Abstract_methods_can_only_appear_within_an_abstract_class);
@@ -16993,7 +17097,7 @@ namespace ts {
else if (isInAmbientContext(accessor)) {
return grammarErrorOnNode(accessor.name, Diagnostics.An_accessor_cannot_be_declared_in_an_ambient_context);
}
else if (accessor.body === undefined) {
else if (accessor.body === undefined && !(accessor.flags & NodeFlags.Abstract)) {
return grammarErrorAtPos(getSourceFileOfNode(accessor), accessor.end - 1, ";".length, Diagnostics._0_expected, "{");
}
else if (accessor.typeParameters) {
+61 -22
View File
@@ -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",
@@ -537,6 +543,7 @@ namespace ts {
return {
options,
fileNames: getFileNames(),
typingOptions: getTypingOptions(),
errors
};
@@ -601,6 +608,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[] } {
@@ -641,28 +677,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 === "") {
@@ -682,4 +697,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;
}
}
+34
View File
@@ -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.
*/
+4 -4
View File
@@ -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;
}
}
@@ -1679,7 +1679,7 @@ namespace ts {
host.getCanonicalFileName,
/*isAbsolutePathAnUrl*/ false);
referencePathsOutput += "/// <reference path=\"" + declFileName + "\" />" + newLine;
referencePathsOutput += '/// <reference path="' + declFileName + '" />' + newLine;
}
return addedBundledEmitReference;
+15 -3
View File
@@ -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
},
@@ -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
},
@@ -1843,6 +1843,14 @@
"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
},
"Import declaration '{0}' is using private name '{1}'.": {
"category": "Error",
"code": 4000
@@ -2800,5 +2808,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
}
}
+27 -29
View File
@@ -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(".");
@@ -3232,8 +3232,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 +3275,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 +3572,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 +3790,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 +3826,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");
@@ -6600,7 +6598,7 @@ const _super = (function (geti, seti) {
emitEs6ExportDefaultCompat(node);
emitContainingModuleName(node);
if (languageVersion === ScriptTarget.ES3) {
write("[\"default\"] = ");
write('["default"] = ');
}
else {
write(".default = ");
@@ -7322,11 +7320,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 + '"');
}
}
@@ -7368,7 +7366,7 @@ const _super = (function (geti, seti) {
}
function emitAMDDependencyList({ aliasedModuleNames, unaliasedModuleNames }: AMDDependencyNames) {
write("[\"require\", \"exports\"");
write('["require", "exports"');
if (aliasedModuleNames.length) {
write(", ");
write(aliasedModuleNames.join(", "));
@@ -7402,8 +7400,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("});");
@@ -7416,8 +7414,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) {
@@ -7443,8 +7441,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("});");
@@ -7502,7 +7500,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;
}
@@ -7525,7 +7523,7 @@ const _super = (function (geti, seti) {
if (entities[m] !== undefined) {
const ch = String.fromCharCode(entities[m]);
// &quot; needs to be escaped
return ch === "\"" ? "\\\"" : ch;
return ch === '"' ? "\\\"" : ch;
}
else {
return s;
@@ -7569,9 +7567,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:
+1 -23
View File
@@ -407,23 +407,6 @@ namespace ts {
return result;
}
/* @internal */
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.TS;
}
}
// 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
@@ -551,12 +534,7 @@ namespace ts {
let parseErrorBeforeNextFinishedNode = false;
export function parseSourceFile(fileName: string, _sourceText: string, languageVersion: ScriptTarget, _syntaxCursor: IncrementalParser.SyntaxCursor, setParentNodes?: boolean, scriptKind?: ScriptKind): SourceFile {
// 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 attempt
// to get the ScriptKind from the file name.
scriptKind = scriptKind ? scriptKind : getScriptKindFromFileName(fileName);
scriptKind = ensureScriptKind(fileName, scriptKind);
initializeState(fileName, _sourceText, languageVersion, _syntaxCursor, scriptKind);
+26 -8
View File
@@ -1030,7 +1030,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[] {
@@ -1244,17 +1251,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());
@@ -1670,6 +1679,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;
+8 -4
View File
@@ -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);
@@ -415,7 +419,7 @@ namespace ts {
const compileResult = compile(rootFileNames, compilerOptions, compilerHost);
if (!compilerOptions.watch) {
if (!isWatchSet(compilerOptions)) {
return sys.exit(compileResult.exitStatus);
}
@@ -441,7 +445,7 @@ namespace ts {
}
// Use default host function
const sourceFile = hostGetSourceFile(fileName, languageVersion, onError);
if (sourceFile && compilerOptions.watch) {
if (sourceFile && isWatchSet(compilerOptions)) {
// 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));
+20 -1
View File
@@ -411,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,
@@ -2371,6 +2371,7 @@ namespace ts {
allowNonTsExtensions?: boolean;
charset?: string;
declaration?: boolean;
declarationDir?: string;
diagnostics?: boolean;
emitBOM?: boolean;
help?: boolean;
@@ -2432,6 +2433,23 @@ 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.
cachePath: string; // The path to the typings cache
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,
@@ -2490,6 +2508,7 @@ namespace ts {
export interface ParsedCommandLine {
options: CompilerOptions;
typingOptions?: TypingOptions;
fileNames: string[];
errors: Diagnostic[];
}
+18 -10
View File
@@ -2012,6 +2012,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 +2077,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 +2102,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) {
+2 -2
View File
@@ -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.
+2 -2
View File
@@ -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: {
+8 -8
View File
@@ -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);
}
}
+1 -1
View File
@@ -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);
}
}
}
+3 -3
View File
@@ -194,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);
@@ -429,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) {
@@ -611,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) {
+1 -1
View File
@@ -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);
};
+4 -4
View File
@@ -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)));
});
}
+32 -32
View File
@@ -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");
}
}
+1 -1
View File
@@ -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.
*/
+2 -2
View File
@@ -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) {
+6 -6
View File
@@ -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.
*/
+1 -1
View 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))) {
+4 -4
View File
@@ -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);
}
}
+1 -1
View File
@@ -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;
+1 -1
View File
@@ -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);
+2 -2
View File
@@ -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);
}
+229
View File
@@ -0,0 +1,229 @@
// 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 cachePath is the path to the typings cache
* @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[],
cachePath: Path,
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);
}
}
}
+50 -50
View File
@@ -155,18 +155,18 @@ namespace ts.NavigationBar {
switch (node.kind) {
case SyntaxKind.ClassDeclaration:
topLevelNodes.push(node);
for (const member of (<ClassDeclaration>node).members) {
if (member.kind === SyntaxKind.MethodDeclaration || member.kind === SyntaxKind.Constructor) {
type FunctionLikeMember = MethodDeclaration | ConstructorDeclaration;
if ((<FunctionLikeMember>member).body) {
// We do not include methods that does not have child functions in it, because of duplications.
if (hasNamedFunctionDeclarations((<Block>(<FunctionLikeMember>member).body).statements)) {
topLevelNodes.push(member);
}
addTopLevelNodes((<Block>(<MethodDeclaration>member).body).statements, topLevelNodes);
for (const member of (<ClassDeclaration>node).members) {
if (member.kind === SyntaxKind.MethodDeclaration || member.kind === SyntaxKind.Constructor) {
type FunctionLikeMember = MethodDeclaration | ConstructorDeclaration;
if ((<FunctionLikeMember>member).body) {
// We do not include methods that does not have child functions in it, because of duplications.
if (hasNamedFunctionDeclarations((<Block>(<FunctionLikeMember>member).body).statements)) {
topLevelNodes.push(member);
}
addTopLevelNodes((<Block>(<MethodDeclaration>member).body).statements, topLevelNodes);
}
}
}
}
break;
case SyntaxKind.EnumDeclaration:
case SyntaxKind.InterfaceDeclaration:
@@ -190,24 +190,24 @@ namespace ts.NavigationBar {
}
}
function hasNamedFunctionDeclarations(nodes: NodeArray<Statement>) {
if (forEach(nodes, s => s.kind === SyntaxKind.FunctionDeclaration && !isEmpty((<FunctionDeclaration>s).name.text))) {
return true;
}
}
function hasNamedFunctionDeclarations(nodes: NodeArray<Statement>) {
if (forEach(nodes, s => s.kind === SyntaxKind.FunctionDeclaration && !isEmpty((<FunctionDeclaration>s).name.text))) {
return true;
}
}
function isTopLevelFunctionDeclaration(functionDeclaration: FunctionLikeDeclaration) {
if (functionDeclaration.kind === SyntaxKind.FunctionDeclaration) {
// A function declaration is 'top level' if it contains any function declarations
// within it.
if (functionDeclaration.body && functionDeclaration.body.kind === SyntaxKind.Block) {
// Proper function declarations can only have identifier names
if (hasNamedFunctionDeclarations((<Block>functionDeclaration.body).statements)) {
if (hasNamedFunctionDeclarations((<Block>functionDeclaration.body).statements)) {
return true;
}
// Or if it is not parented by another function (except for parent functions that
// are methods and constructors). I.e all functions at module scope are 'top level'.
// Or if it is not parented by another function (except for parent functions that
// are methods and constructors). I.e all functions at module scope are 'top level'.
if (!isFunctionBlock(functionDeclaration.parent)) {
return true;
}
@@ -395,16 +395,16 @@ namespace ts.NavigationBar {
case SyntaxKind.ClassDeclaration:
return createClassItem(<ClassDeclaration>node);
case SyntaxKind.MethodDeclaration:
case SyntaxKind.Constructor:
return createMemberFunctionLikeItem(<MethodDeclaration | ConstructorDeclaration>node);
case SyntaxKind.MethodDeclaration:
case SyntaxKind.Constructor:
return createMemberFunctionLikeItem(<MethodDeclaration | ConstructorDeclaration>node);
case SyntaxKind.EnumDeclaration:
return createEnumItem(<EnumDeclaration>node);
case SyntaxKind.InterfaceDeclaration:
return createInterfaceItem(<InterfaceDeclaration>node);
return createInterfaceItem(<InterfaceDeclaration>node);
case SyntaxKind.ModuleDeclaration:
return createModuleItem(<ModuleDeclaration>node);
@@ -462,31 +462,31 @@ namespace ts.NavigationBar {
return undefined;
}
function createMemberFunctionLikeItem(node: MethodDeclaration | ConstructorDeclaration) {
if (node.body && node.body.kind === SyntaxKind.Block) {
let childItems = getItemsWorker(sortNodes((<Block>node.body).statements), createChildItem);
let scriptElementKind: string;
let memberFunctionName: string;
if (node.kind === SyntaxKind.MethodDeclaration) {
memberFunctionName = getPropertyNameForPropertyNameNode(node.name);
scriptElementKind = ts.ScriptElementKind.memberFunctionElement;
}
else {
memberFunctionName = "constructor";
scriptElementKind = ts.ScriptElementKind.constructorImplementationElement;
}
return getNavigationBarItem(memberFunctionName,
scriptElementKind,
getNodeModifiers(node),
[getNodeSpan(node)],
childItems,
getIndent(node));
}
return undefined;
}
function createMemberFunctionLikeItem(node: MethodDeclaration | ConstructorDeclaration) {
if (node.body && node.body.kind === SyntaxKind.Block) {
let childItems = getItemsWorker(sortNodes((<Block>node.body).statements), createChildItem);
let scriptElementKind: string;
let memberFunctionName: string;
if (node.kind === SyntaxKind.MethodDeclaration) {
memberFunctionName = getPropertyNameForPropertyNameNode(node.name);
scriptElementKind = ts.ScriptElementKind.memberFunctionElement;
}
else {
memberFunctionName = "constructor";
scriptElementKind = ts.ScriptElementKind.constructorImplementationElement;
}
return getNavigationBarItem(memberFunctionName,
scriptElementKind,
getNodeModifiers(node),
[getNodeSpan(node)],
childItems,
getIndent(node));
}
return undefined;
}
function createSourceFileItem(node: SourceFile): ts.NavigationBarItem {
let childItems = getItemsWorker(getChildNodes(node.statements), createChildItem);
@@ -548,7 +548,7 @@ namespace ts.NavigationBar {
getIndent(node));
}
function createInterfaceItem(node: InterfaceDeclaration): ts.NavigationBarItem {
function createInterfaceItem(node: InterfaceDeclaration): ts.NavigationBarItem {
let childItems = getItemsWorker(sortNodes(removeDynamicallyNamedProperties(node)), createChildItem);
return getNavigationBarItem(
node.name.text,
+1 -1
View File
@@ -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 ||
+4 -4
View File
@@ -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' />
@@ -1751,14 +1752,13 @@ namespace ts {
private createEntry(fileName: string, path: Path) {
let entry: HostFileInformation;
const scriptKind = this.host.getScriptKind ? this.host.getScriptKind(fileName) : ScriptKind.Unknown;
const scriptSnapshot = this.host.getScriptSnapshot(fileName);
if (scriptSnapshot) {
entry = {
hostFileName: fileName,
version: this.host.getScriptVersion(fileName),
scriptSnapshot: scriptSnapshot,
scriptKind: scriptKind ? scriptKind : getScriptKindFromFileName(fileName)
scriptKind: getScriptKind(fileName, this.host)
};
}
@@ -1824,7 +1824,7 @@ namespace ts {
throw new Error("Could not find file: '" + fileName + "'.");
}
const scriptKind = this.host.getScriptKind ? this.host.getScriptKind(fileName) : ScriptKind.Unknown;
const scriptKind = getScriptKind(fileName, this.host);
const version = this.host.getScriptVersion(fileName);
let sourceFile: SourceFile;
@@ -3134,7 +3134,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;
+31 -4
View File
@@ -78,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;
}
@@ -232,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) {
@@ -422,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);
}
@@ -754,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);
});
@@ -953,6 +962,7 @@ namespace ts {
if (result.error) {
return {
options: {},
typingOptions: {},
files: [],
errors: [realizeDiagnostic(result.error, "\r\n")]
};
@@ -963,6 +973,7 @@ namespace ts {
return {
options: configFile.options,
typingOptions: configFile.typingOptions,
files: configFile.fileNames,
errors: realizeDiagnostics(configFile.errors, "\r\n")
};
@@ -975,6 +986,22 @@ 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.cachePath, info.cachePath, getCanonicalFileName),
toPath(info.projectRootPath, info.projectRootPath, getCanonicalFileName),
toPath(info.safeListPath, info.safeListPath, getCanonicalFileName),
info.packageNameToTypingLocation,
info.typingOptions,
info.compilerOptions);
});
}
}
export class TypeScriptServicesFactory implements ShimFactory {
+3 -3
View File
@@ -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;
// }
+1
View File
@@ -29,6 +29,7 @@
"shims.ts",
"signatureHelp.ts",
"utilities.ts",
"jsTyping.ts",
"formatting/formatting.ts",
"formatting/formattingContext.ts",
"formatting/formattingRequestKind.ts",
+17 -2
View File
@@ -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);
}
}
@@ -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>'.
}
}
@@ -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.
@@ -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'.
@@ -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++; };
@@ -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,5 +1,5 @@
tests/cases/conformance/classes/constructorDeclarations/classConstructorParametersAccessibility.ts(12,1): error TS2341: Property 'p' is private and only accessible within class 'C2'.
tests/cases/conformance/classes/constructorDeclarations/classConstructorParametersAccessibility.ts(19,1): error TS2445: Property 'p' is protected and only accessible within class 'C3' and its subclasses.
tests/cases/conformance/classes/constructorDeclarations/classConstructorParametersAccessibility.ts(12,4): error TS2341: Property 'p' is private and only accessible within class 'C2'.
tests/cases/conformance/classes/constructorDeclarations/classConstructorParametersAccessibility.ts(19,4): error TS2445: Property 'p' is protected and only accessible within class 'C3' and its subclasses.
==== tests/cases/conformance/classes/constructorDeclarations/classConstructorParametersAccessibility.ts (2 errors) ====
@@ -15,7 +15,7 @@ tests/cases/conformance/classes/constructorDeclarations/classConstructorParamete
}
var c2: C2;
c2.p // private, error
~~~~
~
!!! error TS2341: Property 'p' is private and only accessible within class 'C2'.
@@ -24,7 +24,7 @@ tests/cases/conformance/classes/constructorDeclarations/classConstructorParamete
}
var c3: C3;
c3.p // protected, error
~~~~
~
!!! error TS2445: Property 'p' is protected and only accessible within class 'C3' and its subclasses.
class Derived extends C3 {
constructor(p: number) {
@@ -1,5 +1,5 @@
tests/cases/conformance/classes/constructorDeclarations/classConstructorParametersAccessibility2.ts(12,1): error TS2341: Property 'p' is private and only accessible within class 'C2'.
tests/cases/conformance/classes/constructorDeclarations/classConstructorParametersAccessibility2.ts(19,1): error TS2445: Property 'p' is protected and only accessible within class 'C3' and its subclasses.
tests/cases/conformance/classes/constructorDeclarations/classConstructorParametersAccessibility2.ts(12,4): error TS2341: Property 'p' is private and only accessible within class 'C2'.
tests/cases/conformance/classes/constructorDeclarations/classConstructorParametersAccessibility2.ts(19,4): error TS2445: Property 'p' is protected and only accessible within class 'C3' and its subclasses.
==== tests/cases/conformance/classes/constructorDeclarations/classConstructorParametersAccessibility2.ts (2 errors) ====
@@ -15,7 +15,7 @@ tests/cases/conformance/classes/constructorDeclarations/classConstructorParamete
}
var c2: C2;
c2.p // private, error
~~~~
~
!!! error TS2341: Property 'p' is private and only accessible within class 'C2'.
@@ -24,7 +24,7 @@ tests/cases/conformance/classes/constructorDeclarations/classConstructorParamete
}
var c3: C3;
c3.p // protected, error
~~~~
~
!!! error TS2445: Property 'p' is protected and only accessible within class 'C3' and its subclasses.
class Derived extends C3 {
constructor(p: number) {
@@ -2,14 +2,14 @@ tests/cases/conformance/classes/members/accessibility/classPropertyAsPrivate.ts(
tests/cases/conformance/classes/members/accessibility/classPropertyAsPrivate.ts(4,17): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
tests/cases/conformance/classes/members/accessibility/classPropertyAsPrivate.ts(8,24): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
tests/cases/conformance/classes/members/accessibility/classPropertyAsPrivate.ts(9,24): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
tests/cases/conformance/classes/members/accessibility/classPropertyAsPrivate.ts(15,1): error TS2341: Property 'x' is private and only accessible within class 'C'.
tests/cases/conformance/classes/members/accessibility/classPropertyAsPrivate.ts(16,1): error TS2341: Property 'y' is private and only accessible within class 'C'.
tests/cases/conformance/classes/members/accessibility/classPropertyAsPrivate.ts(17,1): error TS2341: Property 'y' is private and only accessible within class 'C'.
tests/cases/conformance/classes/members/accessibility/classPropertyAsPrivate.ts(18,1): error TS2341: Property 'foo' is private and only accessible within class 'C'.
tests/cases/conformance/classes/members/accessibility/classPropertyAsPrivate.ts(20,1): error TS2341: Property 'a' is private and only accessible within class 'C'.
tests/cases/conformance/classes/members/accessibility/classPropertyAsPrivate.ts(21,1): error TS2341: Property 'b' is private and only accessible within class 'C'.
tests/cases/conformance/classes/members/accessibility/classPropertyAsPrivate.ts(22,1): error TS2341: Property 'b' is private and only accessible within class 'C'.
tests/cases/conformance/classes/members/accessibility/classPropertyAsPrivate.ts(23,1): error TS2341: Property 'foo' is private and only accessible within class 'C'.
tests/cases/conformance/classes/members/accessibility/classPropertyAsPrivate.ts(15,3): error TS2341: Property 'x' is private and only accessible within class 'C'.
tests/cases/conformance/classes/members/accessibility/classPropertyAsPrivate.ts(16,3): error TS2341: Property 'y' is private and only accessible within class 'C'.
tests/cases/conformance/classes/members/accessibility/classPropertyAsPrivate.ts(17,3): error TS2341: Property 'y' is private and only accessible within class 'C'.
tests/cases/conformance/classes/members/accessibility/classPropertyAsPrivate.ts(18,3): error TS2341: Property 'foo' is private and only accessible within class 'C'.
tests/cases/conformance/classes/members/accessibility/classPropertyAsPrivate.ts(20,3): error TS2341: Property 'a' is private and only accessible within class 'C'.
tests/cases/conformance/classes/members/accessibility/classPropertyAsPrivate.ts(21,3): error TS2341: Property 'b' is private and only accessible within class 'C'.
tests/cases/conformance/classes/members/accessibility/classPropertyAsPrivate.ts(22,3): error TS2341: Property 'b' is private and only accessible within class 'C'.
tests/cases/conformance/classes/members/accessibility/classPropertyAsPrivate.ts(23,3): error TS2341: Property 'foo' is private and only accessible within class 'C'.
==== tests/cases/conformance/classes/members/accessibility/classPropertyAsPrivate.ts (12 errors) ====
@@ -36,27 +36,27 @@ tests/cases/conformance/classes/members/accessibility/classPropertyAsPrivate.ts(
var c: C;
// all errors
c.x;
~~~
~
!!! error TS2341: Property 'x' is private and only accessible within class 'C'.
c.y;
~~~
~
!!! error TS2341: Property 'y' is private and only accessible within class 'C'.
c.y = 1;
~~~
~
!!! error TS2341: Property 'y' is private and only accessible within class 'C'.
c.foo();
~~~~~
~~~
!!! error TS2341: Property 'foo' is private and only accessible within class 'C'.
C.a;
~~~
~
!!! error TS2341: Property 'a' is private and only accessible within class 'C'.
C.b();
~~~
~
!!! error TS2341: Property 'b' is private and only accessible within class 'C'.
C.b = 1;
~~~
~
!!! error TS2341: Property 'b' is private and only accessible within class 'C'.
C.foo();
~~~~~
~~~
!!! error TS2341: Property 'foo' is private and only accessible within class 'C'.
@@ -2,14 +2,14 @@ tests/cases/conformance/classes/members/accessibility/classPropertyAsProtected.t
tests/cases/conformance/classes/members/accessibility/classPropertyAsProtected.ts(4,19): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
tests/cases/conformance/classes/members/accessibility/classPropertyAsProtected.ts(8,26): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
tests/cases/conformance/classes/members/accessibility/classPropertyAsProtected.ts(9,26): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
tests/cases/conformance/classes/members/accessibility/classPropertyAsProtected.ts(15,1): error TS2445: Property 'x' is protected and only accessible within class 'C' and its subclasses.
tests/cases/conformance/classes/members/accessibility/classPropertyAsProtected.ts(16,1): error TS2445: Property 'y' is protected and only accessible within class 'C' and its subclasses.
tests/cases/conformance/classes/members/accessibility/classPropertyAsProtected.ts(17,1): error TS2445: Property 'y' is protected and only accessible within class 'C' and its subclasses.
tests/cases/conformance/classes/members/accessibility/classPropertyAsProtected.ts(18,1): error TS2445: Property 'foo' is protected and only accessible within class 'C' and its subclasses.
tests/cases/conformance/classes/members/accessibility/classPropertyAsProtected.ts(20,1): error TS2445: Property 'a' is protected and only accessible within class 'C' and its subclasses.
tests/cases/conformance/classes/members/accessibility/classPropertyAsProtected.ts(21,1): error TS2445: Property 'b' is protected and only accessible within class 'C' and its subclasses.
tests/cases/conformance/classes/members/accessibility/classPropertyAsProtected.ts(22,1): error TS2445: Property 'b' is protected and only accessible within class 'C' and its subclasses.
tests/cases/conformance/classes/members/accessibility/classPropertyAsProtected.ts(23,1): error TS2445: Property 'foo' is protected and only accessible within class 'C' and its subclasses.
tests/cases/conformance/classes/members/accessibility/classPropertyAsProtected.ts(15,3): error TS2445: Property 'x' is protected and only accessible within class 'C' and its subclasses.
tests/cases/conformance/classes/members/accessibility/classPropertyAsProtected.ts(16,3): error TS2445: Property 'y' is protected and only accessible within class 'C' and its subclasses.
tests/cases/conformance/classes/members/accessibility/classPropertyAsProtected.ts(17,3): error TS2445: Property 'y' is protected and only accessible within class 'C' and its subclasses.
tests/cases/conformance/classes/members/accessibility/classPropertyAsProtected.ts(18,3): error TS2445: Property 'foo' is protected and only accessible within class 'C' and its subclasses.
tests/cases/conformance/classes/members/accessibility/classPropertyAsProtected.ts(20,3): error TS2445: Property 'a' is protected and only accessible within class 'C' and its subclasses.
tests/cases/conformance/classes/members/accessibility/classPropertyAsProtected.ts(21,3): error TS2445: Property 'b' is protected and only accessible within class 'C' and its subclasses.
tests/cases/conformance/classes/members/accessibility/classPropertyAsProtected.ts(22,3): error TS2445: Property 'b' is protected and only accessible within class 'C' and its subclasses.
tests/cases/conformance/classes/members/accessibility/classPropertyAsProtected.ts(23,3): error TS2445: Property 'foo' is protected and only accessible within class 'C' and its subclasses.
==== tests/cases/conformance/classes/members/accessibility/classPropertyAsProtected.ts (12 errors) ====
@@ -36,27 +36,27 @@ tests/cases/conformance/classes/members/accessibility/classPropertyAsProtected.t
var c: C;
// all errors
c.x;
~~~
~
!!! error TS2445: Property 'x' is protected and only accessible within class 'C' and its subclasses.
c.y;
~~~
~
!!! error TS2445: Property 'y' is protected and only accessible within class 'C' and its subclasses.
c.y = 1;
~~~
~
!!! error TS2445: Property 'y' is protected and only accessible within class 'C' and its subclasses.
c.foo();
~~~~~
~~~
!!! error TS2445: Property 'foo' is protected and only accessible within class 'C' and its subclasses.
C.a;
~~~
~
!!! error TS2445: Property 'a' is protected and only accessible within class 'C' and its subclasses.
C.b();
~~~
~
!!! error TS2445: Property 'b' is protected and only accessible within class 'C' and its subclasses.
C.b = 1;
~~~
~
!!! error TS2445: Property 'b' is protected and only accessible within class 'C' and its subclasses.
C.foo();
~~~~~
~~~
!!! error TS2445: Property 'foo' is protected and only accessible within class 'C' and its subclasses.
@@ -1,11 +1,11 @@
tests/cases/conformance/types/members/classWithPrivateProperty.ts(15,18): error TS2341: Property 'x' is private and only accessible within class 'C'.
tests/cases/conformance/types/members/classWithPrivateProperty.ts(16,18): error TS2341: Property 'a' is private and only accessible within class 'C'.
tests/cases/conformance/types/members/classWithPrivateProperty.ts(17,18): error TS2341: Property 'b' is private and only accessible within class 'C'.
tests/cases/conformance/types/members/classWithPrivateProperty.ts(18,18): error TS2341: Property 'c' is private and only accessible within class 'C'.
tests/cases/conformance/types/members/classWithPrivateProperty.ts(19,18): error TS2341: Property 'd' is private and only accessible within class 'C'.
tests/cases/conformance/types/members/classWithPrivateProperty.ts(20,18): error TS2341: Property 'e' is private and only accessible within class 'C'.
tests/cases/conformance/types/members/classWithPrivateProperty.ts(21,18): error TS2341: Property 'f' is private and only accessible within class 'C'.
tests/cases/conformance/types/members/classWithPrivateProperty.ts(22,18): error TS2341: Property 'g' is private and only accessible within class 'C'.
tests/cases/conformance/types/members/classWithPrivateProperty.ts(15,20): error TS2341: Property 'x' is private and only accessible within class 'C'.
tests/cases/conformance/types/members/classWithPrivateProperty.ts(16,20): error TS2341: Property 'a' is private and only accessible within class 'C'.
tests/cases/conformance/types/members/classWithPrivateProperty.ts(17,20): error TS2341: Property 'b' is private and only accessible within class 'C'.
tests/cases/conformance/types/members/classWithPrivateProperty.ts(18,20): error TS2341: Property 'c' is private and only accessible within class 'C'.
tests/cases/conformance/types/members/classWithPrivateProperty.ts(19,20): error TS2341: Property 'd' is private and only accessible within class 'C'.
tests/cases/conformance/types/members/classWithPrivateProperty.ts(20,20): error TS2341: Property 'e' is private and only accessible within class 'C'.
tests/cases/conformance/types/members/classWithPrivateProperty.ts(21,20): error TS2341: Property 'f' is private and only accessible within class 'C'.
tests/cases/conformance/types/members/classWithPrivateProperty.ts(22,20): error TS2341: Property 'g' is private and only accessible within class 'C'.
==== tests/cases/conformance/types/members/classWithPrivateProperty.ts (8 errors) ====
@@ -24,26 +24,26 @@ tests/cases/conformance/types/members/classWithPrivateProperty.ts(22,18): error
var c = new C();
var r1: string = c.x;
~~~
~
!!! error TS2341: Property 'x' is private and only accessible within class 'C'.
var r2: string = c.a;
~~~
~
!!! error TS2341: Property 'a' is private and only accessible within class 'C'.
var r3: string = c.b;
~~~
~
!!! error TS2341: Property 'b' is private and only accessible within class 'C'.
var r4: string = c.c();
~~~
~
!!! error TS2341: Property 'c' is private and only accessible within class 'C'.
var r5: string = c.d();
~~~
~
!!! error TS2341: Property 'd' is private and only accessible within class 'C'.
var r6: string = C.e;
~~~
~
!!! error TS2341: Property 'e' is private and only accessible within class 'C'.
var r7: string = C.f();
~~~
~
!!! error TS2341: Property 'f' is private and only accessible within class 'C'.
var r8: string = C.g();
~~~
~
!!! error TS2341: Property 'g' is private and only accessible within class 'C'.
@@ -1,4 +1,4 @@
tests/cases/compiler/cloduleStaticMembers.ts(6,13): error TS2341: Property 'x' is private and only accessible within class 'Clod'.
tests/cases/compiler/cloduleStaticMembers.ts(6,18): error TS2341: Property 'x' is private and only accessible within class 'Clod'.
tests/cases/compiler/cloduleStaticMembers.ts(7,13): error TS2304: Cannot find name 'x'.
tests/cases/compiler/cloduleStaticMembers.ts(10,13): error TS2304: Cannot find name 'y'.
@@ -10,7 +10,7 @@ tests/cases/compiler/cloduleStaticMembers.ts(10,13): error TS2304: Cannot find n
}
module Clod {
var p = Clod.x;
~~~~~~
~
!!! error TS2341: Property 'x' is private and only accessible within class 'Clod'.
var q = x;
~
@@ -2,12 +2,12 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/construc
Types of property 'a2' are incompatible.
Type 'new (x: T) => U[]' is not assignable to type 'new (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/constructSignatureAssignabilityInInheritance3.ts(50,19): error TS2430: Interface 'I4' incorrectly extends interface 'A'.
Types of property 'a8' are incompatible.
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.
@@ -61,7 +61,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/construc
!!! error TS2430: Types of property 'a2' are incompatible.
!!! error TS2430: Type 'new (x: T) => U[]' is not assignable to type 'new (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: new (x: T) => U[]; // error, no contextual signature instantiation since I2.a2 is not generic
}
@@ -76,7 +76,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/construc
!!! error TS2430: Types of property 'a8' are incompatible.
!!! error TS2430: 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 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.
@@ -1,8 +1,8 @@
tests/cases/conformance/classes/constructorDeclarations/constructorParameters/constructorParameterProperties.ts(8,10): error TS2341: Property 'x' is private and only accessible within class 'C'.
tests/cases/conformance/classes/constructorDeclarations/constructorParameters/constructorParameterProperties.ts(9,10): error TS2445: Property 'z' is protected and only accessible within class 'C' and its subclasses.
tests/cases/conformance/classes/constructorDeclarations/constructorParameters/constructorParameterProperties.ts(18,10): error TS2341: Property 'x' is private and only accessible within class 'D<T>'.
tests/cases/conformance/classes/constructorDeclarations/constructorParameters/constructorParameterProperties.ts(8,12): error TS2341: Property 'x' is private and only accessible within class 'C'.
tests/cases/conformance/classes/constructorDeclarations/constructorParameters/constructorParameterProperties.ts(9,12): error TS2445: Property 'z' is protected and only accessible within class 'C' and its subclasses.
tests/cases/conformance/classes/constructorDeclarations/constructorParameters/constructorParameterProperties.ts(18,12): error TS2341: Property 'x' is private and only accessible within class 'D<T>'.
tests/cases/conformance/classes/constructorDeclarations/constructorParameters/constructorParameterProperties.ts(19,12): error TS2339: Property 'a' does not exist on type 'D<string>'.
tests/cases/conformance/classes/constructorDeclarations/constructorParameters/constructorParameterProperties.ts(20,10): error TS2445: Property 'z' is protected and only accessible within class 'D<T>' and its subclasses.
tests/cases/conformance/classes/constructorDeclarations/constructorParameters/constructorParameterProperties.ts(20,12): error TS2445: Property 'z' is protected and only accessible within class 'D<T>' and its subclasses.
==== tests/cases/conformance/classes/constructorDeclarations/constructorParameters/constructorParameterProperties.ts (5 errors) ====
@@ -14,10 +14,10 @@ tests/cases/conformance/classes/constructorDeclarations/constructorParameters/co
var c: C;
var r = c.y;
var r2 = c.x; // error
~~~
~
!!! error TS2341: Property 'x' is private and only accessible within class 'C'.
var r3 = c.z; // error
~~~
~
!!! error TS2445: Property 'z' is protected and only accessible within class 'C' and its subclasses.
class D<T> {
@@ -28,12 +28,12 @@ tests/cases/conformance/classes/constructorDeclarations/constructorParameters/co
var d: D<string>;
var r = d.y;
var r2 = d.x; // error
~~~
~
!!! error TS2341: Property 'x' is private and only accessible within class 'D<T>'.
var r3 = d.a; // error
~
!!! error TS2339: Property 'a' does not exist on type 'D<string>'.
var r4 = d.z; // error
~~~
~
!!! error TS2445: Property 'z' is protected and only accessible within class 'D<T>' and its subclasses.
@@ -1,6 +1,6 @@
tests/cases/compiler/contextualTyping24.ts(1,55): error TS2322: Type '(a: string) => number' is not assignable to type '(a: { (): number; (i: number): number; }) => number'.
Types of parameters 'a' and 'a' are incompatible.
Type 'string' is not assignable to type '{ (): number; (i: number): number; }'.
Type '{ (): number; (i: number): number; }' is not assignable to type 'string'.
==== tests/cases/compiler/contextualTyping24.ts (1 errors) ====
@@ -8,4 +8,4 @@ tests/cases/compiler/contextualTyping24.ts(1,55): error TS2322: Type '(a: string
~~~
!!! error TS2322: Type '(a: string) => number' is not assignable to type '(a: { (): number; (i: number): number; }) => number'.
!!! error TS2322: Types of parameters 'a' and 'a' are incompatible.
!!! error TS2322: Type 'string' is not assignable to type '{ (): number; (i: number): number; }'.
!!! error TS2322: Type '{ (): number; (i: number): number; }' is not assignable to type 'string'.
@@ -1,7 +1,7 @@
tests/cases/compiler/contextualTypingOfConditionalExpression2.ts(11,5): error TS2322: Type '((a: C) => number) | ((b: number) => void)' is not assignable to type '(a: A) => void'.
Type '(b: number) => void' is not assignable to type '(a: A) => void'.
Types of parameters 'b' and 'a' are incompatible.
Type 'number' is not assignable to type 'A'.
Type 'A' is not assignable to type 'number'.
==== tests/cases/compiler/contextualTypingOfConditionalExpression2.ts (1 errors) ====
@@ -20,5 +20,5 @@ tests/cases/compiler/contextualTypingOfConditionalExpression2.ts(11,5): error TS
!!! error TS2322: Type '((a: C) => number) | ((b: number) => void)' is not assignable to type '(a: A) => void'.
!!! error TS2322: Type '(b: number) => void' is not assignable to type '(a: A) => void'.
!!! error TS2322: Types of parameters 'b' and 'a' are incompatible.
!!! error TS2322: Type 'number' is not assignable to type 'A'.
!!! error TS2322: Type 'A' is not assignable to type 'number'.
@@ -0,0 +1,51 @@
//// [contextuallyTypedBindingInitializer.ts]
interface Show {
show: (x: number) => string;
}
function f({ show = v => v.toString() }: Show) {}
function f2({ "show": showRename = v => v.toString() }: Show) {}
function f3({ ["show"]: showRename = v => v.toString() }: Show) {}
interface Nested {
nested: Show
}
function ff({ nested = { show: v => v.toString() } }: Nested) {}
interface Tuples {
prop: [string, number];
}
function g({ prop = ["hello", 1234] }: Tuples) {}
interface StringUnion {
prop: "foo" | "bar";
}
function h({ prop = "foo" }: StringUnion) {}
interface StringIdentity {
stringIdentity(s: string): string;
}
let { stringIdentity: id = arg => arg }: StringIdentity = { stringIdentity: x => x};
//// [contextuallyTypedBindingInitializer.js]
function f(_a) {
var _b = _a.show, show = _b === void 0 ? function (v) { return v.toString(); } : _b;
}
function f2(_a) {
var _b = _a["show"], showRename = _b === void 0 ? function (v) { return v.toString(); } : _b;
}
function f3(_a) {
var _b = "show", _c = _a[_b], showRename = _c === void 0 ? function (v) { return v.toString(); } : _c;
}
function ff(_a) {
var _b = _a.nested, nested = _b === void 0 ? { show: function (v) { return v.toString(); } } : _b;
}
function g(_a) {
var _b = _a.prop, prop = _b === void 0 ? ["hello", 1234] : _b;
}
function h(_a) {
var _b = _a.prop, prop = _b === void 0 ? "foo" : _b;
}
var _a = { stringIdentity: function (x) { return x; } }.stringIdentity, id = _a === void 0 ? function (arg) { return arg; } : _a;
@@ -0,0 +1,93 @@
=== tests/cases/conformance/types/contextualTypes/methodDeclarations/contextuallyTypedBindingInitializer.ts ===
interface Show {
>Show : Symbol(Show, Decl(contextuallyTypedBindingInitializer.ts, 0, 0))
show: (x: number) => string;
>show : Symbol(show, Decl(contextuallyTypedBindingInitializer.ts, 0, 16))
>x : Symbol(x, Decl(contextuallyTypedBindingInitializer.ts, 1, 11))
}
function f({ show = v => v.toString() }: Show) {}
>f : Symbol(f, Decl(contextuallyTypedBindingInitializer.ts, 2, 1))
>show : Symbol(show, Decl(contextuallyTypedBindingInitializer.ts, 3, 12))
>v : Symbol(v, Decl(contextuallyTypedBindingInitializer.ts, 3, 19))
>v.toString : Symbol(Number.toString, Decl(lib.d.ts, --, --))
>v : Symbol(v, Decl(contextuallyTypedBindingInitializer.ts, 3, 19))
>toString : Symbol(Number.toString, Decl(lib.d.ts, --, --))
>Show : Symbol(Show, Decl(contextuallyTypedBindingInitializer.ts, 0, 0))
function f2({ "show": showRename = v => v.toString() }: Show) {}
>f2 : Symbol(f2, Decl(contextuallyTypedBindingInitializer.ts, 3, 49))
>showRename : Symbol(showRename, Decl(contextuallyTypedBindingInitializer.ts, 4, 13))
>v : Symbol(v, Decl(contextuallyTypedBindingInitializer.ts, 4, 34))
>v.toString : Symbol(Number.toString, Decl(lib.d.ts, --, --))
>v : Symbol(v, Decl(contextuallyTypedBindingInitializer.ts, 4, 34))
>toString : Symbol(Number.toString, Decl(lib.d.ts, --, --))
>Show : Symbol(Show, Decl(contextuallyTypedBindingInitializer.ts, 0, 0))
function f3({ ["show"]: showRename = v => v.toString() }: Show) {}
>f3 : Symbol(f3, Decl(contextuallyTypedBindingInitializer.ts, 4, 64))
>showRename : Symbol(showRename, Decl(contextuallyTypedBindingInitializer.ts, 5, 13))
>v : Symbol(v, Decl(contextuallyTypedBindingInitializer.ts, 5, 36))
>v.toString : Symbol(Number.toString, Decl(lib.d.ts, --, --))
>v : Symbol(v, Decl(contextuallyTypedBindingInitializer.ts, 5, 36))
>toString : Symbol(Number.toString, Decl(lib.d.ts, --, --))
>Show : Symbol(Show, Decl(contextuallyTypedBindingInitializer.ts, 0, 0))
interface Nested {
>Nested : Symbol(Nested, Decl(contextuallyTypedBindingInitializer.ts, 5, 66))
nested: Show
>nested : Symbol(nested, Decl(contextuallyTypedBindingInitializer.ts, 7, 18))
>Show : Symbol(Show, Decl(contextuallyTypedBindingInitializer.ts, 0, 0))
}
function ff({ nested = { show: v => v.toString() } }: Nested) {}
>ff : Symbol(ff, Decl(contextuallyTypedBindingInitializer.ts, 9, 1))
>nested : Symbol(nested, Decl(contextuallyTypedBindingInitializer.ts, 10, 13))
>show : Symbol(show, Decl(contextuallyTypedBindingInitializer.ts, 10, 24))
>v : Symbol(v, Decl(contextuallyTypedBindingInitializer.ts, 10, 30))
>v.toString : Symbol(Number.toString, Decl(lib.d.ts, --, --))
>v : Symbol(v, Decl(contextuallyTypedBindingInitializer.ts, 10, 30))
>toString : Symbol(Number.toString, Decl(lib.d.ts, --, --))
>Nested : Symbol(Nested, Decl(contextuallyTypedBindingInitializer.ts, 5, 66))
interface Tuples {
>Tuples : Symbol(Tuples, Decl(contextuallyTypedBindingInitializer.ts, 10, 64))
prop: [string, number];
>prop : Symbol(prop, Decl(contextuallyTypedBindingInitializer.ts, 12, 18))
}
function g({ prop = ["hello", 1234] }: Tuples) {}
>g : Symbol(g, Decl(contextuallyTypedBindingInitializer.ts, 14, 1))
>prop : Symbol(prop, Decl(contextuallyTypedBindingInitializer.ts, 15, 12))
>Tuples : Symbol(Tuples, Decl(contextuallyTypedBindingInitializer.ts, 10, 64))
interface StringUnion {
>StringUnion : Symbol(StringUnion, Decl(contextuallyTypedBindingInitializer.ts, 15, 49))
prop: "foo" | "bar";
>prop : Symbol(prop, Decl(contextuallyTypedBindingInitializer.ts, 17, 23))
}
function h({ prop = "foo" }: StringUnion) {}
>h : Symbol(h, Decl(contextuallyTypedBindingInitializer.ts, 19, 1))
>prop : Symbol(prop, Decl(contextuallyTypedBindingInitializer.ts, 20, 12))
>StringUnion : Symbol(StringUnion, Decl(contextuallyTypedBindingInitializer.ts, 15, 49))
interface StringIdentity {
>StringIdentity : Symbol(StringIdentity, Decl(contextuallyTypedBindingInitializer.ts, 20, 44))
stringIdentity(s: string): string;
>stringIdentity : Symbol(stringIdentity, Decl(contextuallyTypedBindingInitializer.ts, 22, 26))
>s : Symbol(s, Decl(contextuallyTypedBindingInitializer.ts, 23, 19))
}
let { stringIdentity: id = arg => arg }: StringIdentity = { stringIdentity: x => x};
>stringIdentity : Symbol(StringIdentity.stringIdentity, Decl(contextuallyTypedBindingInitializer.ts, 22, 26))
>id : Symbol(id, Decl(contextuallyTypedBindingInitializer.ts, 25, 5))
>arg : Symbol(arg, Decl(contextuallyTypedBindingInitializer.ts, 25, 26))
>arg : Symbol(arg, Decl(contextuallyTypedBindingInitializer.ts, 25, 26))
>StringIdentity : Symbol(StringIdentity, Decl(contextuallyTypedBindingInitializer.ts, 20, 44))
>stringIdentity : Symbol(stringIdentity, Decl(contextuallyTypedBindingInitializer.ts, 25, 59))
>x : Symbol(x, Decl(contextuallyTypedBindingInitializer.ts, 25, 75))
>x : Symbol(x, Decl(contextuallyTypedBindingInitializer.ts, 25, 75))
@@ -0,0 +1,110 @@
=== tests/cases/conformance/types/contextualTypes/methodDeclarations/contextuallyTypedBindingInitializer.ts ===
interface Show {
>Show : Show
show: (x: number) => string;
>show : (x: number) => string
>x : number
}
function f({ show = v => v.toString() }: Show) {}
>f : ({show}: Show) => void
>show : (x: number) => string
>v => v.toString() : (v: number) => string
>v : number
>v.toString() : string
>v.toString : (radix?: number) => string
>v : number
>toString : (radix?: number) => string
>Show : Show
function f2({ "show": showRename = v => v.toString() }: Show) {}
>f2 : ({"show": showRename}: Show) => void
>showRename : (x: number) => string
>v => v.toString() : (v: number) => string
>v : number
>v.toString() : string
>v.toString : (radix?: number) => string
>v : number
>toString : (radix?: number) => string
>Show : Show
function f3({ ["show"]: showRename = v => v.toString() }: Show) {}
>f3 : ({["show"]: showRename}: Show) => void
>"show" : string
>showRename : (x: number) => string
>v => v.toString() : (v: number) => string
>v : number
>v.toString() : string
>v.toString : (radix?: number) => string
>v : number
>toString : (radix?: number) => string
>Show : Show
interface Nested {
>Nested : Nested
nested: Show
>nested : Show
>Show : Show
}
function ff({ nested = { show: v => v.toString() } }: Nested) {}
>ff : ({nested}: Nested) => void
>nested : Show
>{ show: v => v.toString() } : { show: (v: number) => string; }
>show : (v: number) => string
>v => v.toString() : (v: number) => string
>v : number
>v.toString() : string
>v.toString : (radix?: number) => string
>v : number
>toString : (radix?: number) => string
>Nested : Nested
interface Tuples {
>Tuples : Tuples
prop: [string, number];
>prop : [string, number]
}
function g({ prop = ["hello", 1234] }: Tuples) {}
>g : ({prop}: Tuples) => void
>prop : [string, number]
>["hello", 1234] : [string, number]
>"hello" : string
>1234 : number
>Tuples : Tuples
interface StringUnion {
>StringUnion : StringUnion
prop: "foo" | "bar";
>prop : "foo" | "bar"
}
function h({ prop = "foo" }: StringUnion) {}
>h : ({prop}: StringUnion) => void
>prop : "foo" | "bar"
>"foo" : "foo"
>StringUnion : StringUnion
interface StringIdentity {
>StringIdentity : StringIdentity
stringIdentity(s: string): string;
>stringIdentity : (s: string) => string
>s : string
}
let { stringIdentity: id = arg => arg }: StringIdentity = { stringIdentity: x => x};
>stringIdentity : any
>id : (s: string) => string
>arg => arg : (arg: string) => string
>arg : string
>arg : string
>StringIdentity : StringIdentity
>{ stringIdentity: x => x} : { stringIdentity: (x: string) => string; }
>stringIdentity : (x: string) => string
>x => x : (x: string) => string
>x : string
>x : string
@@ -0,0 +1,71 @@
tests/cases/conformance/types/contextualTypes/methodDeclarations/contextuallyTypedBindingInitializerNegative.ts(4,20): error TS2322: Type '(v: number) => number' is not assignable to type '(x: number) => string'.
Type 'number' is not assignable to type 'string'.
tests/cases/conformance/types/contextualTypes/methodDeclarations/contextuallyTypedBindingInitializerNegative.ts(5,23): error TS2322: Type '(v: number) => number' is not assignable to type '(x: number) => string'.
Type 'number' is not assignable to type 'string'.
tests/cases/conformance/types/contextualTypes/methodDeclarations/contextuallyTypedBindingInitializerNegative.ts(6,25): error TS2322: Type '(v: number) => number' is not assignable to type '(x: number) => string'.
Type 'number' is not assignable to type 'string'.
tests/cases/conformance/types/contextualTypes/methodDeclarations/contextuallyTypedBindingInitializerNegative.ts(11,23): error TS2322: Type '{ show: (v: number) => number; }' is not assignable to type 'Show'.
Types of property 'show' are incompatible.
Type '(v: number) => number' is not assignable to type '(x: number) => string'.
Type 'number' is not assignable to type 'string'.
tests/cases/conformance/types/contextualTypes/methodDeclarations/contextuallyTypedBindingInitializerNegative.ts(16,23): error TS2322: Type '(arg: string) => number' is not assignable to type '(s: string) => string'.
Type 'number' is not assignable to type 'string'.
tests/cases/conformance/types/contextualTypes/methodDeclarations/contextuallyTypedBindingInitializerNegative.ts(21,14): error TS2322: Type '[number, number]' is not assignable to type '[string, number]'.
Types of property '0' are incompatible.
Type 'number' is not assignable to type 'string'.
tests/cases/conformance/types/contextualTypes/methodDeclarations/contextuallyTypedBindingInitializerNegative.ts(26,14): error TS2322: Type '"baz"' is not assignable to type '"foo" | "bar"'.
Type '"baz"' is not assignable to type '"bar"'.
==== tests/cases/conformance/types/contextualTypes/methodDeclarations/contextuallyTypedBindingInitializerNegative.ts (7 errors) ====
interface Show {
show: (x: number) => string;
}
function f({ show: showRename = v => v }: Show) {}
~~~~~~~~~~
!!! error TS2322: Type '(v: number) => number' is not assignable to type '(x: number) => string'.
!!! error TS2322: Type 'number' is not assignable to type 'string'.
function f2({ "show": showRename = v => v }: Show) {}
~~~~~~~~~~
!!! error TS2322: Type '(v: number) => number' is not assignable to type '(x: number) => string'.
!!! error TS2322: Type 'number' is not assignable to type 'string'.
function f3({ ["show"]: showRename = v => v }: Show) {}
~~~~~~~~~~
!!! error TS2322: Type '(v: number) => number' is not assignable to type '(x: number) => string'.
!!! error TS2322: Type 'number' is not assignable to type 'string'.
interface Nested {
nested: Show
}
function ff({ nested: nestedRename = { show: v => v } }: Nested) {}
~~~~~~~~~~~~
!!! error TS2322: Type '{ show: (v: number) => number; }' is not assignable to type 'Show'.
!!! error TS2322: Types of property 'show' are incompatible.
!!! error TS2322: Type '(v: number) => number' is not assignable to type '(x: number) => string'.
!!! error TS2322: Type 'number' is not assignable to type 'string'.
interface StringIdentity {
stringIdentity(s: string): string;
}
let { stringIdentity: id = arg => arg.length }: StringIdentity = { stringIdentity: x => x};
~~
!!! error TS2322: Type '(arg: string) => number' is not assignable to type '(s: string) => string'.
!!! error TS2322: Type 'number' is not assignable to type 'string'.
interface Tuples {
prop: [string, number];
}
function g({ prop = [101, 1234] }: Tuples) {}
~~~~
!!! error TS2322: Type '[number, number]' is not assignable to type '[string, number]'.
!!! error TS2322: Types of property '0' are incompatible.
!!! error TS2322: Type 'number' is not assignable to type 'string'.
interface StringUnion {
prop: "foo" | "bar";
}
function h({ prop = "baz" }: StringUnion) {}
~~~~
!!! error TS2322: Type '"baz"' is not assignable to type '"foo" | "bar"'.
!!! error TS2322: Type '"baz"' is not assignable to type '"bar"'.
@@ -0,0 +1,49 @@
//// [contextuallyTypedBindingInitializerNegative.ts]
interface Show {
show: (x: number) => string;
}
function f({ show: showRename = v => v }: Show) {}
function f2({ "show": showRename = v => v }: Show) {}
function f3({ ["show"]: showRename = v => v }: Show) {}
interface Nested {
nested: Show
}
function ff({ nested: nestedRename = { show: v => v } }: Nested) {}
interface StringIdentity {
stringIdentity(s: string): string;
}
let { stringIdentity: id = arg => arg.length }: StringIdentity = { stringIdentity: x => x};
interface Tuples {
prop: [string, number];
}
function g({ prop = [101, 1234] }: Tuples) {}
interface StringUnion {
prop: "foo" | "bar";
}
function h({ prop = "baz" }: StringUnion) {}
//// [contextuallyTypedBindingInitializerNegative.js]
function f(_a) {
var _b = _a.show, showRename = _b === void 0 ? function (v) { return v; } : _b;
}
function f2(_a) {
var _b = _a["show"], showRename = _b === void 0 ? function (v) { return v; } : _b;
}
function f3(_a) {
var _b = "show", _c = _a[_b], showRename = _c === void 0 ? function (v) { return v; } : _c;
}
function ff(_a) {
var _b = _a.nested, nestedRename = _b === void 0 ? { show: function (v) { return v; } } : _b;
}
var _a = { stringIdentity: function (x) { return x; } }.stringIdentity, id = _a === void 0 ? function (arg) { return arg.length; } : _a;
function g(_a) {
var _b = _a.prop, prop = _b === void 0 ? [101, 1234] : _b;
}
function h(_a) {
var _b = _a.prop, prop = _b === void 0 ? "baz" : _b;
}
@@ -1,15 +1,18 @@
tests/cases/conformance/types/contextualTypes/jsxAttributes/contextuallyTypedStringLiteralsInJsxAttributes01.tsx(13,15): error TS2322: Type '"f"' is not assignable to type '"A" | "B" | "C"'.
tests/cases/conformance/types/contextualTypes/jsxAttributes/contextuallyTypedStringLiteralsInJsxAttributes01.tsx(16,15): error TS2322: Type '"f"' is not assignable to type '"A" | "B" | "C"'.
Type '"f"' is not assignable to type '"C"'.
tests/cases/conformance/types/contextualTypes/jsxAttributes/contextuallyTypedStringLiteralsInJsxAttributes01.tsx(14,15): error TS2322: Type '"f"' is not assignable to type '"A" | "B" | "C"'.
tests/cases/conformance/types/contextualTypes/jsxAttributes/contextuallyTypedStringLiteralsInJsxAttributes01.tsx(17,15): error TS2322: Type '"f"' is not assignable to type '"A" | "B" | "C"'.
Type '"f"' is not assignable to type '"C"'.
==== tests/cases/conformance/types/contextualTypes/jsxAttributes/contextuallyTypedStringLiteralsInJsxAttributes01.tsx (2 errors) ====
namespace JSX {
interface IntrinsicElements {
export interface IntrinsicElements {
span: {};
}
export interface Element {
something?: any;
}
}
const FooComponent = (props: { foo: "A" | "B" | "C" }) => <span>{props.foo}</span>;
@@ -1,9 +1,12 @@
//// [contextuallyTypedStringLiteralsInJsxAttributes01.tsx]
namespace JSX {
interface IntrinsicElements {
export interface IntrinsicElements {
span: {};
}
export interface Element {
something?: any;
}
}
const FooComponent = (props: { foo: "A" | "B" | "C" }) => <span>{props.foo}</span>;
@@ -24,7 +27,13 @@ var FooComponent = function (props) { return <span>{props.foo}</span>; };
//// [contextuallyTypedStringLiteralsInJsxAttributes01.d.ts]
declare namespace JSX {
interface IntrinsicElements {
span: {};
}
interface Element {
something?: any;
}
}
declare const FooComponent: (props: {
foo: "A" | "B" | "C";
}) => any;
}) => JSX.Element;
@@ -0,0 +1,30 @@
//// [continueInLoopsWithCapturedBlockScopedBindings1.ts]
function foo() {
for (const i of [0, 1]) {
if (i === 0) {
continue;
}
// Trigger non-simple-loop emit
(() => {
return i;
})();
}
}
//// [continueInLoopsWithCapturedBlockScopedBindings1.js]
function foo() {
var _loop_1 = function(i) {
if (i === 0) {
return "continue";
}
// Trigger non-simple-loop emit
(function () {
return i;
})();
};
for (var _i = 0, _a = [0, 1]; _i < _a.length; _i++) {
var i = _a[_i];
_loop_1(i);
}
}
@@ -0,0 +1,21 @@
=== tests/cases/compiler/continueInLoopsWithCapturedBlockScopedBindings1.ts ===
function foo() {
>foo : Symbol(foo, Decl(continueInLoopsWithCapturedBlockScopedBindings1.ts, 0, 0))
for (const i of [0, 1]) {
>i : Symbol(i, Decl(continueInLoopsWithCapturedBlockScopedBindings1.ts, 1, 14))
if (i === 0) {
>i : Symbol(i, Decl(continueInLoopsWithCapturedBlockScopedBindings1.ts, 1, 14))
continue;
}
// Trigger non-simple-loop emit
(() => {
return i;
>i : Symbol(i, Decl(continueInLoopsWithCapturedBlockScopedBindings1.ts, 1, 14))
})();
}
}
@@ -0,0 +1,30 @@
=== tests/cases/compiler/continueInLoopsWithCapturedBlockScopedBindings1.ts ===
function foo() {
>foo : () => void
for (const i of [0, 1]) {
>i : number
>[0, 1] : number[]
>0 : number
>1 : number
if (i === 0) {
>i === 0 : boolean
>i : number
>0 : number
continue;
}
// Trigger non-simple-loop emit
(() => {
>(() => { return i; })() : number
>(() => { return i; }) : () => number
>() => { return i; } : () => number
return i;
>i : number
})();
}
}
@@ -1,23 +1,23 @@
=== tests/cases/compiler/declarationEmitDestructuring5.ts ===
function baz([, z, , ]) { }
>baz : ([, z, , ]: [any, any, any]) => void
>baz : ([, z, ,]: [any, any, any]) => void
> : undefined
>z : any
> : undefined
function foo([, b, ]: [any, any]): void { }
>foo : ([, b, ]: [any, any]) => void
>foo : ([, b,]: [any, any]) => void
> : undefined
>b : any
function bar([z, , , ]) { }
>bar : ([z, , , ]: [any, any, any]) => void
>bar : ([z, , ,]: [any, any, any]) => void
>z : any
> : undefined
> : undefined
function bar1([z, , , ] = [1, 3, 4, 6, 7]) { }
>bar1 : ([z, , , ]?: [number, number, number, number, number]) => void
>bar1 : ([z, , ,]?: [number, number, number, number, number]) => void
>z : number
> : undefined
> : undefined
@@ -29,7 +29,7 @@ function bar1([z, , , ] = [1, 3, 4, 6, 7]) { }
>7 : number
function bar2([,,z, , , ]) { }
>bar2 : ([,,z, , , ]: [any, any, any, any, any]) => void
>bar2 : ([, , z, , ,]: [any, any, any, any, any]) => void
> : undefined
> : undefined
>z : any

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