Merge branch 'master' of https://github.com/Microsoft/TypeScript into fixLargeProjectTry2

# Conflicts:
#	src/compiler/commandLineParser.ts
#	src/compiler/types.ts
This commit is contained in:
zhengbli
2016-03-24 11:42:18 -07:00
105 changed files with 3731 additions and 1126 deletions
+747 -312
View File
File diff suppressed because it is too large Load Diff
+25 -10
View File
@@ -335,6 +335,11 @@ namespace ts {
{
name: "disableSizeLimit",
type: "boolean"
},
{
name: "strictNullChecks",
type: "boolean",
description: Diagnostics.Enable_strict_null_checks
}
];
@@ -594,9 +599,9 @@ namespace ts {
*/
export function parseJsonConfigFileContent(json: any, host: ParseConfigHost, basePath: string, existingOptions: CompilerOptions = {}, configFileName?: string): ParsedCommandLine {
const errors: Diagnostic[] = [];
const compilerOptions: CompilerOptions = convertCompilerOptionsFromJson(optionDeclarations, json["compilerOptions"], basePath, errors, configFileName);
const compilerOptions: CompilerOptions = convertCompilerOptionsFromJsonWorker(json["compilerOptions"], basePath, errors, configFileName);
const options = extend(existingOptions, compilerOptions);
const typingOptions: TypingOptions = convertTypingOptionsFromJson(typingOptionDeclarations, json["typingOptions"], basePath, errors, configFileName);
const typingOptions: TypingOptions = convertTypingOptionsFromJsonWorker(json["typingOptions"], basePath, errors, configFileName);
const fileNames = getFileNames(errors);
@@ -684,28 +689,38 @@ namespace ts {
}
}
/* @internal */
export function convertCompilerOptionsFromJson(optionsDeclarations: CommandLineOption[], jsonOptions: any,
export function convertCompilerOptionsFromJson(jsonOptions: any, basePath: string, configFileName?: string): { options: CompilerOptions, errors: Diagnostic[] } {
const errors: Diagnostic[] = [];
const options = convertCompilerOptionsFromJsonWorker(jsonOptions, basePath, errors, configFileName);
return { options, errors };
}
export function convertTypingOptionsFromJson(jsonOptions: any, basePath: string, configFileName?: string): { options: CompilerOptions, errors: Diagnostic[] } {
const errors: Diagnostic[] = [];
const options = convertTypingOptionsFromJsonWorker(jsonOptions, basePath, errors, configFileName);
return { options, errors };
}
function convertCompilerOptionsFromJsonWorker(jsonOptions: any,
basePath: string, errors: Diagnostic[], configFileName?: string): CompilerOptions {
const options: CompilerOptions = getBaseFileName(configFileName) === "jsconfig.json" ? { allowJs: true } : {};
convertOptionsFromJson<CompilerOptions>(optionDeclarations, jsonOptions, basePath, options, Diagnostics.Unknown_compiler_option_0, errors);
convertOptionsFromJson(optionDeclarations, jsonOptions, basePath, options, Diagnostics.Unknown_compiler_option_0, errors);
return options;
}
/* @internal */
export function convertTypingOptionsFromJson(optionsDeclarations: CommandLineOption[], jsonOptions: any,
function convertTypingOptionsFromJsonWorker(jsonOptions: any,
basePath: string, errors: Diagnostic[], configFileName?: string): TypingOptions {
const options: TypingOptions = getBaseFileName(configFileName) === "jsconfig.json"
? { enableAutoDiscovery: true, include: [], exclude: [] }
: { enableAutoDiscovery: false, include: [], exclude: [] };
convertOptionsFromJson<TypingOptions>(typingOptionDeclarations, jsonOptions, basePath, options, Diagnostics.Unknown_typing_option_0, errors);
convertOptionsFromJson(typingOptionDeclarations, jsonOptions, basePath, options, Diagnostics.Unknown_typing_option_0, errors);
return options;
}
function convertOptionsFromJson<T extends CompilerOptions | TypingOptions>(optionDeclarations: CommandLineOption[], jsonOptions: any, basePath: string,
defaultOptions: T, diagnosticMessage: DiagnosticMessage, errors: Diagnostic[]) {
function convertOptionsFromJson(optionDeclarations: CommandLineOption[], jsonOptions: any, basePath: string,
defaultOptions: CompilerOptions | TypingOptions, diagnosticMessage: DiagnosticMessage, errors: Diagnostic[]) {
if (!jsonOptions) {
return ;
+16 -4
View File
@@ -242,8 +242,14 @@ namespace ts {
const count = array.length;
if (count > 0) {
let pos = 0;
let result = arguments.length <= 2 ? array[pos] : initial;
pos++;
let result: T | U;
if (arguments.length <= 2) {
result = array[pos];
pos++;
}
else {
result = initial;
}
while (pos < count) {
result = f(<U>result, array[pos]);
pos++;
@@ -260,8 +266,14 @@ namespace ts {
if (array) {
let pos = array.length - 1;
if (pos >= 0) {
let result = arguments.length <= 2 ? array[pos] : initial;
pos--;
let result: T | U;
if (arguments.length <= 2) {
result = array[pos];
pos--;
}
else {
result = initial;
}
while (pos >= 0) {
result = f(<U>result, array[pos]);
pos--;
+2
View File
@@ -367,6 +367,8 @@ namespace ts {
case SyntaxKind.BooleanKeyword:
case SyntaxKind.SymbolKeyword:
case SyntaxKind.VoidKeyword:
case SyntaxKind.UndefinedKeyword:
case SyntaxKind.NullKeyword:
case SyntaxKind.ThisType:
case SyntaxKind.StringLiteralType:
return writeTextOfNode(currentText, type);
+17
View File
@@ -1103,6 +1103,10 @@
"category": "Error",
"code": 2365
},
"Function lacks ending return statement and return type does not include 'undefined'.": {
"category": "Error",
"code": 2366
},
"Type parameter name cannot be '{0}'": {
"category": "Error",
"code": 2368
@@ -1423,6 +1427,10 @@
"category": "Error",
"code": 2453
},
"Variable '{0}' is used before being assigned.": {
"category": "Error",
"code": 2454
},
"Type argument candidate '{1}' is not a valid type argument because it is not a supertype of candidate '{0}'.": {
"category": "Error",
"code": 2455
@@ -1719,6 +1727,10 @@
"category": "Error",
"code": 2530
},
"Object is possibly 'null' or 'undefined'.": {
"category": "Error",
"code": 2531
},
"JSX element attributes type '{0}' may not be a union type.": {
"category": "Error",
"code": 2600
@@ -2604,6 +2616,11 @@
"category": "Message",
"code": 6112
},
"Enable strict null checks.": {
"category": "Message",
"code": 6113
},
"Variable '{0}' implicitly has an '{1}' type.": {
"category": "Error",
"code": 7005
+20 -10
View File
@@ -1533,6 +1533,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
case SyntaxKind.JsxSpreadAttribute:
case SyntaxKind.JsxExpression:
case SyntaxKind.NewExpression:
case SyntaxKind.NonNullExpression:
case SyntaxKind.ParenthesizedExpression:
case SyntaxKind.PostfixUnaryExpression:
case SyntaxKind.PrefixUnaryExpression:
@@ -2077,8 +2078,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
function parenthesizeForAccess(expr: Expression): LeftHandSideExpression {
// When diagnosing whether the expression needs parentheses, the decision should be based
// on the innermost expression in a chain of nested type assertions.
while (expr.kind === SyntaxKind.TypeAssertionExpression || expr.kind === SyntaxKind.AsExpression) {
expr = (<AssertionExpression>expr).expression;
while (expr.kind === SyntaxKind.TypeAssertionExpression ||
expr.kind === SyntaxKind.AsExpression ||
expr.kind === SyntaxKind.NonNullExpression) {
expr = (<AssertionExpression | NonNullExpression>expr).expression;
}
// isLeftHandSideExpression is almost the correct criterion for when it is not necessary
@@ -2343,8 +2346,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
}
function skipParentheses(node: Expression): Expression {
while (node.kind === SyntaxKind.ParenthesizedExpression || node.kind === SyntaxKind.TypeAssertionExpression || node.kind === SyntaxKind.AsExpression) {
node = (<ParenthesizedExpression | AssertionExpression>node).expression;
while (node.kind === SyntaxKind.ParenthesizedExpression ||
node.kind === SyntaxKind.TypeAssertionExpression ||
node.kind === SyntaxKind.AsExpression ||
node.kind === SyntaxKind.NonNullExpression) {
node = (<ParenthesizedExpression | AssertionExpression | NonNullExpression>node).expression;
}
return node;
}
@@ -2518,13 +2524,17 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
// not the user. If we didn't want them, the emitter would not have put them
// there.
if (!nodeIsSynthesized(node) && node.parent.kind !== SyntaxKind.ArrowFunction) {
if (node.expression.kind === SyntaxKind.TypeAssertionExpression || node.expression.kind === SyntaxKind.AsExpression) {
let operand = (<TypeAssertion>node.expression).expression;
if (node.expression.kind === SyntaxKind.TypeAssertionExpression ||
node.expression.kind === SyntaxKind.AsExpression ||
node.expression.kind === SyntaxKind.NonNullExpression) {
let operand = (<TypeAssertion | NonNullExpression>node.expression).expression;
// Make sure we consider all nested cast expressions, e.g.:
// (<any><number><any>-A).x;
while (operand.kind === SyntaxKind.TypeAssertionExpression || operand.kind === SyntaxKind.AsExpression) {
operand = (<TypeAssertion>operand).expression;
while (operand.kind === SyntaxKind.TypeAssertionExpression ||
operand.kind === SyntaxKind.AsExpression ||
operand.kind === SyntaxKind.NonNullExpression) {
operand = (<TypeAssertion | NonNullExpression>operand).expression;
}
// We have an expression of the form: (<Type>SubExpr)
@@ -7928,9 +7938,9 @@ const _super = (function (geti, seti) {
case SyntaxKind.TaggedTemplateExpression:
return emitTaggedTemplateExpression(<TaggedTemplateExpression>node);
case SyntaxKind.TypeAssertionExpression:
return emit((<TypeAssertion>node).expression);
case SyntaxKind.AsExpression:
return emit((<AsExpression>node).expression);
case SyntaxKind.NonNullExpression:
return emit((<AssertionExpression | NonNullExpression>node).expression);
case SyntaxKind.ParenthesizedExpression:
return emitParenExpression(<ParenthesizedExpression>node);
case SyntaxKind.FunctionDeclaration:
+14
View File
@@ -177,6 +177,8 @@ namespace ts {
case SyntaxKind.AsExpression:
return visitNode(cbNode, (<AsExpression>node).expression) ||
visitNode(cbNode, (<AsExpression>node).type);
case SyntaxKind.NonNullExpression:
return visitNode(cbNode, (<NonNullExpression>node).expression);
case SyntaxKind.ConditionalExpression:
return visitNode(cbNode, (<ConditionalExpression>node).condition) ||
visitNode(cbNode, (<ConditionalExpression>node).questionToken) ||
@@ -2361,12 +2363,14 @@ namespace ts {
case SyntaxKind.NumberKeyword:
case SyntaxKind.BooleanKeyword:
case SyntaxKind.SymbolKeyword:
case SyntaxKind.UndefinedKeyword:
// If these are followed by a dot, then parse these out as a dotted type reference instead.
const node = tryParse(parseKeywordAndNoDot);
return node || parseTypeReference();
case SyntaxKind.StringLiteral:
return parseStringLiteralTypeNode();
case SyntaxKind.VoidKeyword:
case SyntaxKind.NullKeyword:
return parseTokenNode<TypeNode>();
case SyntaxKind.ThisKeyword: {
const thisKeyword = parseThisTypeNode();
@@ -2398,6 +2402,8 @@ namespace ts {
case SyntaxKind.BooleanKeyword:
case SyntaxKind.SymbolKeyword:
case SyntaxKind.VoidKeyword:
case SyntaxKind.UndefinedKeyword:
case SyntaxKind.NullKeyword:
case SyntaxKind.ThisKeyword:
case SyntaxKind.TypeOfKeyword:
case SyntaxKind.OpenBraceToken:
@@ -3724,6 +3730,14 @@ namespace ts {
continue;
}
if (token === SyntaxKind.ExclamationToken && !scanner.hasPrecedingLineBreak()) {
nextToken();
const nonNullExpression = <NonNullExpression>createNode(SyntaxKind.NonNullExpression, expression.pos);
nonNullExpression.expression = expression;
expression = finishNode(nonNullExpression);
continue;
}
// when in the [Decorator] context, we do not parse ElementAccess as it could be part of a ComputedPropertyName
if (!inDecoratorContext() && parseOptional(SyntaxKind.OpenBracketToken)) {
const indexedAccess = <ElementAccessExpression>createNode(SyntaxKind.ElementAccessExpression, expression.pos);
+1
View File
@@ -114,6 +114,7 @@ namespace ts {
"try": SyntaxKind.TryKeyword,
"type": SyntaxKind.TypeKeyword,
"typeof": SyntaxKind.TypeOfKeyword,
"undefined": SyntaxKind.UndefinedKeyword,
"var": SyntaxKind.VarKeyword,
"void": SyntaxKind.VoidKeyword,
"while": SyntaxKind.WhileKeyword,
+22 -3
View File
@@ -171,6 +171,7 @@ namespace ts {
StringKeyword,
SymbolKeyword,
TypeKeyword,
UndefinedKeyword,
FromKeyword,
GlobalKeyword,
OfKeyword, // LastKeyword and LastToken
@@ -240,6 +241,7 @@ namespace ts {
OmittedExpression,
ExpressionWithTypeArguments,
AsExpression,
NonNullExpression,
// Misc
TemplateSpan,
@@ -475,6 +477,11 @@ namespace ts {
originalKeywordKind?: SyntaxKind; // Original syntaxKind which get set so that we can report an error later
}
// Transient identifier node (marked by id === -1)
export interface TransientIdentifier extends Identifier {
resolvedSymbol: Symbol;
}
// @kind(SyntaxKind.QualifiedName)
export interface QualifiedName extends Node {
// Must have same layout as PropertyAccess
@@ -968,6 +975,8 @@ namespace ts {
name: Identifier;
}
export type IdentifierOrPropertyAccess = Identifier | PropertyAccessExpression;
// @kind(SyntaxKind.ElementAccessExpression)
export interface ElementAccessExpression extends MemberExpression {
expression: LeftHandSideExpression;
@@ -1012,6 +1021,11 @@ namespace ts {
export type AssertionExpression = TypeAssertion | AsExpression;
// @kind(SyntaxKind.NonNullExpression)
export interface NonNullExpression extends LeftHandSideExpression {
expression: Expression;
}
/// A JSX expression of the form <TagName attrs>...</TagName>
// @kind(SyntaxKind.JsxElement)
export interface JsxElement extends PrimaryExpression {
@@ -2030,7 +2044,9 @@ namespace ts {
exportsChecked?: boolean; // True if exports of external module have been checked
isDeclarationWithCollidingName?: boolean; // True if symbol is block scoped redeclaration
bindingElement?: BindingElement; // Binding element associated with property symbol
exportsSomeValue?: boolean; // true if module exports some value (not just types)
exportsSomeValue?: boolean; // True if module exports some value (not just types)
firstAssignmentChecked?: boolean; // True if first assignment node has been computed
firstAssignment?: Node; // First assignment node (undefined if no assignments)
}
/* @internal */
@@ -2073,7 +2089,7 @@ namespace ts {
isVisible?: boolean; // Is this node visible
generatedName?: string; // Generated name for module, enum, or import declaration
generatedNames?: Map<string>; // Generated names table for source file
assignmentChecks?: Map<boolean>; // Cache of assignment checks
assignmentMap?: Map<boolean>; // Cached map of references assigned within this node
hasReportedStatementInAmbientContext?: boolean; // Cache boolean if we report statements in ambient context
importOnRightSide?: Symbol; // for import declarations - import that appear on the right side
jsxFlags?: JsxFlags; // flags for knowing what kind of element/attributes we're dealing with
@@ -2107,7 +2123,7 @@ namespace ts {
/* @internal */
FreshObjectLiteral = 0x00100000, // Fresh object literal type
/* @internal */
ContainsUndefinedOrNull = 0x00200000, // Type is or contains Undefined or Null type
ContainsUndefinedOrNull = 0x00200000, // Type is or contains undefined or null type
/* @internal */
ContainsObjectLiteral = 0x00400000, // Type is or contains object literal type
/* @internal */
@@ -2116,6 +2132,8 @@ namespace ts {
ThisType = 0x02000000, // This type
ObjectLiteralPatternWithComputedProperties = 0x04000000, // Object literal type implied by binding pattern has computed properties
/* @internal */
Nullable = Undefined | Null,
/* @internal */
Intrinsic = Any | String | Number | Boolean | ESSymbol | Void | Undefined | Null,
/* @internal */
@@ -2440,6 +2458,7 @@ namespace ts {
allowSyntheticDefaultImports?: boolean;
allowJs?: boolean;
noImplicitUseStrict?: boolean;
strictNullChecks?: boolean;
disableSizeLimit?: boolean;
lib?: string[];
/* @internal */ stripInternal?: boolean;
+15 -2
View File
@@ -511,6 +511,7 @@ namespace ts {
case SyntaxKind.StringKeyword:
case SyntaxKind.BooleanKeyword:
case SyntaxKind.SymbolKeyword:
case SyntaxKind.UndefinedKeyword:
return true;
case SyntaxKind.VoidKeyword:
return node.parent.kind !== SyntaxKind.VoidExpression;
@@ -952,6 +953,16 @@ namespace ts {
return node.kind === SyntaxKind.ElementAccessExpression;
}
export function isJSXTagName(node: Node) {
const parent = node.parent;
if (parent.kind === SyntaxKind.JsxOpeningElement ||
parent.kind === SyntaxKind.JsxSelfClosingElement ||
parent.kind === SyntaxKind.JsxClosingElement) {
return (<JsxOpeningLikeElement>parent).tagName === node;
}
return false;
}
export function isExpression(node: Node): boolean {
switch (node.kind) {
case SyntaxKind.SuperKeyword:
@@ -968,6 +979,7 @@ namespace ts {
case SyntaxKind.TaggedTemplateExpression:
case SyntaxKind.AsExpression:
case SyntaxKind.TypeAssertionExpression:
case SyntaxKind.NonNullExpression:
case SyntaxKind.ParenthesizedExpression:
case SyntaxKind.FunctionExpression:
case SyntaxKind.ClassExpression:
@@ -992,9 +1004,9 @@ namespace ts {
while (node.parent.kind === SyntaxKind.QualifiedName) {
node = node.parent;
}
return node.parent.kind === SyntaxKind.TypeQuery;
return node.parent.kind === SyntaxKind.TypeQuery || isJSXTagName(node);
case SyntaxKind.Identifier:
if (node.parent.kind === SyntaxKind.TypeQuery) {
if (node.parent.kind === SyntaxKind.TypeQuery || isJSXTagName(node)) {
return true;
}
// fall through
@@ -2406,6 +2418,7 @@ namespace ts {
case SyntaxKind.ElementAccessExpression:
case SyntaxKind.NewExpression:
case SyntaxKind.CallExpression:
case SyntaxKind.NonNullExpression:
case SyntaxKind.JsxElement:
case SyntaxKind.JsxSelfClosingElement:
case SyntaxKind.TaggedTemplateExpression:
+24 -24
View File
@@ -304,13 +304,13 @@ interface String {
* Matches a string with a regular expression, and returns an array containing the results of that search.
* @param regexp A variable name or string literal containing the regular expression pattern and flags.
*/
match(regexp: string): RegExpMatchArray;
match(regexp: string): RegExpMatchArray | null;
/**
* Matches a string with a regular expression, and returns an array containing the results of that search.
* @param regexp A regular expression object that contains the regular expression pattern and applicable flags.
*/
match(regexp: RegExp): RegExpMatchArray;
match(regexp: RegExp): RegExpMatchArray | null;
/**
* Replaces text in a string, using a regular expression or search string.
@@ -813,7 +813,7 @@ interface RegExp {
* Executes a search on a string using a regular expression pattern, and returns an array containing the results of that search.
* @param string The String object or string literal on which to perform the search.
*/
exec(string: string): RegExpExecArray;
exec(string: string): RegExpExecArray | null;
/**
* Returns a Boolean value that indicates whether or not a pattern exists in a searched string.
@@ -836,7 +836,7 @@ interface RegExp {
lastIndex: number;
// Non-standard extensions
compile(): RegExp;
compile(): this;
}
interface RegExpConstructor {
@@ -1108,7 +1108,7 @@ interface Array<T> {
/**
* Removes the last element from an array and returns it.
*/
pop(): T;
pop(): T | undefined;
/**
* Combines two or more arrays.
* @param items Additional items to add to the end of array1.
@@ -1126,7 +1126,7 @@ interface Array<T> {
/**
* Removes the first element from an array and returns it.
*/
shift(): T;
shift(): T | undefined;
/**
* Returns a section of an array.
* @param start The beginning of the specified portion of the array.
@@ -1519,7 +1519,7 @@ interface Int8Array {
* @param thisArg If provided, it will be used as the this value for each invocation of
* predicate. If it is not provided, undefined is used instead.
*/
find(predicate: (value: number, index: number, obj: Array<number>) => boolean, thisArg?: any): number;
find(predicate: (value: number, index: number, obj: Array<number>) => boolean, thisArg?: any): number | undefined;
/**
* Returns the index of the first element in the array where predicate is true, and undefined
@@ -1530,7 +1530,7 @@ interface Int8Array {
* @param thisArg If provided, it will be used as the this value for each invocation of
* predicate. If it is not provided, undefined is used instead.
*/
findIndex(predicate: (value: number) => boolean, thisArg?: any): number;
findIndex(predicate: (value: number) => boolean, thisArg?: any): number | undefined;
/**
* Performs the specified action for each element in an array.
@@ -1792,7 +1792,7 @@ interface Uint8Array {
* @param thisArg If provided, it will be used as the this value for each invocation of
* predicate. If it is not provided, undefined is used instead.
*/
find(predicate: (value: number, index: number, obj: Array<number>) => boolean, thisArg?: any): number;
find(predicate: (value: number, index: number, obj: Array<number>) => boolean, thisArg?: any): number | undefined;
/**
* Returns the index of the first element in the array where predicate is true, and undefined
@@ -1803,7 +1803,7 @@ interface Uint8Array {
* @param thisArg If provided, it will be used as the this value for each invocation of
* predicate. If it is not provided, undefined is used instead.
*/
findIndex(predicate: (value: number) => boolean, thisArg?: any): number;
findIndex(predicate: (value: number) => boolean, thisArg?: any): number | undefined;
/**
* Performs the specified action for each element in an array.
@@ -2066,7 +2066,7 @@ interface Uint8ClampedArray {
* @param thisArg If provided, it will be used as the this value for each invocation of
* predicate. If it is not provided, undefined is used instead.
*/
find(predicate: (value: number, index: number, obj: Array<number>) => boolean, thisArg?: any): number;
find(predicate: (value: number, index: number, obj: Array<number>) => boolean, thisArg?: any): number | undefined;
/**
* Returns the index of the first element in the array where predicate is true, and undefined
@@ -2077,7 +2077,7 @@ interface Uint8ClampedArray {
* @param thisArg If provided, it will be used as the this value for each invocation of
* predicate. If it is not provided, undefined is used instead.
*/
findIndex(predicate: (value: number) => boolean, thisArg?: any): number;
findIndex(predicate: (value: number) => boolean, thisArg?: any): number | undefined;
/**
* Performs the specified action for each element in an array.
@@ -2339,7 +2339,7 @@ interface Int16Array {
* @param thisArg If provided, it will be used as the this value for each invocation of
* predicate. If it is not provided, undefined is used instead.
*/
find(predicate: (value: number, index: number, obj: Array<number>) => boolean, thisArg?: any): number;
find(predicate: (value: number, index: number, obj: Array<number>) => boolean, thisArg?: any): number | undefined;
/**
* Returns the index of the first element in the array where predicate is true, and undefined
@@ -2350,7 +2350,7 @@ interface Int16Array {
* @param thisArg If provided, it will be used as the this value for each invocation of
* predicate. If it is not provided, undefined is used instead.
*/
findIndex(predicate: (value: number) => boolean, thisArg?: any): number;
findIndex(predicate: (value: number) => boolean, thisArg?: any): number | undefined;
/**
* Performs the specified action for each element in an array.
@@ -2613,7 +2613,7 @@ interface Uint16Array {
* @param thisArg If provided, it will be used as the this value for each invocation of
* predicate. If it is not provided, undefined is used instead.
*/
find(predicate: (value: number, index: number, obj: Array<number>) => boolean, thisArg?: any): number;
find(predicate: (value: number, index: number, obj: Array<number>) => boolean, thisArg?: any): number | undefined;
/**
* Returns the index of the first element in the array where predicate is true, and undefined
@@ -2624,7 +2624,7 @@ interface Uint16Array {
* @param thisArg If provided, it will be used as the this value for each invocation of
* predicate. If it is not provided, undefined is used instead.
*/
findIndex(predicate: (value: number) => boolean, thisArg?: any): number;
findIndex(predicate: (value: number) => boolean, thisArg?: any): number | undefined;
/**
* Performs the specified action for each element in an array.
@@ -2886,7 +2886,7 @@ interface Int32Array {
* @param thisArg If provided, it will be used as the this value for each invocation of
* predicate. If it is not provided, undefined is used instead.
*/
find(predicate: (value: number, index: number, obj: Array<number>) => boolean, thisArg?: any): number;
find(predicate: (value: number, index: number, obj: Array<number>) => boolean, thisArg?: any): number | undefined;
/**
* Returns the index of the first element in the array where predicate is true, and undefined
@@ -2897,7 +2897,7 @@ interface Int32Array {
* @param thisArg If provided, it will be used as the this value for each invocation of
* predicate. If it is not provided, undefined is used instead.
*/
findIndex(predicate: (value: number) => boolean, thisArg?: any): number;
findIndex(predicate: (value: number) => boolean, thisArg?: any): number | undefined;
/**
* Performs the specified action for each element in an array.
@@ -3159,7 +3159,7 @@ interface Uint32Array {
* @param thisArg If provided, it will be used as the this value for each invocation of
* predicate. If it is not provided, undefined is used instead.
*/
find(predicate: (value: number, index: number, obj: Array<number>) => boolean, thisArg?: any): number;
find(predicate: (value: number, index: number, obj: Array<number>) => boolean, thisArg?: any): number | undefined;
/**
* Returns the index of the first element in the array where predicate is true, and undefined
@@ -3170,7 +3170,7 @@ interface Uint32Array {
* @param thisArg If provided, it will be used as the this value for each invocation of
* predicate. If it is not provided, undefined is used instead.
*/
findIndex(predicate: (value: number) => boolean, thisArg?: any): number;
findIndex(predicate: (value: number) => boolean, thisArg?: any): number | undefined;
/**
* Performs the specified action for each element in an array.
@@ -3432,7 +3432,7 @@ interface Float32Array {
* @param thisArg If provided, it will be used as the this value for each invocation of
* predicate. If it is not provided, undefined is used instead.
*/
find(predicate: (value: number, index: number, obj: Array<number>) => boolean, thisArg?: any): number;
find(predicate: (value: number, index: number, obj: Array<number>) => boolean, thisArg?: any): number | undefined;
/**
* Returns the index of the first element in the array where predicate is true, and undefined
@@ -3443,7 +3443,7 @@ interface Float32Array {
* @param thisArg If provided, it will be used as the this value for each invocation of
* predicate. If it is not provided, undefined is used instead.
*/
findIndex(predicate: (value: number) => boolean, thisArg?: any): number;
findIndex(predicate: (value: number) => boolean, thisArg?: any): number | undefined;
/**
* Performs the specified action for each element in an array.
@@ -3706,7 +3706,7 @@ interface Float64Array {
* @param thisArg If provided, it will be used as the this value for each invocation of
* predicate. If it is not provided, undefined is used instead.
*/
find(predicate: (value: number, index: number, obj: Array<number>) => boolean, thisArg?: any): number;
find(predicate: (value: number, index: number, obj: Array<number>) => boolean, thisArg?: any): number | undefined;
/**
* Returns the index of the first element in the array where predicate is true, and undefined
@@ -3717,7 +3717,7 @@ interface Float64Array {
* @param thisArg If provided, it will be used as the this value for each invocation of
* predicate. If it is not provided, undefined is used instead.
*/
findIndex(predicate: (value: number) => boolean, thisArg?: any): number;
findIndex(predicate: (value: number) => boolean, thisArg?: any): number | undefined;
/**
* Performs the specified action for each element in an array.
+8 -8
View File
@@ -34,7 +34,7 @@ interface SymbolConstructor {
* Otherwise, returns a undefined.
* @param sym Symbol to find the key for.
*/
keyFor(sym: symbol): string;
keyFor(sym: symbol): string | undefined;
// Well-known Symbols
@@ -320,7 +320,7 @@ interface Array<T> {
* @param thisArg If provided, it will be used as the this value for each invocation of
* predicate. If it is not provided, undefined is used instead.
*/
find(predicate: (value: T, index: number, obj: Array<T>) => boolean, thisArg?: any): T;
find(predicate: (value: T, index: number, obj: Array<T>) => boolean, thisArg?: any): T | undefined;
/**
* Returns the index of the first element in the array where predicate is true, and undefined
@@ -331,7 +331,7 @@ interface Array<T> {
* @param thisArg If provided, it will be used as the this value for each invocation of
* predicate. If it is not provided, undefined is used instead.
*/
findIndex(predicate: (value: T) => boolean, thisArg?: any): number;
findIndex(predicate: (value: T) => boolean, thisArg?: any): number | undefined;
/**
* Returns the this object after filling the section identified by start and end with value
@@ -407,7 +407,7 @@ interface String {
* If there is no element at that position, the result is undefined.
* If a valid UTF-16 surrogate pair does not begin at pos, the result is the code unit at pos.
*/
codePointAt(pos: number): number;
codePointAt(pos: number): number | undefined;
/**
* Returns true if searchString appears as a substring of the result of converting this
@@ -453,7 +453,7 @@ interface String {
* Matches a string an object that supports being matched against, and returns an array containing the results of that search.
* @param matcher An object that supports being matched against.
*/
match(matcher: { [Symbol.match](string: string): RegExpMatchArray; }): RegExpMatchArray;
match(matcher: { [Symbol.match](string: string): RegExpMatchArray | null; }): RegExpMatchArray | null;
/**
* Replaces text in a string, using an object that supports replacement within a string.
@@ -723,7 +723,7 @@ interface RegExp {
* that search.
* @param string A string to search within.
*/
[Symbol.match](string: string): RegExpMatchArray;
[Symbol.match](string: string): RegExpMatchArray | null;
/**
* Replaces text in a string, using this regular expression.
@@ -800,7 +800,7 @@ interface Map<K, V> {
delete(key: K): boolean;
entries(): IterableIterator<[K, V]>;
forEach(callbackfn: (value: V, index: K, map: Map<K, V>) => void, thisArg?: any): void;
get(key: K): V;
get(key: K): V | undefined;
has(key: K): boolean;
keys(): IterableIterator<K>;
set(key: K, value?: V): Map<K, V>;
@@ -821,7 +821,7 @@ declare var Map: MapConstructor;
interface WeakMap<K, V> {
clear(): void;
delete(key: K): boolean;
get(key: K): V;
get(key: K): V | undefined;
has(key: K): boolean;
set(key: K, value?: V): WeakMap<K, V>;
readonly [Symbol.toStringTag]: "WeakMap";
@@ -0,0 +1,70 @@
//// [APISample_parseConfig.ts]
/*
* Note: This test is a public API sample. The sample sources can be found
at: https://github.com/Microsoft/TypeScript/wiki/Using-the-Compiler-API#a-minimal-compiler
* Please log a "breaking change" issue for any API breaking change affecting this issue
*/
declare var process: any;
declare var console: any;
declare var os: any;
import ts = require("typescript");
function printError(error: ts.Diagnostic): void {
if (!error) {
return;
}
console.log(`${error.file && error.file.fileName}: ${error.messageText}`);
}
export function createProgram(rootFiles: string[], compilerOptionsJson: string): ts.Program {
const { config, error } = ts.parseConfigFileTextToJson("tsconfig.json", compilerOptionsJson)
if (error) {
printError(error);
return undefined;
}
const basePath: string = process.cwd();
const settings = ts.convertCompilerOptionsFromJson(config.config["compilerOptions"], basePath);
if (!settings.options) {
for (const err of settings.errors) {
printError(err);
}
return undefined;
}
return ts.createProgram(rootFiles, settings.options);
}
//// [APISample_parseConfig.js]
/*
* Note: This test is a public API sample. The sample sources can be found
at: https://github.com/Microsoft/TypeScript/wiki/Using-the-Compiler-API#a-minimal-compiler
* Please log a "breaking change" issue for any API breaking change affecting this issue
*/
"use strict";
var ts = require("typescript");
function printError(error) {
if (!error) {
return;
}
console.log((error.file && error.file.fileName) + ": " + error.messageText);
}
function createProgram(rootFiles, compilerOptionsJson) {
var _a = ts.parseConfigFileTextToJson("tsconfig.json", compilerOptionsJson), config = _a.config, error = _a.error;
if (error) {
printError(error);
return undefined;
}
var basePath = process.cwd();
var settings = ts.convertCompilerOptionsFromJson(config.config["compilerOptions"], basePath);
if (!settings.options) {
for (var _i = 0, _b = settings.errors; _i < _b.length; _i++) {
var err = _b[_i];
printError(err);
}
return undefined;
}
return ts.createProgram(rootFiles, settings.options);
}
exports.createProgram = createProgram;
@@ -19,7 +19,7 @@ var a = [undefined, undefined];
var b = [[], [null, null]]; // any[][]
>b : any[][]
>[[], [null, null]] : null[][]
>[[], [null, null]] : undefined[][]
>[] : undefined[]
>[null, null] : null[]
>null : null
@@ -1,7 +1,3 @@
tests/cases/conformance/types/tuple/castingTuple.ts(13,23): error TS2352: Neither type '[number, string]' nor type '[number, string, boolean]' is assignable to the other.
Property '2' is missing in type '[number, string]'.
tests/cases/conformance/types/tuple/castingTuple.ts(16,21): error TS2352: Neither type '[C, D]' nor type '[C, D, A]' is assignable to the other.
Property '2' is missing in type '[C, D]'.
tests/cases/conformance/types/tuple/castingTuple.ts(28,10): error TS2352: Neither type '[number, string]' nor type '[number, number]' is assignable to the other.
Types of property '1' are incompatible.
Type 'string' is not assignable to type 'number'.
@@ -10,15 +6,10 @@ tests/cases/conformance/types/tuple/castingTuple.ts(29,10): error TS2352: Neithe
Type 'C' is not assignable to type 'A'.
Property 'a' is missing in type 'C'.
tests/cases/conformance/types/tuple/castingTuple.ts(30,5): error TS2403: Subsequent variable declarations must have the same type. Variable 'array1' must be of type '{}[]', but here has type 'number[]'.
tests/cases/conformance/types/tuple/castingTuple.ts(30,14): error TS2352: Neither type '[number, string]' nor type 'number[]' is assignable to the other.
Types of property 'pop' are incompatible.
Type '() => number | string' is not assignable to type '() => number'.
Type 'number | string' is not assignable to type 'number'.
Type 'string' is not assignable to type 'number'.
tests/cases/conformance/types/tuple/castingTuple.ts(31,1): error TS2304: Cannot find name 't4'.
==== tests/cases/conformance/types/tuple/castingTuple.ts (7 errors) ====
==== tests/cases/conformance/types/tuple/castingTuple.ts (4 errors) ====
interface I { }
class A { a = 10; }
class C implements I { c };
@@ -32,15 +23,9 @@ tests/cases/conformance/types/tuple/castingTuple.ts(31,1): error TS2304: Cannot
var numStrTuple: [number, string] = [5, "foo"];
var emptyObjTuple = <[{}, {}]>numStrTuple;
var numStrBoolTuple = <[number, string, boolean]>numStrTuple;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2352: Neither type '[number, string]' nor type '[number, string, boolean]' is assignable to the other.
!!! error TS2352: Property '2' is missing in type '[number, string]'.
var classCDTuple: [C, D] = [new C(), new D()];
var interfaceIITuple = <[I, I]>classCDTuple;
var classCDATuple = <[C, D, A]>classCDTuple;
~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2352: Neither type '[C, D]' nor type '[C, D, A]' is assignable to the other.
!!! error TS2352: Property '2' is missing in type '[C, D]'.
var eleFromCDA1 = classCDATuple[2]; // A
var eleFromCDA2 = classCDATuple[5]; // C | D | A
var t10: [E1, E2] = [E1.one, E2.one];
@@ -66,12 +51,6 @@ tests/cases/conformance/types/tuple/castingTuple.ts(31,1): error TS2304: Cannot
var array1 = <number[]>numStrTuple;
~~~~~~
!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'array1' must be of type '{}[]', but here has type 'number[]'.
~~~~~~~~~~~~~~~~~~~~~
!!! error TS2352: Neither type '[number, string]' nor type 'number[]' is assignable to the other.
!!! error TS2352: Types of property 'pop' are incompatible.
!!! error TS2352: Type '() => number | string' is not assignable to type '() => number'.
!!! error TS2352: Type 'number | string' is not assignable to type 'number'.
!!! error TS2352: Type 'string' is not assignable to type 'number'.
t4[2] = 10;
~~
!!! error TS2304: Cannot find name 't4'.
@@ -3,7 +3,6 @@ tests/cases/conformance/types/tuple/contextualTypeWithTuple.ts(3,5): error TS232
Type '() => number | string | boolean' is not assignable to type '() => number | string'.
Type 'number | string | boolean' is not assignable to type 'number | string'.
Type 'boolean' is not assignable to type 'number | string'.
Type 'boolean' is not assignable to type 'string'.
tests/cases/conformance/types/tuple/contextualTypeWithTuple.ts(15,1): error TS2322: Type '[number, string, boolean]' is not assignable to type '[number, string]'.
tests/cases/conformance/types/tuple/contextualTypeWithTuple.ts(18,1): error TS2322: Type '[{}, number]' is not assignable to type '[{ a: string; }, number]'.
Types of property '0' are incompatible.
@@ -34,7 +33,6 @@ tests/cases/conformance/types/tuple/contextualTypeWithTuple.ts(25,1): error TS23
!!! error TS2322: Type '() => number | string | boolean' is not assignable to type '() => number | string'.
!!! error TS2322: Type 'number | string | boolean' is not assignable to type 'number | string'.
!!! error TS2322: Type 'boolean' is not assignable to type 'number | string'.
!!! error TS2322: Type 'boolean' is not assignable to type 'string'.
var numStrBoolTuple: [number, string, boolean] = [5, "foo", true];
var objNumTuple: [{ a: string }, number] = [{ a: "world" }, 5];
var strTupleTuple: [string, [number, {}]] = ["bar", [5, { x: 1, y: 1 }]];
@@ -14,7 +14,6 @@ tests/cases/conformance/types/contextualTypes/methodDeclarations/contextuallyTyp
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) ====
@@ -67,5 +66,4 @@ tests/cases/conformance/types/contextualTypes/methodDeclarations/contextuallyTyp
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"'.
@@ -1,7 +1,5 @@
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(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) ====
@@ -23,8 +21,6 @@ tests/cases/conformance/types/contextualTypes/jsxAttributes/contextuallyTypedStr
<FooComponent foo={"f"} />;
~~~~~~~~~
!!! error TS2322: Type '"f"' is not assignable to type '"A" | "B" | "C"'.
!!! error TS2322: Type '"f"' is not assignable to type '"C"'.
<FooComponent foo="f" />;
~~~~~~~
!!! error TS2322: Type '"f"' is not assignable to type '"A" | "B" | "C"'.
!!! error TS2322: Type '"f"' is not assignable to type '"C"'.
!!! error TS2322: Type '"f"' is not assignable to type '"A" | "B" | "C"'.
@@ -7,7 +7,6 @@ tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts(
Type '() => number | string[][] | string' is not assignable to type '() => number | string[][]'.
Type 'number | string[][] | string' is not assignable to type 'number | string[][]'.
Type 'string' is not assignable to type 'number | string[][]'.
Type 'string' is not assignable to type 'string[][]'.
tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts(16,8): error TS2371: A parameter initializer is only allowed in a function or constructor implementation.
tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts(16,16): error TS2371: A parameter initializer is only allowed in a function or constructor implementation.
tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts(23,14): error TS2345: Argument of type '{ x: string; y: boolean; }' is not assignable to parameter of type '{ x: number; y: any; }'.
@@ -29,7 +28,6 @@ tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts(
tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts(38,4): error TS2345: Argument of type '{ b: boolean; }' is not assignable to parameter of type '{ b: number | string; }'.
Types of property 'b' are incompatible.
Type 'boolean' is not assignable to type 'number | string'.
Type 'boolean' is not assignable to type 'string'.
tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts(39,4): error TS2345: Argument of type '[number, number, boolean, boolean]' is not assignable to parameter of type '[any, any, [[any]]]'.
Types of property '2' are incompatible.
Type 'boolean' is not assignable to type '[[any]]'.
@@ -75,7 +73,6 @@ tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts(
!!! error TS2345: Type '() => number | string[][] | string' is not assignable to type '() => number | string[][]'.
!!! error TS2345: Type 'number | string[][] | string' is not assignable to type 'number | string[][]'.
!!! error TS2345: Type 'string' is not assignable to type 'number | string[][]'.
!!! error TS2345: Type 'string' is not assignable to type 'string[][]'.
// If the declaration includes an initializer expression (which is permitted only
@@ -137,7 +134,6 @@ tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts(
!!! error TS2345: Argument of type '{ b: boolean; }' is not assignable to parameter of type '{ b: number | string; }'.
!!! error TS2345: Types of property 'b' are incompatible.
!!! error TS2345: Type 'boolean' is not assignable to type 'number | string'.
!!! error TS2345: Type 'boolean' is not assignable to type 'string'.
c5([1, 2, false, true]); // Error, implied type is [any, any, [[any]]]
~~~~~~~~~~~~~~~~~~~
!!! error TS2345: Argument of type '[number, number, boolean, boolean]' is not assignable to parameter of type '[any, any, [[any]]]'.
@@ -1,7 +1,6 @@
tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration4.ts(11,13): error TS2370: A rest parameter must be of an array type.
tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration4.ts(13,13): error TS2370: A rest parameter must be of an array type.
tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration4.ts(20,19): error TS2345: Argument of type 'boolean' is not assignable to parameter of type 'number | string'.
Type 'boolean' is not assignable to type 'string'.
tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration4.ts(21,7): error TS2304: Cannot find name 'array2'.
tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration4.ts(22,4): error TS2345: Argument of type '[number, number, string, boolean, boolean]' is not assignable to parameter of type '[any, any, [[any]]]'.
Types of property '2' are incompatible.
@@ -43,7 +42,6 @@ tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration4.ts(
a1(1, 2, "hello", true); // Error, parameter type is (number|string)[]
~~~~
!!! error TS2345: Argument of type 'boolean' is not assignable to parameter of type 'number | string'.
!!! error TS2345: Type 'boolean' is not assignable to type 'string'.
a1(...array2); // Error parameter type is (number|string)[]
~~~~~~
!!! error TS2304: Cannot find name 'array2'.
@@ -1,7 +1,6 @@
tests/cases/compiler/errorMessagesIntersectionTypes02.ts(14,5): error TS2322: Type '{ fooProp: string; } & Bar' is not assignable to type 'FooBar'.
Types of property 'fooProp' are incompatible.
Type 'string' is not assignable to type '"hello" | "world"'.
Type 'string' is not assignable to type '"world"'.
==== tests/cases/compiler/errorMessagesIntersectionTypes02.ts (1 errors) ====
@@ -23,6 +22,5 @@ tests/cases/compiler/errorMessagesIntersectionTypes02.ts(14,5): error TS2322: Ty
!!! error TS2322: Type '{ fooProp: string; } & Bar' is not assignable to type 'FooBar'.
!!! error TS2322: Types of property 'fooProp' are incompatible.
!!! error TS2322: Type 'string' is not assignable to type '"hello" | "world"'.
!!! error TS2322: Type 'string' is not assignable to type '"world"'.
fooProp: "frizzlebizzle"
});
@@ -0,0 +1,13 @@
tests/cases/compiler/f2.ts(1,9): error TS2440: Import declaration conflicts with local declaration of 'f'
==== tests/cases/compiler/f1.ts (0 errors) ====
export function f() {
}
==== tests/cases/compiler/f2.ts (1 errors) ====
import {f} from './f1';
~
!!! error TS2440: Import declaration conflicts with local declaration of 'f'
export function f() {
}
@@ -0,0 +1,21 @@
//// [tests/cases/compiler/functionAndImportNameConflict.ts] ////
//// [f1.ts]
export function f() {
}
//// [f2.ts]
import {f} from './f1';
export function f() {
}
//// [f1.js]
"use strict";
function f() {
}
exports.f = f;
//// [f2.js]
"use strict";
function f() {
}
exports.f = f;
@@ -3,7 +3,6 @@ tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithTup
Type '() => string | number | boolean' is not assignable to type '() => string | number'.
Type 'string | number | boolean' is not assignable to type 'string | number'.
Type 'boolean' is not assignable to type 'string | number'.
Type 'boolean' is not assignable to type 'number'.
tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithTupleType.ts(14,1): error TS2322: Type '{ a: string; }' is not assignable to type 'string | number'.
Type '{ a: string; }' is not assignable to type 'number'.
tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithTupleType.ts(22,1): error TS2322: Type '[number, string]' is not assignable to type '[string, number]'.
@@ -35,7 +34,6 @@ tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithTup
!!! error TS2322: Type '() => string | number | boolean' is not assignable to type '() => string | number'.
!!! error TS2322: Type 'string | number | boolean' is not assignable to type 'string | number'.
!!! error TS2322: Type 'boolean' is not assignable to type 'string | number'.
!!! error TS2322: Type 'boolean' is not assignable to type 'number'.
var e3 = i1.tuple1[2]; // {}
i1.tuple1[3] = { a: "string" };
~~~~~~~~~~~~
@@ -0,0 +1,82 @@
//// [tests/cases/compiler/inferenceLimit.ts] ////
//// [file1.ts]
"use strict";
import * as MyModule from "./mymodule";
export class BrokenClass {
constructor() {}
public brokenMethod(field: string, value: string) {
return new Promise<Array<MyModule.MyModel>>((resolve, reject) => {
let result: Array<MyModule.MyModel> = [];
let populateItems = (order) => {
return new Promise((resolve, reject) => {
this.doStuff(order.id)
.then((items) => {
order.items = items;
resolve(order);
});
});
};
return Promise.all(result.map(populateItems))
.then((orders: Array<MyModule.MyModel>) => {
resolve(orders);
});
});
}
public async doStuff(id: number) {
return;
}
}
//// [mymodule.ts]
export interface MyModel {
id: number;
}
//// [mymodule.js]
"use strict";
//// [file1.js]
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator.throw(value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments)).next());
});
};
class BrokenClass {
constructor() {
}
brokenMethod(field, value) {
return new Promise((resolve, reject) => {
let result = [];
let populateItems = (order) => {
return new Promise((resolve, reject) => {
this.doStuff(order.id)
.then((items) => {
order.items = items;
resolve(order);
});
});
};
return Promise.all(result.map(populateItems))
.then((orders) => {
resolve(orders);
});
});
}
doStuff(id) {
return __awaiter(this, void 0, void 0, function* () {
return;
});
}
}
exports.BrokenClass = BrokenClass;
@@ -0,0 +1,101 @@
=== tests/cases/compiler/file1.ts ===
"use strict";
import * as MyModule from "./mymodule";
>MyModule : Symbol(MyModule, Decl(file1.ts, 1, 6))
export class BrokenClass {
>BrokenClass : Symbol(BrokenClass, Decl(file1.ts, 1, 39))
constructor() {}
public brokenMethod(field: string, value: string) {
>brokenMethod : Symbol(BrokenClass.brokenMethod, Decl(file1.ts, 5, 18))
>field : Symbol(field, Decl(file1.ts, 7, 22))
>value : Symbol(value, Decl(file1.ts, 7, 36))
return new Promise<Array<MyModule.MyModel>>((resolve, reject) => {
>Promise : Symbol(Promise, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
>Array : Symbol(Array, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
>MyModule : Symbol(MyModule, Decl(file1.ts, 1, 6))
>MyModel : Symbol(MyModule.MyModel, Decl(mymodule.ts, 0, 0))
>resolve : Symbol(resolve, Decl(file1.ts, 8, 47))
>reject : Symbol(reject, Decl(file1.ts, 8, 55))
let result: Array<MyModule.MyModel> = [];
>result : Symbol(result, Decl(file1.ts, 10, 7))
>Array : Symbol(Array, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
>MyModule : Symbol(MyModule, Decl(file1.ts, 1, 6))
>MyModel : Symbol(MyModule.MyModel, Decl(mymodule.ts, 0, 0))
let populateItems = (order) => {
>populateItems : Symbol(populateItems, Decl(file1.ts, 12, 7))
>order : Symbol(order, Decl(file1.ts, 12, 25))
return new Promise((resolve, reject) => {
>Promise : Symbol(Promise, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
>resolve : Symbol(resolve, Decl(file1.ts, 13, 26))
>reject : Symbol(reject, Decl(file1.ts, 13, 34))
this.doStuff(order.id)
>this.doStuff(order.id) .then : Symbol(Promise.then, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
>this.doStuff : Symbol(BrokenClass.doStuff, Decl(file1.ts, 27, 3))
>this : Symbol(BrokenClass, Decl(file1.ts, 1, 39))
>doStuff : Symbol(BrokenClass.doStuff, Decl(file1.ts, 27, 3))
>order : Symbol(order, Decl(file1.ts, 12, 25))
.then((items) => {
>then : Symbol(Promise.then, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
>items : Symbol(items, Decl(file1.ts, 15, 17))
order.items = items;
>order : Symbol(order, Decl(file1.ts, 12, 25))
>items : Symbol(items, Decl(file1.ts, 15, 17))
resolve(order);
>resolve : Symbol(resolve, Decl(file1.ts, 13, 26))
>order : Symbol(order, Decl(file1.ts, 12, 25))
});
});
};
return Promise.all(result.map(populateItems))
>Promise.all(result.map(populateItems)) .then : Symbol(Promise.then, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
>Promise.all : Symbol(PromiseConstructor.all, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
>Promise : Symbol(Promise, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
>all : Symbol(PromiseConstructor.all, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
>result.map : Symbol(Array.map, Decl(lib.d.ts, --, --))
>result : Symbol(result, Decl(file1.ts, 10, 7))
>map : Symbol(Array.map, Decl(lib.d.ts, --, --))
>populateItems : Symbol(populateItems, Decl(file1.ts, 12, 7))
.then((orders: Array<MyModule.MyModel>) => {
>then : Symbol(Promise.then, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
>orders : Symbol(orders, Decl(file1.ts, 23, 13))
>Array : Symbol(Array, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
>MyModule : Symbol(MyModule, Decl(file1.ts, 1, 6))
>MyModel : Symbol(MyModule.MyModel, Decl(mymodule.ts, 0, 0))
resolve(orders);
>resolve : Symbol(resolve, Decl(file1.ts, 8, 47))
>orders : Symbol(orders, Decl(file1.ts, 23, 13))
});
});
}
public async doStuff(id: number) {
>doStuff : Symbol(BrokenClass.doStuff, Decl(file1.ts, 27, 3))
>id : Symbol(id, Decl(file1.ts, 29, 23))
return;
}
}
=== tests/cases/compiler/mymodule.ts ===
export interface MyModel {
>MyModel : Symbol(MyModel, Decl(mymodule.ts, 0, 0))
id: number;
>id : Symbol(MyModel.id, Decl(mymodule.ts, 0, 26))
}
@@ -0,0 +1,123 @@
=== tests/cases/compiler/file1.ts ===
"use strict";
>"use strict" : string
import * as MyModule from "./mymodule";
>MyModule : typeof MyModule
export class BrokenClass {
>BrokenClass : BrokenClass
constructor() {}
public brokenMethod(field: string, value: string) {
>brokenMethod : (field: string, value: string) => Promise<MyModule.MyModel[]>
>field : string
>value : string
return new Promise<Array<MyModule.MyModel>>((resolve, reject) => {
>new Promise<Array<MyModule.MyModel>>((resolve, reject) => { let result: Array<MyModule.MyModel> = []; let populateItems = (order) => { return new Promise((resolve, reject) => { this.doStuff(order.id) .then((items) => { order.items = items; resolve(order); }); }); }; return Promise.all(result.map(populateItems)) .then((orders: Array<MyModule.MyModel>) => { resolve(orders); }); }) : Promise<MyModule.MyModel[]>
>Promise : PromiseConstructor
>Array : T[]
>MyModule : any
>MyModel : MyModule.MyModel
>(resolve, reject) => { let result: Array<MyModule.MyModel> = []; let populateItems = (order) => { return new Promise((resolve, reject) => { this.doStuff(order.id) .then((items) => { order.items = items; resolve(order); }); }); }; return Promise.all(result.map(populateItems)) .then((orders: Array<MyModule.MyModel>) => { resolve(orders); }); } : (resolve: (value?: MyModule.MyModel[] | PromiseLike<MyModule.MyModel[]>) => void, reject: (reason?: any) => void) => Promise<void>
>resolve : (value?: MyModule.MyModel[] | PromiseLike<MyModule.MyModel[]>) => void
>reject : (reason?: any) => void
let result: Array<MyModule.MyModel> = [];
>result : MyModule.MyModel[]
>Array : T[]
>MyModule : any
>MyModel : MyModule.MyModel
>[] : undefined[]
let populateItems = (order) => {
>populateItems : (order: any) => Promise<{}>
>(order) => { return new Promise((resolve, reject) => { this.doStuff(order.id) .then((items) => { order.items = items; resolve(order); }); }); } : (order: any) => Promise<{}>
>order : any
return new Promise((resolve, reject) => {
>new Promise((resolve, reject) => { this.doStuff(order.id) .then((items) => { order.items = items; resolve(order); }); }) : Promise<{}>
>Promise : PromiseConstructor
>(resolve, reject) => { this.doStuff(order.id) .then((items) => { order.items = items; resolve(order); }); } : (resolve: (value?: {} | PromiseLike<{}>) => void, reject: (reason?: any) => void) => void
>resolve : (value?: {} | PromiseLike<{}>) => void
>reject : (reason?: any) => void
this.doStuff(order.id)
>this.doStuff(order.id) .then((items) => { order.items = items; resolve(order); }) : Promise<void>
>this.doStuff(order.id) .then : { <TResult>(onfulfilled?: (value: void) => TResult | PromiseLike<TResult>, onrejected?: (reason: any) => TResult | PromiseLike<TResult>): Promise<TResult>; <TResult>(onfulfilled?: (value: void) => TResult | PromiseLike<TResult>, onrejected?: (reason: any) => void): Promise<TResult>; }
>this.doStuff(order.id) : Promise<void>
>this.doStuff : (id: number) => Promise<void>
>this : this
>doStuff : (id: number) => Promise<void>
>order.id : any
>order : any
>id : any
.then((items) => {
>then : { <TResult>(onfulfilled?: (value: void) => TResult | PromiseLike<TResult>, onrejected?: (reason: any) => TResult | PromiseLike<TResult>): Promise<TResult>; <TResult>(onfulfilled?: (value: void) => TResult | PromiseLike<TResult>, onrejected?: (reason: any) => void): Promise<TResult>; }
>(items) => { order.items = items; resolve(order); } : (items: void) => void
>items : void
order.items = items;
>order.items = items : void
>order.items : any
>order : any
>items : any
>items : void
resolve(order);
>resolve(order) : void
>resolve : (value?: {} | PromiseLike<{}>) => void
>order : any
});
});
};
return Promise.all(result.map(populateItems))
>Promise.all(result.map(populateItems)) .then((orders: Array<MyModule.MyModel>) => { resolve(orders); }) : Promise<void>
>Promise.all(result.map(populateItems)) .then : { <TResult>(onfulfilled?: (value: {}[]) => TResult | PromiseLike<TResult>, onrejected?: (reason: any) => TResult | PromiseLike<TResult>): Promise<TResult>; <TResult>(onfulfilled?: (value: {}[]) => TResult | PromiseLike<TResult>, onrejected?: (reason: any) => void): Promise<TResult>; }
>Promise.all(result.map(populateItems)) : Promise<{}[]>
>Promise.all : { <T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>, T4 | PromiseLike<T4>, T5 | PromiseLike<T5>, T6 | PromiseLike<T6>, T7 | PromiseLike<T7>, T8 | PromiseLike<T8>, T9 | PromiseLike<T9>, T10 | PromiseLike<T10>]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10]>; <T1, T2, T3, T4, T5, T6, T7, T8, T9>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>, T4 | PromiseLike<T4>, T5 | PromiseLike<T5>, T6 | PromiseLike<T6>, T7 | PromiseLike<T7>, T8 | PromiseLike<T8>, T9 | PromiseLike<T9>]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8, T9]>; <T1, T2, T3, T4, T5, T6, T7, T8>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>, T4 | PromiseLike<T4>, T5 | PromiseLike<T5>, T6 | PromiseLike<T6>, T7 | PromiseLike<T7>, T8 | PromiseLike<T8>]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8]>; <T1, T2, T3, T4, T5, T6, T7>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>, T4 | PromiseLike<T4>, T5 | PromiseLike<T5>, T6 | PromiseLike<T6>, T7 | PromiseLike<T7>]): Promise<[T1, T2, T3, T4, T5, T6, T7]>; <T1, T2, T3, T4, T5, T6>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>, T4 | PromiseLike<T4>, T5 | PromiseLike<T5>, T6 | PromiseLike<T6>]): Promise<[T1, T2, T3, T4, T5, T6]>; <T1, T2, T3, T4, T5>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>, T4 | PromiseLike<T4>, T5 | PromiseLike<T5>]): Promise<[T1, T2, T3, T4, T5]>; <T1, T2, T3, T4>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>, T4 | PromiseLike<T4>]): Promise<[T1, T2, T3, T4]>; <T1, T2, T3>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>]): Promise<[T1, T2, T3]>; <T1, T2>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>]): Promise<[T1, T2]>; <TAll>(values: Iterable<TAll | PromiseLike<TAll>>): Promise<TAll[]>; }
>Promise : PromiseConstructor
>all : { <T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>, T4 | PromiseLike<T4>, T5 | PromiseLike<T5>, T6 | PromiseLike<T6>, T7 | PromiseLike<T7>, T8 | PromiseLike<T8>, T9 | PromiseLike<T9>, T10 | PromiseLike<T10>]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10]>; <T1, T2, T3, T4, T5, T6, T7, T8, T9>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>, T4 | PromiseLike<T4>, T5 | PromiseLike<T5>, T6 | PromiseLike<T6>, T7 | PromiseLike<T7>, T8 | PromiseLike<T8>, T9 | PromiseLike<T9>]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8, T9]>; <T1, T2, T3, T4, T5, T6, T7, T8>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>, T4 | PromiseLike<T4>, T5 | PromiseLike<T5>, T6 | PromiseLike<T6>, T7 | PromiseLike<T7>, T8 | PromiseLike<T8>]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8]>; <T1, T2, T3, T4, T5, T6, T7>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>, T4 | PromiseLike<T4>, T5 | PromiseLike<T5>, T6 | PromiseLike<T6>, T7 | PromiseLike<T7>]): Promise<[T1, T2, T3, T4, T5, T6, T7]>; <T1, T2, T3, T4, T5, T6>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>, T4 | PromiseLike<T4>, T5 | PromiseLike<T5>, T6 | PromiseLike<T6>]): Promise<[T1, T2, T3, T4, T5, T6]>; <T1, T2, T3, T4, T5>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>, T4 | PromiseLike<T4>, T5 | PromiseLike<T5>]): Promise<[T1, T2, T3, T4, T5]>; <T1, T2, T3, T4>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>, T4 | PromiseLike<T4>]): Promise<[T1, T2, T3, T4]>; <T1, T2, T3>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>]): Promise<[T1, T2, T3]>; <T1, T2>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>]): Promise<[T1, T2]>; <TAll>(values: Iterable<TAll | PromiseLike<TAll>>): Promise<TAll[]>; }
>result.map(populateItems) : Promise<{}>[]
>result.map : <U>(callbackfn: (value: MyModule.MyModel, index: number, array: MyModule.MyModel[]) => U, thisArg?: any) => U[]
>result : MyModule.MyModel[]
>map : <U>(callbackfn: (value: MyModule.MyModel, index: number, array: MyModule.MyModel[]) => U, thisArg?: any) => U[]
>populateItems : (order: any) => Promise<{}>
.then((orders: Array<MyModule.MyModel>) => {
>then : { <TResult>(onfulfilled?: (value: {}[]) => TResult | PromiseLike<TResult>, onrejected?: (reason: any) => TResult | PromiseLike<TResult>): Promise<TResult>; <TResult>(onfulfilled?: (value: {}[]) => TResult | PromiseLike<TResult>, onrejected?: (reason: any) => void): Promise<TResult>; }
>(orders: Array<MyModule.MyModel>) => { resolve(orders); } : (orders: MyModule.MyModel[]) => void
>orders : MyModule.MyModel[]
>Array : T[]
>MyModule : any
>MyModel : MyModule.MyModel
resolve(orders);
>resolve(orders) : void
>resolve : (value?: MyModule.MyModel[] | PromiseLike<MyModule.MyModel[]>) => void
>orders : MyModule.MyModel[]
});
});
}
public async doStuff(id: number) {
>doStuff : (id: number) => Promise<void>
>id : number
return;
}
}
=== tests/cases/compiler/mymodule.ts ===
export interface MyModel {
>MyModel : MyModel
id: number;
>id : number
}
@@ -1,12 +1,10 @@
tests/cases/conformance/es6/spread/iteratorSpreadInCall6.ts(1,28): error TS2345: Argument of type 'string' is not assignable to parameter of type 'symbol | number'.
Type 'string' is not assignable to type 'number'.
==== tests/cases/conformance/es6/spread/iteratorSpreadInCall6.ts (1 errors) ====
foo(...new SymbolIterator, ...new StringIterator);
~~~~~~~~~~~~~~~~~~~~~
!!! error TS2345: Argument of type 'string' is not assignable to parameter of type 'symbol | number'.
!!! error TS2345: Type 'string' is not assignable to type 'number'.
function foo(...s: (symbol | number)[]) { }
class SymbolIterator {
@@ -56,9 +56,11 @@ declare var hasOwnProperty:any;
>div : Symbol(unknown)
<Component>{foo}<br />{bar}</Component>
>Component : Symbol(Component, Decl(jsxReactTestSuite.tsx, 2, 11))
>foo : Symbol(foo, Decl(jsxReactTestSuite.tsx, 7, 11))
>br : Symbol(unknown)
>bar : Symbol(bar, Decl(jsxReactTestSuite.tsx, 8, 11))
>Component : Symbol(Component, Decl(jsxReactTestSuite.tsx, 2, 11))
<br />
>br : Symbol(unknown)
@@ -68,12 +70,20 @@ declare var hasOwnProperty:any;
<Composite>
>Composite : Symbol(Composite, Decl(jsxReactTestSuite.tsx, 3, 11))
{this.props.children}
</Composite>;
>Composite : Symbol(Composite, Decl(jsxReactTestSuite.tsx, 3, 11))
<Composite>
>Composite : Symbol(Composite, Decl(jsxReactTestSuite.tsx, 3, 11))
<Composite2 />
>Composite2 : Symbol(Composite2, Decl(jsxReactTestSuite.tsx, 4, 11))
</Composite>;
>Composite : Symbol(Composite, Decl(jsxReactTestSuite.tsx, 3, 11))
var x =
>x : Symbol(x, Decl(jsxReactTestSuite.tsx, 10, 11), Decl(jsxReactTestSuite.tsx, 35, 3))
@@ -164,13 +174,17 @@ var x =
>hasOwnProperty : Symbol(unknown)
<Component constructor="foo" />;
>Component : Symbol(Component, Decl(jsxReactTestSuite.tsx, 2, 11))
>constructor : Symbol(unknown)
<Namespace.Component />;
>Namespace : Symbol(Namespace, Decl(jsxReactTestSuite.tsx, 6, 11))
<Namespace.DeepNamespace.Component />;
>Namespace : Symbol(Namespace, Decl(jsxReactTestSuite.tsx, 6, 11))
<Component { ... x } y
>Component : Symbol(Component, Decl(jsxReactTestSuite.tsx, 2, 11))
>x : Symbol(x, Decl(jsxReactTestSuite.tsx, 10, 11), Decl(jsxReactTestSuite.tsx, 35, 3))
>y : Symbol(unknown)
@@ -178,6 +192,8 @@ var x =
>z : Symbol(unknown)
<Component
>Component : Symbol(Component, Decl(jsxReactTestSuite.tsx, 2, 11))
{...this.props} sound="moo" />;
>sound : Symbol(unknown)
@@ -185,6 +201,7 @@ var x =
>font-face : Symbol(unknown)
<Component x={y} />;
>Component : Symbol(Component, Decl(jsxReactTestSuite.tsx, 2, 11))
>x : Symbol(unknown)
>y : Symbol(y, Decl(jsxReactTestSuite.tsx, 9, 11))
@@ -192,34 +209,43 @@ var x =
>x-component : Symbol(unknown)
<Component {...x} />;
>Component : Symbol(Component, Decl(jsxReactTestSuite.tsx, 2, 11))
>x : Symbol(x, Decl(jsxReactTestSuite.tsx, 10, 11), Decl(jsxReactTestSuite.tsx, 35, 3))
<Component { ...x } y={2} />;
>Component : Symbol(Component, Decl(jsxReactTestSuite.tsx, 2, 11))
>x : Symbol(x, Decl(jsxReactTestSuite.tsx, 10, 11), Decl(jsxReactTestSuite.tsx, 35, 3))
>y : Symbol(unknown)
<Component { ... x } y={2} z />;
>Component : Symbol(Component, Decl(jsxReactTestSuite.tsx, 2, 11))
>x : Symbol(x, Decl(jsxReactTestSuite.tsx, 10, 11), Decl(jsxReactTestSuite.tsx, 35, 3))
>y : Symbol(unknown)
>z : Symbol(unknown)
<Component x={1} {...y} />;
>Component : Symbol(Component, Decl(jsxReactTestSuite.tsx, 2, 11))
>x : Symbol(unknown)
>y : Symbol(y, Decl(jsxReactTestSuite.tsx, 9, 11))
<Component x={1} y="2" {...z} {...z}><Child /></Component>;
>Component : Symbol(Component, Decl(jsxReactTestSuite.tsx, 2, 11))
>x : Symbol(unknown)
>y : Symbol(unknown)
>z : Symbol(z, Decl(jsxReactTestSuite.tsx, 11, 11))
>z : Symbol(z, Decl(jsxReactTestSuite.tsx, 11, 11))
>Child : Symbol(Child, Decl(jsxReactTestSuite.tsx, 5, 11))
>Component : Symbol(Component, Decl(jsxReactTestSuite.tsx, 2, 11))
<Component x="1" {...(z = { y: 2 }, z)} z={3}>Text</Component>;
>Component : Symbol(Component, Decl(jsxReactTestSuite.tsx, 2, 11))
>x : Symbol(unknown)
>z : Symbol(z, Decl(jsxReactTestSuite.tsx, 11, 11))
>y : Symbol(y, Decl(jsxReactTestSuite.tsx, 113, 27))
>z : Symbol(z, Decl(jsxReactTestSuite.tsx, 11, 11))
>z : Symbol(unknown)
>Component : Symbol(Component, Decl(jsxReactTestSuite.tsx, 2, 11))
@@ -235,11 +235,14 @@ var x =
<Namespace.Component />;
><Namespace.Component /> : any
>Namespace.Component : any
>Namespace : any
>Component : any
<Namespace.DeepNamespace.Component />;
><Namespace.DeepNamespace.Component /> : any
>Namespace.DeepNamespace.Component : any
>Namespace.DeepNamespace : any
>Namespace : any
>DeepNamespace : any
>Component : any
@@ -623,7 +623,7 @@ var rj8 = a8 && undefined;
var rj9 = null && undefined;
>rj9 : any
>null && undefined : undefined
>null && undefined : null
>null : null
>undefined : undefined
@@ -1,19 +1,13 @@
tests/cases/conformance/expressions/unaryOperators/logicalNotOperator/logicalNotOperatorInvalidOperations.ts(5,17): error TS1005: ',' expected.
tests/cases/conformance/expressions/unaryOperators/logicalNotOperator/logicalNotOperatorInvalidOperations.ts(5,18): error TS1109: Expression expected.
tests/cases/conformance/expressions/unaryOperators/logicalNotOperator/logicalNotOperatorInvalidOperations.ts(8,16): error TS2365: Operator '+' cannot be applied to types 'boolean' and 'number'.
tests/cases/conformance/expressions/unaryOperators/logicalNotOperator/logicalNotOperatorInvalidOperations.ts(11,16): error TS1109: Expression expected.
==== tests/cases/conformance/expressions/unaryOperators/logicalNotOperator/logicalNotOperatorInvalidOperations.ts (4 errors) ====
==== tests/cases/conformance/expressions/unaryOperators/logicalNotOperator/logicalNotOperatorInvalidOperations.ts (2 errors) ====
// Unary operator !
var b: number;
// operand before !
var BOOLEAN1 = b!; //expect error
~
!!! error TS1005: ',' expected.
~
!!! error TS1109: Expression expected.
// miss parentheses
var BOOLEAN2 = !b + b;
@@ -15,8 +15,7 @@ var BOOLEAN3 =!;
// Unary operator !
var b;
// operand before !
var BOOLEAN1 = b;
!; //expect error
var BOOLEAN1 = b; //expect error
// miss parentheses
var BOOLEAN2 = !b + b;
// miss an operand
@@ -0,0 +1,20 @@
//// [tests/cases/compiler/mergeWithImportedNamespace.ts] ////
//// [f1.ts]
export namespace N { export var x = 1; }
//// [f2.ts]
import {N} from "./f1";
// partial revert of https://github.com/Microsoft/TypeScript/pull/7583 to prevent breaking changes
export namespace N {
export interface I {x: any}
}
//// [f1.js]
"use strict";
var N;
(function (N) {
N.x = 1;
})(N = exports.N || (exports.N = {}));
//// [f2.js]
"use strict";
@@ -0,0 +1,17 @@
=== tests/cases/compiler/f1.ts ===
export namespace N { export var x = 1; }
>N : Symbol(N, Decl(f1.ts, 0, 0))
>x : Symbol(x, Decl(f1.ts, 0, 31))
=== tests/cases/compiler/f2.ts ===
import {N} from "./f1";
>N : Symbol(N, Decl(f2.ts, 0, 8), Decl(f2.ts, 0, 23))
// partial revert of https://github.com/Microsoft/TypeScript/pull/7583 to prevent breaking changes
export namespace N {
>N : Symbol(N, Decl(f2.ts, 0, 23))
export interface I {x: any}
>I : Symbol(I, Decl(f2.ts, 2, 20))
>x : Symbol(I.x, Decl(f2.ts, 3, 24))
}
@@ -0,0 +1,18 @@
=== tests/cases/compiler/f1.ts ===
export namespace N { export var x = 1; }
>N : typeof N
>x : number
>1 : number
=== tests/cases/compiler/f2.ts ===
import {N} from "./f1";
>N : typeof N
// partial revert of https://github.com/Microsoft/TypeScript/pull/7583 to prevent breaking changes
export namespace N {
>N : any
export interface I {x: any}
>I : I
>x : any
}
@@ -0,0 +1,18 @@
//// [tests/cases/compiler/mergeWithImportedType.ts] ////
//// [f1.ts]
export enum E {X}
//// [f2.ts]
import {E} from "./f1";
// partial revert of https://github.com/Microsoft/TypeScript/pull/7583 to prevent breaking changes
export type E = E;
//// [f1.js]
"use strict";
(function (E) {
E[E["X"] = 0] = "X";
})(exports.E || (exports.E = {}));
var E = exports.E;
//// [f2.js]
"use strict";
@@ -0,0 +1,14 @@
=== tests/cases/compiler/f1.ts ===
export enum E {X}
>E : Symbol(E, Decl(f1.ts, 0, 0))
>X : Symbol(E.X, Decl(f1.ts, 0, 15))
=== tests/cases/compiler/f2.ts ===
import {E} from "./f1";
>E : Symbol(E, Decl(f2.ts, 0, 8), Decl(f2.ts, 0, 23))
// partial revert of https://github.com/Microsoft/TypeScript/pull/7583 to prevent breaking changes
export type E = E;
>E : Symbol(E, Decl(f2.ts, 0, 23))
>E : Symbol(E, Decl(f2.ts, 0, 8), Decl(f2.ts, 0, 23))
@@ -0,0 +1,14 @@
=== tests/cases/compiler/f1.ts ===
export enum E {X}
>E : E
>X : E
=== tests/cases/compiler/f2.ts ===
import {E} from "./f1";
>E : typeof E
// partial revert of https://github.com/Microsoft/TypeScript/pull/7583 to prevent breaking changes
export type E = E;
>E : E
>E : E
@@ -0,0 +1,84 @@
//// [privateClassPropertyAccessibleWithinNestedClass.ts]
// no errors
class C {
private x: string;
private get y() { return this.x; }
private set y(x) { this.y = this.x; }
private foo() { return this.foo; }
private static x: string;
private static get y() { return this.x; }
private static set y(x) { this.y = this.x; }
private static foo() { return this.foo; }
private static bar() { this.foo(); }
private bar() {
class C2 {
private foo() {
let x: C;
var x1 = x.foo;
var x2 = x.bar;
var x3 = x.x;
var x4 = x.y;
var sx1 = C.x;
var sx2 = C.y;
var sx3 = C.bar;
var sx4 = C.foo;
let y = new C();
var y1 = y.foo;
var y2 = y.bar;
var y3 = y.x;
var y4 = y.y;
}
}
}
}
//// [privateClassPropertyAccessibleWithinNestedClass.js]
// no errors
var C = (function () {
function C() {
}
Object.defineProperty(C.prototype, "y", {
get: function () { return this.x; },
set: function (x) { this.y = this.x; },
enumerable: true,
configurable: true
});
C.prototype.foo = function () { return this.foo; };
Object.defineProperty(C, "y", {
get: function () { return this.x; },
set: function (x) { this.y = this.x; },
enumerable: true,
configurable: true
});
C.foo = function () { return this.foo; };
C.bar = function () { this.foo(); };
C.prototype.bar = function () {
var C2 = (function () {
function C2() {
}
C2.prototype.foo = function () {
var x;
var x1 = x.foo;
var x2 = x.bar;
var x3 = x.x;
var x4 = x.y;
var sx1 = C.x;
var sx2 = C.y;
var sx3 = C.bar;
var sx4 = C.foo;
var y = new C();
var y1 = y.foo;
var y2 = y.bar;
var y3 = y.x;
var y4 = y.y;
};
return C2;
}());
};
return C;
}());
@@ -0,0 +1,154 @@
=== tests/cases/conformance/classes/members/accessibility/privateClassPropertyAccessibleWithinNestedClass.ts ===
// no errors
class C {
>C : Symbol(C, Decl(privateClassPropertyAccessibleWithinNestedClass.ts, 0, 0))
private x: string;
>x : Symbol(C.x, Decl(privateClassPropertyAccessibleWithinNestedClass.ts, 2, 9))
private get y() { return this.x; }
>y : Symbol(C.y, Decl(privateClassPropertyAccessibleWithinNestedClass.ts, 3, 22), Decl(privateClassPropertyAccessibleWithinNestedClass.ts, 4, 38))
>this.x : Symbol(C.x, Decl(privateClassPropertyAccessibleWithinNestedClass.ts, 2, 9))
>this : Symbol(C, Decl(privateClassPropertyAccessibleWithinNestedClass.ts, 0, 0))
>x : Symbol(C.x, Decl(privateClassPropertyAccessibleWithinNestedClass.ts, 2, 9))
private set y(x) { this.y = this.x; }
>y : Symbol(C.y, Decl(privateClassPropertyAccessibleWithinNestedClass.ts, 3, 22), Decl(privateClassPropertyAccessibleWithinNestedClass.ts, 4, 38))
>x : Symbol(x, Decl(privateClassPropertyAccessibleWithinNestedClass.ts, 5, 18))
>this.y : Symbol(C.y, Decl(privateClassPropertyAccessibleWithinNestedClass.ts, 3, 22), Decl(privateClassPropertyAccessibleWithinNestedClass.ts, 4, 38))
>this : Symbol(C, Decl(privateClassPropertyAccessibleWithinNestedClass.ts, 0, 0))
>y : Symbol(C.y, Decl(privateClassPropertyAccessibleWithinNestedClass.ts, 3, 22), Decl(privateClassPropertyAccessibleWithinNestedClass.ts, 4, 38))
>this.x : Symbol(C.x, Decl(privateClassPropertyAccessibleWithinNestedClass.ts, 2, 9))
>this : Symbol(C, Decl(privateClassPropertyAccessibleWithinNestedClass.ts, 0, 0))
>x : Symbol(C.x, Decl(privateClassPropertyAccessibleWithinNestedClass.ts, 2, 9))
private foo() { return this.foo; }
>foo : Symbol(C.foo, Decl(privateClassPropertyAccessibleWithinNestedClass.ts, 5, 41))
>this.foo : Symbol(C.foo, Decl(privateClassPropertyAccessibleWithinNestedClass.ts, 5, 41))
>this : Symbol(C, Decl(privateClassPropertyAccessibleWithinNestedClass.ts, 0, 0))
>foo : Symbol(C.foo, Decl(privateClassPropertyAccessibleWithinNestedClass.ts, 5, 41))
private static x: string;
>x : Symbol(C.x, Decl(privateClassPropertyAccessibleWithinNestedClass.ts, 6, 38))
private static get y() { return this.x; }
>y : Symbol(C.y, Decl(privateClassPropertyAccessibleWithinNestedClass.ts, 8, 29), Decl(privateClassPropertyAccessibleWithinNestedClass.ts, 9, 45))
>this.x : Symbol(C.x, Decl(privateClassPropertyAccessibleWithinNestedClass.ts, 6, 38))
>this : Symbol(C, Decl(privateClassPropertyAccessibleWithinNestedClass.ts, 0, 0))
>x : Symbol(C.x, Decl(privateClassPropertyAccessibleWithinNestedClass.ts, 6, 38))
private static set y(x) { this.y = this.x; }
>y : Symbol(C.y, Decl(privateClassPropertyAccessibleWithinNestedClass.ts, 8, 29), Decl(privateClassPropertyAccessibleWithinNestedClass.ts, 9, 45))
>x : Symbol(x, Decl(privateClassPropertyAccessibleWithinNestedClass.ts, 10, 25))
>this.y : Symbol(C.y, Decl(privateClassPropertyAccessibleWithinNestedClass.ts, 8, 29), Decl(privateClassPropertyAccessibleWithinNestedClass.ts, 9, 45))
>this : Symbol(C, Decl(privateClassPropertyAccessibleWithinNestedClass.ts, 0, 0))
>y : Symbol(C.y, Decl(privateClassPropertyAccessibleWithinNestedClass.ts, 8, 29), Decl(privateClassPropertyAccessibleWithinNestedClass.ts, 9, 45))
>this.x : Symbol(C.x, Decl(privateClassPropertyAccessibleWithinNestedClass.ts, 6, 38))
>this : Symbol(C, Decl(privateClassPropertyAccessibleWithinNestedClass.ts, 0, 0))
>x : Symbol(C.x, Decl(privateClassPropertyAccessibleWithinNestedClass.ts, 6, 38))
private static foo() { return this.foo; }
>foo : Symbol(C.foo, Decl(privateClassPropertyAccessibleWithinNestedClass.ts, 10, 48))
>this.foo : Symbol(C.foo, Decl(privateClassPropertyAccessibleWithinNestedClass.ts, 10, 48))
>this : Symbol(C, Decl(privateClassPropertyAccessibleWithinNestedClass.ts, 0, 0))
>foo : Symbol(C.foo, Decl(privateClassPropertyAccessibleWithinNestedClass.ts, 10, 48))
private static bar() { this.foo(); }
>bar : Symbol(C.bar, Decl(privateClassPropertyAccessibleWithinNestedClass.ts, 11, 45))
>this.foo : Symbol(C.foo, Decl(privateClassPropertyAccessibleWithinNestedClass.ts, 10, 48))
>this : Symbol(C, Decl(privateClassPropertyAccessibleWithinNestedClass.ts, 0, 0))
>foo : Symbol(C.foo, Decl(privateClassPropertyAccessibleWithinNestedClass.ts, 10, 48))
private bar() {
>bar : Symbol(C.bar, Decl(privateClassPropertyAccessibleWithinNestedClass.ts, 12, 40))
class C2 {
>C2 : Symbol(C2, Decl(privateClassPropertyAccessibleWithinNestedClass.ts, 14, 19))
private foo() {
>foo : Symbol(C2.foo, Decl(privateClassPropertyAccessibleWithinNestedClass.ts, 15, 18))
let x: C;
>x : Symbol(x, Decl(privateClassPropertyAccessibleWithinNestedClass.ts, 17, 19))
>C : Symbol(C, Decl(privateClassPropertyAccessibleWithinNestedClass.ts, 0, 0))
var x1 = x.foo;
>x1 : Symbol(x1, Decl(privateClassPropertyAccessibleWithinNestedClass.ts, 18, 19))
>x.foo : Symbol(C.foo, Decl(privateClassPropertyAccessibleWithinNestedClass.ts, 5, 41))
>x : Symbol(x, Decl(privateClassPropertyAccessibleWithinNestedClass.ts, 17, 19))
>foo : Symbol(C.foo, Decl(privateClassPropertyAccessibleWithinNestedClass.ts, 5, 41))
var x2 = x.bar;
>x2 : Symbol(x2, Decl(privateClassPropertyAccessibleWithinNestedClass.ts, 19, 19))
>x.bar : Symbol(C.bar, Decl(privateClassPropertyAccessibleWithinNestedClass.ts, 12, 40))
>x : Symbol(x, Decl(privateClassPropertyAccessibleWithinNestedClass.ts, 17, 19))
>bar : Symbol(C.bar, Decl(privateClassPropertyAccessibleWithinNestedClass.ts, 12, 40))
var x3 = x.x;
>x3 : Symbol(x3, Decl(privateClassPropertyAccessibleWithinNestedClass.ts, 20, 19))
>x.x : Symbol(C.x, Decl(privateClassPropertyAccessibleWithinNestedClass.ts, 2, 9))
>x : Symbol(x, Decl(privateClassPropertyAccessibleWithinNestedClass.ts, 17, 19))
>x : Symbol(C.x, Decl(privateClassPropertyAccessibleWithinNestedClass.ts, 2, 9))
var x4 = x.y;
>x4 : Symbol(x4, Decl(privateClassPropertyAccessibleWithinNestedClass.ts, 21, 19))
>x.y : Symbol(C.y, Decl(privateClassPropertyAccessibleWithinNestedClass.ts, 3, 22), Decl(privateClassPropertyAccessibleWithinNestedClass.ts, 4, 38))
>x : Symbol(x, Decl(privateClassPropertyAccessibleWithinNestedClass.ts, 17, 19))
>y : Symbol(C.y, Decl(privateClassPropertyAccessibleWithinNestedClass.ts, 3, 22), Decl(privateClassPropertyAccessibleWithinNestedClass.ts, 4, 38))
var sx1 = C.x;
>sx1 : Symbol(sx1, Decl(privateClassPropertyAccessibleWithinNestedClass.ts, 23, 19))
>C.x : Symbol(C.x, Decl(privateClassPropertyAccessibleWithinNestedClass.ts, 6, 38))
>C : Symbol(C, Decl(privateClassPropertyAccessibleWithinNestedClass.ts, 0, 0))
>x : Symbol(C.x, Decl(privateClassPropertyAccessibleWithinNestedClass.ts, 6, 38))
var sx2 = C.y;
>sx2 : Symbol(sx2, Decl(privateClassPropertyAccessibleWithinNestedClass.ts, 24, 19))
>C.y : Symbol(C.y, Decl(privateClassPropertyAccessibleWithinNestedClass.ts, 8, 29), Decl(privateClassPropertyAccessibleWithinNestedClass.ts, 9, 45))
>C : Symbol(C, Decl(privateClassPropertyAccessibleWithinNestedClass.ts, 0, 0))
>y : Symbol(C.y, Decl(privateClassPropertyAccessibleWithinNestedClass.ts, 8, 29), Decl(privateClassPropertyAccessibleWithinNestedClass.ts, 9, 45))
var sx3 = C.bar;
>sx3 : Symbol(sx3, Decl(privateClassPropertyAccessibleWithinNestedClass.ts, 25, 19))
>C.bar : Symbol(C.bar, Decl(privateClassPropertyAccessibleWithinNestedClass.ts, 11, 45))
>C : Symbol(C, Decl(privateClassPropertyAccessibleWithinNestedClass.ts, 0, 0))
>bar : Symbol(C.bar, Decl(privateClassPropertyAccessibleWithinNestedClass.ts, 11, 45))
var sx4 = C.foo;
>sx4 : Symbol(sx4, Decl(privateClassPropertyAccessibleWithinNestedClass.ts, 26, 19))
>C.foo : Symbol(C.foo, Decl(privateClassPropertyAccessibleWithinNestedClass.ts, 10, 48))
>C : Symbol(C, Decl(privateClassPropertyAccessibleWithinNestedClass.ts, 0, 0))
>foo : Symbol(C.foo, Decl(privateClassPropertyAccessibleWithinNestedClass.ts, 10, 48))
let y = new C();
>y : Symbol(y, Decl(privateClassPropertyAccessibleWithinNestedClass.ts, 28, 19))
>C : Symbol(C, Decl(privateClassPropertyAccessibleWithinNestedClass.ts, 0, 0))
var y1 = y.foo;
>y1 : Symbol(y1, Decl(privateClassPropertyAccessibleWithinNestedClass.ts, 29, 19))
>y.foo : Symbol(C.foo, Decl(privateClassPropertyAccessibleWithinNestedClass.ts, 5, 41))
>y : Symbol(y, Decl(privateClassPropertyAccessibleWithinNestedClass.ts, 28, 19))
>foo : Symbol(C.foo, Decl(privateClassPropertyAccessibleWithinNestedClass.ts, 5, 41))
var y2 = y.bar;
>y2 : Symbol(y2, Decl(privateClassPropertyAccessibleWithinNestedClass.ts, 30, 19))
>y.bar : Symbol(C.bar, Decl(privateClassPropertyAccessibleWithinNestedClass.ts, 12, 40))
>y : Symbol(y, Decl(privateClassPropertyAccessibleWithinNestedClass.ts, 28, 19))
>bar : Symbol(C.bar, Decl(privateClassPropertyAccessibleWithinNestedClass.ts, 12, 40))
var y3 = y.x;
>y3 : Symbol(y3, Decl(privateClassPropertyAccessibleWithinNestedClass.ts, 31, 19))
>y.x : Symbol(C.x, Decl(privateClassPropertyAccessibleWithinNestedClass.ts, 2, 9))
>y : Symbol(y, Decl(privateClassPropertyAccessibleWithinNestedClass.ts, 28, 19))
>x : Symbol(C.x, Decl(privateClassPropertyAccessibleWithinNestedClass.ts, 2, 9))
var y4 = y.y;
>y4 : Symbol(y4, Decl(privateClassPropertyAccessibleWithinNestedClass.ts, 32, 19))
>y.y : Symbol(C.y, Decl(privateClassPropertyAccessibleWithinNestedClass.ts, 3, 22), Decl(privateClassPropertyAccessibleWithinNestedClass.ts, 4, 38))
>y : Symbol(y, Decl(privateClassPropertyAccessibleWithinNestedClass.ts, 28, 19))
>y : Symbol(C.y, Decl(privateClassPropertyAccessibleWithinNestedClass.ts, 3, 22), Decl(privateClassPropertyAccessibleWithinNestedClass.ts, 4, 38))
}
}
}
}
@@ -0,0 +1,158 @@
=== tests/cases/conformance/classes/members/accessibility/privateClassPropertyAccessibleWithinNestedClass.ts ===
// no errors
class C {
>C : C
private x: string;
>x : string
private get y() { return this.x; }
>y : string
>this.x : string
>this : this
>x : string
private set y(x) { this.y = this.x; }
>y : string
>x : string
>this.y = this.x : string
>this.y : string
>this : this
>y : string
>this.x : string
>this : this
>x : string
private foo() { return this.foo; }
>foo : () => any
>this.foo : () => any
>this : this
>foo : () => any
private static x: string;
>x : string
private static get y() { return this.x; }
>y : string
>this.x : string
>this : typeof C
>x : string
private static set y(x) { this.y = this.x; }
>y : string
>x : string
>this.y = this.x : string
>this.y : string
>this : typeof C
>y : string
>this.x : string
>this : typeof C
>x : string
private static foo() { return this.foo; }
>foo : () => typeof C.foo
>this.foo : () => typeof C.foo
>this : typeof C
>foo : () => typeof C.foo
private static bar() { this.foo(); }
>bar : () => void
>this.foo() : () => typeof C.foo
>this.foo : () => typeof C.foo
>this : typeof C
>foo : () => typeof C.foo
private bar() {
>bar : () => void
class C2 {
>C2 : C2
private foo() {
>foo : () => void
let x: C;
>x : C
>C : C
var x1 = x.foo;
>x1 : () => any
>x.foo : () => any
>x : C
>foo : () => any
var x2 = x.bar;
>x2 : () => void
>x.bar : () => void
>x : C
>bar : () => void
var x3 = x.x;
>x3 : string
>x.x : string
>x : C
>x : string
var x4 = x.y;
>x4 : string
>x.y : string
>x : C
>y : string
var sx1 = C.x;
>sx1 : string
>C.x : string
>C : typeof C
>x : string
var sx2 = C.y;
>sx2 : string
>C.y : string
>C : typeof C
>y : string
var sx3 = C.bar;
>sx3 : () => void
>C.bar : () => void
>C : typeof C
>bar : () => void
var sx4 = C.foo;
>sx4 : () => typeof C.foo
>C.foo : () => typeof C.foo
>C : typeof C
>foo : () => typeof C.foo
let y = new C();
>y : C
>new C() : C
>C : typeof C
var y1 = y.foo;
>y1 : () => any
>y.foo : () => any
>y : C
>foo : () => any
var y2 = y.bar;
>y2 : () => void
>y.bar : () => void
>y : C
>bar : () => void
var y3 = y.x;
>y3 : string
>y.x : string
>y : C
>x : string
var y4 = y.y;
>y4 : string
>y.y : string
>y : C
>y : string
}
}
}
}
@@ -0,0 +1,84 @@
//// [protectedClassPropertyAccessibleWithinNestedClass.ts]
// no errors
class C {
protected x: string;
protected get y() { return this.x; }
protected set y(x) { this.y = this.x; }
protected foo() { return this.foo; }
protected static x: string;
protected static get y() { return this.x; }
protected static set y(x) { this.y = this.x; }
protected static foo() { return this.foo; }
protected static bar() { this.foo(); }
protected bar() {
class C2 {
protected foo() {
let x: C;
var x1 = x.foo;
var x2 = x.bar;
var x3 = x.x;
var x4 = x.y;
var sx1 = C.x;
var sx2 = C.y;
var sx3 = C.bar;
var sx4 = C.foo;
let y = new C();
var y1 = y.foo;
var y2 = y.bar;
var y3 = y.x;
var y4 = y.y;
}
}
}
}
//// [protectedClassPropertyAccessibleWithinNestedClass.js]
// no errors
var C = (function () {
function C() {
}
Object.defineProperty(C.prototype, "y", {
get: function () { return this.x; },
set: function (x) { this.y = this.x; },
enumerable: true,
configurable: true
});
C.prototype.foo = function () { return this.foo; };
Object.defineProperty(C, "y", {
get: function () { return this.x; },
set: function (x) { this.y = this.x; },
enumerable: true,
configurable: true
});
C.foo = function () { return this.foo; };
C.bar = function () { this.foo(); };
C.prototype.bar = function () {
var C2 = (function () {
function C2() {
}
C2.prototype.foo = function () {
var x;
var x1 = x.foo;
var x2 = x.bar;
var x3 = x.x;
var x4 = x.y;
var sx1 = C.x;
var sx2 = C.y;
var sx3 = C.bar;
var sx4 = C.foo;
var y = new C();
var y1 = y.foo;
var y2 = y.bar;
var y3 = y.x;
var y4 = y.y;
};
return C2;
}());
};
return C;
}());
@@ -0,0 +1,154 @@
=== tests/cases/conformance/classes/members/accessibility/protectedClassPropertyAccessibleWithinNestedClass.ts ===
// no errors
class C {
>C : Symbol(C, Decl(protectedClassPropertyAccessibleWithinNestedClass.ts, 0, 0))
protected x: string;
>x : Symbol(C.x, Decl(protectedClassPropertyAccessibleWithinNestedClass.ts, 2, 9))
protected get y() { return this.x; }
>y : Symbol(C.y, Decl(protectedClassPropertyAccessibleWithinNestedClass.ts, 3, 24), Decl(protectedClassPropertyAccessibleWithinNestedClass.ts, 4, 40))
>this.x : Symbol(C.x, Decl(protectedClassPropertyAccessibleWithinNestedClass.ts, 2, 9))
>this : Symbol(C, Decl(protectedClassPropertyAccessibleWithinNestedClass.ts, 0, 0))
>x : Symbol(C.x, Decl(protectedClassPropertyAccessibleWithinNestedClass.ts, 2, 9))
protected set y(x) { this.y = this.x; }
>y : Symbol(C.y, Decl(protectedClassPropertyAccessibleWithinNestedClass.ts, 3, 24), Decl(protectedClassPropertyAccessibleWithinNestedClass.ts, 4, 40))
>x : Symbol(x, Decl(protectedClassPropertyAccessibleWithinNestedClass.ts, 5, 20))
>this.y : Symbol(C.y, Decl(protectedClassPropertyAccessibleWithinNestedClass.ts, 3, 24), Decl(protectedClassPropertyAccessibleWithinNestedClass.ts, 4, 40))
>this : Symbol(C, Decl(protectedClassPropertyAccessibleWithinNestedClass.ts, 0, 0))
>y : Symbol(C.y, Decl(protectedClassPropertyAccessibleWithinNestedClass.ts, 3, 24), Decl(protectedClassPropertyAccessibleWithinNestedClass.ts, 4, 40))
>this.x : Symbol(C.x, Decl(protectedClassPropertyAccessibleWithinNestedClass.ts, 2, 9))
>this : Symbol(C, Decl(protectedClassPropertyAccessibleWithinNestedClass.ts, 0, 0))
>x : Symbol(C.x, Decl(protectedClassPropertyAccessibleWithinNestedClass.ts, 2, 9))
protected foo() { return this.foo; }
>foo : Symbol(C.foo, Decl(protectedClassPropertyAccessibleWithinNestedClass.ts, 5, 43))
>this.foo : Symbol(C.foo, Decl(protectedClassPropertyAccessibleWithinNestedClass.ts, 5, 43))
>this : Symbol(C, Decl(protectedClassPropertyAccessibleWithinNestedClass.ts, 0, 0))
>foo : Symbol(C.foo, Decl(protectedClassPropertyAccessibleWithinNestedClass.ts, 5, 43))
protected static x: string;
>x : Symbol(C.x, Decl(protectedClassPropertyAccessibleWithinNestedClass.ts, 6, 40))
protected static get y() { return this.x; }
>y : Symbol(C.y, Decl(protectedClassPropertyAccessibleWithinNestedClass.ts, 8, 31), Decl(protectedClassPropertyAccessibleWithinNestedClass.ts, 9, 47))
>this.x : Symbol(C.x, Decl(protectedClassPropertyAccessibleWithinNestedClass.ts, 6, 40))
>this : Symbol(C, Decl(protectedClassPropertyAccessibleWithinNestedClass.ts, 0, 0))
>x : Symbol(C.x, Decl(protectedClassPropertyAccessibleWithinNestedClass.ts, 6, 40))
protected static set y(x) { this.y = this.x; }
>y : Symbol(C.y, Decl(protectedClassPropertyAccessibleWithinNestedClass.ts, 8, 31), Decl(protectedClassPropertyAccessibleWithinNestedClass.ts, 9, 47))
>x : Symbol(x, Decl(protectedClassPropertyAccessibleWithinNestedClass.ts, 10, 27))
>this.y : Symbol(C.y, Decl(protectedClassPropertyAccessibleWithinNestedClass.ts, 8, 31), Decl(protectedClassPropertyAccessibleWithinNestedClass.ts, 9, 47))
>this : Symbol(C, Decl(protectedClassPropertyAccessibleWithinNestedClass.ts, 0, 0))
>y : Symbol(C.y, Decl(protectedClassPropertyAccessibleWithinNestedClass.ts, 8, 31), Decl(protectedClassPropertyAccessibleWithinNestedClass.ts, 9, 47))
>this.x : Symbol(C.x, Decl(protectedClassPropertyAccessibleWithinNestedClass.ts, 6, 40))
>this : Symbol(C, Decl(protectedClassPropertyAccessibleWithinNestedClass.ts, 0, 0))
>x : Symbol(C.x, Decl(protectedClassPropertyAccessibleWithinNestedClass.ts, 6, 40))
protected static foo() { return this.foo; }
>foo : Symbol(C.foo, Decl(protectedClassPropertyAccessibleWithinNestedClass.ts, 10, 50))
>this.foo : Symbol(C.foo, Decl(protectedClassPropertyAccessibleWithinNestedClass.ts, 10, 50))
>this : Symbol(C, Decl(protectedClassPropertyAccessibleWithinNestedClass.ts, 0, 0))
>foo : Symbol(C.foo, Decl(protectedClassPropertyAccessibleWithinNestedClass.ts, 10, 50))
protected static bar() { this.foo(); }
>bar : Symbol(C.bar, Decl(protectedClassPropertyAccessibleWithinNestedClass.ts, 11, 47))
>this.foo : Symbol(C.foo, Decl(protectedClassPropertyAccessibleWithinNestedClass.ts, 10, 50))
>this : Symbol(C, Decl(protectedClassPropertyAccessibleWithinNestedClass.ts, 0, 0))
>foo : Symbol(C.foo, Decl(protectedClassPropertyAccessibleWithinNestedClass.ts, 10, 50))
protected bar() {
>bar : Symbol(C.bar, Decl(protectedClassPropertyAccessibleWithinNestedClass.ts, 12, 42))
class C2 {
>C2 : Symbol(C2, Decl(protectedClassPropertyAccessibleWithinNestedClass.ts, 14, 21))
protected foo() {
>foo : Symbol(C2.foo, Decl(protectedClassPropertyAccessibleWithinNestedClass.ts, 15, 18))
let x: C;
>x : Symbol(x, Decl(protectedClassPropertyAccessibleWithinNestedClass.ts, 17, 19))
>C : Symbol(C, Decl(protectedClassPropertyAccessibleWithinNestedClass.ts, 0, 0))
var x1 = x.foo;
>x1 : Symbol(x1, Decl(protectedClassPropertyAccessibleWithinNestedClass.ts, 18, 19))
>x.foo : Symbol(C.foo, Decl(protectedClassPropertyAccessibleWithinNestedClass.ts, 5, 43))
>x : Symbol(x, Decl(protectedClassPropertyAccessibleWithinNestedClass.ts, 17, 19))
>foo : Symbol(C.foo, Decl(protectedClassPropertyAccessibleWithinNestedClass.ts, 5, 43))
var x2 = x.bar;
>x2 : Symbol(x2, Decl(protectedClassPropertyAccessibleWithinNestedClass.ts, 19, 19))
>x.bar : Symbol(C.bar, Decl(protectedClassPropertyAccessibleWithinNestedClass.ts, 12, 42))
>x : Symbol(x, Decl(protectedClassPropertyAccessibleWithinNestedClass.ts, 17, 19))
>bar : Symbol(C.bar, Decl(protectedClassPropertyAccessibleWithinNestedClass.ts, 12, 42))
var x3 = x.x;
>x3 : Symbol(x3, Decl(protectedClassPropertyAccessibleWithinNestedClass.ts, 20, 19))
>x.x : Symbol(C.x, Decl(protectedClassPropertyAccessibleWithinNestedClass.ts, 2, 9))
>x : Symbol(x, Decl(protectedClassPropertyAccessibleWithinNestedClass.ts, 17, 19))
>x : Symbol(C.x, Decl(protectedClassPropertyAccessibleWithinNestedClass.ts, 2, 9))
var x4 = x.y;
>x4 : Symbol(x4, Decl(protectedClassPropertyAccessibleWithinNestedClass.ts, 21, 19))
>x.y : Symbol(C.y, Decl(protectedClassPropertyAccessibleWithinNestedClass.ts, 3, 24), Decl(protectedClassPropertyAccessibleWithinNestedClass.ts, 4, 40))
>x : Symbol(x, Decl(protectedClassPropertyAccessibleWithinNestedClass.ts, 17, 19))
>y : Symbol(C.y, Decl(protectedClassPropertyAccessibleWithinNestedClass.ts, 3, 24), Decl(protectedClassPropertyAccessibleWithinNestedClass.ts, 4, 40))
var sx1 = C.x;
>sx1 : Symbol(sx1, Decl(protectedClassPropertyAccessibleWithinNestedClass.ts, 23, 19))
>C.x : Symbol(C.x, Decl(protectedClassPropertyAccessibleWithinNestedClass.ts, 6, 40))
>C : Symbol(C, Decl(protectedClassPropertyAccessibleWithinNestedClass.ts, 0, 0))
>x : Symbol(C.x, Decl(protectedClassPropertyAccessibleWithinNestedClass.ts, 6, 40))
var sx2 = C.y;
>sx2 : Symbol(sx2, Decl(protectedClassPropertyAccessibleWithinNestedClass.ts, 24, 19))
>C.y : Symbol(C.y, Decl(protectedClassPropertyAccessibleWithinNestedClass.ts, 8, 31), Decl(protectedClassPropertyAccessibleWithinNestedClass.ts, 9, 47))
>C : Symbol(C, Decl(protectedClassPropertyAccessibleWithinNestedClass.ts, 0, 0))
>y : Symbol(C.y, Decl(protectedClassPropertyAccessibleWithinNestedClass.ts, 8, 31), Decl(protectedClassPropertyAccessibleWithinNestedClass.ts, 9, 47))
var sx3 = C.bar;
>sx3 : Symbol(sx3, Decl(protectedClassPropertyAccessibleWithinNestedClass.ts, 25, 19))
>C.bar : Symbol(C.bar, Decl(protectedClassPropertyAccessibleWithinNestedClass.ts, 11, 47))
>C : Symbol(C, Decl(protectedClassPropertyAccessibleWithinNestedClass.ts, 0, 0))
>bar : Symbol(C.bar, Decl(protectedClassPropertyAccessibleWithinNestedClass.ts, 11, 47))
var sx4 = C.foo;
>sx4 : Symbol(sx4, Decl(protectedClassPropertyAccessibleWithinNestedClass.ts, 26, 19))
>C.foo : Symbol(C.foo, Decl(protectedClassPropertyAccessibleWithinNestedClass.ts, 10, 50))
>C : Symbol(C, Decl(protectedClassPropertyAccessibleWithinNestedClass.ts, 0, 0))
>foo : Symbol(C.foo, Decl(protectedClassPropertyAccessibleWithinNestedClass.ts, 10, 50))
let y = new C();
>y : Symbol(y, Decl(protectedClassPropertyAccessibleWithinNestedClass.ts, 28, 19))
>C : Symbol(C, Decl(protectedClassPropertyAccessibleWithinNestedClass.ts, 0, 0))
var y1 = y.foo;
>y1 : Symbol(y1, Decl(protectedClassPropertyAccessibleWithinNestedClass.ts, 29, 19))
>y.foo : Symbol(C.foo, Decl(protectedClassPropertyAccessibleWithinNestedClass.ts, 5, 43))
>y : Symbol(y, Decl(protectedClassPropertyAccessibleWithinNestedClass.ts, 28, 19))
>foo : Symbol(C.foo, Decl(protectedClassPropertyAccessibleWithinNestedClass.ts, 5, 43))
var y2 = y.bar;
>y2 : Symbol(y2, Decl(protectedClassPropertyAccessibleWithinNestedClass.ts, 30, 19))
>y.bar : Symbol(C.bar, Decl(protectedClassPropertyAccessibleWithinNestedClass.ts, 12, 42))
>y : Symbol(y, Decl(protectedClassPropertyAccessibleWithinNestedClass.ts, 28, 19))
>bar : Symbol(C.bar, Decl(protectedClassPropertyAccessibleWithinNestedClass.ts, 12, 42))
var y3 = y.x;
>y3 : Symbol(y3, Decl(protectedClassPropertyAccessibleWithinNestedClass.ts, 31, 19))
>y.x : Symbol(C.x, Decl(protectedClassPropertyAccessibleWithinNestedClass.ts, 2, 9))
>y : Symbol(y, Decl(protectedClassPropertyAccessibleWithinNestedClass.ts, 28, 19))
>x : Symbol(C.x, Decl(protectedClassPropertyAccessibleWithinNestedClass.ts, 2, 9))
var y4 = y.y;
>y4 : Symbol(y4, Decl(protectedClassPropertyAccessibleWithinNestedClass.ts, 32, 19))
>y.y : Symbol(C.y, Decl(protectedClassPropertyAccessibleWithinNestedClass.ts, 3, 24), Decl(protectedClassPropertyAccessibleWithinNestedClass.ts, 4, 40))
>y : Symbol(y, Decl(protectedClassPropertyAccessibleWithinNestedClass.ts, 28, 19))
>y : Symbol(C.y, Decl(protectedClassPropertyAccessibleWithinNestedClass.ts, 3, 24), Decl(protectedClassPropertyAccessibleWithinNestedClass.ts, 4, 40))
}
}
}
}
@@ -0,0 +1,158 @@
=== tests/cases/conformance/classes/members/accessibility/protectedClassPropertyAccessibleWithinNestedClass.ts ===
// no errors
class C {
>C : C
protected x: string;
>x : string
protected get y() { return this.x; }
>y : string
>this.x : string
>this : this
>x : string
protected set y(x) { this.y = this.x; }
>y : string
>x : string
>this.y = this.x : string
>this.y : string
>this : this
>y : string
>this.x : string
>this : this
>x : string
protected foo() { return this.foo; }
>foo : () => any
>this.foo : () => any
>this : this
>foo : () => any
protected static x: string;
>x : string
protected static get y() { return this.x; }
>y : string
>this.x : string
>this : typeof C
>x : string
protected static set y(x) { this.y = this.x; }
>y : string
>x : string
>this.y = this.x : string
>this.y : string
>this : typeof C
>y : string
>this.x : string
>this : typeof C
>x : string
protected static foo() { return this.foo; }
>foo : () => typeof C.foo
>this.foo : () => typeof C.foo
>this : typeof C
>foo : () => typeof C.foo
protected static bar() { this.foo(); }
>bar : () => void
>this.foo() : () => typeof C.foo
>this.foo : () => typeof C.foo
>this : typeof C
>foo : () => typeof C.foo
protected bar() {
>bar : () => void
class C2 {
>C2 : C2
protected foo() {
>foo : () => void
let x: C;
>x : C
>C : C
var x1 = x.foo;
>x1 : () => any
>x.foo : () => any
>x : C
>foo : () => any
var x2 = x.bar;
>x2 : () => void
>x.bar : () => void
>x : C
>bar : () => void
var x3 = x.x;
>x3 : string
>x.x : string
>x : C
>x : string
var x4 = x.y;
>x4 : string
>x.y : string
>x : C
>y : string
var sx1 = C.x;
>sx1 : string
>C.x : string
>C : typeof C
>x : string
var sx2 = C.y;
>sx2 : string
>C.y : string
>C : typeof C
>y : string
var sx3 = C.bar;
>sx3 : () => void
>C.bar : () => void
>C : typeof C
>bar : () => void
var sx4 = C.foo;
>sx4 : () => typeof C.foo
>C.foo : () => typeof C.foo
>C : typeof C
>foo : () => typeof C.foo
let y = new C();
>y : C
>new C() : C
>C : typeof C
var y1 = y.foo;
>y1 : () => any
>y.foo : () => any
>y : C
>foo : () => any
var y2 = y.bar;
>y2 : () => void
>y.bar : () => void
>y : C
>bar : () => void
var y3 = y.x;
>y3 : string
>y.x : string
>y : C
>x : string
var y4 = y.y;
>y4 : string
>y.y : string
>y : C
>y : string
}
}
}
}
@@ -0,0 +1,44 @@
tests/cases/conformance/classes/members/accessibility/protectedClassPropertyAccessibleWithinNestedSubclass.ts(25,28): error TS2339: Property 'z' does not exist on type 'C'.
==== tests/cases/conformance/classes/members/accessibility/protectedClassPropertyAccessibleWithinNestedSubclass.ts (1 errors) ====
class B {
protected x: string;
protected static x: string;
}
class C extends B {
protected get y() { return this.x; }
protected set y(x) { this.y = this.x; }
protected foo() { return this.x; }
protected static get y() { return this.x; }
protected static set y(x) { this.y = this.x; }
protected static foo() { return this.x; }
protected static bar() { this.foo(); }
protected bar() {
class D {
protected foo() {
var c = new C();
var c1 = c.y;
var c2 = c.x;
var c3 = c.foo;
var c4 = c.bar;
var c5 = c.z; // error
~
!!! error TS2339: Property 'z' does not exist on type 'C'.
var sc1 = C.x;
var sc2 = C.y;
var sc3 = C.foo;
var sc4 = C.bar;
}
}
}
}
class E extends C {
protected z: string;
}
@@ -0,0 +1,99 @@
//// [protectedClassPropertyAccessibleWithinNestedSubclass.ts]
class B {
protected x: string;
protected static x: string;
}
class C extends B {
protected get y() { return this.x; }
protected set y(x) { this.y = this.x; }
protected foo() { return this.x; }
protected static get y() { return this.x; }
protected static set y(x) { this.y = this.x; }
protected static foo() { return this.x; }
protected static bar() { this.foo(); }
protected bar() {
class D {
protected foo() {
var c = new C();
var c1 = c.y;
var c2 = c.x;
var c3 = c.foo;
var c4 = c.bar;
var c5 = c.z; // error
var sc1 = C.x;
var sc2 = C.y;
var sc3 = C.foo;
var sc4 = C.bar;
}
}
}
}
class E extends C {
protected z: string;
}
//// [protectedClassPropertyAccessibleWithinNestedSubclass.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() {
}
return B;
}());
var C = (function (_super) {
__extends(C, _super);
function C() {
_super.apply(this, arguments);
}
Object.defineProperty(C.prototype, "y", {
get: function () { return this.x; },
set: function (x) { this.y = this.x; },
enumerable: true,
configurable: true
});
C.prototype.foo = function () { return this.x; };
Object.defineProperty(C, "y", {
get: function () { return this.x; },
set: function (x) { this.y = this.x; },
enumerable: true,
configurable: true
});
C.foo = function () { return this.x; };
C.bar = function () { this.foo(); };
C.prototype.bar = function () {
var D = (function () {
function D() {
}
D.prototype.foo = function () {
var c = new C();
var c1 = c.y;
var c2 = c.x;
var c3 = c.foo;
var c4 = c.bar;
var c5 = c.z; // error
var sc1 = C.x;
var sc2 = C.y;
var sc3 = C.foo;
var sc4 = C.bar;
};
return D;
}());
};
return C;
}(B));
var E = (function (_super) {
__extends(E, _super);
function E() {
_super.apply(this, arguments);
}
return E;
}(C));
@@ -0,0 +1,180 @@
tests/cases/conformance/classes/members/accessibility/protectedClassPropertyAccessibleWithinNestedSubclass1.ts(15,20): error TS2445: Property 'x' is protected and only accessible within class 'Derived3' and its subclasses.
tests/cases/conformance/classes/members/accessibility/protectedClassPropertyAccessibleWithinNestedSubclass1.ts(32,19): error TS2446: Property 'x' is protected and only accessible through an instance of class 'Derived1'.
tests/cases/conformance/classes/members/accessibility/protectedClassPropertyAccessibleWithinNestedSubclass1.ts(34,20): error TS2446: Property 'x' is protected and only accessible through an instance of class 'Derived1'.
tests/cases/conformance/classes/members/accessibility/protectedClassPropertyAccessibleWithinNestedSubclass1.ts(35,20): error TS2445: Property 'x' is protected and only accessible within class 'Derived3' and its subclasses.
tests/cases/conformance/classes/members/accessibility/protectedClassPropertyAccessibleWithinNestedSubclass1.ts(36,20): error TS2446: Property 'x' is protected and only accessible through an instance of class 'Derived1'.
tests/cases/conformance/classes/members/accessibility/protectedClassPropertyAccessibleWithinNestedSubclass1.ts(52,19): error TS2446: Property 'x' is protected and only accessible through an instance of class 'Derived2'.
tests/cases/conformance/classes/members/accessibility/protectedClassPropertyAccessibleWithinNestedSubclass1.ts(53,20): error TS2446: Property 'x' is protected and only accessible through an instance of class 'Derived2'.
tests/cases/conformance/classes/members/accessibility/protectedClassPropertyAccessibleWithinNestedSubclass1.ts(55,20): error TS2445: Property 'x' is protected and only accessible within class 'Derived3' and its subclasses.
tests/cases/conformance/classes/members/accessibility/protectedClassPropertyAccessibleWithinNestedSubclass1.ts(73,19): error TS2446: Property 'x' is protected and only accessible through an instance of class 'Derived3'.
tests/cases/conformance/classes/members/accessibility/protectedClassPropertyAccessibleWithinNestedSubclass1.ts(74,20): error TS2446: Property 'x' is protected and only accessible through an instance of class 'Derived3'.
tests/cases/conformance/classes/members/accessibility/protectedClassPropertyAccessibleWithinNestedSubclass1.ts(75,20): error TS2446: Property 'x' is protected and only accessible through an instance of class 'Derived3'.
tests/cases/conformance/classes/members/accessibility/protectedClassPropertyAccessibleWithinNestedSubclass1.ts(77,20): error TS2446: Property 'x' is protected and only accessible through an instance of class 'Derived3'.
tests/cases/conformance/classes/members/accessibility/protectedClassPropertyAccessibleWithinNestedSubclass1.ts(93,19): error TS2446: Property 'x' is protected and only accessible through an instance of class 'Derived4'.
tests/cases/conformance/classes/members/accessibility/protectedClassPropertyAccessibleWithinNestedSubclass1.ts(94,20): error TS2446: Property 'x' is protected and only accessible through an instance of class 'Derived4'.
tests/cases/conformance/classes/members/accessibility/protectedClassPropertyAccessibleWithinNestedSubclass1.ts(95,20): error TS2446: Property 'x' is protected and only accessible through an instance of class 'Derived4'.
tests/cases/conformance/classes/members/accessibility/protectedClassPropertyAccessibleWithinNestedSubclass1.ts(96,20): error TS2445: Property 'x' is protected and only accessible within class 'Derived3' and its subclasses.
tests/cases/conformance/classes/members/accessibility/protectedClassPropertyAccessibleWithinNestedSubclass1.ts(110,3): error TS2445: Property 'x' is protected and only accessible within class 'Base' and its subclasses.
tests/cases/conformance/classes/members/accessibility/protectedClassPropertyAccessibleWithinNestedSubclass1.ts(111,4): error TS2445: Property 'x' is protected and only accessible within class 'Base' and its subclasses.
tests/cases/conformance/classes/members/accessibility/protectedClassPropertyAccessibleWithinNestedSubclass1.ts(112,4): error TS2445: Property 'x' is protected and only accessible within class 'Base' and its subclasses.
tests/cases/conformance/classes/members/accessibility/protectedClassPropertyAccessibleWithinNestedSubclass1.ts(113,4): error TS2445: Property 'x' is protected and only accessible within class 'Derived3' and its subclasses.
tests/cases/conformance/classes/members/accessibility/protectedClassPropertyAccessibleWithinNestedSubclass1.ts(114,4): error TS2445: Property 'x' is protected and only accessible within class 'Base' and its subclasses.
==== tests/cases/conformance/classes/members/accessibility/protectedClassPropertyAccessibleWithinNestedSubclass1.ts (21 errors) ====
class Base {
protected x: string;
method() {
class A {
methoda() {
var b: Base;
var d1: Derived1;
var d2: Derived2;
var d3: Derived3;
var d4: Derived4;
b.x; // OK, accessed within their declaring class
d1.x; // OK, accessed within their declaring class
d2.x; // OK, accessed within their declaring class
d3.x; // Error, redefined in a subclass, can only be accessed in the declaring class or one of its subclasses
~
!!! error TS2445: Property 'x' is protected and only accessible within class 'Derived3' and its subclasses.
d4.x; // OK, accessed within their declaring class
}
}
}
}
class Derived1 extends Base {
method1() {
class B {
method1b() {
var b: Base;
var d1: Derived1;
var d2: Derived2;
var d3: Derived3;
var d4: Derived4;
b.x; // Error, isn't accessed through an instance of the enclosing class
~
!!! error TS2446: Property 'x' is protected and only accessible through an instance of class 'Derived1'.
d1.x; // OK, accessed within a class derived from their declaring class, and through an instance of the enclosing class
d2.x; // Error, isn't accessed through an instance of the enclosing class
~
!!! error TS2446: Property 'x' is protected and only accessible through an instance of class 'Derived1'.
d3.x; // Error, redefined in a subclass, can only be accessed in the declaring class or one of its subclasses
~
!!! error TS2445: Property 'x' is protected and only accessible within class 'Derived3' and its subclasses.
d4.x; // Error, isn't accessed through an instance of the enclosing class
~
!!! error TS2446: Property 'x' is protected and only accessible through an instance of class 'Derived1'.
}
}
}
}
class Derived2 extends Base {
method2() {
class C {
method2c() {
var b: Base;
var d1: Derived1;
var d2: Derived2;
var d3: Derived3;
var d4: Derived4;
b.x; // Error, isn't accessed through an instance of the enclosing class
~
!!! error TS2446: Property 'x' is protected and only accessible through an instance of class 'Derived2'.
d1.x; // Error, isn't accessed through an instance of the enclosing class
~
!!! error TS2446: Property 'x' is protected and only accessible through an instance of class 'Derived2'.
d2.x; // OK, accessed within a class derived from their declaring class, and through an instance of the enclosing class
d3.x; // Error, redefined in a subclass, can only be accessed in the declaring class or one of its subclasses
~
!!! error TS2445: Property 'x' is protected and only accessible within class 'Derived3' and its subclasses.
d4.x; // OK, accessed within a class derived from their declaring class, and through an instance of the enclosing class or one of its subclasses
}
}
}
}
class Derived3 extends Derived1 {
protected x: string;
method3() {
class D {
method3d() {
var b: Base;
var d1: Derived1;
var d2: Derived2;
var d3: Derived3;
var d4: Derived4;
b.x; // Error, isn't accessed through an instance of the enclosing class
~
!!! error TS2446: Property 'x' is protected and only accessible through an instance of class 'Derived3'.
d1.x; // Error, isn't accessed through an instance of the enclosing class
~
!!! error TS2446: Property 'x' is protected and only accessible through an instance of class 'Derived3'.
d2.x; // Error, isn't accessed through an instance of the enclosing class
~
!!! error TS2446: Property 'x' is protected and only accessible through an instance of class 'Derived3'.
d3.x; // OK, accessed within their declaring class
d4.x; // Error, isn't accessed through an instance of the enclosing class
~
!!! error TS2446: Property 'x' is protected and only accessible through an instance of class 'Derived3'.
}
}
}
}
class Derived4 extends Derived2 {
method4() {
class E {
method4e() {
var b: Base;
var d1: Derived1;
var d2: Derived2;
var d3: Derived3;
var d4: Derived4;
b.x; // Error, isn't accessed through an instance of the enclosing class
~
!!! error TS2446: Property 'x' is protected and only accessible through an instance of class 'Derived4'.
d1.x; // Error, isn't accessed through an instance of the enclosing class
~
!!! error TS2446: Property 'x' is protected and only accessible through an instance of class 'Derived4'.
d2.x; // Error, isn't accessed through an instance of the enclosing class
~
!!! error TS2446: Property 'x' is protected and only accessible through an instance of class 'Derived4'.
d3.x; // Error, redefined in a subclass, can only be accessed in the declaring class or one of its subclasses
~
!!! error TS2445: Property 'x' is protected and only accessible within class 'Derived3' and its subclasses.
d4.x; // OK, accessed within a class derived from their declaring class, and through an instance of the enclosing class
}
}
}
}
var b: Base;
var d1: Derived1;
var d2: Derived2;
var d3: Derived3;
var d4: Derived4;
b.x; // Error, neither within their declaring class nor classes derived from their declaring class
~
!!! error TS2445: Property 'x' is protected and only accessible within class 'Base' and its subclasses.
d1.x; // Error, neither within their declaring class nor classes derived from their declaring class
~
!!! error TS2445: Property 'x' is protected and only accessible within class 'Base' and its subclasses.
d2.x; // Error, neither within their declaring class nor classes derived from their declaring class
~
!!! error TS2445: Property 'x' is protected and only accessible within class 'Base' and its subclasses.
d3.x; // Error, neither within their declaring class nor classes derived from their declaring class
~
!!! error TS2445: Property 'x' is protected and only accessible within class 'Derived3' and its subclasses.
d4.x; // Error, neither within their declaring class nor classes derived from their declaring class
~
!!! error TS2445: Property 'x' is protected and only accessible within class 'Base' and its subclasses.
@@ -0,0 +1,260 @@
//// [protectedClassPropertyAccessibleWithinNestedSubclass1.ts]
class Base {
protected x: string;
method() {
class A {
methoda() {
var b: Base;
var d1: Derived1;
var d2: Derived2;
var d3: Derived3;
var d4: Derived4;
b.x; // OK, accessed within their declaring class
d1.x; // OK, accessed within their declaring class
d2.x; // OK, accessed within their declaring class
d3.x; // Error, redefined in a subclass, can only be accessed in the declaring class or one of its subclasses
d4.x; // OK, accessed within their declaring class
}
}
}
}
class Derived1 extends Base {
method1() {
class B {
method1b() {
var b: Base;
var d1: Derived1;
var d2: Derived2;
var d3: Derived3;
var d4: Derived4;
b.x; // Error, isn't accessed through an instance of the enclosing class
d1.x; // OK, accessed within a class derived from their declaring class, and through an instance of the enclosing class
d2.x; // Error, isn't accessed through an instance of the enclosing class
d3.x; // Error, redefined in a subclass, can only be accessed in the declaring class or one of its subclasses
d4.x; // Error, isn't accessed through an instance of the enclosing class
}
}
}
}
class Derived2 extends Base {
method2() {
class C {
method2c() {
var b: Base;
var d1: Derived1;
var d2: Derived2;
var d3: Derived3;
var d4: Derived4;
b.x; // Error, isn't accessed through an instance of the enclosing class
d1.x; // Error, isn't accessed through an instance of the enclosing class
d2.x; // OK, accessed within a class derived from their declaring class, and through an instance of the enclosing class
d3.x; // Error, redefined in a subclass, can only be accessed in the declaring class or one of its subclasses
d4.x; // OK, accessed within a class derived from their declaring class, and through an instance of the enclosing class or one of its subclasses
}
}
}
}
class Derived3 extends Derived1 {
protected x: string;
method3() {
class D {
method3d() {
var b: Base;
var d1: Derived1;
var d2: Derived2;
var d3: Derived3;
var d4: Derived4;
b.x; // Error, isn't accessed through an instance of the enclosing class
d1.x; // Error, isn't accessed through an instance of the enclosing class
d2.x; // Error, isn't accessed through an instance of the enclosing class
d3.x; // OK, accessed within their declaring class
d4.x; // Error, isn't accessed through an instance of the enclosing class
}
}
}
}
class Derived4 extends Derived2 {
method4() {
class E {
method4e() {
var b: Base;
var d1: Derived1;
var d2: Derived2;
var d3: Derived3;
var d4: Derived4;
b.x; // Error, isn't accessed through an instance of the enclosing class
d1.x; // Error, isn't accessed through an instance of the enclosing class
d2.x; // Error, isn't accessed through an instance of the enclosing class
d3.x; // Error, redefined in a subclass, can only be accessed in the declaring class or one of its subclasses
d4.x; // OK, accessed within a class derived from their declaring class, and through an instance of the enclosing class
}
}
}
}
var b: Base;
var d1: Derived1;
var d2: Derived2;
var d3: Derived3;
var d4: Derived4;
b.x; // Error, neither within their declaring class nor classes derived from their declaring class
d1.x; // Error, neither within their declaring class nor classes derived from their declaring class
d2.x; // Error, neither within their declaring class nor classes derived from their declaring class
d3.x; // Error, neither within their declaring class nor classes derived from their declaring class
d4.x; // Error, neither within their declaring class nor classes derived from their declaring class
//// [protectedClassPropertyAccessibleWithinNestedSubclass1.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 Base = (function () {
function Base() {
}
Base.prototype.method = function () {
var A = (function () {
function A() {
}
A.prototype.methoda = function () {
var b;
var d1;
var d2;
var d3;
var d4;
b.x; // OK, accessed within their declaring class
d1.x; // OK, accessed within their declaring class
d2.x; // OK, accessed within their declaring class
d3.x; // Error, redefined in a subclass, can only be accessed in the declaring class or one of its subclasses
d4.x; // OK, accessed within their declaring class
};
return A;
}());
};
return Base;
}());
var Derived1 = (function (_super) {
__extends(Derived1, _super);
function Derived1() {
_super.apply(this, arguments);
}
Derived1.prototype.method1 = function () {
var B = (function () {
function B() {
}
B.prototype.method1b = function () {
var b;
var d1;
var d2;
var d3;
var d4;
b.x; // Error, isn't accessed through an instance of the enclosing class
d1.x; // OK, accessed within a class derived from their declaring class, and through an instance of the enclosing class
d2.x; // Error, isn't accessed through an instance of the enclosing class
d3.x; // Error, redefined in a subclass, can only be accessed in the declaring class or one of its subclasses
d4.x; // Error, isn't accessed through an instance of the enclosing class
};
return B;
}());
};
return Derived1;
}(Base));
var Derived2 = (function (_super) {
__extends(Derived2, _super);
function Derived2() {
_super.apply(this, arguments);
}
Derived2.prototype.method2 = function () {
var C = (function () {
function C() {
}
C.prototype.method2c = function () {
var b;
var d1;
var d2;
var d3;
var d4;
b.x; // Error, isn't accessed through an instance of the enclosing class
d1.x; // Error, isn't accessed through an instance of the enclosing class
d2.x; // OK, accessed within a class derived from their declaring class, and through an instance of the enclosing class
d3.x; // Error, redefined in a subclass, can only be accessed in the declaring class or one of its subclasses
d4.x; // OK, accessed within a class derived from their declaring class, and through an instance of the enclosing class or one of its subclasses
};
return C;
}());
};
return Derived2;
}(Base));
var Derived3 = (function (_super) {
__extends(Derived3, _super);
function Derived3() {
_super.apply(this, arguments);
}
Derived3.prototype.method3 = function () {
var D = (function () {
function D() {
}
D.prototype.method3d = function () {
var b;
var d1;
var d2;
var d3;
var d4;
b.x; // Error, isn't accessed through an instance of the enclosing class
d1.x; // Error, isn't accessed through an instance of the enclosing class
d2.x; // Error, isn't accessed through an instance of the enclosing class
d3.x; // OK, accessed within their declaring class
d4.x; // Error, isn't accessed through an instance of the enclosing class
};
return D;
}());
};
return Derived3;
}(Derived1));
var Derived4 = (function (_super) {
__extends(Derived4, _super);
function Derived4() {
_super.apply(this, arguments);
}
Derived4.prototype.method4 = function () {
var E = (function () {
function E() {
}
E.prototype.method4e = function () {
var b;
var d1;
var d2;
var d3;
var d4;
b.x; // Error, isn't accessed through an instance of the enclosing class
d1.x; // Error, isn't accessed through an instance of the enclosing class
d2.x; // Error, isn't accessed through an instance of the enclosing class
d3.x; // Error, redefined in a subclass, can only be accessed in the declaring class or one of its subclasses
d4.x; // OK, accessed within a class derived from their declaring class, and through an instance of the enclosing class
};
return E;
}());
};
return Derived4;
}(Derived2));
var b;
var d1;
var d2;
var d3;
var d4;
b.x; // Error, neither within their declaring class nor classes derived from their declaring class
d1.x; // Error, neither within their declaring class nor classes derived from their declaring class
d2.x; // Error, neither within their declaring class nor classes derived from their declaring class
d3.x; // Error, neither within their declaring class nor classes derived from their declaring class
d4.x; // Error, neither within their declaring class nor classes derived from their declaring class
@@ -17,6 +17,7 @@ declare var x: any;
>data : Symbol(unknown)
<Bar x={x} />;
>Bar : Symbol(Bar, Decl(reactNamespaceJSXEmit.tsx, 3, 11))
>x : Symbol(unknown)
>x : Symbol(x, Decl(reactNamespaceJSXEmit.tsx, 4, 11))
@@ -24,9 +25,11 @@ declare var x: any;
>x-component : Symbol(unknown)
<Bar {...x} />;
>Bar : Symbol(Bar, Decl(reactNamespaceJSXEmit.tsx, 3, 11))
>x : Symbol(x, Decl(reactNamespaceJSXEmit.tsx, 4, 11))
<Bar { ...x } y={2} />;
>Bar : Symbol(Bar, Decl(reactNamespaceJSXEmit.tsx, 3, 11))
>x : Symbol(x, Decl(reactNamespaceJSXEmit.tsx, 4, 11))
>y : Symbol(unknown)
@@ -7,9 +7,12 @@ tests/cases/conformance/types/stringLiteral/stringLiteralTypesWithVariousOperato
tests/cases/conformance/types/stringLiteral/stringLiteralTypesWithVariousOperators02.ts(13,11): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type.
tests/cases/conformance/types/stringLiteral/stringLiteralTypesWithVariousOperators02.ts(14,9): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/types/stringLiteral/stringLiteralTypesWithVariousOperators02.ts(15,9): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/types/stringLiteral/stringLiteralTypesWithVariousOperators02.ts(16,9): error TS2365: Operator '<' cannot be applied to types '"ABC"' and '"XYZ"'.
tests/cases/conformance/types/stringLiteral/stringLiteralTypesWithVariousOperators02.ts(17,9): error TS2365: Operator '===' cannot be applied to types '"ABC"' and '"XYZ"'.
tests/cases/conformance/types/stringLiteral/stringLiteralTypesWithVariousOperators02.ts(18,9): error TS2365: Operator '!=' cannot be applied to types '"ABC"' and '"XYZ"'.
==== tests/cases/conformance/types/stringLiteral/stringLiteralTypesWithVariousOperators02.ts (9 errors) ====
==== tests/cases/conformance/types/stringLiteral/stringLiteralTypesWithVariousOperators02.ts (12 errors) ====
let abc: "ABC" = "ABC";
let xyz: "XYZ" = "XYZ";
@@ -44,5 +47,11 @@ tests/cases/conformance/types/stringLiteral/stringLiteralTypesWithVariousOperato
~~~~~~~~~~~~~~~~
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
let j = abc < xyz;
~~~~~~~~~
!!! error TS2365: Operator '<' cannot be applied to types '"ABC"' and '"XYZ"'.
let k = abc === xyz;
let l = abc != xyz;
~~~~~~~~~~~
!!! error TS2365: Operator '===' cannot be applied to types '"ABC"' and '"XYZ"'.
let l = abc != xyz;
~~~~~~~~~~
!!! error TS2365: Operator '!=' cannot be applied to types '"ABC"' and '"XYZ"'.
@@ -5,6 +5,6 @@ function Test() { }
<Test></Test>
><Test></Test> : any
>Test : any
>Test : any
>Test : () => void
>Test : () => void
@@ -47,5 +47,7 @@ var d = <Other />;
var e = <Dotted.Name />;
>e : Symbol(e, Decl(tsxElementResolution.tsx, 23, 3))
>Dotted.Name : Symbol(Dotted.Name, Decl(tsxElementResolution.tsx, 12, 15))
>Dotted : Symbol(Dotted, Decl(tsxElementResolution.tsx, 10, 14))
>Name : Symbol(Dotted.Name, Decl(tsxElementResolution.tsx, 12, 15))
@@ -51,6 +51,7 @@ var d = <Other />;
var e = <Dotted.Name />;
>e : any
><Dotted.Name /> : any
>Dotted : any
>Name : any
>Dotted.Name : typeof Dotted.Name
>Dotted : typeof Dotted
>Name : typeof Dotted.Name
@@ -8,6 +8,8 @@ import s2 = require('elements2');
>s2 : Symbol(s2, Decl(consumer.tsx, 2, 33))
<s1.MyElement />;
>s1.MyElement : Symbol(s1.MyElement, Decl(file.tsx, 6, 28))
>s1 : Symbol(s1, Decl(consumer.tsx, 0, 0))
>MyElement : Symbol(s1.MyElement, Decl(file.tsx, 6, 28))
=== tests/cases/conformance/jsx/file.tsx ===
@@ -9,8 +9,9 @@ import s2 = require('elements2');
<s1.MyElement />;
><s1.MyElement /> : JSX.Element
>s1 : any
>MyElement : any
>s1.MyElement : typeof s1.MyElement
>s1 : typeof s1
>MyElement : typeof s1.MyElement
=== tests/cases/conformance/jsx/file.tsx ===
@@ -24,5 +24,5 @@ import {MyClass} from './file1';
>MyClass : Symbol(MyClass, Decl(file2.tsx, 3, 8))
<MyClass />;
>MyClass : Symbol(MyClass, Decl(file1.tsx, 2, 1))
>MyClass : Symbol(MyClass, Decl(file2.tsx, 3, 8))
@@ -59,6 +59,8 @@ module M {
>S.Bar : Symbol(S.Bar, Decl(file.tsx, 8, 18))
>S : Symbol(S, Decl(file.tsx, 7, 39), Decl(file.tsx, 18, 14))
>Bar : Symbol(S.Bar, Decl(file.tsx, 8, 18))
>S.Bar : Symbol(S.Bar, Decl(file.tsx, 8, 18))
>S : Symbol(S, Decl(file.tsx, 7, 39), Decl(file.tsx, 18, 14))
>Bar : Symbol(S.Bar, Decl(file.tsx, 8, 18))
}
+3 -2
View File
@@ -67,8 +67,9 @@ module M {
>S : typeof S
>Bar : typeof S.Bar
><S.Bar /> : JSX.Element
>S : any
>Bar : any
>S.Bar : typeof S.Bar
>S : typeof S
>Bar : typeof S.Bar
}
module M {
@@ -25,7 +25,7 @@ export class App extends React.Component<any, any> {
>render : Symbol(App.render, Decl(app.tsx, 5, 52))
return <Button />;
>Button : Symbol(Button, Decl(button.tsx, 0, 31))
>Button : Symbol(Button, Decl(app.tsx, 3, 8))
}
}
@@ -18,11 +18,15 @@ declare var Foo, React;
// Should see mod_1['default'] in emit here
<Foo handler={Main}></Foo>;
>Foo : Symbol(Foo, Decl(app.tsx, 1, 11))
>handler : Symbol(unknown)
>Main : Symbol(Main, Decl(app.tsx, 0, 6))
>Foo : Symbol(Foo, Decl(app.tsx, 1, 11))
// Should see mod_1['default'] in emit here
<Foo {...Main}></Foo>;
>Foo : Symbol(Foo, Decl(app.tsx, 1, 11))
>Main : Symbol(Main, Decl(app.tsx, 0, 6))
>Foo : Symbol(Foo, Decl(app.tsx, 1, 11))
@@ -15,6 +15,8 @@ var T, T1, T2;
// This is an element
var x1 = <T>() => {}</T>;
>x1 : Symbol(x1, Decl(file.tsx, 7, 3))
>T : Symbol(T, Decl(file.tsx, 4, 3))
>T : Symbol(T, Decl(file.tsx, 4, 3))
x1.isElement;
>x1.isElement : Symbol(JSX.Element.isElement, Decl(file.tsx, 1, 20))
@@ -41,7 +43,9 @@ x3();
// This is an element
var x4 = <T extends={true}>() => {}</T>;
>x4 : Symbol(x4, Decl(file.tsx, 19, 3))
>T : Symbol(T, Decl(file.tsx, 4, 3))
>extends : Symbol(unknown)
>T : Symbol(T, Decl(file.tsx, 4, 3))
x4.isElement;
>x4.isElement : Symbol(JSX.Element.isElement, Decl(file.tsx, 1, 20))
@@ -51,7 +55,9 @@ x4.isElement;
// This is an element
var x5 = <T extends>() => {}</T>;
>x5 : Symbol(x5, Decl(file.tsx, 23, 3))
>T : Symbol(T, Decl(file.tsx, 4, 3))
>extends : Symbol(unknown)
>T : Symbol(T, Decl(file.tsx, 4, 3))
x5.isElement;
>x5.isElement : Symbol(JSX.Element.isElement, Decl(file.tsx, 1, 20))
@@ -16,4 +16,18 @@ declare module A.B.C {
}
<A.B.C.D>foo</A . B . C.D>
>A.B.C.D : Symbol(A.B.C.D, Decl(file.tsx, 5, 5))
>A.B.C : Symbol(A.B.C, Decl(file.tsx, 4, 19))
>A.B : Symbol(A.B, Decl(file.tsx, 4, 17))
>A : Symbol(A, Decl(file.tsx, 2, 1))
>B : Symbol(A.B, Decl(file.tsx, 4, 17))
>C : Symbol(A.B.C, Decl(file.tsx, 4, 19))
>D : Symbol(A.B.C.D, Decl(file.tsx, 5, 5))
>A . B . C.D : Symbol(A.B.C.D, Decl(file.tsx, 5, 5))
>A . B . C : Symbol(A.B.C, Decl(file.tsx, 4, 19))
>A . B : Symbol(A.B, Decl(file.tsx, 4, 17))
>A : Symbol(A, Decl(file.tsx, 2, 1))
>B : Symbol(A.B, Decl(file.tsx, 4, 17))
>C : Symbol(A.B.C, Decl(file.tsx, 4, 19))
>D : Symbol(A.B.C.D, Decl(file.tsx, 5, 5))
@@ -17,12 +17,18 @@ declare module A.B.C {
<A.B.C.D>foo</A . B . C.D>
><A.B.C.D>foo</A . B . C.D> : JSX.Element
>A : any
>B : any
>C : any
>A.B.C.D : any
>A.B.C : typeof A.B.C
>A.B : typeof A.B
>A : typeof A
>B : typeof A.B
>C : typeof A.B.C
>D : any
>A : any
>B : any
>C : any
>A . B . C.D : any
>A . B . C : typeof A.B.C
>A . B : typeof A.B
>A : typeof A
>B : typeof A.B
>C : typeof A.B.C
>D : any
@@ -13,6 +13,7 @@ import Route = ReactRouter.Route;
var routes1 = <Route />;
>routes1 : Symbol(routes1, Decl(test.tsx, 6, 3))
>Route : Symbol(Route, Decl(test.tsx, 2, 45))
module M {
>M : Symbol(M, Decl(test.tsx, 6, 24), Decl(test.tsx, 10, 1))
@@ -26,6 +27,8 @@ module M {
// Should emit 'M.X' in both opening and closing tags
var y = <X></X>;
>y : Symbol(y, Decl(test.tsx, 13, 4))
>X : Symbol(X, Decl(test.tsx, 9, 11))
>X : Symbol(X, Decl(test.tsx, 9, 11))
}
=== tests/cases/conformance/jsx/react.d.ts ===
@@ -6,4 +6,5 @@ var Route: any;
var routes1 = <Route />;
>routes1 : Symbol(routes1, Decl(test.tsx, 3, 3))
>Route : Symbol(Route, Decl(test.tsx, 2, 3))
@@ -13,3 +13,11 @@ declare var Foo, Bar, baz;
>baz : Symbol(baz, Decl(test.tsx, 4, 21))
<Foo> <Bar> q </Bar> <Bar/> s <Bar/><Bar/></Foo>;
>Foo : Symbol(Foo, Decl(test.tsx, 4, 11))
>Bar : Symbol(Bar, Decl(test.tsx, 4, 16))
>Bar : Symbol(Bar, Decl(test.tsx, 4, 16))
>Bar : Symbol(Bar, Decl(test.tsx, 4, 16))
>Bar : Symbol(Bar, Decl(test.tsx, 4, 16))
>Bar : Symbol(Bar, Decl(test.tsx, 4, 16))
>Foo : Symbol(Foo, Decl(test.tsx, 4, 11))
@@ -11,7 +11,7 @@ const Foo = (props: any) => <div/>;
// Should be OK
const foo = <Foo />;
>foo : Symbol(foo, Decl(file.tsx, 5, 5))
>Foo : Symbol((Anonymous function), Decl(file.tsx, 3, 11))
>Foo : Symbol(Foo, Decl(file.tsx, 3, 5))
// Should be OK
@@ -40,7 +40,7 @@ var App: React.StatelessComponent<{ children }> = ({children}) => (
>div : Symbol(JSX.IntrinsicElements.div, Decl(react.d.ts, 927, 45))
<MainMenu/>
>MainMenu : Symbol(React.StatelessComponent, Decl(react.d.ts, 139, 5))
>MainMenu : Symbol(MainMenu, Decl(file.tsx, 9, 3))
</div>
>div : Symbol(JSX.IntrinsicElements.div, Decl(react.d.ts, 927, 45))
@@ -4,15 +4,10 @@ tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes0
tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(40,25): error TS2345: Argument of type 'string' is not assignable to parameter of type '"Hello"'.
tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(41,25): error TS2345: Argument of type 'string' is not assignable to parameter of type '"Hello"'.
tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(44,30): error TS2345: Argument of type 'string' is not assignable to parameter of type '"Hello" | "World"'.
Type 'string' is not assignable to type '"World"'.
tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(45,30): error TS2345: Argument of type 'string' is not assignable to parameter of type '"Hello" | "World"'.
Type 'string' is not assignable to type '"World"'.
tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(46,30): error TS2345: Argument of type 'string' is not assignable to parameter of type '"Hello" | "World"'.
Type 'string' is not assignable to type '"World"'.
tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(47,30): error TS2345: Argument of type 'string' is not assignable to parameter of type '"Hello" | "World"'.
Type 'string' is not assignable to type '"World"'.
tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(48,30): error TS2345: Argument of type 'string' is not assignable to parameter of type '"Hello" | "World"'.
Type 'string' is not assignable to type '"World"'.
tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(55,43): error TS2345: Argument of type '"World"' is not assignable to parameter of type '"Hello"'.
tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(57,52): error TS2345: Argument of type '"World"' is not assignable to parameter of type '"Hello"'.
tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(58,43): error TS2345: Argument of type '"World"' is not assignable to parameter of type '"Hello"'.
@@ -26,9 +21,7 @@ tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes0
tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(88,43): error TS2345: Argument of type '"Hello"' is not assignable to parameter of type '"World"'.
tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(89,52): error TS2345: Argument of type '"World"' is not assignable to parameter of type '"Hello"'.
tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(93,5): error TS2322: Type 'string' is not assignable to type '"Hello" | "World"'.
Type 'string' is not assignable to type '"World"'.
tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(97,5): error TS2322: Type 'string' is not assignable to type '"Hello" | "World"'.
Type 'string' is not assignable to type '"World"'.
tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(100,25): error TS2345: Argument of type '"Hello" | "World"' is not assignable to parameter of type '"Hello"'.
Type '"World"' is not assignable to type '"Hello"'.
tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(104,25): error TS2345: Argument of type '"Hello" | "World"' is not assignable to parameter of type '"Hello"'.
@@ -92,23 +85,18 @@ tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes0
a = takeReturnHelloWorld(a);
~
!!! error TS2345: Argument of type 'string' is not assignable to parameter of type '"Hello" | "World"'.
!!! error TS2345: Type 'string' is not assignable to type '"World"'.
b = takeReturnHelloWorld(b);
~
!!! error TS2345: Argument of type 'string' is not assignable to parameter of type '"Hello" | "World"'.
!!! error TS2345: Type 'string' is not assignable to type '"World"'.
c = takeReturnHelloWorld(c);
~
!!! error TS2345: Argument of type 'string' is not assignable to parameter of type '"Hello" | "World"'.
!!! error TS2345: Type 'string' is not assignable to type '"World"'.
d = takeReturnHelloWorld(d);
~
!!! error TS2345: Argument of type 'string' is not assignable to parameter of type '"Hello" | "World"'.
!!! error TS2345: Type 'string' is not assignable to type '"World"'.
e = takeReturnHelloWorld(e);
~
!!! error TS2345: Argument of type 'string' is not assignable to parameter of type '"Hello" | "World"'.
!!! error TS2345: Type 'string' is not assignable to type '"World"'.
}
namespace n2 {
@@ -178,14 +166,12 @@ tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes0
a = takeReturnString(a);
~
!!! error TS2322: Type 'string' is not assignable to type '"Hello" | "World"'.
!!! error TS2322: Type 'string' is not assignable to type '"World"'.
b = takeReturnString(b);
c = takeReturnString(c);
d = takeReturnString(d);
e = takeReturnString(e);
~
!!! error TS2322: Type 'string' is not assignable to type '"Hello" | "World"'.
!!! error TS2322: Type 'string' is not assignable to type '"World"'.
// Passing these as arguments should cause an error.
a = takeReturnHello(a);
@@ -174,9 +174,9 @@ if (holder2.a.isLeader()) {
>isLeader : () => this is LeadGuard
holder2.a;
>holder2.a : RoyalGuard
>holder2.a : LeadGuard
>holder2 : { a: RoyalGuard; }
>a : RoyalGuard
>a : LeadGuard
}
else {
holder2.a;
@@ -0,0 +1,30 @@
tests/cases/conformance/expressions/typeGuards/typeGuardInClass.ts(6,17): error TS2322: Type 'string | number' is not assignable to type 'string'.
Type 'number' is not assignable to type 'string'.
tests/cases/conformance/expressions/typeGuards/typeGuardInClass.ts(13,17): error TS2322: Type 'string | number' is not assignable to type 'number'.
Type 'string' is not assignable to type 'number'.
==== tests/cases/conformance/expressions/typeGuards/typeGuardInClass.ts (2 errors) ====
let x: string | number;
if (typeof x === "string") {
let n = class {
constructor() {
let y: string = x;
~
!!! error TS2322: Type 'string | number' is not assignable to type 'string'.
!!! error TS2322: Type 'number' is not assignable to type 'string'.
}
}
}
else {
let m = class {
constructor() {
let y: number = x;
~
!!! error TS2322: Type 'string | number' is not assignable to type 'number'.
!!! error TS2322: Type 'string' is not assignable to type 'number'.
}
}
}
@@ -1,29 +0,0 @@
=== tests/cases/conformance/expressions/typeGuards/typeGuardInClass.ts ===
let x: string | number;
>x : Symbol(x, Decl(typeGuardInClass.ts, 0, 3))
if (typeof x === "string") {
>x : Symbol(x, Decl(typeGuardInClass.ts, 0, 3))
let n = class {
>n : Symbol(n, Decl(typeGuardInClass.ts, 3, 7))
constructor() {
let y: string = x;
>y : Symbol(y, Decl(typeGuardInClass.ts, 5, 15))
>x : Symbol(x, Decl(typeGuardInClass.ts, 0, 3))
}
}
}
else {
let m = class {
>m : Symbol(m, Decl(typeGuardInClass.ts, 10, 7))
constructor() {
let y: number = x;
>y : Symbol(y, Decl(typeGuardInClass.ts, 12, 15))
>x : Symbol(x, Decl(typeGuardInClass.ts, 0, 3))
}
}
}
@@ -1,34 +0,0 @@
=== tests/cases/conformance/expressions/typeGuards/typeGuardInClass.ts ===
let x: string | number;
>x : string | number
if (typeof x === "string") {
>typeof x === "string" : boolean
>typeof x : string
>x : string | number
>"string" : string
let n = class {
>n : typeof (Anonymous class)
>class { constructor() { let y: string = x; } } : typeof (Anonymous class)
constructor() {
let y: string = x;
>y : string
>x : string
}
}
}
else {
let m = class {
>m : typeof (Anonymous class)
>class { constructor() { let y: number = x; } } : typeof (Anonymous class)
constructor() {
let y: number = x;
>y : number
>x : number
}
}
}
@@ -0,0 +1,50 @@
tests/cases/conformance/expressions/typeGuards/typeGuardOfFormTypeOfEqualEqualHasNoEffect.ts(13,9): error TS2403: Subsequent variable declarations must have the same type. Variable 'r1' must be of type 'string', but here has type 'number'.
tests/cases/conformance/expressions/typeGuards/typeGuardOfFormTypeOfEqualEqualHasNoEffect.ts(20,9): error TS2403: Subsequent variable declarations must have the same type. Variable 'r2' must be of type 'boolean', but here has type 'string'.
tests/cases/conformance/expressions/typeGuards/typeGuardOfFormTypeOfEqualEqualHasNoEffect.ts(27,9): error TS2403: Subsequent variable declarations must have the same type. Variable 'r3' must be of type 'number', but here has type 'boolean'.
tests/cases/conformance/expressions/typeGuards/typeGuardOfFormTypeOfEqualEqualHasNoEffect.ts(34,9): error TS2403: Subsequent variable declarations must have the same type. Variable 'r4' must be of type 'C', but here has type 'string'.
==== tests/cases/conformance/expressions/typeGuards/typeGuardOfFormTypeOfEqualEqualHasNoEffect.ts (4 errors) ====
class C { private p: string };
var strOrNum: string | number;
var strOrBool: string | boolean;
var numOrBool: number | boolean
var strOrC: string | C;
// typeof x == s has not effect on typeguard
if (typeof strOrNum == "string") {
var r1 = strOrNum; // string | number
}
else {
var r1 = strOrNum; // string | number
~~
!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'r1' must be of type 'string', but here has type 'number'.
}
if (typeof strOrBool == "boolean") {
var r2 = strOrBool; // string | boolean
}
else {
var r2 = strOrBool; // string | boolean
~~
!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'r2' must be of type 'boolean', but here has type 'string'.
}
if (typeof numOrBool == "number") {
var r3 = numOrBool; // number | boolean
}
else {
var r3 = numOrBool; // number | boolean
~~
!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'r3' must be of type 'number', but here has type 'boolean'.
}
if (typeof strOrC == "Object") {
var r4 = strOrC; // string | C
}
else {
var r4 = strOrC; // string | C
~~
!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'r4' must be of type 'C', but here has type 'string'.
}
@@ -1,70 +0,0 @@
=== tests/cases/conformance/expressions/typeGuards/typeGuardOfFormTypeOfEqualEqualHasNoEffect.ts ===
class C { private p: string };
>C : Symbol(C, Decl(typeGuardOfFormTypeOfEqualEqualHasNoEffect.ts, 0, 0))
>p : Symbol(C.p, Decl(typeGuardOfFormTypeOfEqualEqualHasNoEffect.ts, 0, 9))
var strOrNum: string | number;
>strOrNum : Symbol(strOrNum, Decl(typeGuardOfFormTypeOfEqualEqualHasNoEffect.ts, 2, 3))
var strOrBool: string | boolean;
>strOrBool : Symbol(strOrBool, Decl(typeGuardOfFormTypeOfEqualEqualHasNoEffect.ts, 3, 3))
var numOrBool: number | boolean
>numOrBool : Symbol(numOrBool, Decl(typeGuardOfFormTypeOfEqualEqualHasNoEffect.ts, 4, 3))
var strOrC: string | C;
>strOrC : Symbol(strOrC, Decl(typeGuardOfFormTypeOfEqualEqualHasNoEffect.ts, 5, 3))
>C : Symbol(C, Decl(typeGuardOfFormTypeOfEqualEqualHasNoEffect.ts, 0, 0))
// typeof x == s has not effect on typeguard
if (typeof strOrNum == "string") {
>strOrNum : Symbol(strOrNum, Decl(typeGuardOfFormTypeOfEqualEqualHasNoEffect.ts, 2, 3))
var r1 = strOrNum; // string | number
>r1 : Symbol(r1, Decl(typeGuardOfFormTypeOfEqualEqualHasNoEffect.ts, 9, 7), Decl(typeGuardOfFormTypeOfEqualEqualHasNoEffect.ts, 12, 7))
>strOrNum : Symbol(strOrNum, Decl(typeGuardOfFormTypeOfEqualEqualHasNoEffect.ts, 2, 3))
}
else {
var r1 = strOrNum; // string | number
>r1 : Symbol(r1, Decl(typeGuardOfFormTypeOfEqualEqualHasNoEffect.ts, 9, 7), Decl(typeGuardOfFormTypeOfEqualEqualHasNoEffect.ts, 12, 7))
>strOrNum : Symbol(strOrNum, Decl(typeGuardOfFormTypeOfEqualEqualHasNoEffect.ts, 2, 3))
}
if (typeof strOrBool == "boolean") {
>strOrBool : Symbol(strOrBool, Decl(typeGuardOfFormTypeOfEqualEqualHasNoEffect.ts, 3, 3))
var r2 = strOrBool; // string | boolean
>r2 : Symbol(r2, Decl(typeGuardOfFormTypeOfEqualEqualHasNoEffect.ts, 16, 7), Decl(typeGuardOfFormTypeOfEqualEqualHasNoEffect.ts, 19, 7))
>strOrBool : Symbol(strOrBool, Decl(typeGuardOfFormTypeOfEqualEqualHasNoEffect.ts, 3, 3))
}
else {
var r2 = strOrBool; // string | boolean
>r2 : Symbol(r2, Decl(typeGuardOfFormTypeOfEqualEqualHasNoEffect.ts, 16, 7), Decl(typeGuardOfFormTypeOfEqualEqualHasNoEffect.ts, 19, 7))
>strOrBool : Symbol(strOrBool, Decl(typeGuardOfFormTypeOfEqualEqualHasNoEffect.ts, 3, 3))
}
if (typeof numOrBool == "number") {
>numOrBool : Symbol(numOrBool, Decl(typeGuardOfFormTypeOfEqualEqualHasNoEffect.ts, 4, 3))
var r3 = numOrBool; // number | boolean
>r3 : Symbol(r3, Decl(typeGuardOfFormTypeOfEqualEqualHasNoEffect.ts, 23, 7), Decl(typeGuardOfFormTypeOfEqualEqualHasNoEffect.ts, 26, 7))
>numOrBool : Symbol(numOrBool, Decl(typeGuardOfFormTypeOfEqualEqualHasNoEffect.ts, 4, 3))
}
else {
var r3 = numOrBool; // number | boolean
>r3 : Symbol(r3, Decl(typeGuardOfFormTypeOfEqualEqualHasNoEffect.ts, 23, 7), Decl(typeGuardOfFormTypeOfEqualEqualHasNoEffect.ts, 26, 7))
>numOrBool : Symbol(numOrBool, Decl(typeGuardOfFormTypeOfEqualEqualHasNoEffect.ts, 4, 3))
}
if (typeof strOrC == "Object") {
>strOrC : Symbol(strOrC, Decl(typeGuardOfFormTypeOfEqualEqualHasNoEffect.ts, 5, 3))
var r4 = strOrC; // string | C
>r4 : Symbol(r4, Decl(typeGuardOfFormTypeOfEqualEqualHasNoEffect.ts, 30, 7), Decl(typeGuardOfFormTypeOfEqualEqualHasNoEffect.ts, 33, 7))
>strOrC : Symbol(strOrC, Decl(typeGuardOfFormTypeOfEqualEqualHasNoEffect.ts, 5, 3))
}
else {
var r4 = strOrC; // string | C
>r4 : Symbol(r4, Decl(typeGuardOfFormTypeOfEqualEqualHasNoEffect.ts, 30, 7), Decl(typeGuardOfFormTypeOfEqualEqualHasNoEffect.ts, 33, 7))
>strOrC : Symbol(strOrC, Decl(typeGuardOfFormTypeOfEqualEqualHasNoEffect.ts, 5, 3))
}
@@ -1,82 +0,0 @@
=== tests/cases/conformance/expressions/typeGuards/typeGuardOfFormTypeOfEqualEqualHasNoEffect.ts ===
class C { private p: string };
>C : C
>p : string
var strOrNum: string | number;
>strOrNum : string | number
var strOrBool: string | boolean;
>strOrBool : string | boolean
var numOrBool: number | boolean
>numOrBool : number | boolean
var strOrC: string | C;
>strOrC : string | C
>C : C
// typeof x == s has not effect on typeguard
if (typeof strOrNum == "string") {
>typeof strOrNum == "string" : boolean
>typeof strOrNum : string
>strOrNum : string | number
>"string" : string
var r1 = strOrNum; // string | number
>r1 : string | number
>strOrNum : string | number
}
else {
var r1 = strOrNum; // string | number
>r1 : string | number
>strOrNum : string | number
}
if (typeof strOrBool == "boolean") {
>typeof strOrBool == "boolean" : boolean
>typeof strOrBool : string
>strOrBool : string | boolean
>"boolean" : string
var r2 = strOrBool; // string | boolean
>r2 : string | boolean
>strOrBool : string | boolean
}
else {
var r2 = strOrBool; // string | boolean
>r2 : string | boolean
>strOrBool : string | boolean
}
if (typeof numOrBool == "number") {
>typeof numOrBool == "number" : boolean
>typeof numOrBool : string
>numOrBool : number | boolean
>"number" : string
var r3 = numOrBool; // number | boolean
>r3 : number | boolean
>numOrBool : number | boolean
}
else {
var r3 = numOrBool; // number | boolean
>r3 : number | boolean
>numOrBool : number | boolean
}
if (typeof strOrC == "Object") {
>typeof strOrC == "Object" : boolean
>typeof strOrC : string
>strOrC : string | C
>"Object" : string
var r4 = strOrC; // string | C
>r4 : string | C
>strOrC : string | C
}
else {
var r4 = strOrC; // string | C
>r4 : string | C
>strOrC : string | C
}
@@ -0,0 +1,50 @@
tests/cases/conformance/expressions/typeGuards/typeGuardOfFormTypeOfNotEqualHasNoEffect.ts(13,9): error TS2403: Subsequent variable declarations must have the same type. Variable 'r1' must be of type 'number', but here has type 'string'.
tests/cases/conformance/expressions/typeGuards/typeGuardOfFormTypeOfNotEqualHasNoEffect.ts(20,9): error TS2403: Subsequent variable declarations must have the same type. Variable 'r2' must be of type 'string', but here has type 'boolean'.
tests/cases/conformance/expressions/typeGuards/typeGuardOfFormTypeOfNotEqualHasNoEffect.ts(27,9): error TS2403: Subsequent variable declarations must have the same type. Variable 'r3' must be of type 'boolean', but here has type 'number'.
tests/cases/conformance/expressions/typeGuards/typeGuardOfFormTypeOfNotEqualHasNoEffect.ts(34,9): error TS2403: Subsequent variable declarations must have the same type. Variable 'r4' must be of type 'string', but here has type 'C'.
==== tests/cases/conformance/expressions/typeGuards/typeGuardOfFormTypeOfNotEqualHasNoEffect.ts (4 errors) ====
class C { private p: string };
var strOrNum: string | number;
var strOrBool: string | boolean;
var numOrBool: number | boolean
var strOrC: string | C;
// typeof x != s has not effect on typeguard
if (typeof strOrNum != "string") {
var r1 = strOrNum; // string | number
}
else {
var r1 = strOrNum; // string | number
~~
!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'r1' must be of type 'number', but here has type 'string'.
}
if (typeof strOrBool != "boolean") {
var r2 = strOrBool; // string | boolean
}
else {
var r2 = strOrBool; // string | boolean
~~
!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'r2' must be of type 'string', but here has type 'boolean'.
}
if (typeof numOrBool != "number") {
var r3 = numOrBool; // number | boolean
}
else {
var r3 = numOrBool; // number | boolean
~~
!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'r3' must be of type 'boolean', but here has type 'number'.
}
if (typeof strOrC != "Object") {
var r4 = strOrC; // string | C
}
else {
var r4 = strOrC; // string | C
~~
!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'r4' must be of type 'string', but here has type 'C'.
}
@@ -1,70 +0,0 @@
=== tests/cases/conformance/expressions/typeGuards/typeGuardOfFormTypeOfNotEqualHasNoEffect.ts ===
class C { private p: string };
>C : Symbol(C, Decl(typeGuardOfFormTypeOfNotEqualHasNoEffect.ts, 0, 0))
>p : Symbol(C.p, Decl(typeGuardOfFormTypeOfNotEqualHasNoEffect.ts, 0, 9))
var strOrNum: string | number;
>strOrNum : Symbol(strOrNum, Decl(typeGuardOfFormTypeOfNotEqualHasNoEffect.ts, 2, 3))
var strOrBool: string | boolean;
>strOrBool : Symbol(strOrBool, Decl(typeGuardOfFormTypeOfNotEqualHasNoEffect.ts, 3, 3))
var numOrBool: number | boolean
>numOrBool : Symbol(numOrBool, Decl(typeGuardOfFormTypeOfNotEqualHasNoEffect.ts, 4, 3))
var strOrC: string | C;
>strOrC : Symbol(strOrC, Decl(typeGuardOfFormTypeOfNotEqualHasNoEffect.ts, 5, 3))
>C : Symbol(C, Decl(typeGuardOfFormTypeOfNotEqualHasNoEffect.ts, 0, 0))
// typeof x != s has not effect on typeguard
if (typeof strOrNum != "string") {
>strOrNum : Symbol(strOrNum, Decl(typeGuardOfFormTypeOfNotEqualHasNoEffect.ts, 2, 3))
var r1 = strOrNum; // string | number
>r1 : Symbol(r1, Decl(typeGuardOfFormTypeOfNotEqualHasNoEffect.ts, 9, 7), Decl(typeGuardOfFormTypeOfNotEqualHasNoEffect.ts, 12, 7))
>strOrNum : Symbol(strOrNum, Decl(typeGuardOfFormTypeOfNotEqualHasNoEffect.ts, 2, 3))
}
else {
var r1 = strOrNum; // string | number
>r1 : Symbol(r1, Decl(typeGuardOfFormTypeOfNotEqualHasNoEffect.ts, 9, 7), Decl(typeGuardOfFormTypeOfNotEqualHasNoEffect.ts, 12, 7))
>strOrNum : Symbol(strOrNum, Decl(typeGuardOfFormTypeOfNotEqualHasNoEffect.ts, 2, 3))
}
if (typeof strOrBool != "boolean") {
>strOrBool : Symbol(strOrBool, Decl(typeGuardOfFormTypeOfNotEqualHasNoEffect.ts, 3, 3))
var r2 = strOrBool; // string | boolean
>r2 : Symbol(r2, Decl(typeGuardOfFormTypeOfNotEqualHasNoEffect.ts, 16, 7), Decl(typeGuardOfFormTypeOfNotEqualHasNoEffect.ts, 19, 7))
>strOrBool : Symbol(strOrBool, Decl(typeGuardOfFormTypeOfNotEqualHasNoEffect.ts, 3, 3))
}
else {
var r2 = strOrBool; // string | boolean
>r2 : Symbol(r2, Decl(typeGuardOfFormTypeOfNotEqualHasNoEffect.ts, 16, 7), Decl(typeGuardOfFormTypeOfNotEqualHasNoEffect.ts, 19, 7))
>strOrBool : Symbol(strOrBool, Decl(typeGuardOfFormTypeOfNotEqualHasNoEffect.ts, 3, 3))
}
if (typeof numOrBool != "number") {
>numOrBool : Symbol(numOrBool, Decl(typeGuardOfFormTypeOfNotEqualHasNoEffect.ts, 4, 3))
var r3 = numOrBool; // number | boolean
>r3 : Symbol(r3, Decl(typeGuardOfFormTypeOfNotEqualHasNoEffect.ts, 23, 7), Decl(typeGuardOfFormTypeOfNotEqualHasNoEffect.ts, 26, 7))
>numOrBool : Symbol(numOrBool, Decl(typeGuardOfFormTypeOfNotEqualHasNoEffect.ts, 4, 3))
}
else {
var r3 = numOrBool; // number | boolean
>r3 : Symbol(r3, Decl(typeGuardOfFormTypeOfNotEqualHasNoEffect.ts, 23, 7), Decl(typeGuardOfFormTypeOfNotEqualHasNoEffect.ts, 26, 7))
>numOrBool : Symbol(numOrBool, Decl(typeGuardOfFormTypeOfNotEqualHasNoEffect.ts, 4, 3))
}
if (typeof strOrC != "Object") {
>strOrC : Symbol(strOrC, Decl(typeGuardOfFormTypeOfNotEqualHasNoEffect.ts, 5, 3))
var r4 = strOrC; // string | C
>r4 : Symbol(r4, Decl(typeGuardOfFormTypeOfNotEqualHasNoEffect.ts, 30, 7), Decl(typeGuardOfFormTypeOfNotEqualHasNoEffect.ts, 33, 7))
>strOrC : Symbol(strOrC, Decl(typeGuardOfFormTypeOfNotEqualHasNoEffect.ts, 5, 3))
}
else {
var r4 = strOrC; // string | C
>r4 : Symbol(r4, Decl(typeGuardOfFormTypeOfNotEqualHasNoEffect.ts, 30, 7), Decl(typeGuardOfFormTypeOfNotEqualHasNoEffect.ts, 33, 7))
>strOrC : Symbol(strOrC, Decl(typeGuardOfFormTypeOfNotEqualHasNoEffect.ts, 5, 3))
}
@@ -1,82 +0,0 @@
=== tests/cases/conformance/expressions/typeGuards/typeGuardOfFormTypeOfNotEqualHasNoEffect.ts ===
class C { private p: string };
>C : C
>p : string
var strOrNum: string | number;
>strOrNum : string | number
var strOrBool: string | boolean;
>strOrBool : string | boolean
var numOrBool: number | boolean
>numOrBool : number | boolean
var strOrC: string | C;
>strOrC : string | C
>C : C
// typeof x != s has not effect on typeguard
if (typeof strOrNum != "string") {
>typeof strOrNum != "string" : boolean
>typeof strOrNum : string
>strOrNum : string | number
>"string" : string
var r1 = strOrNum; // string | number
>r1 : string | number
>strOrNum : string | number
}
else {
var r1 = strOrNum; // string | number
>r1 : string | number
>strOrNum : string | number
}
if (typeof strOrBool != "boolean") {
>typeof strOrBool != "boolean" : boolean
>typeof strOrBool : string
>strOrBool : string | boolean
>"boolean" : string
var r2 = strOrBool; // string | boolean
>r2 : string | boolean
>strOrBool : string | boolean
}
else {
var r2 = strOrBool; // string | boolean
>r2 : string | boolean
>strOrBool : string | boolean
}
if (typeof numOrBool != "number") {
>typeof numOrBool != "number" : boolean
>typeof numOrBool : string
>numOrBool : number | boolean
>"number" : string
var r3 = numOrBool; // number | boolean
>r3 : number | boolean
>numOrBool : number | boolean
}
else {
var r3 = numOrBool; // number | boolean
>r3 : number | boolean
>numOrBool : number | boolean
}
if (typeof strOrC != "Object") {
>typeof strOrC != "Object" : boolean
>typeof strOrC : string
>strOrC : string | C
>"Object" : string
var r4 = strOrC; // string | C
>r4 : string | C
>strOrC : string | C
}
else {
var r4 = strOrC; // string | C
>r4 : string | C
>strOrC : string | C
}
@@ -0,0 +1,52 @@
tests/cases/conformance/expressions/typeGuards/typeGuardsDefeat.ts(21,20): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/expressions/typeGuards/typeGuardsDefeat.ts(21,24): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/expressions/typeGuards/typeGuardsDefeat.ts(32,23): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/expressions/typeGuards/typeGuardsDefeat.ts(32,27): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
==== tests/cases/conformance/expressions/typeGuards/typeGuardsDefeat.ts (4 errors) ====
// Also note that it is possible to defeat a type guard by calling a function that changes the
// type of the guarded variable.
function foo(x: number | string) {
function f() {
x = 10;
}
if (typeof x === "string") {
f();
return x.length; // string
}
else {
return x++; // number
}
}
function foo2(x: number | string) {
if (typeof x === "string") {
return x.length; // string
}
else {
var f = function () {
return x * x;
~
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
~
!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
};
}
x = "hello";
f();
}
function foo3(x: number | string) {
if (typeof x === "string") {
return x.length; // string
}
else {
var f = () => x * x;
~
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
~
!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
}
x = "hello";
f();
}
@@ -1,82 +0,0 @@
=== tests/cases/conformance/expressions/typeGuards/typeGuardsDefeat.ts ===
// Also note that it is possible to defeat a type guard by calling a function that changes the
// type of the guarded variable.
function foo(x: number | string) {
>foo : Symbol(foo, Decl(typeGuardsDefeat.ts, 0, 0))
>x : Symbol(x, Decl(typeGuardsDefeat.ts, 2, 13))
function f() {
>f : Symbol(f, Decl(typeGuardsDefeat.ts, 2, 34))
x = 10;
>x : Symbol(x, Decl(typeGuardsDefeat.ts, 2, 13))
}
if (typeof x === "string") {
>x : Symbol(x, Decl(typeGuardsDefeat.ts, 2, 13))
f();
>f : Symbol(f, Decl(typeGuardsDefeat.ts, 2, 34))
return x.length; // string
>x.length : Symbol(String.length, Decl(lib.d.ts, --, --))
>x : Symbol(x, Decl(typeGuardsDefeat.ts, 2, 13))
>length : Symbol(String.length, Decl(lib.d.ts, --, --))
}
else {
return x++; // number
>x : Symbol(x, Decl(typeGuardsDefeat.ts, 2, 13))
}
}
function foo2(x: number | string) {
>foo2 : Symbol(foo2, Decl(typeGuardsDefeat.ts, 13, 1))
>x : Symbol(x, Decl(typeGuardsDefeat.ts, 14, 14))
if (typeof x === "string") {
>x : Symbol(x, Decl(typeGuardsDefeat.ts, 14, 14))
return x.length; // string
>x.length : Symbol(String.length, Decl(lib.d.ts, --, --))
>x : Symbol(x, Decl(typeGuardsDefeat.ts, 14, 14))
>length : Symbol(String.length, Decl(lib.d.ts, --, --))
}
else {
var f = function () {
>f : Symbol(f, Decl(typeGuardsDefeat.ts, 19, 11))
return x * x;
>x : Symbol(x, Decl(typeGuardsDefeat.ts, 14, 14))
>x : Symbol(x, Decl(typeGuardsDefeat.ts, 14, 14))
};
}
x = "hello";
>x : Symbol(x, Decl(typeGuardsDefeat.ts, 14, 14))
f();
>f : Symbol(f, Decl(typeGuardsDefeat.ts, 19, 11))
}
function foo3(x: number | string) {
>foo3 : Symbol(foo3, Decl(typeGuardsDefeat.ts, 25, 1))
>x : Symbol(x, Decl(typeGuardsDefeat.ts, 26, 14))
if (typeof x === "string") {
>x : Symbol(x, Decl(typeGuardsDefeat.ts, 26, 14))
return x.length; // string
>x.length : Symbol(String.length, Decl(lib.d.ts, --, --))
>x : Symbol(x, Decl(typeGuardsDefeat.ts, 26, 14))
>length : Symbol(String.length, Decl(lib.d.ts, --, --))
}
else {
var f = () => x * x;
>f : Symbol(f, Decl(typeGuardsDefeat.ts, 31, 11))
>x : Symbol(x, Decl(typeGuardsDefeat.ts, 26, 14))
>x : Symbol(x, Decl(typeGuardsDefeat.ts, 26, 14))
}
x = "hello";
>x : Symbol(x, Decl(typeGuardsDefeat.ts, 26, 14))
f();
>f : Symbol(f, Decl(typeGuardsDefeat.ts, 31, 11))
}
@@ -1,105 +0,0 @@
=== tests/cases/conformance/expressions/typeGuards/typeGuardsDefeat.ts ===
// Also note that it is possible to defeat a type guard by calling a function that changes the
// type of the guarded variable.
function foo(x: number | string) {
>foo : (x: number | string) => number
>x : number | string
function f() {
>f : () => void
x = 10;
>x = 10 : number
>x : number | string
>10 : number
}
if (typeof x === "string") {
>typeof x === "string" : boolean
>typeof x : string
>x : number | string
>"string" : string
f();
>f() : void
>f : () => void
return x.length; // string
>x.length : number
>x : string
>length : number
}
else {
return x++; // number
>x++ : number
>x : number
}
}
function foo2(x: number | string) {
>foo2 : (x: number | string) => number
>x : number | string
if (typeof x === "string") {
>typeof x === "string" : boolean
>typeof x : string
>x : number | string
>"string" : string
return x.length; // string
>x.length : number
>x : string
>length : number
}
else {
var f = function () {
>f : () => number
>function () { return x * x; } : () => number
return x * x;
>x * x : number
>x : number
>x : number
};
}
x = "hello";
>x = "hello" : string
>x : number | string
>"hello" : string
f();
>f() : number
>f : () => number
}
function foo3(x: number | string) {
>foo3 : (x: number | string) => number
>x : number | string
if (typeof x === "string") {
>typeof x === "string" : boolean
>typeof x : string
>x : number | string
>"string" : string
return x.length; // string
>x.length : number
>x : string
>length : number
}
else {
var f = () => x * x;
>f : () => number
>() => x * x : () => number
>x * x : number
>x : number
>x : number
}
x = "hello";
>x = "hello" : string
>x : number | string
>"hello" : string
f();
>f() : number
>f : () => number
}
@@ -44,13 +44,13 @@ if (typeof var2 === "string") {
// export makes the var property and not variable
strOrNum = var2; // string | number
>strOrNum = var2 : string | number
>strOrNum = var2 : string
>strOrNum : string | number
>var2 : string | number
>var2 : string
}
else {
strOrNum = var2; // number | string
>strOrNum = var2 : string | number
>strOrNum = var2 : number
>strOrNum : string | number
>var2 : string | number
>var2 : number
}
@@ -27,9 +27,9 @@ function foo(x: number | string | boolean) {
>toString : Symbol(Object.toString, Decl(lib.d.ts, --, --))
: x.toString(); // number
>x.toString : Symbol(Number.toString, Decl(lib.d.ts, --, --))
>x.toString : Symbol(toString, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
>x : Symbol(x, Decl(typeGuardsInFunctionAndModuleBlock.ts, 2, 13))
>toString : Symbol(Number.toString, Decl(lib.d.ts, --, --))
>toString : Symbol(toString, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
} ();
}
@@ -60,9 +60,9 @@ function foo2(x: number | string | boolean) {
>toString : Symbol(Object.toString, Decl(lib.d.ts, --, --))
: x.toString(); // number
>x.toString : Symbol(Number.toString, Decl(lib.d.ts, --, --))
>x.toString : Symbol(toString, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
>x : Symbol(x, Decl(typeGuardsInFunctionAndModuleBlock.ts, 12, 14))
>toString : Symbol(Number.toString, Decl(lib.d.ts, --, --))
>toString : Symbol(toString, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
} (x); // x here is narrowed to number | boolean
>x : Symbol(x, Decl(typeGuardsInFunctionAndModuleBlock.ts, 12, 14))
@@ -91,9 +91,9 @@ function foo3(x: number | string | boolean) {
>toString : Symbol(Object.toString, Decl(lib.d.ts, --, --))
: x.toString(); // number
>x.toString : Symbol(Number.toString, Decl(lib.d.ts, --, --))
>x.toString : Symbol(toString, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
>x : Symbol(x, Decl(typeGuardsInFunctionAndModuleBlock.ts, 22, 14))
>toString : Symbol(Number.toString, Decl(lib.d.ts, --, --))
>toString : Symbol(toString, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
})();
}
@@ -123,9 +123,9 @@ function foo4(x: number | string | boolean) {
>toString : Symbol(Object.toString, Decl(lib.d.ts, --, --))
: x.toString(); // number
>x.toString : Symbol(Number.toString, Decl(lib.d.ts, --, --))
>x.toString : Symbol(toString, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
>x : Symbol(x, Decl(typeGuardsInFunctionAndModuleBlock.ts, 32, 14))
>toString : Symbol(Number.toString, Decl(lib.d.ts, --, --))
>toString : Symbol(toString, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
})(x); // x here is narrowed to number | boolean
>x : Symbol(x, Decl(typeGuardsInFunctionAndModuleBlock.ts, 32, 14))
@@ -21,14 +21,14 @@ function foo(x: number | string | boolean) {
>f : () => string
var b = x; // number | boolean
>b : number | boolean
>x : number | boolean
>b : number | string | boolean
>x : number | string | boolean
return typeof x === "boolean"
>typeof x === "boolean" ? x.toString() // boolean : x.toString() : string
>typeof x === "boolean" : boolean
>typeof x : string
>x : number | boolean
>x : number | string | boolean
>"boolean" : string
? x.toString() // boolean
@@ -40,7 +40,7 @@ function foo(x: number | string | boolean) {
: x.toString(); // number
>x.toString() : string
>x.toString : (radix?: number) => string
>x : number
>x : number | string
>toString : (radix?: number) => string
} ();
@@ -66,14 +66,14 @@ function foo2(x: number | string | boolean) {
>a : number | boolean
var b = x; // new scope - number | boolean
>b : number | boolean
>x : number | boolean
>b : number | string | boolean
>x : number | string | boolean
return typeof x === "boolean"
>typeof x === "boolean" ? x.toString() // boolean : x.toString() : string
>typeof x === "boolean" : boolean
>typeof x : string
>x : number | boolean
>x : number | string | boolean
>"boolean" : string
? x.toString() // boolean
@@ -85,7 +85,7 @@ function foo2(x: number | string | boolean) {
: x.toString(); // number
>x.toString() : string
>x.toString : (radix?: number) => string
>x : number
>x : number | string
>toString : (radix?: number) => string
} (x); // x here is narrowed to number | boolean
@@ -111,14 +111,14 @@ function foo3(x: number | string | boolean) {
>() => { var b = x; // new scope - number | boolean return typeof x === "boolean" ? x.toString() // boolean : x.toString(); // number } : () => string
var b = x; // new scope - number | boolean
>b : number | boolean
>x : number | boolean
>b : number | string | boolean
>x : number | string | boolean
return typeof x === "boolean"
>typeof x === "boolean" ? x.toString() // boolean : x.toString() : string
>typeof x === "boolean" : boolean
>typeof x : string
>x : number | boolean
>x : number | string | boolean
>"boolean" : string
? x.toString() // boolean
@@ -130,7 +130,7 @@ function foo3(x: number | string | boolean) {
: x.toString(); // number
>x.toString() : string
>x.toString : (radix?: number) => string
>x : number
>x : number | string
>toString : (radix?: number) => string
})();
@@ -156,14 +156,14 @@ function foo4(x: number | string | boolean) {
>a : number | boolean
var b = x; // new scope - number | boolean
>b : number | boolean
>x : number | boolean
>b : number | string | boolean
>x : number | string | boolean
return typeof x === "boolean"
>typeof x === "boolean" ? x.toString() // boolean : x.toString() : string
>typeof x === "boolean" : boolean
>typeof x : string
>x : number | boolean
>x : number | string | boolean
>"boolean" : string
? x.toString() // boolean
@@ -175,7 +175,7 @@ function foo4(x: number | string | boolean) {
: x.toString(); // number
>x.toString() : string
>x.toString : (radix?: number) => string
>x : number
>x : number | string
>toString : (radix?: number) => string
})(x); // x here is narrowed to number | boolean
@@ -200,8 +200,8 @@ function foo5(x: number | string | boolean) {
>foo : () => void
var z = x; // string
>z : string
>x : string
>z : number | string | boolean
>x : number | string | boolean
}
}
}
@@ -64,15 +64,15 @@ module m1 {
>"string" : string
strOrNum = var3; // string | number
>strOrNum = var3 : string | number
>strOrNum = var3 : string
>strOrNum : string | number
>var3 : string | number
>var3 : string
}
else {
strOrNum = var3; // string | number
>strOrNum = var3 : string | number
>strOrNum = var3 : number
>strOrNum : string | number
>var3 : string | number
>var3 : number
}
}
// local module
@@ -116,14 +116,14 @@ module m2 {
// exported variable from outer the module
strOrNum = typeof var3 === "string" && var3; // string | number
>strOrNum = typeof var3 === "string" && var3 : string | number
>strOrNum = typeof var3 === "string" && var3 : string
>strOrNum : string | number
>typeof var3 === "string" && var3 : string | number
>typeof var3 === "string" && var3 : string
>typeof var3 === "string" : boolean
>typeof var3 : string
>var3 : string | number
>"string" : string
>var3 : string | number
>var3 : string
// variables in module declaration
var var4: string | number;
@@ -160,15 +160,15 @@ module m2 {
>"string" : string
strOrNum = var5; // string | number
>strOrNum = var5 : string | number
>strOrNum = var5 : string
>strOrNum : string | number
>var5 : string | number
>var5 : string
}
else {
strOrNum = var5; // string | number
>strOrNum = var5 : string | number
>strOrNum = var5 : number
>strOrNum : string | number
>var5 : string | number
>var5 : number
}
}
}
@@ -225,15 +225,15 @@ module m3.m4 {
>"string" : string
strOrNum = var3; // string | number
>strOrNum = var3 : string | number
>strOrNum = var3 : string
>strOrNum : string | number
>var3 : string | number
>var3 : string
}
else {
strOrNum = var3; // string | number
>strOrNum = var3 : string | number
>strOrNum = var3 : number
>strOrNum : string | number
>var3 : string | number
>var3 : number
}
}
@@ -29,32 +29,32 @@ class C1 {
>method : () => void
strOrNum = typeof this.pp1 === "string" && this.pp1; // string | number
>strOrNum = typeof this.pp1 === "string" && this.pp1 : string | number
>strOrNum = typeof this.pp1 === "string" && this.pp1 : string
>strOrNum : string | number
>typeof this.pp1 === "string" && this.pp1 : string | number
>typeof this.pp1 === "string" && this.pp1 : string
>typeof this.pp1 === "string" : boolean
>typeof this.pp1 : string
>this.pp1 : string | number
>this : this
>pp1 : string | number
>"string" : string
>this.pp1 : string | number
>this.pp1 : string
>this : this
>pp1 : string | number
>pp1 : string
strOrNum = typeof this.pp2 === "string" && this.pp2; // string | number
>strOrNum = typeof this.pp2 === "string" && this.pp2 : string | number
>strOrNum = typeof this.pp2 === "string" && this.pp2 : string
>strOrNum : string | number
>typeof this.pp2 === "string" && this.pp2 : string | number
>typeof this.pp2 === "string" && this.pp2 : string
>typeof this.pp2 === "string" : boolean
>typeof this.pp2 : string
>this.pp2 : string | number
>this : this
>pp2 : string | number
>"string" : string
>this.pp2 : string | number
>this.pp2 : string
>this : this
>pp2 : string | number
>pp2 : string
strOrNum = typeof this.pp3 === "string" && this.pp3; // string | number
>strOrNum = typeof this.pp3 === "string" && this.pp3 : string | number
@@ -76,18 +76,18 @@ var c1: C1;
>C1 : C1
strOrNum = typeof c1.pp2 === "string" && c1.pp2; // string | number
>strOrNum = typeof c1.pp2 === "string" && c1.pp2 : string | number
>strOrNum = typeof c1.pp2 === "string" && c1.pp2 : string
>strOrNum : string | number
>typeof c1.pp2 === "string" && c1.pp2 : string | number
>typeof c1.pp2 === "string" && c1.pp2 : string
>typeof c1.pp2 === "string" : boolean
>typeof c1.pp2 : string
>c1.pp2 : string | number
>c1 : C1
>pp2 : string | number
>"string" : string
>c1.pp2 : string | number
>c1.pp2 : string
>c1 : C1
>pp2 : string | number
>pp2 : string
strOrNum = typeof c1.pp3 === "string" && c1.pp3; // string | number
>strOrNum = typeof c1.pp3 === "string" && c1.pp3 : string | number
@@ -111,16 +111,16 @@ var obj1: {
};
strOrNum = typeof obj1.x === "string" && obj1.x; // string | number
>strOrNum = typeof obj1.x === "string" && obj1.x : string | number
>strOrNum = typeof obj1.x === "string" && obj1.x : string
>strOrNum : string | number
>typeof obj1.x === "string" && obj1.x : string | number
>typeof obj1.x === "string" && obj1.x : string
>typeof obj1.x === "string" : boolean
>typeof obj1.x : string
>obj1.x : string | number
>obj1 : { x: string | number; }
>x : string | number
>"string" : string
>obj1.x : string | number
>obj1.x : string
>obj1 : { x: string | number; }
>x : string | number
>x : string
@@ -1,37 +0,0 @@
tests/cases/conformance/expressions/typeGuards/typeGuardsOnClassProperty.ts(14,70): error TS2339: Property 'join' does not exist on type 'string | string[]'.
tests/cases/conformance/expressions/typeGuards/typeGuardsOnClassProperty.ts(26,44): error TS2339: Property 'toLowerCase' does not exist on type 'number | string'.
==== tests/cases/conformance/expressions/typeGuards/typeGuardsOnClassProperty.ts (2 errors) ====
// Note that type guards affect types of variables and parameters only and
// have no effect on members of objects such as properties.
// Note that the class's property must be copied to a local variable for
// the type guard to have an effect
class D {
data: string | string[];
getData() {
var data = this.data;
return typeof data === "string" ? data : data.join(" ");
}
getData1() {
return typeof this.data === "string" ? this.data : this.data.join(" ");
~~~~
!!! error TS2339: Property 'join' does not exist on type 'string | string[]'.
}
}
var o: {
prop1: number|string;
prop2: boolean|string;
} = {
prop1: "string" ,
prop2: true
}
if (typeof o.prop1 === "string" && o.prop1.toLowerCase()) {}
~~~~~~~~~~~
!!! error TS2339: Property 'toLowerCase' does not exist on type 'number | string'.
var prop1 = o.prop1;
if (typeof prop1 === "string" && prop1.toLocaleLowerCase()) { }
@@ -0,0 +1,86 @@
=== tests/cases/conformance/expressions/typeGuards/typeGuardsOnClassProperty.ts ===
// Note that type guards affect types of variables and parameters only and
// have no effect on members of objects such as properties.
// Note that the class's property must be copied to a local variable for
// the type guard to have an effect
class D {
>D : Symbol(D, Decl(typeGuardsOnClassProperty.ts, 0, 0))
data: string | string[];
>data : Symbol(D.data, Decl(typeGuardsOnClassProperty.ts, 5, 9))
getData() {
>getData : Symbol(D.getData, Decl(typeGuardsOnClassProperty.ts, 6, 28))
var data = this.data;
>data : Symbol(data, Decl(typeGuardsOnClassProperty.ts, 8, 11))
>this.data : Symbol(D.data, Decl(typeGuardsOnClassProperty.ts, 5, 9))
>this : Symbol(D, Decl(typeGuardsOnClassProperty.ts, 0, 0))
>data : Symbol(D.data, Decl(typeGuardsOnClassProperty.ts, 5, 9))
return typeof data === "string" ? data : data.join(" ");
>data : Symbol(data, Decl(typeGuardsOnClassProperty.ts, 8, 11))
>data : Symbol(data, Decl(typeGuardsOnClassProperty.ts, 8, 11))
>data.join : Symbol(Array.join, Decl(lib.d.ts, --, --))
>data : Symbol(data, Decl(typeGuardsOnClassProperty.ts, 8, 11))
>join : Symbol(Array.join, Decl(lib.d.ts, --, --))
}
getData1() {
>getData1 : Symbol(D.getData1, Decl(typeGuardsOnClassProperty.ts, 10, 5))
return typeof this.data === "string" ? this.data : this.data.join(" ");
>this.data : Symbol(D.data, Decl(typeGuardsOnClassProperty.ts, 5, 9))
>this : Symbol(D, Decl(typeGuardsOnClassProperty.ts, 0, 0))
>data : Symbol(D.data, Decl(typeGuardsOnClassProperty.ts, 5, 9))
>this.data : Symbol(D.data, Decl(typeGuardsOnClassProperty.ts, 5, 9))
>this : Symbol(D, Decl(typeGuardsOnClassProperty.ts, 0, 0))
>data : Symbol(D.data, Decl(typeGuardsOnClassProperty.ts, 5, 9))
>this.data.join : Symbol(Array.join, Decl(lib.d.ts, --, --))
>this.data : Symbol(D.data, Decl(typeGuardsOnClassProperty.ts, 5, 9))
>this : Symbol(D, Decl(typeGuardsOnClassProperty.ts, 0, 0))
>data : Symbol(D.data, Decl(typeGuardsOnClassProperty.ts, 5, 9))
>join : Symbol(Array.join, Decl(lib.d.ts, --, --))
}
}
var o: {
>o : Symbol(o, Decl(typeGuardsOnClassProperty.ts, 17, 3))
prop1: number|string;
>prop1 : Symbol(prop1, Decl(typeGuardsOnClassProperty.ts, 17, 8))
prop2: boolean|string;
>prop2 : Symbol(prop2, Decl(typeGuardsOnClassProperty.ts, 18, 25))
} = {
prop1: "string" ,
>prop1 : Symbol(prop1, Decl(typeGuardsOnClassProperty.ts, 20, 5))
prop2: true
>prop2 : Symbol(prop2, Decl(typeGuardsOnClassProperty.ts, 21, 25))
}
if (typeof o.prop1 === "string" && o.prop1.toLowerCase()) {}
>o.prop1 : Symbol(prop1, Decl(typeGuardsOnClassProperty.ts, 17, 8))
>o : Symbol(o, Decl(typeGuardsOnClassProperty.ts, 17, 3))
>prop1 : Symbol(prop1, Decl(typeGuardsOnClassProperty.ts, 17, 8))
>o.prop1.toLowerCase : Symbol(String.toLowerCase, Decl(lib.d.ts, --, --))
>o.prop1 : Symbol(prop1, Decl(typeGuardsOnClassProperty.ts, 17, 8))
>o : Symbol(o, Decl(typeGuardsOnClassProperty.ts, 17, 3))
>prop1 : Symbol(prop1, Decl(typeGuardsOnClassProperty.ts, 17, 8))
>toLowerCase : Symbol(String.toLowerCase, Decl(lib.d.ts, --, --))
var prop1 = o.prop1;
>prop1 : Symbol(prop1, Decl(typeGuardsOnClassProperty.ts, 26, 3))
>o.prop1 : Symbol(prop1, Decl(typeGuardsOnClassProperty.ts, 17, 8))
>o : Symbol(o, Decl(typeGuardsOnClassProperty.ts, 17, 3))
>prop1 : Symbol(prop1, Decl(typeGuardsOnClassProperty.ts, 17, 8))
if (typeof prop1 === "string" && prop1.toLocaleLowerCase()) { }
>prop1 : Symbol(prop1, Decl(typeGuardsOnClassProperty.ts, 26, 3))
>prop1.toLocaleLowerCase : Symbol(String.toLocaleLowerCase, Decl(lib.d.ts, --, --))
>prop1 : Symbol(prop1, Decl(typeGuardsOnClassProperty.ts, 26, 3))
>toLocaleLowerCase : Symbol(String.toLocaleLowerCase, Decl(lib.d.ts, --, --))
@@ -0,0 +1,112 @@
=== tests/cases/conformance/expressions/typeGuards/typeGuardsOnClassProperty.ts ===
// Note that type guards affect types of variables and parameters only and
// have no effect on members of objects such as properties.
// Note that the class's property must be copied to a local variable for
// the type guard to have an effect
class D {
>D : D
data: string | string[];
>data : string | string[]
getData() {
>getData : () => string
var data = this.data;
>data : string | string[]
>this.data : string | string[]
>this : this
>data : string | string[]
return typeof data === "string" ? data : data.join(" ");
>typeof data === "string" ? data : data.join(" ") : string
>typeof data === "string" : boolean
>typeof data : string
>data : string | string[]
>"string" : string
>data : string
>data.join(" ") : string
>data.join : (separator?: string) => string
>data : string[]
>join : (separator?: string) => string
>" " : string
}
getData1() {
>getData1 : () => string
return typeof this.data === "string" ? this.data : this.data.join(" ");
>typeof this.data === "string" ? this.data : this.data.join(" ") : string
>typeof this.data === "string" : boolean
>typeof this.data : string
>this.data : string | string[]
>this : this
>data : string | string[]
>"string" : string
>this.data : string
>this : this
>data : string
>this.data.join(" ") : string
>this.data.join : (separator?: string) => string
>this.data : string[]
>this : this
>data : string[]
>join : (separator?: string) => string
>" " : string
}
}
var o: {
>o : { prop1: number | string; prop2: boolean | string; }
prop1: number|string;
>prop1 : number | string
prop2: boolean|string;
>prop2 : boolean | string
} = {
>{ prop1: "string" , prop2: true } : { prop1: string; prop2: boolean; }
prop1: "string" ,
>prop1 : string
>"string" : string
prop2: true
>prop2 : boolean
>true : boolean
}
if (typeof o.prop1 === "string" && o.prop1.toLowerCase()) {}
>typeof o.prop1 === "string" && o.prop1.toLowerCase() : string
>typeof o.prop1 === "string" : boolean
>typeof o.prop1 : string
>o.prop1 : number | string
>o : { prop1: number | string; prop2: boolean | string; }
>prop1 : number | string
>"string" : string
>o.prop1.toLowerCase() : string
>o.prop1.toLowerCase : () => string
>o.prop1 : string
>o : { prop1: number | string; prop2: boolean | string; }
>prop1 : string
>toLowerCase : () => string
var prop1 = o.prop1;
>prop1 : number | string
>o.prop1 : number | string
>o : { prop1: number | string; prop2: boolean | string; }
>prop1 : number | string
if (typeof prop1 === "string" && prop1.toLocaleLowerCase()) { }
>typeof prop1 === "string" && prop1.toLocaleLowerCase() : string
>typeof prop1 === "string" : boolean
>typeof prop1 : string
>prop1 : number | string
>"string" : string
>prop1.toLocaleLowerCase() : string
>prop1.toLocaleLowerCase : () => string
>prop1 : string
>toLocaleLowerCase : () => string
@@ -1,11 +1,9 @@
tests/cases/compiler/typeParameterConstraints1.ts(6,25): error TS2304: Cannot find name 'hm'.
tests/cases/compiler/typeParameterConstraints1.ts(9,25): error TS1110: Type expected.
tests/cases/compiler/typeParameterConstraints1.ts(10,26): error TS1110: Type expected.
tests/cases/compiler/typeParameterConstraints1.ts(11,26): error TS1110: Type expected.
tests/cases/compiler/typeParameterConstraints1.ts(12,26): error TS2304: Cannot find name 'undefined'.
==== tests/cases/compiler/typeParameterConstraints1.ts (5 errors) ====
==== tests/cases/compiler/typeParameterConstraints1.ts (3 errors) ====
function foo1<T extends any>(test: T) { }
function foo2<T extends number>(test: T) { }
function foo3<T extends string>(test: T) { }
@@ -23,9 +21,5 @@ tests/cases/compiler/typeParameterConstraints1.ts(12,26): error TS2304: Cannot f
~
!!! error TS1110: Type expected.
function foo11<T extends null> (test: T) { }
~~~~
!!! error TS1110: Type expected.
function foo12<T extends undefined>(test: T) { }
~~~~~~~~~
!!! error TS2304: Cannot find name 'undefined'.
function foo13<T extends void>(test: T) { }
@@ -0,0 +1,39 @@
// @module: commonjs
// @includebuiltfile: typescript_standalone.d.ts
// @stripInternal:true
/*
* Note: This test is a public API sample. The sample sources can be found
at: https://github.com/Microsoft/TypeScript/wiki/Using-the-Compiler-API#a-minimal-compiler
* Please log a "breaking change" issue for any API breaking change affecting this issue
*/
declare var process: any;
declare var console: any;
declare var os: any;
import ts = require("typescript");
function printError(error: ts.Diagnostic): void {
if (!error) {
return;
}
console.log(`${error.file && error.file.fileName}: ${error.messageText}`);
}
export function createProgram(rootFiles: string[], compilerOptionsJson: string): ts.Program {
const { config, error } = ts.parseConfigFileTextToJson("tsconfig.json", compilerOptionsJson)
if (error) {
printError(error);
return undefined;
}
const basePath: string = process.cwd();
const settings = ts.convertCompilerOptionsFromJson(config.config["compilerOptions"], basePath);
if (!settings.options) {
for (const err of settings.errors) {
printError(err);
}
return undefined;
}
return ts.createProgram(rootFiles, settings.options);
}
@@ -0,0 +1,9 @@
// @module: commonjs
// @filename: f1.ts
export function f() {
}
// @filename: f2.ts
import {f} from './f1';
export function f() {
}
+41
View File
@@ -0,0 +1,41 @@
// @target: es6
// @module: commonjs
// @filename: file1.ts
"use strict";
import * as MyModule from "./mymodule";
export class BrokenClass {
constructor() {}
public brokenMethod(field: string, value: string) {
return new Promise<Array<MyModule.MyModel>>((resolve, reject) => {
let result: Array<MyModule.MyModel> = [];
let populateItems = (order) => {
return new Promise((resolve, reject) => {
this.doStuff(order.id)
.then((items) => {
order.items = items;
resolve(order);
});
});
};
return Promise.all(result.map(populateItems))
.then((orders: Array<MyModule.MyModel>) => {
resolve(orders);
});
});
}
public async doStuff(id: number) {
return;
}
}
// @filename: mymodule.ts
export interface MyModel {
id: number;
}
@@ -0,0 +1,10 @@
// @module:commonjs
// @filename: f1.ts
export namespace N { export var x = 1; }
// @filename: f2.ts
import {N} from "./f1";
// partial revert of https://github.com/Microsoft/TypeScript/pull/7583 to prevent breaking changes
export namespace N {
export interface I {x: any}
}
@@ -0,0 +1,8 @@
// @module:commonjs
// @filename: f1.ts
export enum E {X}
// @filename: f2.ts
import {E} from "./f1";
// partial revert of https://github.com/Microsoft/TypeScript/pull/7583 to prevent breaking changes
export type E = E;
@@ -0,0 +1,38 @@
// @target: ES5
// no errors
class C {
private x: string;
private get y() { return this.x; }
private set y(x) { this.y = this.x; }
private foo() { return this.foo; }
private static x: string;
private static get y() { return this.x; }
private static set y(x) { this.y = this.x; }
private static foo() { return this.foo; }
private static bar() { this.foo(); }
private bar() {
class C2 {
private foo() {
let x: C;
var x1 = x.foo;
var x2 = x.bar;
var x3 = x.x;
var x4 = x.y;
var sx1 = C.x;
var sx2 = C.y;
var sx3 = C.bar;
var sx4 = C.foo;
let y = new C();
var y1 = y.foo;
var y2 = y.bar;
var y3 = y.x;
var y4 = y.y;
}
}
}
}
@@ -0,0 +1,38 @@
// @target: ES5
// no errors
class C {
protected x: string;
protected get y() { return this.x; }
protected set y(x) { this.y = this.x; }
protected foo() { return this.foo; }
protected static x: string;
protected static get y() { return this.x; }
protected static set y(x) { this.y = this.x; }
protected static foo() { return this.foo; }
protected static bar() { this.foo(); }
protected bar() {
class C2 {
protected foo() {
let x: C;
var x1 = x.foo;
var x2 = x.bar;
var x3 = x.x;
var x4 = x.y;
var sx1 = C.x;
var sx2 = C.y;
var sx3 = C.bar;
var sx4 = C.foo;
let y = new C();
var y1 = y.foo;
var y2 = y.bar;
var y3 = y.x;
var y4 = y.y;
}
}
}
}
@@ -0,0 +1,39 @@
// @target: ES5
class B {
protected x: string;
protected static x: string;
}
class C extends B {
protected get y() { return this.x; }
protected set y(x) { this.y = this.x; }
protected foo() { return this.x; }
protected static get y() { return this.x; }
protected static set y(x) { this.y = this.x; }
protected static foo() { return this.x; }
protected static bar() { this.foo(); }
protected bar() {
class D {
protected foo() {
var c = new C();
var c1 = c.y;
var c2 = c.x;
var c3 = c.foo;
var c4 = c.bar;
var c5 = c.z; // error
var sc1 = C.x;
var sc2 = C.y;
var sc3 = C.foo;
var sc4 = C.bar;
}
}
}
}
class E extends C {
protected z: string;
}
@@ -0,0 +1,114 @@
class Base {
protected x: string;
method() {
class A {
methoda() {
var b: Base;
var d1: Derived1;
var d2: Derived2;
var d3: Derived3;
var d4: Derived4;
b.x; // OK, accessed within their declaring class
d1.x; // OK, accessed within their declaring class
d2.x; // OK, accessed within their declaring class
d3.x; // Error, redefined in a subclass, can only be accessed in the declaring class or one of its subclasses
d4.x; // OK, accessed within their declaring class
}
}
}
}
class Derived1 extends Base {
method1() {
class B {
method1b() {
var b: Base;
var d1: Derived1;
var d2: Derived2;
var d3: Derived3;
var d4: Derived4;
b.x; // Error, isn't accessed through an instance of the enclosing class
d1.x; // OK, accessed within a class derived from their declaring class, and through an instance of the enclosing class
d2.x; // Error, isn't accessed through an instance of the enclosing class
d3.x; // Error, redefined in a subclass, can only be accessed in the declaring class or one of its subclasses
d4.x; // Error, isn't accessed through an instance of the enclosing class
}
}
}
}
class Derived2 extends Base {
method2() {
class C {
method2c() {
var b: Base;
var d1: Derived1;
var d2: Derived2;
var d3: Derived3;
var d4: Derived4;
b.x; // Error, isn't accessed through an instance of the enclosing class
d1.x; // Error, isn't accessed through an instance of the enclosing class
d2.x; // OK, accessed within a class derived from their declaring class, and through an instance of the enclosing class
d3.x; // Error, redefined in a subclass, can only be accessed in the declaring class or one of its subclasses
d4.x; // OK, accessed within a class derived from their declaring class, and through an instance of the enclosing class or one of its subclasses
}
}
}
}
class Derived3 extends Derived1 {
protected x: string;
method3() {
class D {
method3d() {
var b: Base;
var d1: Derived1;
var d2: Derived2;
var d3: Derived3;
var d4: Derived4;
b.x; // Error, isn't accessed through an instance of the enclosing class
d1.x; // Error, isn't accessed through an instance of the enclosing class
d2.x; // Error, isn't accessed through an instance of the enclosing class
d3.x; // OK, accessed within their declaring class
d4.x; // Error, isn't accessed through an instance of the enclosing class
}
}
}
}
class Derived4 extends Derived2 {
method4() {
class E {
method4e() {
var b: Base;
var d1: Derived1;
var d2: Derived2;
var d3: Derived3;
var d4: Derived4;
b.x; // Error, isn't accessed through an instance of the enclosing class
d1.x; // Error, isn't accessed through an instance of the enclosing class
d2.x; // Error, isn't accessed through an instance of the enclosing class
d3.x; // Error, redefined in a subclass, can only be accessed in the declaring class or one of its subclasses
d4.x; // OK, accessed within a class derived from their declaring class, and through an instance of the enclosing class
}
}
}
}
var b: Base;
var d1: Derived1;
var d2: Derived2;
var d3: Derived3;
var d4: Derived4;
b.x; // Error, neither within their declaring class nor classes derived from their declaring class
d1.x; // Error, neither within their declaring class nor classes derived from their declaring class
d2.x; // Error, neither within their declaring class nor classes derived from their declaring class
d3.x; // Error, neither within their declaring class nor classes derived from their declaring class
d4.x; // Error, neither within their declaring class nor classes derived from their declaring class

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