mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Merge branch 'master' into object-spread
This commit is contained in:
+18
-8
@@ -499,8 +499,8 @@ namespace ts {
|
||||
const saveReturnTarget = currentReturnTarget;
|
||||
const saveActiveLabels = activeLabels;
|
||||
const saveHasExplicitReturn = hasExplicitReturn;
|
||||
const isIIFE = containerFlags & ContainerFlags.IsFunctionExpression && !!getImmediatelyInvokedFunctionExpression(node);
|
||||
// An IIFE is considered part of the containing control flow. Return statements behave
|
||||
const isIIFE = containerFlags & ContainerFlags.IsFunctionExpression && !hasModifier(node, ModifierFlags.Async) && !!getImmediatelyInvokedFunctionExpression(node);
|
||||
// A non-async IIFE is considered part of the containing control flow. Return statements behave
|
||||
// similarly to break statements that exit to a label just past the statement body.
|
||||
if (isIIFE) {
|
||||
currentReturnTarget = createBranchLabel();
|
||||
@@ -892,8 +892,13 @@ namespace ts {
|
||||
|
||||
function bindDoStatement(node: DoStatement): void {
|
||||
const preDoLabel = createLoopLabel();
|
||||
const preConditionLabel = createBranchLabel();
|
||||
const postDoLabel = createBranchLabel();
|
||||
const enclosingLabeledStatement = node.parent.kind === SyntaxKind.LabeledStatement
|
||||
? lastOrUndefined(activeLabels)
|
||||
: undefined;
|
||||
// if do statement is wrapped in labeled statement then target labels for break/continue with or without
|
||||
// label should be the same
|
||||
const preConditionLabel = enclosingLabeledStatement ? enclosingLabeledStatement.continueTarget : createBranchLabel();
|
||||
const postDoLabel = enclosingLabeledStatement ? enclosingLabeledStatement.breakTarget : createBranchLabel();
|
||||
addAntecedent(preDoLabel, currentFlow);
|
||||
currentFlow = preDoLabel;
|
||||
bindIterativeStatement(node.statement, postDoLabel, preConditionLabel);
|
||||
@@ -1111,8 +1116,11 @@ namespace ts {
|
||||
if (!activeLabel.referenced && !options.allowUnusedLabels) {
|
||||
file.bindDiagnostics.push(createDiagnosticForNode(node.label, Diagnostics.Unused_label));
|
||||
}
|
||||
addAntecedent(postStatementLabel, currentFlow);
|
||||
currentFlow = finishFlowLabel(postStatementLabel);
|
||||
if (!node.statement || node.statement.kind !== SyntaxKind.DoStatement) {
|
||||
// do statement sets current flow inside bindDoStatement
|
||||
addAntecedent(postStatementLabel, currentFlow);
|
||||
currentFlow = finishFlowLabel(postStatementLabel);
|
||||
}
|
||||
}
|
||||
|
||||
function bindDestructuringTargetFlow(node: Expression) {
|
||||
@@ -1204,9 +1212,9 @@ namespace ts {
|
||||
}
|
||||
else {
|
||||
forEachChild(node, bind);
|
||||
if (operator === SyntaxKind.EqualsToken && !isAssignmentTarget(node)) {
|
||||
if (isAssignmentOperator(operator) && !isAssignmentTarget(node)) {
|
||||
bindAssignmentTargetFlow(node.left);
|
||||
if (node.left.kind === SyntaxKind.ElementAccessExpression) {
|
||||
if (operator === SyntaxKind.EqualsToken && node.left.kind === SyntaxKind.ElementAccessExpression) {
|
||||
const elementAccess = <ElementAccessExpression>node.left;
|
||||
if (isNarrowableOperand(elementAccess.expression)) {
|
||||
currentFlow = createFlowArrayMutation(currentFlow, node);
|
||||
@@ -3093,6 +3101,8 @@ namespace ts {
|
||||
case SyntaxKind.InterfaceDeclaration:
|
||||
case SyntaxKind.TypeAliasDeclaration:
|
||||
case SyntaxKind.ThisType:
|
||||
case SyntaxKind.TypeOperator:
|
||||
case SyntaxKind.IndexedAccessType:
|
||||
case SyntaxKind.LiteralType:
|
||||
// Types and signatures are TypeScript syntax, and exclude all other facts.
|
||||
transformFlags = TransformFlags.AssertTypeScript;
|
||||
|
||||
+416
-337
File diff suppressed because it is too large
Load Diff
@@ -1008,9 +1008,7 @@ namespace ts {
|
||||
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: [] };
|
||||
const options: TypingOptions = { enableAutoDiscovery: getBaseFileName(configFileName) === "jsconfig.json", include: [], exclude: [] };
|
||||
convertOptionsFromJson(typingOptionDeclarations, jsonOptions, basePath, options, Diagnostics.Unknown_typing_option_0, errors);
|
||||
return options;
|
||||
}
|
||||
@@ -1263,12 +1261,13 @@ namespace ts {
|
||||
/**
|
||||
* Gets directories in a set of include patterns that should be watched for changes.
|
||||
*/
|
||||
function getWildcardDirectories(include: string[], exclude: string[], path: string, useCaseSensitiveFileNames: boolean) {
|
||||
function getWildcardDirectories(include: string[], exclude: string[], path: string, useCaseSensitiveFileNames: boolean): Map<WatchDirectoryFlags> {
|
||||
// We watch a directory recursively if it contains a wildcard anywhere in a directory segment
|
||||
// of the pattern:
|
||||
//
|
||||
// /a/b/**/d - Watch /a/b recursively to catch changes to any d in any subfolder recursively
|
||||
// /a/b/*/d - Watch /a/b recursively to catch any d in any immediate subfolder, even if a new subfolder is added
|
||||
// /a/b - Watch /a/b recursively to catch changes to anything in any recursive subfoler
|
||||
//
|
||||
// We watch a directory without recursion if it contains a wildcard in the file segment of
|
||||
// the pattern:
|
||||
@@ -1281,15 +1280,14 @@ namespace ts {
|
||||
if (include !== undefined) {
|
||||
const recursiveKeys: string[] = [];
|
||||
for (const file of include) {
|
||||
const name = normalizePath(combinePaths(path, file));
|
||||
if (excludeRegex && excludeRegex.test(name)) {
|
||||
const spec = normalizePath(combinePaths(path, file));
|
||||
if (excludeRegex && excludeRegex.test(spec)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const match = wildcardDirectoryPattern.exec(name);
|
||||
const match = getWildcardDirectoryFromSpec(spec, useCaseSensitiveFileNames);
|
||||
if (match) {
|
||||
const key = useCaseSensitiveFileNames ? match[0] : match[0].toLowerCase();
|
||||
const flags = watchRecursivePattern.test(name) ? WatchDirectoryFlags.Recursive : WatchDirectoryFlags.None;
|
||||
const { key, flags } = match;
|
||||
const existingFlags = wildcardDirectories[key];
|
||||
if (existingFlags === undefined || existingFlags < flags) {
|
||||
wildcardDirectories[key] = flags;
|
||||
@@ -1313,6 +1311,20 @@ namespace ts {
|
||||
return wildcardDirectories;
|
||||
}
|
||||
|
||||
function getWildcardDirectoryFromSpec(spec: string, useCaseSensitiveFileNames: boolean): { key: string, flags: WatchDirectoryFlags } | undefined {
|
||||
const match = wildcardDirectoryPattern.exec(spec);
|
||||
if (match) {
|
||||
return {
|
||||
key: useCaseSensitiveFileNames ? match[0] : match[0].toLowerCase(),
|
||||
flags: watchRecursivePattern.test(spec) ? WatchDirectoryFlags.Recursive : WatchDirectoryFlags.None
|
||||
};
|
||||
}
|
||||
if (isImplicitGlob(spec)) {
|
||||
return { key: spec, flags: WatchDirectoryFlags.Recursive };
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines whether a literal or wildcard file has already been included that has a higher
|
||||
* extension priority.
|
||||
|
||||
+135
-78
@@ -124,6 +124,13 @@ namespace ts {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
export function zipWith<T, U>(arrayA: T[], arrayB: U[], callback: (a: T, b: U, index: number) => void): void {
|
||||
Debug.assert(arrayA.length === arrayB.length);
|
||||
for (let i = 0; i < arrayA.length; i++) {
|
||||
callback(arrayA[i], arrayB[i], i);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Iterates through `array` by index and performs the callback on each element of array until the callback
|
||||
* returns a falsey value, then returns false.
|
||||
@@ -439,8 +446,8 @@ namespace ts {
|
||||
}
|
||||
|
||||
export function concatenate<T>(array1: T[], array2: T[]): T[] {
|
||||
if (!array2 || !array2.length) return array1;
|
||||
if (!array1 || !array1.length) return array2;
|
||||
if (!some(array2)) return array1;
|
||||
if (!some(array1)) return array2;
|
||||
return [...array1, ...array2];
|
||||
}
|
||||
|
||||
@@ -520,6 +527,27 @@ namespace ts {
|
||||
return result || array;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the relative complement of `arrayA` with respect to `b`, returning the elements that
|
||||
* are not present in `arrayA` but are present in `arrayB`. Assumes both arrays are sorted
|
||||
* based on the provided comparer.
|
||||
*/
|
||||
export function relativeComplement<T>(arrayA: T[] | undefined, arrayB: T[] | undefined, comparer: (x: T, y: T) => Comparison = compareValues, offsetA = 0, offsetB = 0): T[] | undefined {
|
||||
if (!arrayB || !arrayA || arrayB.length === 0 || arrayA.length === 0) return arrayB;
|
||||
const result: T[] = [];
|
||||
outer: for (; offsetB < arrayB.length; offsetB++) {
|
||||
inner: for (; offsetA < arrayA.length; offsetA++) {
|
||||
switch (comparer(arrayB[offsetB], arrayA[offsetA])) {
|
||||
case Comparison.LessThan: break inner;
|
||||
case Comparison.EqualTo: continue outer;
|
||||
case Comparison.GreaterThan: continue inner;
|
||||
}
|
||||
}
|
||||
result.push(arrayB[offsetB]);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
export function sum(array: any[], prop: string): number {
|
||||
let result = 0;
|
||||
for (const v of array) {
|
||||
@@ -619,12 +647,12 @@ namespace ts {
|
||||
* @param array A sorted array whose first element must be no larger than number
|
||||
* @param number The value to be searched for in the array.
|
||||
*/
|
||||
export function binarySearch<T>(array: T[], value: T, comparer?: (v1: T, v2: T) => number): number {
|
||||
export function binarySearch<T>(array: T[], value: T, comparer?: (v1: T, v2: T) => number, offset?: number): number {
|
||||
if (!array || array.length === 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
let low = 0;
|
||||
let low = offset || 0;
|
||||
let high = array.length - 1;
|
||||
comparer = comparer !== undefined
|
||||
? comparer
|
||||
@@ -1305,7 +1333,7 @@ namespace ts {
|
||||
*/
|
||||
export function getDirectoryPath(path: Path): Path;
|
||||
export function getDirectoryPath(path: string): string;
|
||||
export function getDirectoryPath(path: string): any {
|
||||
export function getDirectoryPath(path: string): string {
|
||||
return path.substr(0, Math.max(getRootLength(path), path.lastIndexOf(directorySeparator)));
|
||||
}
|
||||
|
||||
@@ -1565,6 +1593,10 @@ namespace ts {
|
||||
return expectedPos >= 0 && str.indexOf(suffix, expectedPos) === expectedPos;
|
||||
}
|
||||
|
||||
export function hasExtension(fileName: string): boolean {
|
||||
return getBaseFileName(fileName).indexOf(".") >= 0;
|
||||
}
|
||||
|
||||
export function fileExtensionIs(path: string, extension: string): boolean {
|
||||
return path.length > extension.length && endsWith(path, extension);
|
||||
}
|
||||
@@ -1610,73 +1642,21 @@ namespace ts {
|
||||
|
||||
let pattern = "";
|
||||
let hasWrittenSubpattern = false;
|
||||
spec: for (const spec of specs) {
|
||||
for (const spec of specs) {
|
||||
if (!spec) {
|
||||
continue;
|
||||
}
|
||||
|
||||
let subpattern = "";
|
||||
let hasRecursiveDirectoryWildcard = false;
|
||||
let hasWrittenComponent = false;
|
||||
const components = getNormalizedPathComponents(spec, basePath);
|
||||
if (usage !== "exclude" && components[components.length - 1] === "**") {
|
||||
continue spec;
|
||||
}
|
||||
|
||||
// getNormalizedPathComponents includes the separator for the root component.
|
||||
// We need to remove to create our regex correctly.
|
||||
components[0] = removeTrailingDirectorySeparator(components[0]);
|
||||
|
||||
let optionalCount = 0;
|
||||
for (let component of components) {
|
||||
if (component === "**") {
|
||||
if (hasRecursiveDirectoryWildcard) {
|
||||
continue spec;
|
||||
}
|
||||
|
||||
subpattern += doubleAsteriskRegexFragment;
|
||||
hasRecursiveDirectoryWildcard = true;
|
||||
hasWrittenComponent = true;
|
||||
}
|
||||
else {
|
||||
if (usage === "directories") {
|
||||
subpattern += "(";
|
||||
optionalCount++;
|
||||
}
|
||||
|
||||
if (hasWrittenComponent) {
|
||||
subpattern += directorySeparator;
|
||||
}
|
||||
|
||||
if (usage !== "exclude") {
|
||||
// The * and ? wildcards should not match directories or files that start with . if they
|
||||
// appear first in a component. Dotted directories and files can be included explicitly
|
||||
// like so: **/.*/.*
|
||||
if (component.charCodeAt(0) === CharacterCodes.asterisk) {
|
||||
subpattern += "([^./]" + singleAsteriskRegexFragment + ")?";
|
||||
component = component.substr(1);
|
||||
}
|
||||
else if (component.charCodeAt(0) === CharacterCodes.question) {
|
||||
subpattern += "[^./]";
|
||||
component = component.substr(1);
|
||||
}
|
||||
}
|
||||
|
||||
subpattern += component.replace(reservedCharacterPattern, replaceWildcardCharacter);
|
||||
hasWrittenComponent = true;
|
||||
}
|
||||
}
|
||||
|
||||
while (optionalCount > 0) {
|
||||
subpattern += ")?";
|
||||
optionalCount--;
|
||||
const subPattern = getSubPatternFromSpec(spec, basePath, usage, singleAsteriskRegexFragment, doubleAsteriskRegexFragment, replaceWildcardCharacter);
|
||||
if (subPattern === undefined) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (hasWrittenSubpattern) {
|
||||
pattern += "|";
|
||||
}
|
||||
|
||||
pattern += "(" + subpattern + ")";
|
||||
pattern += "(" + subPattern + ")";
|
||||
hasWrittenSubpattern = true;
|
||||
}
|
||||
|
||||
@@ -1684,7 +1664,83 @@ namespace ts {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
return "^(" + pattern + (usage === "exclude" ? ")($|/)" : ")$");
|
||||
// If excluding, match "foo/bar/baz...", but if including, only allow "foo".
|
||||
const terminator = usage === "exclude" ? "($|/)" : "$";
|
||||
return `^(${pattern})${terminator}`;
|
||||
}
|
||||
|
||||
/**
|
||||
* An "includes" path "foo" is implicitly a glob "foo/** /*" (without the space) if its last component has no extension,
|
||||
* and does not contain any glob characters itself.
|
||||
*/
|
||||
export function isImplicitGlob(lastPathComponent: string): boolean {
|
||||
return !/[.*?]/.test(lastPathComponent);
|
||||
}
|
||||
|
||||
function getSubPatternFromSpec(spec: string, basePath: string, usage: "files" | "directories" | "exclude", singleAsteriskRegexFragment: string, doubleAsteriskRegexFragment: string, replaceWildcardCharacter: (match: string) => string): string | undefined {
|
||||
let subpattern = "";
|
||||
let hasRecursiveDirectoryWildcard = false;
|
||||
let hasWrittenComponent = false;
|
||||
const components = getNormalizedPathComponents(spec, basePath);
|
||||
const lastComponent = lastOrUndefined(components);
|
||||
if (usage !== "exclude" && lastComponent === "**") {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
// getNormalizedPathComponents includes the separator for the root component.
|
||||
// We need to remove to create our regex correctly.
|
||||
components[0] = removeTrailingDirectorySeparator(components[0]);
|
||||
|
||||
if (isImplicitGlob(lastComponent)) {
|
||||
components.push("**", "*");
|
||||
}
|
||||
|
||||
let optionalCount = 0;
|
||||
for (let component of components) {
|
||||
if (component === "**") {
|
||||
if (hasRecursiveDirectoryWildcard) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
subpattern += doubleAsteriskRegexFragment;
|
||||
hasRecursiveDirectoryWildcard = true;
|
||||
}
|
||||
else {
|
||||
if (usage === "directories") {
|
||||
subpattern += "(";
|
||||
optionalCount++;
|
||||
}
|
||||
|
||||
if (hasWrittenComponent) {
|
||||
subpattern += directorySeparator;
|
||||
}
|
||||
|
||||
if (usage !== "exclude") {
|
||||
// The * and ? wildcards should not match directories or files that start with . if they
|
||||
// appear first in a component. Dotted directories and files can be included explicitly
|
||||
// like so: **/.*/.*
|
||||
if (component.charCodeAt(0) === CharacterCodes.asterisk) {
|
||||
subpattern += "([^./]" + singleAsteriskRegexFragment + ")?";
|
||||
component = component.substr(1);
|
||||
}
|
||||
else if (component.charCodeAt(0) === CharacterCodes.question) {
|
||||
subpattern += "[^./]";
|
||||
component = component.substr(1);
|
||||
}
|
||||
}
|
||||
|
||||
subpattern += component.replace(reservedCharacterPattern, replaceWildcardCharacter);
|
||||
}
|
||||
|
||||
hasWrittenComponent = true;
|
||||
}
|
||||
|
||||
while (optionalCount > 0) {
|
||||
subpattern += ")?";
|
||||
optionalCount--;
|
||||
}
|
||||
|
||||
return subpattern;
|
||||
}
|
||||
|
||||
function replaceWildCardCharacterFiles(match: string) {
|
||||
@@ -1771,6 +1827,7 @@ namespace ts {
|
||||
function getBasePaths(path: string, includes: string[], useCaseSensitiveFileNames: boolean) {
|
||||
// Storage for our results in the form of literal paths (e.g. the paths as written by the user).
|
||||
const basePaths: string[] = [path];
|
||||
|
||||
if (includes) {
|
||||
// Storage for literal base paths amongst the include patterns.
|
||||
const includeBasePaths: string[] = [];
|
||||
@@ -1778,14 +1835,8 @@ namespace ts {
|
||||
// We also need to check the relative paths by converting them to absolute and normalizing
|
||||
// in case they escape the base path (e.g "..\somedirectory")
|
||||
const absolute: string = isRootedDiskPath(include) ? include : normalizePath(combinePaths(path, include));
|
||||
|
||||
const wildcardOffset = indexOfAnyCharCode(absolute, wildcardCharCodes);
|
||||
const includeBasePath = wildcardOffset < 0
|
||||
? removeTrailingDirectorySeparator(getDirectoryPath(absolute))
|
||||
: absolute.substring(0, absolute.lastIndexOf(directorySeparator, wildcardOffset));
|
||||
|
||||
// Append the literal and canonical candidate base paths.
|
||||
includeBasePaths.push(includeBasePath);
|
||||
includeBasePaths.push(getIncludeBasePath(absolute));
|
||||
}
|
||||
|
||||
// Sort the offsets array using either the literal or canonical path representations.
|
||||
@@ -1793,21 +1844,27 @@ namespace ts {
|
||||
|
||||
// Iterate over each include base path and include unique base paths that are not a
|
||||
// subpath of an existing base path
|
||||
include: for (let i = 0; i < includeBasePaths.length; i++) {
|
||||
const includeBasePath = includeBasePaths[i];
|
||||
for (let j = 0; j < basePaths.length; j++) {
|
||||
if (containsPath(basePaths[j], includeBasePath, path, !useCaseSensitiveFileNames)) {
|
||||
continue include;
|
||||
}
|
||||
for (const includeBasePath of includeBasePaths) {
|
||||
if (ts.every(basePaths, basePath => !containsPath(basePath, includeBasePath, path, !useCaseSensitiveFileNames))) {
|
||||
basePaths.push(includeBasePath);
|
||||
}
|
||||
|
||||
basePaths.push(includeBasePath);
|
||||
}
|
||||
}
|
||||
|
||||
return basePaths;
|
||||
}
|
||||
|
||||
function getIncludeBasePath(absolute: string): string {
|
||||
const wildcardOffset = indexOfAnyCharCode(absolute, wildcardCharCodes);
|
||||
if (wildcardOffset < 0) {
|
||||
// No "*" or "?" in the path
|
||||
return !hasExtension(absolute)
|
||||
? absolute
|
||||
: removeTrailingDirectorySeparator(getDirectoryPath(absolute));
|
||||
}
|
||||
return absolute.substring(0, absolute.lastIndexOf(directorySeparator, wildcardOffset));
|
||||
}
|
||||
|
||||
export function ensureScriptKind(fileName: string, scriptKind?: ScriptKind): ScriptKind {
|
||||
// Using scriptKind as a condition handles both:
|
||||
// - 'scriptKind' is unspecified and thus it is `undefined`
|
||||
|
||||
@@ -413,6 +413,10 @@ namespace ts {
|
||||
return emitIntersectionType(<IntersectionTypeNode>type);
|
||||
case SyntaxKind.ParenthesizedType:
|
||||
return emitParenType(<ParenthesizedTypeNode>type);
|
||||
case SyntaxKind.TypeOperator:
|
||||
return emitTypeOperator(<TypeOperatorNode>type);
|
||||
case SyntaxKind.IndexedAccessType:
|
||||
return emitPropertyAccessType(<IndexedAccessTypeNode>type);
|
||||
case SyntaxKind.FunctionType:
|
||||
case SyntaxKind.ConstructorType:
|
||||
return emitSignatureDeclarationWithJsDocComments(<FunctionOrConstructorTypeNode>type);
|
||||
@@ -506,6 +510,19 @@ namespace ts {
|
||||
write(")");
|
||||
}
|
||||
|
||||
function emitTypeOperator(type: TypeOperatorNode) {
|
||||
write(tokenToString(type.operator));
|
||||
write(" ");
|
||||
emitType(type.type);
|
||||
}
|
||||
|
||||
function emitPropertyAccessType(node: IndexedAccessTypeNode) {
|
||||
emitType(node.objectType);
|
||||
write("[");
|
||||
emitType(node.indexType);
|
||||
write("]");
|
||||
}
|
||||
|
||||
function emitTypeLiteral(type: TypeLiteralNode) {
|
||||
write("{");
|
||||
if (type.members.length) {
|
||||
|
||||
@@ -163,7 +163,7 @@
|
||||
"category": "Error",
|
||||
"code": 1054
|
||||
},
|
||||
"Type '{0}' is not a valid async function return type.": {
|
||||
"Type '{0}' is not a valid async function return type in ES5/ES3 because it does not refer to a Promise-compatible constructor value.": {
|
||||
"category": "Error",
|
||||
"code": 1055
|
||||
},
|
||||
@@ -1071,7 +1071,7 @@
|
||||
"category": "Error",
|
||||
"code": 2356
|
||||
},
|
||||
"The operand of an increment or decrement operator must be a variable, property or indexer.": {
|
||||
"The operand of an increment or decrement operator must be a variable or a property access.": {
|
||||
"category": "Error",
|
||||
"code": 2357
|
||||
},
|
||||
@@ -1099,7 +1099,7 @@
|
||||
"category": "Error",
|
||||
"code": 2363
|
||||
},
|
||||
"Invalid left-hand side of assignment expression.": {
|
||||
"The left-hand side of an assignment expression must be a variable or a property access.": {
|
||||
"category": "Error",
|
||||
"code": 2364
|
||||
},
|
||||
@@ -1259,7 +1259,7 @@
|
||||
"category": "Error",
|
||||
"code": 2405
|
||||
},
|
||||
"Invalid left-hand side in 'for...in' statement.": {
|
||||
"The left-hand side of a 'for...in' statement must be a variable or a property access.": {
|
||||
"category": "Error",
|
||||
"code": 2406
|
||||
},
|
||||
@@ -1411,14 +1411,6 @@
|
||||
"category": "Error",
|
||||
"code": 2448
|
||||
},
|
||||
"The operand of an increment or decrement operator cannot be a constant or a read-only property.": {
|
||||
"category": "Error",
|
||||
"code": 2449
|
||||
},
|
||||
"Left-hand side of assignment expression cannot be a constant or a read-only property.": {
|
||||
"category": "Error",
|
||||
"code": 2450
|
||||
},
|
||||
"Cannot redeclare block-scoped variable '{0}'.": {
|
||||
"category": "Error",
|
||||
"code": 2451
|
||||
@@ -1551,15 +1543,7 @@
|
||||
"category": "Error",
|
||||
"code": 2484
|
||||
},
|
||||
"The left-hand side of a 'for...of' statement cannot be a constant or a read-only property.": {
|
||||
"category": "Error",
|
||||
"code": 2485
|
||||
},
|
||||
"The left-hand side of a 'for...in' statement cannot be a constant or a read-only property.": {
|
||||
"category": "Error",
|
||||
"code": 2486
|
||||
},
|
||||
"Invalid left-hand side in 'for...of' statement.": {
|
||||
"The left-hand side of a 'for...of' statement must be a variable or a property access.": {
|
||||
"category": "Error",
|
||||
"code": 2487
|
||||
},
|
||||
@@ -1747,6 +1731,34 @@
|
||||
"category": "Error",
|
||||
"code": 2535
|
||||
},
|
||||
"Type '{0}' is not constrained to 'keyof {1}'.": {
|
||||
"category": "Error",
|
||||
"code": 2536
|
||||
},
|
||||
"Type '{0}' has no matching index signature for type '{1}'.": {
|
||||
"category": "Error",
|
||||
"code": 2537
|
||||
},
|
||||
"Type '{0}' cannot be used as an index type.": {
|
||||
"category": "Error",
|
||||
"code": 2538
|
||||
},
|
||||
"Cannot assign to '{0}' because it is not a variable.": {
|
||||
"category": "Error",
|
||||
"code": 2539
|
||||
},
|
||||
"Cannot assign to '{0}' because it is a constant or a read-only property.": {
|
||||
"category": "Error",
|
||||
"code": 2540
|
||||
},
|
||||
"The target of an assignment must be a variable or a property access.": {
|
||||
"category": "Error",
|
||||
"code": 2541
|
||||
},
|
||||
"Index signature in type '{0}' only permits reading.": {
|
||||
"category": "Error",
|
||||
"code": 2542
|
||||
},
|
||||
"JSX element attributes type '{0}' may not be a union type.": {
|
||||
"category": "Error",
|
||||
"code": 2600
|
||||
@@ -1839,6 +1851,10 @@
|
||||
"category": "Error",
|
||||
"code": 2664
|
||||
},
|
||||
"Invalid module name in augmentation. Module '{0}' resolves to an untyped module at '{1}', which cannot be augmented.": {
|
||||
"category": "Error",
|
||||
"code": 2665
|
||||
},
|
||||
"Exports and export assignments are not permitted in module augmentations.": {
|
||||
"category": "Error",
|
||||
"code": 2666
|
||||
@@ -1963,14 +1979,18 @@
|
||||
"category": "Error",
|
||||
"code": 2696
|
||||
},
|
||||
"Interface declaration cannot contain a spread property.": {
|
||||
"An async function or method must return a 'Promise'. Make sure you have a declaration for 'Promise' or include 'ES2015' in your `--lib` option.": {
|
||||
"category": "Error",
|
||||
"code": 2697
|
||||
},
|
||||
"Type literals with spreads cannot contain index, call or construct signatures.": {
|
||||
"Interface declaration cannot contain a spread property.": {
|
||||
"category": "Error",
|
||||
"code": 2698
|
||||
},
|
||||
"Type literals with spreads cannot contain index, call or construct signatures.": {
|
||||
"category": "Error",
|
||||
"code": 2699
|
||||
},
|
||||
|
||||
"Import declaration '{0}' is using private name '{1}'.": {
|
||||
"category": "Error",
|
||||
@@ -2909,7 +2929,11 @@
|
||||
"category": "Error",
|
||||
"code": 7015
|
||||
},
|
||||
"Index signature of object type implicitly has an 'any' type.": {
|
||||
"Could not find a declaration file for module '{0}'. '{1}' implicitly has an 'any' type.": {
|
||||
"category": "Error",
|
||||
"code": 7016
|
||||
},
|
||||
"Element implicitly has an 'any' type because type '{0}' has no index signature.": {
|
||||
"category": "Error",
|
||||
"code": 7017
|
||||
},
|
||||
|
||||
@@ -594,6 +594,10 @@ const _super = (function (geti, seti) {
|
||||
return emitExpressionWithTypeArguments(<ExpressionWithTypeArguments>node);
|
||||
case SyntaxKind.ThisType:
|
||||
return emitThisType();
|
||||
case SyntaxKind.TypeOperator:
|
||||
return emitTypeOperator(<TypeOperatorNode>node);
|
||||
case SyntaxKind.IndexedAccessType:
|
||||
return emitPropertyAccessType(<IndexedAccessTypeNode>node);
|
||||
case SyntaxKind.LiteralType:
|
||||
return emitLiteralType(<LiteralTypeNode>node);
|
||||
|
||||
@@ -1088,6 +1092,19 @@ const _super = (function (geti, seti) {
|
||||
write("this");
|
||||
}
|
||||
|
||||
function emitTypeOperator(node: TypeOperatorNode) {
|
||||
writeTokenText(node.operator);
|
||||
write(" ");
|
||||
emit(node.type);
|
||||
}
|
||||
|
||||
function emitPropertyAccessType(node: IndexedAccessTypeNode) {
|
||||
emit(node.objectType);
|
||||
write("[");
|
||||
emit(node.indexType);
|
||||
write("]");
|
||||
}
|
||||
|
||||
function emitLiteralType(node: LiteralTypeNode) {
|
||||
emitExpression(node.literal);
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
/** Adds `isExernalLibraryImport` to a Resolved to get a ResolvedModule. */
|
||||
function resolvedModuleFromResolved({ path, extension }: Resolved, isExternalLibraryImport: boolean): ResolvedModule {
|
||||
function resolvedModuleFromResolved({ path, extension }: Resolved, isExternalLibraryImport: boolean): ResolvedModuleFull {
|
||||
return { resolvedFileName: path, extension, isExternalLibraryImport };
|
||||
}
|
||||
|
||||
|
||||
+35
-6
@@ -138,7 +138,11 @@ namespace ts {
|
||||
case SyntaxKind.IntersectionType:
|
||||
return visitNodes(cbNodes, (<UnionOrIntersectionTypeNode>node).types);
|
||||
case SyntaxKind.ParenthesizedType:
|
||||
return visitNode(cbNode, (<ParenthesizedTypeNode>node).type);
|
||||
case SyntaxKind.TypeOperator:
|
||||
return visitNode(cbNode, (<ParenthesizedTypeNode | TypeOperatorNode>node).type);
|
||||
case SyntaxKind.IndexedAccessType:
|
||||
return visitNode(cbNode, (<IndexedAccessTypeNode>node).objectType) ||
|
||||
visitNode(cbNode, (<IndexedAccessTypeNode>node).indexType);
|
||||
case SyntaxKind.LiteralType:
|
||||
return visitNode(cbNode, (<LiteralTypeNode>node).literal);
|
||||
case SyntaxKind.ObjectBindingPattern:
|
||||
@@ -2538,14 +2542,39 @@ namespace ts {
|
||||
function parseArrayTypeOrHigher(): TypeNode {
|
||||
let type = parseNonArrayType();
|
||||
while (!scanner.hasPrecedingLineBreak() && parseOptional(SyntaxKind.OpenBracketToken)) {
|
||||
parseExpected(SyntaxKind.CloseBracketToken);
|
||||
const node = <ArrayTypeNode>createNode(SyntaxKind.ArrayType, type.pos);
|
||||
node.elementType = type;
|
||||
type = finishNode(node);
|
||||
if (isStartOfType()) {
|
||||
const node = <IndexedAccessTypeNode>createNode(SyntaxKind.IndexedAccessType, type.pos);
|
||||
node.objectType = type;
|
||||
node.indexType = parseType();
|
||||
parseExpected(SyntaxKind.CloseBracketToken);
|
||||
type = finishNode(node);
|
||||
}
|
||||
else {
|
||||
const node = <ArrayTypeNode>createNode(SyntaxKind.ArrayType, type.pos);
|
||||
node.elementType = type;
|
||||
parseExpected(SyntaxKind.CloseBracketToken);
|
||||
type = finishNode(node);
|
||||
}
|
||||
}
|
||||
return type;
|
||||
}
|
||||
|
||||
function parseTypeOperator(operator: SyntaxKind.KeyOfKeyword) {
|
||||
const node = <TypeOperatorNode>createNode(SyntaxKind.TypeOperator);
|
||||
parseExpected(operator);
|
||||
node.operator = operator;
|
||||
node.type = parseTypeOperatorOrHigher();
|
||||
return finishNode(node);
|
||||
}
|
||||
|
||||
function parseTypeOperatorOrHigher(): TypeNode {
|
||||
switch (token()) {
|
||||
case SyntaxKind.KeyOfKeyword:
|
||||
return parseTypeOperator(SyntaxKind.KeyOfKeyword);
|
||||
}
|
||||
return parseArrayTypeOrHigher();
|
||||
}
|
||||
|
||||
function parseUnionOrIntersectionType(kind: SyntaxKind, parseConstituentType: () => TypeNode, operator: SyntaxKind): TypeNode {
|
||||
let type = parseConstituentType();
|
||||
if (token() === operator) {
|
||||
@@ -2562,7 +2591,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
function parseIntersectionTypeOrHigher(): TypeNode {
|
||||
return parseUnionOrIntersectionType(SyntaxKind.IntersectionType, parseArrayTypeOrHigher, SyntaxKind.AmpersandToken);
|
||||
return parseUnionOrIntersectionType(SyntaxKind.IntersectionType, parseTypeOperatorOrHigher, SyntaxKind.AmpersandToken);
|
||||
}
|
||||
|
||||
function parseUnionTypeOrHigher(): TypeNode {
|
||||
|
||||
+34
-24
@@ -329,16 +329,16 @@ namespace ts {
|
||||
// Map storing if there is emit blocking diagnostics for given input
|
||||
const hasEmitBlockingDiagnostics = createFileMap<boolean>(getCanonicalFileName);
|
||||
|
||||
let resolveModuleNamesWorker: (moduleNames: string[], containingFile: string) => ResolvedModule[];
|
||||
let resolveModuleNamesWorker: (moduleNames: string[], containingFile: string) => ResolvedModuleFull[];
|
||||
if (host.resolveModuleNames) {
|
||||
resolveModuleNamesWorker = (moduleNames, containingFile) => host.resolveModuleNames(moduleNames, containingFile).map(resolved => {
|
||||
// An older host may have omitted extension, in which case we should infer it from the file extension of resolvedFileName.
|
||||
if (!resolved || resolved.extension !== undefined) {
|
||||
return resolved;
|
||||
if (!resolved || (resolved as ResolvedModuleFull).extension !== undefined) {
|
||||
return resolved as ResolvedModuleFull;
|
||||
}
|
||||
resolved = clone(resolved);
|
||||
resolved.extension = extensionFromPath(resolved.resolvedFileName);
|
||||
return resolved;
|
||||
const withExtension = clone(resolved) as ResolvedModuleFull;
|
||||
withExtension.extension = extensionFromPath(resolved.resolvedFileName);
|
||||
return withExtension;
|
||||
});
|
||||
}
|
||||
else {
|
||||
@@ -719,6 +719,14 @@ namespace ts {
|
||||
}
|
||||
|
||||
function getSyntacticDiagnosticsForFile(sourceFile: SourceFile): Diagnostic[] {
|
||||
// For JavaScript files, we report semantic errors for using TypeScript-only
|
||||
// constructs from within a JavaScript file as syntactic errors.
|
||||
if (isSourceFileJavaScript(sourceFile)) {
|
||||
if (!sourceFile.additionalSyntacticDiagnostics) {
|
||||
sourceFile.additionalSyntacticDiagnostics = getJavaScriptSyntacticDiagnosticsForFile(sourceFile);
|
||||
}
|
||||
return concatenate(sourceFile.additionalSyntacticDiagnostics, sourceFile.parseDiagnostics);
|
||||
}
|
||||
return sourceFile.parseDiagnostics;
|
||||
}
|
||||
|
||||
@@ -751,12 +759,10 @@ namespace ts {
|
||||
|
||||
Debug.assert(!!sourceFile.bindDiagnostics);
|
||||
const bindDiagnostics = sourceFile.bindDiagnostics;
|
||||
// For JavaScript files, we don't want to report the normal typescript semantic errors.
|
||||
// Instead, we just report errors for using TypeScript-only constructs from within a
|
||||
// JavaScript file.
|
||||
const checkDiagnostics = isSourceFileJavaScript(sourceFile) ?
|
||||
getJavaScriptSemanticDiagnosticsForFile(sourceFile) :
|
||||
typeChecker.getDiagnostics(sourceFile, cancellationToken);
|
||||
// For JavaScript files, we don't want to report semantic errors.
|
||||
// Instead, we'll report errors for using TypeScript-only constructs from within a
|
||||
// JavaScript file when we get syntactic diagnostics for the file.
|
||||
const checkDiagnostics = isSourceFileJavaScript(sourceFile) ? [] : typeChecker.getDiagnostics(sourceFile, cancellationToken);
|
||||
const fileProcessingDiagnosticsInFile = fileProcessingDiagnostics.getDiagnostics(sourceFile.fileName);
|
||||
const programDiagnosticsInFile = programDiagnostics.getDiagnostics(sourceFile.fileName);
|
||||
|
||||
@@ -764,7 +770,7 @@ namespace ts {
|
||||
});
|
||||
}
|
||||
|
||||
function getJavaScriptSemanticDiagnosticsForFile(sourceFile: SourceFile): Diagnostic[] {
|
||||
function getJavaScriptSyntacticDiagnosticsForFile(sourceFile: SourceFile): Diagnostic[] {
|
||||
return runWithCancellationToken(() => {
|
||||
const diagnostics: Diagnostic[] = [];
|
||||
walk(sourceFile);
|
||||
@@ -965,10 +971,6 @@ namespace ts {
|
||||
return sortAndDeduplicateDiagnostics(allDiagnostics);
|
||||
}
|
||||
|
||||
function hasExtension(fileName: string): boolean {
|
||||
return getBaseFileName(fileName).indexOf(".") >= 0;
|
||||
}
|
||||
|
||||
function processRootFile(fileName: string, isDefaultLib: boolean) {
|
||||
processSourceFile(normalizePath(fileName), isDefaultLib);
|
||||
}
|
||||
@@ -1294,7 +1296,7 @@ namespace ts {
|
||||
function processImportedModules(file: SourceFile) {
|
||||
collectExternalModuleReferences(file);
|
||||
if (file.imports.length || file.moduleAugmentations.length) {
|
||||
file.resolvedModules = createMap<ResolvedModule>();
|
||||
file.resolvedModules = createMap<ResolvedModuleFull>();
|
||||
const moduleNames = map(concatenate(file.imports, file.moduleAugmentations), getTextOfLiteral);
|
||||
const resolutions = resolveModuleNamesWorker(moduleNames, getNormalizedAbsolutePath(file.fileName, currentDirectory));
|
||||
Debug.assert(resolutions.length === moduleNames.length);
|
||||
@@ -1321,6 +1323,7 @@ namespace ts {
|
||||
// - it's not a top level JavaScript module that exceeded the search max
|
||||
const elideImport = isJsFileFromNodeModules && currentNodeModulesDepth > maxNodeModuleJsDepth;
|
||||
// Don't add the file if it has a bad extension (e.g. 'tsx' if we don't have '--allowJs')
|
||||
// This may still end up being an untyped module -- the file won't be included but imports will be allowed.
|
||||
const shouldAddFile = resolvedFileName && !getResolutionDiagnostic(options, resolution) && !options.noResolve && i < file.imports.length && !elideImport;
|
||||
|
||||
if (elideImport) {
|
||||
@@ -1568,22 +1571,29 @@ namespace ts {
|
||||
|
||||
/* @internal */
|
||||
/**
|
||||
* Returns a DiagnosticMessage if we can't use a resolved module due to its extension.
|
||||
* Returns a DiagnosticMessage if we won't include a resolved module due to its extension.
|
||||
* The DiagnosticMessage's parameters are the imported module name, and the filename it resolved to.
|
||||
* This returns a diagnostic even if the module will be an untyped module.
|
||||
*/
|
||||
export function getResolutionDiagnostic(options: CompilerOptions, { extension }: ResolvedModule): DiagnosticMessage | undefined {
|
||||
export function getResolutionDiagnostic(options: CompilerOptions, { extension }: ResolvedModuleFull): DiagnosticMessage | undefined {
|
||||
switch (extension) {
|
||||
case Extension.Ts:
|
||||
case Extension.Dts:
|
||||
// These are always allowed.
|
||||
return undefined;
|
||||
|
||||
case Extension.Tsx:
|
||||
return needJsx();
|
||||
case Extension.Jsx:
|
||||
return options.jsx ? undefined : Diagnostics.Module_0_was_resolved_to_1_but_jsx_is_not_set;
|
||||
|
||||
return needJsx() || needAllowJs();
|
||||
case Extension.Js:
|
||||
return options.allowJs ? undefined : Diagnostics.Module_0_was_resolved_to_1_but_allowJs_is_not_set;
|
||||
return needAllowJs();
|
||||
}
|
||||
|
||||
function needJsx() {
|
||||
return options.jsx ? undefined : Diagnostics.Module_0_was_resolved_to_1_but_jsx_is_not_set;
|
||||
}
|
||||
function needAllowJs() {
|
||||
return options.allowJs ? undefined : Diagnostics.Module_0_was_resolved_to_1_but_allowJs_is_not_set;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -90,6 +90,7 @@ namespace ts {
|
||||
"instanceof": SyntaxKind.InstanceOfKeyword,
|
||||
"interface": SyntaxKind.InterfaceKeyword,
|
||||
"is": SyntaxKind.IsKeyword,
|
||||
"keyof": SyntaxKind.KeyOfKeyword,
|
||||
"let": SyntaxKind.LetKeyword,
|
||||
"module": SyntaxKind.ModuleKeyword,
|
||||
"namespace": SyntaxKind.NamespaceKeyword,
|
||||
|
||||
@@ -262,7 +262,8 @@ namespace ts {
|
||||
}
|
||||
|
||||
function transformAsyncFunctionBody(node: FunctionLikeDeclaration): ConciseBody | FunctionBody {
|
||||
const nodeType = node.original ? (<FunctionLikeDeclaration>node.original).type : node.type;
|
||||
const original = getOriginalNode(node, isFunctionLike);
|
||||
const nodeType = original.type;
|
||||
const promiseConstructor = languageVersion < ScriptTarget.ES2015 ? getPromiseConstructor(nodeType) : undefined;
|
||||
const isArrowFunction = node.kind === SyntaxKind.ArrowFunction;
|
||||
const hasLexicalArguments = (resolver.getNodeCheckFlags(node) & NodeCheckFlags.CaptureArguments) !== 0;
|
||||
@@ -336,15 +337,16 @@ namespace ts {
|
||||
}
|
||||
|
||||
function getPromiseConstructor(type: TypeNode) {
|
||||
const typeName = getEntityNameFromTypeNode(type);
|
||||
if (typeName && isEntityName(typeName)) {
|
||||
const serializationKind = resolver.getTypeReferenceSerializationKind(typeName);
|
||||
if (serializationKind === TypeReferenceSerializationKind.TypeWithConstructSignatureAndValue
|
||||
|| serializationKind === TypeReferenceSerializationKind.Unknown) {
|
||||
return typeName;
|
||||
if (type) {
|
||||
const typeName = getEntityNameFromTypeNode(type);
|
||||
if (typeName && isEntityName(typeName)) {
|
||||
const serializationKind = resolver.getTypeReferenceSerializationKind(typeName);
|
||||
if (serializationKind === TypeReferenceSerializationKind.TypeWithConstructSignatureAndValue
|
||||
|| serializationKind === TypeReferenceSerializationKind.Unknown) {
|
||||
return typeName;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return undefined;
|
||||
}
|
||||
|
||||
|
||||
@@ -300,6 +300,8 @@ namespace ts {
|
||||
case SyntaxKind.IntersectionType:
|
||||
case SyntaxKind.ParenthesizedType:
|
||||
case SyntaxKind.ThisType:
|
||||
case SyntaxKind.TypeOperator:
|
||||
case SyntaxKind.IndexedAccessType:
|
||||
case SyntaxKind.LiteralType:
|
||||
// TypeScript type nodes are elided.
|
||||
|
||||
@@ -1783,6 +1785,8 @@ namespace ts {
|
||||
}
|
||||
// Fallthrough
|
||||
case SyntaxKind.TypeQuery:
|
||||
case SyntaxKind.TypeOperator:
|
||||
case SyntaxKind.IndexedAccessType:
|
||||
case SyntaxKind.TypeLiteral:
|
||||
case SyntaxKind.AnyKeyword:
|
||||
case SyntaxKind.ThisType:
|
||||
|
||||
+56
-17
@@ -168,6 +168,7 @@ namespace ts {
|
||||
DeclareKeyword,
|
||||
GetKeyword,
|
||||
IsKeyword,
|
||||
KeyOfKeyword,
|
||||
ModuleKeyword,
|
||||
NamespaceKeyword,
|
||||
NeverKeyword,
|
||||
@@ -216,6 +217,8 @@ namespace ts {
|
||||
IntersectionType,
|
||||
ParenthesizedType,
|
||||
ThisType,
|
||||
TypeOperator,
|
||||
IndexedAccessType,
|
||||
LiteralType,
|
||||
// Binding patterns
|
||||
ObjectBindingPattern,
|
||||
@@ -426,7 +429,7 @@ namespace ts {
|
||||
ThisNodeHasError = 1 << 19, // If the parser encountered an error when parsing the code that created this node
|
||||
JavaScriptFile = 1 << 20, // If node was parsed in a JavaScript
|
||||
ThisNodeOrAnySubNodesHasError = 1 << 21, // If this node or any of its children had an error
|
||||
HasAggregatedChildData = 1 << 22, // If we've computed data from children and cached it in this node
|
||||
HasAggregatedChildData = 1 << 22, // If we've computed data from children and cached it in this node
|
||||
|
||||
BlockScoped = Let | Const,
|
||||
|
||||
@@ -895,6 +898,18 @@ namespace ts {
|
||||
type: TypeNode;
|
||||
}
|
||||
|
||||
export interface TypeOperatorNode extends TypeNode {
|
||||
kind: SyntaxKind.TypeOperator;
|
||||
operator: SyntaxKind.KeyOfKeyword;
|
||||
type: TypeNode;
|
||||
}
|
||||
|
||||
export interface IndexedAccessTypeNode extends TypeNode {
|
||||
kind: SyntaxKind.IndexedAccessType;
|
||||
objectType: TypeNode;
|
||||
indexType: TypeNode;
|
||||
}
|
||||
|
||||
export interface LiteralTypeNode extends TypeNode {
|
||||
kind: SyntaxKind.LiteralType;
|
||||
literal: Expression;
|
||||
@@ -966,10 +981,6 @@ namespace ts {
|
||||
operator: PostfixUnaryOperator;
|
||||
}
|
||||
|
||||
export interface PostfixExpression extends UnaryExpression {
|
||||
_postfixExpressionBrand: any;
|
||||
}
|
||||
|
||||
export interface LeftHandSideExpression extends IncrementExpression {
|
||||
_leftHandSideExpressionBrand: any;
|
||||
}
|
||||
@@ -2087,6 +2098,9 @@ namespace ts {
|
||||
// as well as code diagnostics).
|
||||
/* @internal */ parseDiagnostics: Diagnostic[];
|
||||
|
||||
// Stores additional file level diagnostics reported by the program
|
||||
/* @internal */ additionalSyntacticDiagnostics?: Diagnostic[];
|
||||
|
||||
// File level diagnostics reported by the binder.
|
||||
/* @internal */ bindDiagnostics: Diagnostic[];
|
||||
|
||||
@@ -2097,7 +2111,7 @@ namespace ts {
|
||||
// Stores a mapping 'external module reference text' -> 'resolved file name' | undefined
|
||||
// It is used to resolve module names in the checker.
|
||||
// Content of this field should never be used directly - use getResolvedModuleFileName/setResolvedModuleFileName functions instead
|
||||
/* @internal */ resolvedModules: Map<ResolvedModule>;
|
||||
/* @internal */ resolvedModules: Map<ResolvedModuleFull>;
|
||||
/* @internal */ resolvedTypeReferenceDirectiveNames: Map<ResolvedTypeReferenceDirective>;
|
||||
/* @internal */ imports: LiteralExpression[];
|
||||
/* @internal */ moduleAugmentations: LiteralExpression[];
|
||||
@@ -2687,15 +2701,17 @@ namespace ts {
|
||||
Object = 1 << 15, // Object type
|
||||
Union = 1 << 16, // Union (T | U)
|
||||
Intersection = 1 << 17, // Intersection (T & U)
|
||||
Index = 1 << 18, // keyof T
|
||||
IndexedAccess = 1 << 19, // T[K]
|
||||
/* @internal */
|
||||
FreshLiteral = 1 << 18, // Fresh literal type
|
||||
FreshLiteral = 1 << 20, // Fresh literal type
|
||||
/* @internal */
|
||||
ContainsWideningType = 1 << 19, // Type is or contains undefined or null widening type
|
||||
ContainsWideningType = 1 << 21, // Type is or contains undefined or null widening type
|
||||
/* @internal */
|
||||
ContainsObjectLiteral = 1 << 20, // Type is or contains object literal type
|
||||
ContainsObjectLiteral = 1 << 22, // Type is or contains object literal type
|
||||
/* @internal */
|
||||
ContainsAnyFunctionType = 1 << 21, // Type is or contains object literal type
|
||||
Spread = 1 << 22, // Spread types
|
||||
ContainsAnyFunctionType = 1 << 23, // Type is or contains object literal type
|
||||
Spread = 1 << 24, // Spread types
|
||||
|
||||
/* @internal */
|
||||
Nullable = Undefined | Null,
|
||||
@@ -2718,7 +2734,7 @@ namespace ts {
|
||||
|
||||
// 'Narrowable' types are types where narrowing actually narrows.
|
||||
// This *should* be every type other than null, undefined, void, and never
|
||||
Narrowable = Any | StructuredType | TypeParameter | StringLike | NumberLike | BooleanLike | ESSymbol | Spread,
|
||||
Narrowable = Any | StructuredType | TypeParameter | Index | IndexedAccess | StringLike | NumberLike | BooleanLike | ESSymbol | Spread,
|
||||
NotUnionOrUnit = Any | ESSymbol | Object,
|
||||
/* @internal */
|
||||
RequiresWidening = ContainsWideningType | ContainsObjectLiteral,
|
||||
@@ -2887,9 +2903,22 @@ namespace ts {
|
||||
/* @internal */
|
||||
resolvedApparentType: Type;
|
||||
/* @internal */
|
||||
resolvedIndexType: IndexType;
|
||||
/* @internal */
|
||||
resolvedIndexedAccessTypes: IndexedAccessType[];
|
||||
/* @internal */
|
||||
isThisType?: boolean;
|
||||
}
|
||||
|
||||
export interface IndexType extends Type {
|
||||
type: TypeParameter;
|
||||
}
|
||||
|
||||
export interface IndexedAccessType extends Type {
|
||||
objectType: Type;
|
||||
indexType: TypeParameter;
|
||||
}
|
||||
|
||||
export const enum SignatureKind {
|
||||
Call,
|
||||
Construct,
|
||||
@@ -3172,6 +3201,7 @@ namespace ts {
|
||||
Pretty,
|
||||
}
|
||||
|
||||
/** Either a parsed command line or a parsed tsconfig.json */
|
||||
export interface ParsedCommandLine {
|
||||
options: CompilerOptions;
|
||||
typingOptions?: TypingOptions;
|
||||
@@ -3382,14 +3412,11 @@ namespace ts {
|
||||
* Module resolution will pick up tsx/jsx/js files even if '--jsx' and '--allowJs' are turned off.
|
||||
* The Program will then filter results based on these flags.
|
||||
*
|
||||
* At least one of `resolvedTsFileName` or `resolvedJsFileName` must be defined,
|
||||
* else resolution should just return `undefined` instead of a ResolvedModule.
|
||||
* Prefer to return a `ResolvedModuleFull` so that the file type does not have to be inferred.
|
||||
*/
|
||||
export interface ResolvedModule {
|
||||
/** Path of the file the module was resolved to. */
|
||||
resolvedFileName: string;
|
||||
/** Extension of resolvedFileName. This must match what's at the end of resolvedFileName. */
|
||||
extension: Extension;
|
||||
/**
|
||||
* Denotes if 'resolvedFileName' is isExternalLibraryImport and thus should be a proper external module:
|
||||
* - be a .d.ts file
|
||||
@@ -3399,6 +3426,18 @@ namespace ts {
|
||||
isExternalLibraryImport?: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* ResolvedModule with an explicitly provided `extension` property.
|
||||
* Prefer this over `ResolvedModule`.
|
||||
*/
|
||||
export interface ResolvedModuleFull extends ResolvedModule {
|
||||
/**
|
||||
* Extension of resolvedFileName. This must match what's at the end of resolvedFileName.
|
||||
* This is optional for backwards-compatibility, but will be added if not provided.
|
||||
*/
|
||||
extension: Extension;
|
||||
}
|
||||
|
||||
export enum Extension {
|
||||
Ts,
|
||||
Tsx,
|
||||
@@ -3409,7 +3448,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
export interface ResolvedModuleWithFailedLookupLocations {
|
||||
resolvedModule: ResolvedModule | undefined;
|
||||
resolvedModule: ResolvedModuleFull | undefined;
|
||||
failedLookupLocations: string[];
|
||||
}
|
||||
|
||||
|
||||
+70
-38
@@ -87,13 +87,13 @@ namespace ts {
|
||||
return !!(sourceFile && sourceFile.resolvedModules && sourceFile.resolvedModules[moduleNameText]);
|
||||
}
|
||||
|
||||
export function getResolvedModule(sourceFile: SourceFile, moduleNameText: string): ResolvedModule {
|
||||
export function getResolvedModule(sourceFile: SourceFile, moduleNameText: string): ResolvedModuleFull {
|
||||
return hasResolvedModule(sourceFile, moduleNameText) ? sourceFile.resolvedModules[moduleNameText] : undefined;
|
||||
}
|
||||
|
||||
export function setResolvedModule(sourceFile: SourceFile, moduleNameText: string, resolvedModule: ResolvedModule): void {
|
||||
export function setResolvedModule(sourceFile: SourceFile, moduleNameText: string, resolvedModule: ResolvedModuleFull): void {
|
||||
if (!sourceFile.resolvedModules) {
|
||||
sourceFile.resolvedModules = createMap<ResolvedModule>();
|
||||
sourceFile.resolvedModules = createMap<ResolvedModuleFull>();
|
||||
}
|
||||
|
||||
sourceFile.resolvedModules[moduleNameText] = resolvedModule;
|
||||
@@ -108,11 +108,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
/* @internal */
|
||||
/**
|
||||
* Considers two ResolvedModules equal if they have the same `resolvedFileName`.
|
||||
* Thus `{ ts: foo, js: bar }` is equal to `{ ts: foo, js: baz }` because `ts` is preferred.
|
||||
*/
|
||||
export function moduleResolutionIsEqualTo(oldResolution: ResolvedModule, newResolution: ResolvedModule): boolean {
|
||||
export function moduleResolutionIsEqualTo(oldResolution: ResolvedModuleFull, newResolution: ResolvedModuleFull): boolean {
|
||||
return oldResolution.isExternalLibraryImport === newResolution.isExternalLibraryImport &&
|
||||
oldResolution.extension === newResolution.extension &&
|
||||
oldResolution.resolvedFileName === newResolution.resolvedFileName;
|
||||
@@ -406,6 +402,7 @@ namespace ts {
|
||||
((<ModuleDeclaration>node).name.kind === SyntaxKind.StringLiteral || isGlobalScopeAugmentation(<ModuleDeclaration>node));
|
||||
}
|
||||
|
||||
/** Given a symbol for a module, checks that it is either an untyped import or a shorthand ambient module. */
|
||||
export function isShorthandAmbientModuleSymbol(moduleSymbol: Symbol): boolean {
|
||||
return isShorthandAmbientModule(moduleSymbol.valueDeclaration);
|
||||
}
|
||||
@@ -488,6 +485,17 @@ namespace ts {
|
||||
return getFullWidth(name) === 0 ? "(Missing)" : getTextOfNode(name);
|
||||
}
|
||||
|
||||
export function entityNameToString(name: EntityNameOrEntityNameExpression): string {
|
||||
switch (name.kind) {
|
||||
case SyntaxKind.Identifier:
|
||||
return getFullWidth(name) === 0 ? unescapeIdentifier((<Identifier>name).text) : getTextOfNode(name);
|
||||
case SyntaxKind.QualifiedName:
|
||||
return entityNameToString((<QualifiedName>name).left) + "." + entityNameToString((<QualifiedName>name).right);
|
||||
case SyntaxKind.PropertyAccessExpression:
|
||||
return entityNameToString((<PropertyAccessEntityNameExpression>name).expression) + "." + entityNameToString((<PropertyAccessEntityNameExpression>name).name);
|
||||
}
|
||||
}
|
||||
|
||||
export function createDiagnosticForNode(node: Node, message: DiagnosticMessage, arg0?: string | number, arg1?: string | number, arg2?: string | number): Diagnostic {
|
||||
const sourceFile = getSourceFileOfNode(node);
|
||||
const span = getErrorSpanForNode(sourceFile, node);
|
||||
@@ -1045,17 +1053,19 @@ namespace ts {
|
||||
}
|
||||
|
||||
export function getEntityNameFromTypeNode(node: TypeNode): EntityNameOrEntityNameExpression {
|
||||
if (node) {
|
||||
switch (node.kind) {
|
||||
case SyntaxKind.TypeReference:
|
||||
return (<TypeReferenceNode>node).typeName;
|
||||
case SyntaxKind.ExpressionWithTypeArguments:
|
||||
Debug.assert(isEntityNameExpression((<ExpressionWithTypeArguments>node).expression));
|
||||
return <EntityNameExpression>(<ExpressionWithTypeArguments>node).expression;
|
||||
case SyntaxKind.Identifier:
|
||||
case SyntaxKind.QualifiedName:
|
||||
return (<EntityName><Node>node);
|
||||
}
|
||||
switch (node.kind) {
|
||||
case SyntaxKind.TypeReference:
|
||||
case SyntaxKind.JSDocTypeReference:
|
||||
return (<TypeReferenceNode>node).typeName;
|
||||
|
||||
case SyntaxKind.ExpressionWithTypeArguments:
|
||||
return isEntityNameExpression((<ExpressionWithTypeArguments>node).expression)
|
||||
? <EntityNameExpression>(<ExpressionWithTypeArguments>node).expression
|
||||
: undefined;
|
||||
|
||||
case SyntaxKind.Identifier:
|
||||
case SyntaxKind.QualifiedName:
|
||||
return (<EntityName><Node>node);
|
||||
}
|
||||
|
||||
return undefined;
|
||||
@@ -1609,29 +1619,51 @@ namespace ts {
|
||||
return node && node.dotDotDotToken !== undefined;
|
||||
}
|
||||
|
||||
export const enum AssignmentKind {
|
||||
None, Definite, Compound
|
||||
}
|
||||
|
||||
export function getAssignmentTargetKind(node: Node): AssignmentKind {
|
||||
let parent = node.parent;
|
||||
while (true) {
|
||||
switch (parent.kind) {
|
||||
case SyntaxKind.BinaryExpression:
|
||||
const binaryOperator = (<BinaryExpression>parent).operatorToken.kind;
|
||||
return isAssignmentOperator(binaryOperator) && (<BinaryExpression>parent).left === node ?
|
||||
binaryOperator === SyntaxKind.EqualsToken ? AssignmentKind.Definite : AssignmentKind.Compound :
|
||||
AssignmentKind.None;
|
||||
case SyntaxKind.PrefixUnaryExpression:
|
||||
case SyntaxKind.PostfixUnaryExpression:
|
||||
const unaryOperator = (<PrefixUnaryExpression | PostfixUnaryExpression>parent).operator;
|
||||
return unaryOperator === SyntaxKind.PlusPlusToken || unaryOperator === SyntaxKind.MinusMinusToken ? AssignmentKind.Compound : AssignmentKind.None;
|
||||
case SyntaxKind.ForInStatement:
|
||||
case SyntaxKind.ForOfStatement:
|
||||
return (<ForInStatement | ForOfStatement>parent).initializer === node ? AssignmentKind.Definite : AssignmentKind.None;
|
||||
case SyntaxKind.ParenthesizedExpression:
|
||||
case SyntaxKind.ArrayLiteralExpression:
|
||||
case SyntaxKind.SpreadExpression:
|
||||
node = parent;
|
||||
break;
|
||||
case SyntaxKind.ShorthandPropertyAssignment:
|
||||
if ((<ShorthandPropertyAssignment>parent).name !== node) {
|
||||
return AssignmentKind.None;
|
||||
}
|
||||
// Fall through
|
||||
case SyntaxKind.PropertyAssignment:
|
||||
node = parent.parent;
|
||||
break;
|
||||
default:
|
||||
return AssignmentKind.None;
|
||||
}
|
||||
parent = node.parent;
|
||||
}
|
||||
}
|
||||
|
||||
// A node is an assignment target if it is on the left hand side of an '=' token, if it is parented by a property
|
||||
// assignment in an object literal that is an assignment target, or if it is parented by an array literal that is
|
||||
// an assignment target. Examples include 'a = xxx', '{ p: a } = xxx', '[{ p: a}] = xxx'.
|
||||
export function isAssignmentTarget(node: Node): boolean {
|
||||
while (node.parent.kind === SyntaxKind.ParenthesizedExpression) {
|
||||
node = node.parent;
|
||||
}
|
||||
while (true) {
|
||||
const parent = node.parent;
|
||||
if (parent.kind === SyntaxKind.ArrayLiteralExpression || parent.kind === SyntaxKind.SpreadExpression) {
|
||||
node = parent;
|
||||
continue;
|
||||
}
|
||||
if (parent.kind === SyntaxKind.PropertyAssignment || parent.kind === SyntaxKind.ShorthandPropertyAssignment) {
|
||||
node = parent.parent;
|
||||
continue;
|
||||
}
|
||||
return parent.kind === SyntaxKind.BinaryExpression &&
|
||||
isAssignmentOperator((<BinaryExpression>parent).operatorToken.kind) &&
|
||||
(<BinaryExpression>parent).left === node ||
|
||||
(parent.kind === SyntaxKind.ForInStatement || parent.kind === SyntaxKind.ForOfStatement) &&
|
||||
(<ForInStatement | ForOfStatement>parent).initializer === node;
|
||||
}
|
||||
return getAssignmentTargetKind(node) !== AssignmentKind.None;
|
||||
}
|
||||
|
||||
export function isNodeDescendantOf(node: Node, ancestor: Node): boolean {
|
||||
|
||||
+48
-93
@@ -438,9 +438,8 @@ namespace FourSlash {
|
||||
private getAllDiagnostics(): ts.Diagnostic[] {
|
||||
const diagnostics: ts.Diagnostic[] = [];
|
||||
|
||||
const fileNames = this.languageServiceAdapterHost.getFilenames();
|
||||
for (let i = 0, n = fileNames.length; i < n; i++) {
|
||||
diagnostics.push.apply(this.getDiagnostics(fileNames[i]));
|
||||
for (const fileName of this.languageServiceAdapterHost.getFilenames()) {
|
||||
diagnostics.push.apply(this.getDiagnostics(fileName));
|
||||
}
|
||||
|
||||
return diagnostics;
|
||||
@@ -580,12 +579,12 @@ namespace FourSlash {
|
||||
this.raiseError(`goToDefinitions failed - expected to find ${endMarkers.length} definitions but got ${definitions.length}`);
|
||||
}
|
||||
|
||||
for (let i = 0; i < endMarkers.length; i++) {
|
||||
const marker = this.getMarkerByName(endMarkers[i]), definition = definitions[i];
|
||||
ts.zipWith(endMarkers, definitions, (endMarker, definition, i) => {
|
||||
const marker = this.getMarkerByName(endMarker);
|
||||
if (marker.fileName !== definition.fileName || marker.position !== definition.textSpan.start) {
|
||||
this.raiseError(`goToDefinition failed for definition ${i}: expected ${marker.fileName} at ${marker.position}, got ${definition.fileName} at ${definition.textSpan.start}`);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public verifyGetEmitOutputForCurrentFile(expected: string): void {
|
||||
@@ -602,10 +601,10 @@ namespace FourSlash {
|
||||
public verifyGetEmitOutputContentsForCurrentFile(expected: ts.OutputFile[]): void {
|
||||
const emit = this.languageService.getEmitOutput(this.activeFile.fileName);
|
||||
assert.equal(emit.outputFiles.length, expected.length, "Number of emit output files");
|
||||
for (let i = 0; i < emit.outputFiles.length; i++) {
|
||||
assert.equal(emit.outputFiles[i].name, expected[i].name, "FileName");
|
||||
assert.equal(emit.outputFiles[i].text, expected[i].text, "Content");
|
||||
}
|
||||
ts.zipWith(emit.outputFiles, expected, (outputFile, expected) => {
|
||||
assert.equal(outputFile.name, expected.name, "FileName");
|
||||
assert.equal(outputFile.text, expected.text, "Content");
|
||||
});
|
||||
}
|
||||
|
||||
public verifyMemberListContains(symbol: string, text?: string, documentation?: string, kind?: string) {
|
||||
@@ -668,9 +667,9 @@ namespace FourSlash {
|
||||
|
||||
const entries = this.getCompletionListAtCaret().entries;
|
||||
assert.isTrue(items.length <= entries.length, `Amount of expected items in completion list [ ${items.length} ] is greater than actual number of items in list [ ${entries.length} ]`);
|
||||
for (let i = 0; i < items.length; i++) {
|
||||
assert.equal(entries[i].name, items[i], `Unexpected item in completion list`);
|
||||
}
|
||||
ts.zipWith(entries, items, (entry, item) => {
|
||||
assert.equal(entry.name, item, `Unexpected item in completion list`);
|
||||
});
|
||||
}
|
||||
|
||||
public noItemsWithSameNameButDifferentKind(): void {
|
||||
@@ -692,15 +691,7 @@ namespace FourSlash {
|
||||
this.raiseError("Member list is empty at Caret");
|
||||
}
|
||||
else if ((members && members.entries.length !== 0) && !negative) {
|
||||
|
||||
let errorMsg = "\n" + "Member List contains: [" + members.entries[0].name;
|
||||
for (let i = 1; i < members.entries.length; i++) {
|
||||
errorMsg += ", " + members.entries[i].name;
|
||||
}
|
||||
errorMsg += "]\n";
|
||||
|
||||
this.raiseError("Member list is not empty at Caret: " + errorMsg);
|
||||
|
||||
this.raiseError(`Member list is not empty at Caret:\nMember List contains: ${stringify(members.entries.map(e => e.name))}`);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -710,13 +701,8 @@ namespace FourSlash {
|
||||
this.raiseError("Completion list is empty at caret at position " + this.activeFile.fileName + " " + this.currentCaretPosition);
|
||||
}
|
||||
else if (completions && completions.entries.length !== 0 && !negative) {
|
||||
let errorMsg = "\n" + "Completion List contains: [" + completions.entries[0].name;
|
||||
for (let i = 1; i < completions.entries.length; i++) {
|
||||
errorMsg += ", " + completions.entries[i].name;
|
||||
}
|
||||
errorMsg += "]\n";
|
||||
|
||||
this.raiseError("Completion list is not empty at caret at position " + this.activeFile.fileName + " " + this.currentCaretPosition + errorMsg);
|
||||
this.raiseError(`Completion list is not empty at caret at position ${this.activeFile.fileName} ${this.currentCaretPosition}\n` +
|
||||
`Completion List contains: ${stringify(completions.entries.map(e => e.name))}`);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -890,8 +876,7 @@ namespace FourSlash {
|
||||
}
|
||||
|
||||
private verifyReferencesWorker(references: ts.ReferenceEntry[], fileName: string, start: number, end: number, isWriteAccess?: boolean, isDefinition?: boolean) {
|
||||
for (let i = 0; i < references.length; i++) {
|
||||
const reference = references[i];
|
||||
for (const reference of references) {
|
||||
if (reference && reference.fileName === fileName && reference.textSpan.start === start && ts.textSpanEnd(reference.textSpan) === end) {
|
||||
if (typeof isWriteAccess !== "undefined" && reference.isWriteAccess !== isWriteAccess) {
|
||||
this.raiseError(`verifyReferencesAtPositionListContains failed - item isWriteAccess value does not match, actual: ${reference.isWriteAccess}, expected: ${isWriteAccess}.`);
|
||||
@@ -1008,16 +993,11 @@ namespace FourSlash {
|
||||
ranges = ranges.sort((r1, r2) => r1.start - r2.start);
|
||||
references = references.sort((r1, r2) => r1.textSpan.start - r2.textSpan.start);
|
||||
|
||||
for (let i = 0, n = ranges.length; i < n; i++) {
|
||||
const reference = references[i];
|
||||
const range = ranges[i];
|
||||
|
||||
if (reference.textSpan.start !== range.start ||
|
||||
ts.textSpanEnd(reference.textSpan) !== range.end) {
|
||||
|
||||
ts.zipWith(references, ranges, (reference, range) => {
|
||||
if (reference.textSpan.start !== range.start || ts.textSpanEnd(reference.textSpan) !== range.end) {
|
||||
this.raiseError("Rename location results do not match.\n\nExpected: " + stringify(ranges) + "\n\nActual:" + JSON.stringify(references));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
else {
|
||||
this.raiseError("Expected rename to succeed, but it actually failed.");
|
||||
@@ -1247,8 +1227,7 @@ namespace FourSlash {
|
||||
const emitFiles: FourSlashFile[] = []; // List of FourSlashFile that has emitThisFile flag on
|
||||
|
||||
const allFourSlashFiles = this.testData.files;
|
||||
for (let idx = 0; idx < allFourSlashFiles.length; idx++) {
|
||||
const file = allFourSlashFiles[idx];
|
||||
for (const file of allFourSlashFiles) {
|
||||
if (file.fileOptions[metadataOptionNames.emitThisFile] === "true") {
|
||||
// Find a file with the flag emitThisFile turned on
|
||||
emitFiles.push(file);
|
||||
@@ -1273,8 +1252,8 @@ namespace FourSlash {
|
||||
if (emitOutput.emitSkipped) {
|
||||
resultString += "Diagnostics:" + Harness.IO.newLine();
|
||||
const diagnostics = ts.getPreEmitDiagnostics(this.languageService.getProgram());
|
||||
for (let i = 0, n = diagnostics.length; i < n; i++) {
|
||||
resultString += " " + diagnostics[0].messageText + Harness.IO.newLine();
|
||||
for (const diagnostic of diagnostics) {
|
||||
resultString += " " + diagnostic.messageText + Harness.IO.newLine();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1340,8 +1319,7 @@ namespace FourSlash {
|
||||
}
|
||||
|
||||
public printCurrentFileState(makeWhitespaceVisible = false, makeCaretVisible = true) {
|
||||
for (let i = 0; i < this.testData.files.length; i++) {
|
||||
const file = this.testData.files[i];
|
||||
for (const file of this.testData.files) {
|
||||
const active = (this.activeFile === file);
|
||||
Harness.IO.log(`=== Script (${file.fileName}) ${(active ? "(active, cursor at |)" : "")} ===`);
|
||||
let content = this.getFileContent(file.fileName);
|
||||
@@ -1576,10 +1554,10 @@ namespace FourSlash {
|
||||
edits = edits.sort((a, b) => a.span.start - b.span.start);
|
||||
// Get a snapshot of the content of the file so we can make sure any formatting edits didn't destroy non-whitespace characters
|
||||
const oldContent = this.getFileContent(this.activeFile.fileName);
|
||||
for (let j = 0; j < edits.length; j++) {
|
||||
this.languageServiceAdapterHost.editScript(fileName, edits[j].span.start + runningOffset, ts.textSpanEnd(edits[j].span) + runningOffset, edits[j].newText);
|
||||
this.updateMarkersForEdit(fileName, edits[j].span.start + runningOffset, ts.textSpanEnd(edits[j].span) + runningOffset, edits[j].newText);
|
||||
const change = (edits[j].span.start - ts.textSpanEnd(edits[j].span)) + edits[j].newText.length;
|
||||
for (const edit of edits) {
|
||||
this.languageServiceAdapterHost.editScript(fileName, edit.span.start + runningOffset, ts.textSpanEnd(edit.span) + runningOffset, edit.newText);
|
||||
this.updateMarkersForEdit(fileName, edit.span.start + runningOffset, ts.textSpanEnd(edit.span) + runningOffset, edit.newText);
|
||||
const change = (edit.span.start - ts.textSpanEnd(edit.span)) + edit.newText.length;
|
||||
runningOffset += change;
|
||||
// TODO: Consider doing this at least some of the time for higher fidelity. Currently causes a failure (bug 707150)
|
||||
// this.languageService.getScriptLexicalStructure(fileName);
|
||||
@@ -1913,10 +1891,7 @@ namespace FourSlash {
|
||||
jsonMismatchString());
|
||||
}
|
||||
|
||||
for (let i = 0; i < expected.length; i++) {
|
||||
const expectedClassification = expected[i];
|
||||
const actualClassification = actual[i];
|
||||
|
||||
ts.zipWith(expected, actual, (expectedClassification, actualClassification) => {
|
||||
const expectedType: string = (<any>ts.ClassificationTypeNames)[expectedClassification.classificationType];
|
||||
if (expectedType !== actualClassification.classificationType) {
|
||||
this.raiseError("verifyClassifications failed - expected classifications type to be " +
|
||||
@@ -1946,7 +1921,7 @@ namespace FourSlash {
|
||||
actualText +
|
||||
jsonMismatchString());
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
function jsonMismatchString() {
|
||||
return Harness.IO.newLine() +
|
||||
@@ -1991,13 +1966,11 @@ namespace FourSlash {
|
||||
this.raiseError(`verifyOutliningSpans failed - expected total spans to be ${spans.length}, but was ${actual.length}`);
|
||||
}
|
||||
|
||||
for (let i = 0; i < spans.length; i++) {
|
||||
const expectedSpan = spans[i];
|
||||
const actualSpan = actual[i];
|
||||
ts.zipWith(spans, actual, (expectedSpan, actualSpan, i) => {
|
||||
if (expectedSpan.start !== actualSpan.textSpan.start || expectedSpan.end !== ts.textSpanEnd(actualSpan.textSpan)) {
|
||||
this.raiseError(`verifyOutliningSpans failed - span ${(i + 1)} expected: (${expectedSpan.start},${expectedSpan.end}), actual: (${actualSpan.textSpan.start},${ts.textSpanEnd(actualSpan.textSpan)})`);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public verifyTodoComments(descriptors: string[], spans: TextSpan[]) {
|
||||
@@ -2008,15 +1981,13 @@ namespace FourSlash {
|
||||
this.raiseError(`verifyTodoComments failed - expected total spans to be ${spans.length}, but was ${actual.length}`);
|
||||
}
|
||||
|
||||
for (let i = 0; i < spans.length; i++) {
|
||||
const expectedSpan = spans[i];
|
||||
const actualComment = actual[i];
|
||||
ts.zipWith(spans, actual, (expectedSpan, actualComment, i) => {
|
||||
const actualCommentSpan = ts.createTextSpan(actualComment.position, actualComment.message.length);
|
||||
|
||||
if (expectedSpan.start !== actualCommentSpan.start || expectedSpan.end !== ts.textSpanEnd(actualCommentSpan)) {
|
||||
this.raiseError(`verifyOutliningSpans failed - span ${(i + 1)} expected: (${expectedSpan.start},${expectedSpan.end}), actual: (${actualCommentSpan.start},${ts.textSpanEnd(actualCommentSpan)})`);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private getCodeFixes(errorCode?: number) {
|
||||
@@ -2163,11 +2134,9 @@ namespace FourSlash {
|
||||
public verifyNavigationItemsCount(expected: number, searchValue: string, matchKind?: string, fileName?: string) {
|
||||
const items = this.languageService.getNavigateToItems(searchValue, /*maxResultCount*/ undefined, fileName);
|
||||
let actual = 0;
|
||||
let item: ts.NavigateToItem;
|
||||
|
||||
// Count only the match that match the same MatchKind
|
||||
for (let i = 0; i < items.length; i++) {
|
||||
item = items[i];
|
||||
for (const item of items) {
|
||||
if (!matchKind || item.matchKind === matchKind) {
|
||||
actual++;
|
||||
}
|
||||
@@ -2195,8 +2164,7 @@ namespace FourSlash {
|
||||
this.raiseError("verifyNavigationItemsListContains failed - found 0 navigation items, expected at least one.");
|
||||
}
|
||||
|
||||
for (let i = 0; i < items.length; i++) {
|
||||
const item = items[i];
|
||||
for (const item of items) {
|
||||
if (item && item.name === name && item.kind === kind &&
|
||||
(matchKind === undefined || item.matchKind === matchKind) &&
|
||||
(fileName === undefined || item.fileName === fileName) &&
|
||||
@@ -2247,24 +2215,16 @@ namespace FourSlash {
|
||||
|
||||
public printNavigationItems(searchValue: string) {
|
||||
const items = this.languageService.getNavigateToItems(searchValue);
|
||||
const length = items && items.length;
|
||||
|
||||
Harness.IO.log(`NavigationItems list (${length} items)`);
|
||||
|
||||
for (let i = 0; i < length; i++) {
|
||||
const item = items[i];
|
||||
Harness.IO.log(`NavigationItems list (${items.length} items)`);
|
||||
for (const item of items) {
|
||||
Harness.IO.log(`name: ${item.name}, kind: ${item.kind}, parentName: ${item.containerName}, fileName: ${item.fileName}`);
|
||||
}
|
||||
}
|
||||
|
||||
public printNavigationBar() {
|
||||
const items = this.languageService.getNavigationBarItems(this.activeFile.fileName);
|
||||
const length = items && items.length;
|
||||
|
||||
Harness.IO.log(`Navigation bar (${length} items)`);
|
||||
|
||||
for (let i = 0; i < length; i++) {
|
||||
const item = items[i];
|
||||
Harness.IO.log(`Navigation bar (${items.length} items)`);
|
||||
for (const item of items) {
|
||||
Harness.IO.log(`${repeatString(item.indent, " ")}name: ${item.text}, kind: ${item.kind}, childItems: ${item.childItems.map(child => child.text)}`);
|
||||
}
|
||||
}
|
||||
@@ -2385,8 +2345,7 @@ namespace FourSlash {
|
||||
}
|
||||
|
||||
private assertItemInCompletionList(items: ts.CompletionEntry[], name: string, text?: string, documentation?: string, kind?: string, spanIndex?: number) {
|
||||
for (let i = 0; i < items.length; i++) {
|
||||
const item = items[i];
|
||||
for (const item of items) {
|
||||
if (item.name === name) {
|
||||
if (documentation != undefined || text !== undefined) {
|
||||
const details = this.getCompletionEntryDetails(item.name);
|
||||
@@ -2435,20 +2394,17 @@ namespace FourSlash {
|
||||
name = name.indexOf("/") === -1 ? (this.basePath + "/" + name) : name;
|
||||
|
||||
const availableNames: string[] = [];
|
||||
let foundIt = false;
|
||||
for (let i = 0; i < this.testData.files.length; i++) {
|
||||
const fn = this.testData.files[i].fileName;
|
||||
result = ts.forEach(this.testData.files, file => {
|
||||
const fn = file.fileName;
|
||||
if (fn) {
|
||||
if (fn === name) {
|
||||
result = this.testData.files[i];
|
||||
foundIt = true;
|
||||
break;
|
||||
return file;
|
||||
}
|
||||
availableNames.push(fn);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
if (!foundIt) {
|
||||
if (!result) {
|
||||
throw new Error(`No test file named "${name}" exists. Available file names are: ${availableNames.join(", ")}`);
|
||||
}
|
||||
}
|
||||
@@ -2549,8 +2505,8 @@ ${code}
|
||||
|
||||
function chompLeadingSpace(content: string) {
|
||||
const lines = content.split("\n");
|
||||
for (let i = 0; i < lines.length; i++) {
|
||||
if ((lines[i].length !== 0) && (lines[i].charAt(0) !== " ")) {
|
||||
for (const line of lines) {
|
||||
if ((line.length !== 0) && (line.charAt(0) !== " ")) {
|
||||
return content;
|
||||
}
|
||||
}
|
||||
@@ -2588,8 +2544,7 @@ ${code}
|
||||
currentFileName = fileName;
|
||||
}
|
||||
|
||||
for (let i = 0; i < lines.length; i++) {
|
||||
let line = lines[i];
|
||||
for (let line of lines) {
|
||||
const lineLength = line.length;
|
||||
|
||||
if (lineLength > 0 && line.charAt(lineLength - 1) === "\r") {
|
||||
|
||||
+37
-24
@@ -1029,7 +1029,7 @@ namespace Harness {
|
||||
},
|
||||
realpath: realPathMap && ((f: string) => {
|
||||
const path = ts.toPath(f, currentDirectory, getCanonicalFileName);
|
||||
return realPathMap.contains(path) ? realPathMap.get(path) : path;
|
||||
return realPathMap.get(path) || path;
|
||||
}),
|
||||
directoryExists: dir => {
|
||||
let path = ts.toPath(dir, currentDirectory, getCanonicalFileName);
|
||||
@@ -1037,13 +1037,7 @@ namespace Harness {
|
||||
if (path[path.length - 1] === "/") {
|
||||
path = <ts.Path>path.substr(0, path.length - 1);
|
||||
}
|
||||
let exists = false;
|
||||
fileMap.forEachValue(key => {
|
||||
if (key.indexOf(path) === 0 && key[path.length] === "/") {
|
||||
exists = true;
|
||||
}
|
||||
});
|
||||
return exists;
|
||||
return mapHasFileInDirectory(path, fileMap) || mapHasFileInDirectory(path, realPathMap);
|
||||
},
|
||||
getDirectories: d => {
|
||||
const path = ts.toPath(d, currentDirectory, getCanonicalFileName);
|
||||
@@ -1064,6 +1058,19 @@ namespace Harness {
|
||||
};
|
||||
}
|
||||
|
||||
function mapHasFileInDirectory(directoryPath: ts.Path, map: ts.FileMap<any>): boolean {
|
||||
if (!map) {
|
||||
return false;
|
||||
}
|
||||
let exists = false;
|
||||
map.forEachValue(fileName => {
|
||||
if (!exists && ts.startsWith(fileName, directoryPath) && fileName[directoryPath.length] === "/") {
|
||||
exists = true;
|
||||
}
|
||||
});
|
||||
return exists;
|
||||
}
|
||||
|
||||
interface HarnessOptions {
|
||||
useCaseSensitiveFileNames?: boolean;
|
||||
includeBuiltFile?: string;
|
||||
@@ -1108,22 +1115,7 @@ namespace Harness {
|
||||
const option = getCommandLineOption(name);
|
||||
if (option) {
|
||||
const errors: ts.Diagnostic[] = [];
|
||||
switch (option.type) {
|
||||
case "boolean":
|
||||
options[option.name] = value.toLowerCase() === "true";
|
||||
break;
|
||||
case "string":
|
||||
options[option.name] = value;
|
||||
break;
|
||||
// If not a primitive, the possible types are specified in what is effectively a map of options.
|
||||
case "list":
|
||||
options[option.name] = ts.parseListTypeOption(<ts.CommandLineOptionOfListType>option, value, errors);
|
||||
break;
|
||||
default:
|
||||
options[option.name] = ts.parseCustomTypeOption(<ts.CommandLineOptionOfCustomType>option, value, errors);
|
||||
break;
|
||||
}
|
||||
|
||||
options[option.name] = optionValue(option, value, errors);
|
||||
if (errors.length > 0) {
|
||||
throw new Error(`Unknown value '${value}' for compiler option '${name}'.`);
|
||||
}
|
||||
@@ -1135,6 +1127,27 @@ namespace Harness {
|
||||
}
|
||||
}
|
||||
|
||||
function optionValue(option: ts.CommandLineOption, value: string, errors: ts.Diagnostic[]): any {
|
||||
switch (option.type) {
|
||||
case "boolean":
|
||||
return value.toLowerCase() === "true";
|
||||
case "string":
|
||||
return value;
|
||||
case "number": {
|
||||
const number = parseInt(value, 10);
|
||||
if (isNaN(number)) {
|
||||
throw new Error(`Value must be a number, got: ${JSON.stringify(value)}`);
|
||||
}
|
||||
return number;
|
||||
}
|
||||
// If not a primitive, the possible types are specified in what is effectively a map of options.
|
||||
case "list":
|
||||
return ts.parseListTypeOption(<ts.CommandLineOptionOfListType>option, value, errors);
|
||||
default:
|
||||
return ts.parseCustomTypeOption(<ts.CommandLineOptionOfCustomType>option, value, errors);
|
||||
}
|
||||
}
|
||||
|
||||
export interface TestFile {
|
||||
unitName: string;
|
||||
content: string;
|
||||
|
||||
@@ -22,33 +22,17 @@ namespace ts {
|
||||
newLine: "\r\n",
|
||||
useCaseSensitiveFileNames: false,
|
||||
write: noop,
|
||||
readFile: (path: string): string => {
|
||||
return path in fileMap ? fileMap[path].content : undefined;
|
||||
},
|
||||
writeFile: (_path: string, _data: string, _writeByteOrderMark?: boolean) => {
|
||||
return ts.notImplemented();
|
||||
},
|
||||
resolvePath: (_path: string): string => {
|
||||
return ts.notImplemented();
|
||||
},
|
||||
fileExists: (path: string): boolean => {
|
||||
return path in fileMap;
|
||||
},
|
||||
directoryExists: (path: string): boolean => {
|
||||
return existingDirectories[path] || false;
|
||||
},
|
||||
readFile: path => path in fileMap ? fileMap[path].content : undefined,
|
||||
writeFile: notImplemented,
|
||||
resolvePath: notImplemented,
|
||||
fileExists: path => path in fileMap,
|
||||
directoryExists: path => existingDirectories[path] || false,
|
||||
createDirectory: noop,
|
||||
getExecutingFilePath: (): string => {
|
||||
return "";
|
||||
},
|
||||
getCurrentDirectory: (): string => {
|
||||
return "";
|
||||
},
|
||||
getExecutingFilePath: () => "",
|
||||
getCurrentDirectory: () => "",
|
||||
getDirectories: () => [],
|
||||
getEnvironmentVariable: () => "",
|
||||
readDirectory: (_path: string, _extension?: string[], _exclude?: string[], _include?: string[]): string[] => {
|
||||
return ts.notImplemented();
|
||||
},
|
||||
readDirectory: notImplemented,
|
||||
exit: noop,
|
||||
watchFile: () => ({
|
||||
close: noop
|
||||
@@ -58,8 +42,8 @@ namespace ts {
|
||||
}),
|
||||
setTimeout,
|
||||
clearTimeout,
|
||||
setImmediate,
|
||||
clearImmediate
|
||||
setImmediate: typeof setImmediate !== "undefined" ? setImmediate : action => setTimeout(action, 0),
|
||||
clearImmediate: typeof clearImmediate !== "undefined" ? clearImmediate : clearTimeout
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -91,6 +91,12 @@ namespace ts {
|
||||
|
||||
const defaultExcludes = ["node_modules", "bower_components", "jspm_packages"];
|
||||
|
||||
function assertParsed(actual: ts.ParsedCommandLine, expected: ts.ParsedCommandLine): void {
|
||||
assert.deepEqual(actual.fileNames, expected.fileNames);
|
||||
assert.deepEqual(actual.wildcardDirectories, expected.wildcardDirectories);
|
||||
assert.deepEqual(actual.errors, expected.errors);
|
||||
}
|
||||
|
||||
describe("matchFiles", () => {
|
||||
describe("with literal file list", () => {
|
||||
it("without exclusions", () => {
|
||||
@@ -110,9 +116,7 @@ namespace ts {
|
||||
wildcardDirectories: {},
|
||||
};
|
||||
const actual = ts.parseJsonConfigFileContent(json, caseInsensitiveHost, caseInsensitiveBasePath);
|
||||
assert.deepEqual(actual.fileNames, expected.fileNames);
|
||||
assert.deepEqual(actual.wildcardDirectories, expected.wildcardDirectories);
|
||||
assert.deepEqual(actual.errors, expected.errors);
|
||||
assertParsed(actual, expected);
|
||||
});
|
||||
it("missing files are still present", () => {
|
||||
const json = {
|
||||
@@ -131,9 +135,7 @@ namespace ts {
|
||||
wildcardDirectories: {},
|
||||
};
|
||||
const actual = ts.parseJsonConfigFileContent(json, caseInsensitiveHost, caseInsensitiveBasePath);
|
||||
assert.deepEqual(actual.fileNames, expected.fileNames);
|
||||
assert.deepEqual(actual.wildcardDirectories, expected.wildcardDirectories);
|
||||
assert.deepEqual(actual.errors, expected.errors);
|
||||
assertParsed(actual, expected);
|
||||
});
|
||||
it("are not removed due to excludes", () => {
|
||||
const json = {
|
||||
@@ -155,9 +157,7 @@ namespace ts {
|
||||
wildcardDirectories: {},
|
||||
};
|
||||
const actual = ts.parseJsonConfigFileContent(json, caseInsensitiveHost, caseInsensitiveBasePath);
|
||||
assert.deepEqual(actual.fileNames, expected.fileNames);
|
||||
assert.deepEqual(actual.wildcardDirectories, expected.wildcardDirectories);
|
||||
assert.deepEqual(actual.errors, expected.errors);
|
||||
assertParsed(actual, expected);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -179,9 +179,7 @@ namespace ts {
|
||||
wildcardDirectories: {},
|
||||
};
|
||||
const actual = ts.parseJsonConfigFileContent(json, caseInsensitiveHost, caseInsensitiveBasePath);
|
||||
assert.deepEqual(actual.fileNames, expected.fileNames);
|
||||
assert.deepEqual(actual.wildcardDirectories, expected.wildcardDirectories);
|
||||
assert.deepEqual(actual.errors, expected.errors);
|
||||
assertParsed(actual, expected);
|
||||
});
|
||||
it("with non .ts file extensions are excluded", () => {
|
||||
const json = {
|
||||
@@ -200,9 +198,7 @@ namespace ts {
|
||||
wildcardDirectories: {},
|
||||
};
|
||||
const actual = ts.parseJsonConfigFileContent(json, caseInsensitiveHost, caseInsensitiveBasePath, undefined, caseInsensitiveTsconfigPath);
|
||||
assert.deepEqual(actual.fileNames, expected.fileNames);
|
||||
assert.deepEqual(actual.wildcardDirectories, expected.wildcardDirectories);
|
||||
assert.deepEqual(actual.errors, expected.errors);
|
||||
assertParsed(actual, expected);
|
||||
});
|
||||
it("with missing files are excluded", () => {
|
||||
const json = {
|
||||
@@ -221,9 +217,7 @@ namespace ts {
|
||||
wildcardDirectories: {},
|
||||
};
|
||||
const actual = ts.parseJsonConfigFileContent(json, caseInsensitiveHost, caseInsensitiveBasePath, undefined, caseInsensitiveTsconfigPath);
|
||||
assert.deepEqual(actual.fileNames, expected.fileNames);
|
||||
assert.deepEqual(actual.wildcardDirectories, expected.wildcardDirectories);
|
||||
assert.deepEqual(actual.errors, expected.errors);
|
||||
assertParsed(actual, expected);
|
||||
});
|
||||
it("with literal excludes", () => {
|
||||
const json = {
|
||||
@@ -244,9 +238,7 @@ namespace ts {
|
||||
wildcardDirectories: {},
|
||||
};
|
||||
const actual = ts.parseJsonConfigFileContent(json, caseInsensitiveHost, caseInsensitiveBasePath);
|
||||
assert.deepEqual(actual.fileNames, expected.fileNames);
|
||||
assert.deepEqual(actual.wildcardDirectories, expected.wildcardDirectories);
|
||||
assert.deepEqual(actual.errors, expected.errors);
|
||||
assertParsed(actual, expected);
|
||||
});
|
||||
it("with wildcard excludes", () => {
|
||||
const json = {
|
||||
@@ -274,9 +266,7 @@ namespace ts {
|
||||
wildcardDirectories: {},
|
||||
};
|
||||
const actual = ts.parseJsonConfigFileContent(json, caseInsensitiveHost, caseInsensitiveBasePath);
|
||||
assert.deepEqual(actual.fileNames, expected.fileNames);
|
||||
assert.deepEqual(actual.wildcardDirectories, expected.wildcardDirectories);
|
||||
assert.deepEqual(actual.errors, expected.errors);
|
||||
assertParsed(actual, expected);
|
||||
});
|
||||
it("with recursive excludes", () => {
|
||||
const json = {
|
||||
@@ -303,9 +293,7 @@ namespace ts {
|
||||
wildcardDirectories: {},
|
||||
};
|
||||
const actual = ts.parseJsonConfigFileContent(json, caseInsensitiveHost, caseInsensitiveBasePath);
|
||||
assert.deepEqual(actual.fileNames, expected.fileNames);
|
||||
assert.deepEqual(actual.wildcardDirectories, expected.wildcardDirectories);
|
||||
assert.deepEqual(actual.errors, expected.errors);
|
||||
assertParsed(actual, expected);
|
||||
});
|
||||
it("with case sensitive exclude", () => {
|
||||
const json = {
|
||||
@@ -325,9 +313,7 @@ namespace ts {
|
||||
wildcardDirectories: {},
|
||||
};
|
||||
const actual = ts.parseJsonConfigFileContent(json, caseSensitiveHost, caseSensitiveBasePath);
|
||||
assert.deepEqual(actual.fileNames, expected.fileNames);
|
||||
assert.deepEqual(actual.wildcardDirectories, expected.wildcardDirectories);
|
||||
assert.deepEqual(actual.errors, expected.errors);
|
||||
assertParsed(actual, expected);
|
||||
});
|
||||
it("with common package folders and no exclusions", () => {
|
||||
const json = {
|
||||
@@ -349,9 +335,7 @@ namespace ts {
|
||||
wildcardDirectories: {},
|
||||
};
|
||||
const actual = ts.parseJsonConfigFileContent(json, caseInsensitiveCommonFoldersHost, caseInsensitiveBasePath);
|
||||
assert.deepEqual(actual.fileNames, expected.fileNames);
|
||||
assert.deepEqual(actual.wildcardDirectories, expected.wildcardDirectories);
|
||||
assert.deepEqual(actual.errors, expected.errors);
|
||||
assertParsed(actual, expected);
|
||||
});
|
||||
it("with common package folders and exclusions", () => {
|
||||
const json = {
|
||||
@@ -378,9 +362,7 @@ namespace ts {
|
||||
wildcardDirectories: {},
|
||||
};
|
||||
const actual = ts.parseJsonConfigFileContent(json, caseInsensitiveCommonFoldersHost, caseInsensitiveBasePath);
|
||||
assert.deepEqual(actual.fileNames, expected.fileNames);
|
||||
assert.deepEqual(actual.wildcardDirectories, expected.wildcardDirectories);
|
||||
assert.deepEqual(actual.errors, expected.errors);
|
||||
assertParsed(actual, expected);
|
||||
});
|
||||
it("with common package folders and empty exclude", () => {
|
||||
const json = {
|
||||
@@ -406,9 +388,7 @@ namespace ts {
|
||||
wildcardDirectories: {},
|
||||
};
|
||||
const actual = ts.parseJsonConfigFileContent(json, caseInsensitiveCommonFoldersHost, caseInsensitiveBasePath);
|
||||
assert.deepEqual(actual.fileNames, expected.fileNames);
|
||||
assert.deepEqual(actual.wildcardDirectories, expected.wildcardDirectories);
|
||||
assert.deepEqual(actual.errors, expected.errors);
|
||||
assertParsed(actual, expected);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -432,9 +412,7 @@ namespace ts {
|
||||
},
|
||||
};
|
||||
const actual = ts.parseJsonConfigFileContent(json, caseInsensitiveHost, caseInsensitiveBasePath);
|
||||
assert.deepEqual(actual.fileNames, expected.fileNames);
|
||||
assert.deepEqual(actual.wildcardDirectories, expected.wildcardDirectories);
|
||||
assert.deepEqual(actual.errors, expected.errors);
|
||||
assertParsed(actual, expected);
|
||||
});
|
||||
it("`*` matches only ts files", () => {
|
||||
const json = {
|
||||
@@ -455,9 +433,7 @@ namespace ts {
|
||||
},
|
||||
};
|
||||
const actual = ts.parseJsonConfigFileContent(json, caseInsensitiveHost, caseInsensitiveBasePath);
|
||||
assert.deepEqual(actual.fileNames, expected.fileNames);
|
||||
assert.deepEqual(actual.wildcardDirectories, expected.wildcardDirectories);
|
||||
assert.deepEqual(actual.errors, expected.errors);
|
||||
assertParsed(actual, expected);
|
||||
});
|
||||
it("`?` matches only a single character", () => {
|
||||
const json = {
|
||||
@@ -477,9 +453,7 @@ namespace ts {
|
||||
},
|
||||
};
|
||||
const actual = ts.parseJsonConfigFileContent(json, caseInsensitiveHost, caseInsensitiveBasePath);
|
||||
assert.deepEqual(actual.fileNames, expected.fileNames);
|
||||
assert.deepEqual(actual.wildcardDirectories, expected.wildcardDirectories);
|
||||
assert.deepEqual(actual.errors, expected.errors);
|
||||
assertParsed(actual, expected);
|
||||
});
|
||||
it("with recursive directory", () => {
|
||||
const json = {
|
||||
@@ -501,9 +475,7 @@ namespace ts {
|
||||
},
|
||||
};
|
||||
const actual = ts.parseJsonConfigFileContent(json, caseInsensitiveHost, caseInsensitiveBasePath);
|
||||
assert.deepEqual(actual.fileNames, expected.fileNames);
|
||||
assert.deepEqual(actual.wildcardDirectories, expected.wildcardDirectories);
|
||||
assert.deepEqual(actual.errors, expected.errors);
|
||||
assertParsed(actual, expected);
|
||||
});
|
||||
it("with multiple recursive directories", () => {
|
||||
const json = {
|
||||
@@ -527,9 +499,7 @@ namespace ts {
|
||||
},
|
||||
};
|
||||
const actual = ts.parseJsonConfigFileContent(json, caseInsensitiveHost, caseInsensitiveBasePath);
|
||||
assert.deepEqual(actual.fileNames, expected.fileNames);
|
||||
assert.deepEqual(actual.wildcardDirectories, expected.wildcardDirectories);
|
||||
assert.deepEqual(actual.errors, expected.errors);
|
||||
assertParsed(actual, expected);
|
||||
});
|
||||
it("case sensitive", () => {
|
||||
const json = {
|
||||
@@ -548,9 +518,7 @@ namespace ts {
|
||||
},
|
||||
};
|
||||
const actual = ts.parseJsonConfigFileContent(json, caseSensitiveHost, caseSensitiveBasePath);
|
||||
assert.deepEqual(actual.fileNames, expected.fileNames);
|
||||
assert.deepEqual(actual.wildcardDirectories, expected.wildcardDirectories);
|
||||
assert.deepEqual(actual.errors, expected.errors);
|
||||
assertParsed(actual, expected);
|
||||
});
|
||||
it("with missing files are excluded", () => {
|
||||
const json = {
|
||||
@@ -570,9 +538,7 @@ namespace ts {
|
||||
},
|
||||
};
|
||||
const actual = ts.parseJsonConfigFileContent(json, caseInsensitiveHost, caseInsensitiveBasePath, undefined, caseInsensitiveTsconfigPath);
|
||||
assert.deepEqual(actual.fileNames, expected.fileNames);
|
||||
assert.deepEqual(actual.wildcardDirectories, expected.wildcardDirectories);
|
||||
assert.deepEqual(actual.errors, expected.errors);
|
||||
assertParsed(actual, expected);
|
||||
});
|
||||
it("always include literal files", () => {
|
||||
const json = {
|
||||
@@ -597,9 +563,7 @@ namespace ts {
|
||||
},
|
||||
};
|
||||
const actual = ts.parseJsonConfigFileContent(json, caseInsensitiveHost, caseInsensitiveBasePath);
|
||||
assert.deepEqual(actual.fileNames, expected.fileNames);
|
||||
assert.deepEqual(actual.wildcardDirectories, expected.wildcardDirectories);
|
||||
assert.deepEqual(actual.errors, expected.errors);
|
||||
assertParsed(actual, expected);
|
||||
});
|
||||
it("exclude folders", () => {
|
||||
const json = {
|
||||
@@ -624,9 +588,7 @@ namespace ts {
|
||||
}
|
||||
};
|
||||
const actual = ts.parseJsonConfigFileContent(json, caseInsensitiveHost, caseInsensitiveBasePath);
|
||||
assert.deepEqual(actual.fileNames, expected.fileNames);
|
||||
assert.deepEqual(actual.wildcardDirectories, expected.wildcardDirectories);
|
||||
assert.deepEqual(actual.errors, expected.errors);
|
||||
assertParsed(actual, expected);
|
||||
});
|
||||
it("with common package folders and no exclusions", () => {
|
||||
const json = {
|
||||
@@ -645,9 +607,7 @@ namespace ts {
|
||||
},
|
||||
};
|
||||
const actual = ts.parseJsonConfigFileContent(json, caseInsensitiveCommonFoldersHost, caseInsensitiveBasePath);
|
||||
assert.deepEqual(actual.fileNames, expected.fileNames);
|
||||
assert.deepEqual(actual.wildcardDirectories, expected.wildcardDirectories);
|
||||
assert.deepEqual(actual.errors, expected.errors);
|
||||
assertParsed(actual, expected);
|
||||
});
|
||||
it("with common package folders and exclusions", () => {
|
||||
const json = {
|
||||
@@ -671,9 +631,7 @@ namespace ts {
|
||||
},
|
||||
};
|
||||
const actual = ts.parseJsonConfigFileContent(json, caseInsensitiveCommonFoldersHost, caseInsensitiveBasePath);
|
||||
assert.deepEqual(actual.fileNames, expected.fileNames);
|
||||
assert.deepEqual(actual.wildcardDirectories, expected.wildcardDirectories);
|
||||
assert.deepEqual(actual.errors, expected.errors);
|
||||
assertParsed(actual, expected);
|
||||
});
|
||||
it("with common package folders and empty exclude", () => {
|
||||
const json = {
|
||||
@@ -696,9 +654,7 @@ namespace ts {
|
||||
},
|
||||
};
|
||||
const actual = ts.parseJsonConfigFileContent(json, caseInsensitiveCommonFoldersHost, caseInsensitiveBasePath);
|
||||
assert.deepEqual(actual.fileNames, expected.fileNames);
|
||||
assert.deepEqual(actual.wildcardDirectories, expected.wildcardDirectories);
|
||||
assert.deepEqual(actual.errors, expected.errors);
|
||||
assertParsed(actual, expected);
|
||||
});
|
||||
it("exclude .js files when allowJs=false", () => {
|
||||
const json = {
|
||||
@@ -723,9 +679,7 @@ namespace ts {
|
||||
}
|
||||
};
|
||||
const actual = ts.parseJsonConfigFileContent(json, caseInsensitiveHost, caseInsensitiveBasePath, undefined, caseInsensitiveTsconfigPath);
|
||||
assert.deepEqual(actual.fileNames, expected.fileNames);
|
||||
assert.deepEqual(actual.wildcardDirectories, expected.wildcardDirectories);
|
||||
assert.deepEqual(actual.errors, expected.errors);
|
||||
assertParsed(actual, expected);
|
||||
});
|
||||
it("include .js files when allowJs=true", () => {
|
||||
const json = {
|
||||
@@ -750,9 +704,7 @@ namespace ts {
|
||||
}
|
||||
};
|
||||
const actual = ts.parseJsonConfigFileContent(json, caseInsensitiveHost, caseInsensitiveBasePath);
|
||||
assert.deepEqual(actual.fileNames, expected.fileNames);
|
||||
assert.deepEqual(actual.wildcardDirectories, expected.wildcardDirectories);
|
||||
assert.deepEqual(actual.errors, expected.errors);
|
||||
assertParsed(actual, expected);
|
||||
});
|
||||
it("include explicitly listed .min.js files when allowJs=true", () => {
|
||||
const json = {
|
||||
@@ -777,9 +729,7 @@ namespace ts {
|
||||
}
|
||||
};
|
||||
const actual = ts.parseJsonConfigFileContent(json, caseInsensitiveHost, caseInsensitiveBasePath);
|
||||
assert.deepEqual(actual.fileNames, expected.fileNames);
|
||||
assert.deepEqual(actual.wildcardDirectories, expected.wildcardDirectories);
|
||||
assert.deepEqual(actual.errors, expected.errors);
|
||||
assertParsed(actual, expected);
|
||||
});
|
||||
it("include paths outside of the project", () => {
|
||||
const json = {
|
||||
@@ -803,9 +753,7 @@ namespace ts {
|
||||
}
|
||||
};
|
||||
const actual = ts.parseJsonConfigFileContent(json, caseInsensitiveHost, caseInsensitiveBasePath);
|
||||
assert.deepEqual(actual.fileNames, expected.fileNames);
|
||||
assert.deepEqual(actual.wildcardDirectories, expected.wildcardDirectories);
|
||||
assert.deepEqual(actual.errors, expected.errors);
|
||||
assertParsed(actual, expected);
|
||||
});
|
||||
it("include paths outside of the project using relative paths", () => {
|
||||
const json = {
|
||||
@@ -828,9 +776,7 @@ namespace ts {
|
||||
}
|
||||
};
|
||||
const actual = ts.parseJsonConfigFileContent(json, caseInsensitiveHost, caseInsensitiveBasePath);
|
||||
assert.deepEqual(actual.fileNames, expected.fileNames);
|
||||
assert.deepEqual(actual.wildcardDirectories, expected.wildcardDirectories);
|
||||
assert.deepEqual(actual.errors, expected.errors);
|
||||
assertParsed(actual, expected);
|
||||
});
|
||||
it("exclude paths outside of the project using relative paths", () => {
|
||||
const json = {
|
||||
@@ -851,9 +797,7 @@ namespace ts {
|
||||
wildcardDirectories: {}
|
||||
};
|
||||
const actual = ts.parseJsonConfigFileContent(json, caseInsensitiveHost, caseInsensitiveBasePath, undefined, caseInsensitiveTsconfigPath);
|
||||
assert.deepEqual(actual.fileNames, expected.fileNames);
|
||||
assert.deepEqual(actual.wildcardDirectories, expected.wildcardDirectories);
|
||||
assert.deepEqual(actual.errors, expected.errors);
|
||||
assertParsed(actual, expected);
|
||||
});
|
||||
it("include files with .. in their name", () => {
|
||||
const json = {
|
||||
@@ -873,9 +817,7 @@ namespace ts {
|
||||
wildcardDirectories: {}
|
||||
};
|
||||
const actual = ts.parseJsonConfigFileContent(json, caseInsensitiveHost, caseInsensitiveBasePath);
|
||||
assert.deepEqual(actual.fileNames, expected.fileNames);
|
||||
assert.deepEqual(actual.wildcardDirectories, expected.wildcardDirectories);
|
||||
assert.deepEqual(actual.errors, expected.errors);
|
||||
assertParsed(actual, expected);
|
||||
});
|
||||
it("exclude files with .. in their name", () => {
|
||||
const json = {
|
||||
@@ -897,9 +839,7 @@ namespace ts {
|
||||
}
|
||||
};
|
||||
const actual = ts.parseJsonConfigFileContent(json, caseInsensitiveHost, caseInsensitiveBasePath);
|
||||
assert.deepEqual(actual.fileNames, expected.fileNames);
|
||||
assert.deepEqual(actual.wildcardDirectories, expected.wildcardDirectories);
|
||||
assert.deepEqual(actual.errors, expected.errors);
|
||||
assertParsed(actual, expected);
|
||||
});
|
||||
it("with jsx=none, allowJs=false", () => {
|
||||
const json = {
|
||||
@@ -922,9 +862,7 @@ namespace ts {
|
||||
}
|
||||
};
|
||||
const actual = ts.parseJsonConfigFileContent(json, caseInsensitiveMixedExtensionHost, caseInsensitiveBasePath);
|
||||
assert.deepEqual(actual.fileNames, expected.fileNames);
|
||||
assert.deepEqual(actual.wildcardDirectories, expected.wildcardDirectories);
|
||||
assert.deepEqual(actual.errors, expected.errors);
|
||||
assertParsed(actual, expected);
|
||||
});
|
||||
it("with jsx=preserve, allowJs=false", () => {
|
||||
const json = {
|
||||
@@ -949,9 +887,7 @@ namespace ts {
|
||||
}
|
||||
};
|
||||
const actual = ts.parseJsonConfigFileContent(json, caseInsensitiveMixedExtensionHost, caseInsensitiveBasePath);
|
||||
assert.deepEqual(actual.fileNames, expected.fileNames);
|
||||
assert.deepEqual(actual.wildcardDirectories, expected.wildcardDirectories);
|
||||
assert.deepEqual(actual.errors, expected.errors);
|
||||
assertParsed(actual, expected);
|
||||
});
|
||||
it("with jsx=none, allowJs=true", () => {
|
||||
const json = {
|
||||
@@ -976,9 +912,7 @@ namespace ts {
|
||||
}
|
||||
};
|
||||
const actual = ts.parseJsonConfigFileContent(json, caseInsensitiveMixedExtensionHost, caseInsensitiveBasePath);
|
||||
assert.deepEqual(actual.fileNames, expected.fileNames);
|
||||
assert.deepEqual(actual.wildcardDirectories, expected.wildcardDirectories);
|
||||
assert.deepEqual(actual.errors, expected.errors);
|
||||
assertParsed(actual, expected);
|
||||
});
|
||||
it("with jsx=preserve, allowJs=true", () => {
|
||||
const json = {
|
||||
@@ -1005,9 +939,7 @@ namespace ts {
|
||||
}
|
||||
};
|
||||
const actual = ts.parseJsonConfigFileContent(json, caseInsensitiveMixedExtensionHost, caseInsensitiveBasePath);
|
||||
assert.deepEqual(actual.fileNames, expected.fileNames);
|
||||
assert.deepEqual(actual.wildcardDirectories, expected.wildcardDirectories);
|
||||
assert.deepEqual(actual.errors, expected.errors);
|
||||
assertParsed(actual, expected);
|
||||
});
|
||||
it("exclude .min.js files using wildcards", () => {
|
||||
const json = {
|
||||
@@ -1034,9 +966,7 @@ namespace ts {
|
||||
}
|
||||
};
|
||||
const actual = ts.parseJsonConfigFileContent(json, caseInsensitiveHost, caseInsensitiveBasePath);
|
||||
assert.deepEqual(actual.fileNames, expected.fileNames);
|
||||
assert.deepEqual(actual.wildcardDirectories, expected.wildcardDirectories);
|
||||
assert.deepEqual(actual.errors, expected.errors);
|
||||
assertParsed(actual, expected);
|
||||
});
|
||||
describe("with trailing recursive directory", () => {
|
||||
it("in includes", () => {
|
||||
@@ -1056,9 +986,7 @@ namespace ts {
|
||||
wildcardDirectories: {}
|
||||
};
|
||||
const actual = ts.parseJsonConfigFileContent(json, caseInsensitiveHost, caseInsensitiveBasePath, undefined, caseInsensitiveTsconfigPath);
|
||||
assert.deepEqual(actual.fileNames, expected.fileNames);
|
||||
assert.deepEqual(actual.wildcardDirectories, expected.wildcardDirectories);
|
||||
assert.deepEqual(actual.errors, expected.errors);
|
||||
assertParsed(actual, expected);
|
||||
});
|
||||
it("in excludes", () => {
|
||||
const json = {
|
||||
@@ -1079,9 +1007,7 @@ namespace ts {
|
||||
wildcardDirectories: {}
|
||||
};
|
||||
const actual = ts.parseJsonConfigFileContent(json, caseInsensitiveHost, caseInsensitiveBasePath, undefined, caseInsensitiveTsconfigPath);
|
||||
assert.deepEqual(actual.fileNames, expected.fileNames);
|
||||
assert.deepEqual(actual.wildcardDirectories, expected.wildcardDirectories);
|
||||
assert.deepEqual(actual.errors, expected.errors);
|
||||
assertParsed(actual, expected);
|
||||
});
|
||||
});
|
||||
describe("with multiple recursive directory patterns", () => {
|
||||
@@ -1102,9 +1028,7 @@ namespace ts {
|
||||
wildcardDirectories: {}
|
||||
};
|
||||
const actual = ts.parseJsonConfigFileContent(json, caseInsensitiveHost, caseInsensitiveBasePath, undefined, caseInsensitiveTsconfigPath);
|
||||
assert.deepEqual(actual.fileNames, expected.fileNames);
|
||||
assert.deepEqual(actual.wildcardDirectories, expected.wildcardDirectories);
|
||||
assert.deepEqual(actual.errors, expected.errors);
|
||||
assertParsed(actual, expected);
|
||||
});
|
||||
it("in excludes", () => {
|
||||
const json = {
|
||||
@@ -1131,9 +1055,7 @@ namespace ts {
|
||||
}
|
||||
};
|
||||
const actual = ts.parseJsonConfigFileContent(json, caseInsensitiveHost, caseInsensitiveBasePath);
|
||||
assert.deepEqual(actual.fileNames, expected.fileNames);
|
||||
assert.deepEqual(actual.wildcardDirectories, expected.wildcardDirectories);
|
||||
assert.deepEqual(actual.errors, expected.errors);
|
||||
assertParsed(actual, expected);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1155,9 +1077,7 @@ namespace ts {
|
||||
wildcardDirectories: {}
|
||||
};
|
||||
const actual = ts.parseJsonConfigFileContent(json, caseInsensitiveHost, caseInsensitiveBasePath, undefined, caseInsensitiveTsconfigPath);
|
||||
assert.deepEqual(actual.fileNames, expected.fileNames);
|
||||
assert.deepEqual(actual.wildcardDirectories, expected.wildcardDirectories);
|
||||
assert.deepEqual(actual.errors, expected.errors);
|
||||
assertParsed(actual, expected);
|
||||
});
|
||||
|
||||
it("in includes after a subdirectory", () => {
|
||||
@@ -1177,9 +1097,7 @@ namespace ts {
|
||||
wildcardDirectories: {}
|
||||
};
|
||||
const actual = ts.parseJsonConfigFileContent(json, caseInsensitiveHost, caseInsensitiveBasePath, undefined, caseInsensitiveTsconfigPath);
|
||||
assert.deepEqual(actual.fileNames, expected.fileNames);
|
||||
assert.deepEqual(actual.wildcardDirectories, expected.wildcardDirectories);
|
||||
assert.deepEqual(actual.errors, expected.errors);
|
||||
assertParsed(actual, expected);
|
||||
});
|
||||
|
||||
it("in excludes immediately after", () => {
|
||||
@@ -1207,9 +1125,7 @@ namespace ts {
|
||||
}
|
||||
};
|
||||
const actual = ts.parseJsonConfigFileContent(json, caseInsensitiveHost, caseInsensitiveBasePath);
|
||||
assert.deepEqual(actual.fileNames, expected.fileNames);
|
||||
assert.deepEqual(actual.wildcardDirectories, expected.wildcardDirectories);
|
||||
assert.deepEqual(actual.errors, expected.errors);
|
||||
assertParsed(actual, expected);
|
||||
});
|
||||
|
||||
it("in excludes after a subdirectory", () => {
|
||||
@@ -1237,9 +1153,25 @@ namespace ts {
|
||||
}
|
||||
};
|
||||
const actual = ts.parseJsonConfigFileContent(json, caseInsensitiveHost, caseInsensitiveBasePath);
|
||||
assert.deepEqual(actual.fileNames, expected.fileNames);
|
||||
assert.deepEqual(actual.wildcardDirectories, expected.wildcardDirectories);
|
||||
assert.deepEqual(actual.errors, expected.errors);
|
||||
assertParsed(actual, expected);
|
||||
});
|
||||
});
|
||||
|
||||
describe("with implicit globbification", () => {
|
||||
it("Expands 'z' to 'z/**/*'", () => {
|
||||
const json = {
|
||||
include: ["z"]
|
||||
};
|
||||
const expected: ts.ParsedCommandLine = {
|
||||
options: {},
|
||||
errors: [],
|
||||
fileNames: [ "a.ts", "aba.ts", "abz.ts", "b.ts", "bba.ts", "bbz.ts" ].map(x => `c:/dev/z/${x}`),
|
||||
wildcardDirectories: {
|
||||
"c:/dev/z": ts.WatchDirectoryFlags.Recursive
|
||||
}
|
||||
};
|
||||
const actual = ts.parseJsonConfigFileContent(json, caseInsensitiveHost, caseInsensitiveBasePath);
|
||||
assertParsed(actual, expected);
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -1264,9 +1196,7 @@ namespace ts {
|
||||
}
|
||||
};
|
||||
const actual = ts.parseJsonConfigFileContent(json, caseInsensitiveDottedFoldersHost, caseInsensitiveBasePath);
|
||||
assert.deepEqual(actual.fileNames, expected.fileNames);
|
||||
assert.deepEqual(actual.wildcardDirectories, expected.wildcardDirectories);
|
||||
assert.deepEqual(actual.errors, expected.errors);
|
||||
assertParsed(actual, expected);
|
||||
});
|
||||
describe("that are explicitly included", () => {
|
||||
it("without wildcards", () => {
|
||||
@@ -1286,9 +1216,7 @@ namespace ts {
|
||||
wildcardDirectories: {}
|
||||
};
|
||||
const actual = ts.parseJsonConfigFileContent(json, caseInsensitiveDottedFoldersHost, caseInsensitiveBasePath);
|
||||
assert.deepEqual(actual.fileNames, expected.fileNames);
|
||||
assert.deepEqual(actual.wildcardDirectories, expected.wildcardDirectories);
|
||||
assert.deepEqual(actual.errors, expected.errors);
|
||||
assertParsed(actual, expected);
|
||||
});
|
||||
it("with recursive wildcards that match directories", () => {
|
||||
const json = {
|
||||
@@ -1310,9 +1238,7 @@ namespace ts {
|
||||
}
|
||||
};
|
||||
const actual = ts.parseJsonConfigFileContent(json, caseInsensitiveDottedFoldersHost, caseInsensitiveBasePath);
|
||||
assert.deepEqual(actual.fileNames, expected.fileNames);
|
||||
assert.deepEqual(actual.wildcardDirectories, expected.wildcardDirectories);
|
||||
assert.deepEqual(actual.errors, expected.errors);
|
||||
assertParsed(actual, expected);
|
||||
});
|
||||
it("with recursive wildcards that match nothing", () => {
|
||||
const json = {
|
||||
@@ -1334,9 +1260,7 @@ namespace ts {
|
||||
}
|
||||
};
|
||||
const actual = ts.parseJsonConfigFileContent(json, caseInsensitiveDottedFoldersHost, caseInsensitiveBasePath);
|
||||
assert.deepEqual(actual.fileNames, expected.fileNames);
|
||||
assert.deepEqual(actual.wildcardDirectories, expected.wildcardDirectories);
|
||||
assert.deepEqual(actual.errors, expected.errors);
|
||||
assertParsed(actual, expected);
|
||||
});
|
||||
it("with wildcard excludes that implicitly exclude dotted files", () => {
|
||||
const json = {
|
||||
@@ -1357,9 +1281,7 @@ namespace ts {
|
||||
wildcardDirectories: {}
|
||||
};
|
||||
const actual = ts.parseJsonConfigFileContent(json, caseInsensitiveDottedFoldersHost, caseInsensitiveBasePath, undefined, caseInsensitiveTsconfigPath);
|
||||
assert.deepEqual(actual.fileNames, expected.fileNames);
|
||||
assert.deepEqual(actual.wildcardDirectories, expected.wildcardDirectories);
|
||||
assert.deepEqual(actual.errors, expected.errors);
|
||||
assertParsed(actual, expected);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/// <reference path="..\harness.ts" />
|
||||
|
||||
namespace ts {
|
||||
export function checkResolvedModule(expected: ResolvedModule, actual: ResolvedModule): boolean {
|
||||
export function checkResolvedModule(expected: ResolvedModuleFull, actual: ResolvedModuleFull): boolean {
|
||||
if (!expected === !actual) {
|
||||
if (expected) {
|
||||
assert.isTrue(expected.resolvedFileName === actual.resolvedFileName, `'resolvedFileName': expected '${expected.resolvedFileName}' to be equal to '${actual.resolvedFileName}'`);
|
||||
@@ -13,13 +13,13 @@ namespace ts {
|
||||
return false;
|
||||
}
|
||||
|
||||
export function checkResolvedModuleWithFailedLookupLocations(actual: ResolvedModuleWithFailedLookupLocations, expectedResolvedModule: ResolvedModule, expectedFailedLookupLocations: string[]): void {
|
||||
export function checkResolvedModuleWithFailedLookupLocations(actual: ResolvedModuleWithFailedLookupLocations, expectedResolvedModule: ResolvedModuleFull, expectedFailedLookupLocations: string[]): void {
|
||||
assert.isTrue(actual.resolvedModule !== undefined, "module should be resolved");
|
||||
checkResolvedModule(actual.resolvedModule, expectedResolvedModule);
|
||||
assert.deepEqual(actual.failedLookupLocations, expectedFailedLookupLocations);
|
||||
}
|
||||
|
||||
export function createResolvedModule(resolvedFileName: string, isExternalLibraryImport = false): ResolvedModule {
|
||||
export function createResolvedModule(resolvedFileName: string, isExternalLibraryImport = false): ResolvedModuleFull {
|
||||
return { resolvedFileName, extension: extensionFromPath(resolvedFileName), isExternalLibraryImport };
|
||||
}
|
||||
|
||||
|
||||
@@ -150,7 +150,8 @@ namespace ts.server {
|
||||
target: ScriptTarget.ES5,
|
||||
jsx: JsxEmit.React,
|
||||
newLine: NewLineKind.LineFeed,
|
||||
moduleResolution: ModuleResolutionKind.NodeJs
|
||||
moduleResolution: ModuleResolutionKind.NodeJs,
|
||||
allowNonTsExtensions: true // injected by tsserver
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -2471,4 +2471,38 @@ namespace ts.projectSystem {
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
describe("Inferred projects", () => {
|
||||
it("should support files without extensions", () => {
|
||||
const f = {
|
||||
path: "/a/compile",
|
||||
content: "let x = 1"
|
||||
};
|
||||
const host = createServerHost([f]);
|
||||
const session = createSession(host);
|
||||
session.executeCommand(<server.protocol.SetCompilerOptionsForInferredProjectsRequest>{
|
||||
seq: 1,
|
||||
type: "request",
|
||||
command: "compilerOptionsForInferredProjects",
|
||||
arguments: {
|
||||
options: {
|
||||
allowJs: true
|
||||
}
|
||||
}
|
||||
});
|
||||
session.executeCommand(<server.protocol.OpenRequest>{
|
||||
seq: 2,
|
||||
type: "request",
|
||||
command: "open",
|
||||
arguments: {
|
||||
file: f.path,
|
||||
fileContent: f.content,
|
||||
scriptKindName: "JS"
|
||||
}
|
||||
});
|
||||
const projectService = session.getProjectService();
|
||||
checkNumberOfProjects(projectService, { inferredProjects: 1 });
|
||||
checkProjectActualFiles(projectService.inferredProjects[0], [f.path]);
|
||||
});
|
||||
});
|
||||
}
|
||||
Vendored
+16
-12
@@ -1679,6 +1679,7 @@ interface CSSStyleDeclaration {
|
||||
writingMode: string | null;
|
||||
zIndex: string | null;
|
||||
zoom: string | null;
|
||||
resize: string | null;
|
||||
getPropertyPriority(propertyName: string): string;
|
||||
getPropertyValue(propertyName: string): string;
|
||||
item(index: number): string;
|
||||
@@ -1748,6 +1749,7 @@ declare var CanvasGradient: {
|
||||
}
|
||||
|
||||
interface CanvasPattern {
|
||||
setTransform(matrix: SVGMatrix): void;
|
||||
}
|
||||
|
||||
declare var CanvasPattern: {
|
||||
@@ -2173,7 +2175,7 @@ interface DataTransfer {
|
||||
effectAllowed: string;
|
||||
readonly files: FileList;
|
||||
readonly items: DataTransferItemList;
|
||||
readonly types: DOMStringList;
|
||||
readonly types: string[];
|
||||
clearData(format?: string): boolean;
|
||||
getData(format: string): string;
|
||||
setData(format: string, data: string): boolean;
|
||||
@@ -7584,7 +7586,7 @@ declare var IDBCursorWithValue: {
|
||||
|
||||
interface IDBDatabase extends EventTarget {
|
||||
readonly name: string;
|
||||
readonly objectStoreNames: DOMStringList;
|
||||
readonly objectStoreNames: string[];
|
||||
onabort: (this: this, ev: Event) => any;
|
||||
onerror: (this: this, ev: ErrorEvent) => any;
|
||||
version: number;
|
||||
@@ -7650,7 +7652,7 @@ declare var IDBKeyRange: {
|
||||
}
|
||||
|
||||
interface IDBObjectStore {
|
||||
readonly indexNames: DOMStringList;
|
||||
readonly indexNames: string[];
|
||||
keyPath: string | string[];
|
||||
readonly name: string;
|
||||
readonly transaction: IDBTransaction;
|
||||
@@ -8602,7 +8604,7 @@ interface MouseEvent extends UIEvent {
|
||||
readonly x: number;
|
||||
readonly y: number;
|
||||
getModifierState(keyArg: string): boolean;
|
||||
initMouseEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, viewArg: Window, detailArg: number, screenXArg: number, screenYArg: number, clientXArg: number, clientYArg: number, ctrlKeyArg: boolean, altKeyArg: boolean, shiftKeyArg: boolean, metaKeyArg: boolean, buttonArg: number, relatedTargetArg: EventTarget): void;
|
||||
initMouseEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, viewArg: Window, detailArg: number, screenXArg: number, screenYArg: number, clientXArg: number, clientYArg: number, ctrlKeyArg: boolean, altKeyArg: boolean, shiftKeyArg: boolean, metaKeyArg: boolean, buttonArg: number, relatedTargetArg: EventTarget | null): void;
|
||||
}
|
||||
|
||||
declare var MouseEvent: {
|
||||
@@ -8715,6 +8717,7 @@ interface Navigator extends Object, NavigatorID, NavigatorOnLine, NavigatorConte
|
||||
readonly plugins: PluginArray;
|
||||
readonly pointerEnabled: boolean;
|
||||
readonly webdriver: boolean;
|
||||
readonly hardwareConcurrency: number;
|
||||
getGamepads(): Gamepad[];
|
||||
javaEnabled(): boolean;
|
||||
msLaunchUri(uri: string, successCallback?: MSLaunchUriCallback, noHandlerCallback?: MSLaunchUriCallback): void;
|
||||
@@ -8732,18 +8735,18 @@ interface Node extends EventTarget {
|
||||
readonly attributes: NamedNodeMap;
|
||||
readonly baseURI: string | null;
|
||||
readonly childNodes: NodeList;
|
||||
readonly firstChild: Node;
|
||||
readonly lastChild: Node;
|
||||
readonly firstChild: Node | null;
|
||||
readonly lastChild: Node | null;
|
||||
readonly localName: string | null;
|
||||
readonly namespaceURI: string | null;
|
||||
readonly nextSibling: Node;
|
||||
readonly nextSibling: Node | null;
|
||||
readonly nodeName: string;
|
||||
readonly nodeType: number;
|
||||
nodeValue: string | null;
|
||||
readonly ownerDocument: Document;
|
||||
readonly parentElement: HTMLElement;
|
||||
readonly parentNode: Node;
|
||||
readonly previousSibling: Node;
|
||||
readonly parentElement: HTMLElement | null;
|
||||
readonly parentNode: Node | null;
|
||||
readonly previousSibling: Node | null;
|
||||
textContent: string | null;
|
||||
appendChild(newChild: Node): Node;
|
||||
cloneNode(deep?: boolean): Node;
|
||||
@@ -12853,7 +12856,7 @@ interface Window extends EventTarget, WindowTimers, WindowSessionStorage, Window
|
||||
readonly devicePixelRatio: number;
|
||||
readonly doNotTrack: string;
|
||||
readonly document: Document;
|
||||
event: Event;
|
||||
event: Event | undefined;
|
||||
readonly external: External;
|
||||
readonly frameElement: Element;
|
||||
readonly frames: Window;
|
||||
@@ -13155,6 +13158,7 @@ interface XMLHttpRequest extends EventTarget, XMLHttpRequestEventTarget {
|
||||
readonly upload: XMLHttpRequestUpload;
|
||||
withCredentials: boolean;
|
||||
msCaching?: string;
|
||||
readonly responseURL: string;
|
||||
abort(): void;
|
||||
getAllResponseHeaders(): string;
|
||||
getResponseHeader(header: string): string | null;
|
||||
@@ -14301,7 +14305,7 @@ declare var defaultStatus: string;
|
||||
declare var devicePixelRatio: number;
|
||||
declare var doNotTrack: string;
|
||||
declare var document: Document;
|
||||
declare var event: Event;
|
||||
declare var event: Event | undefined;
|
||||
declare var external: External;
|
||||
declare var frameElement: Element;
|
||||
declare var frames: Window;
|
||||
|
||||
Vendored
+4
-2
@@ -341,7 +341,7 @@ declare var IDBCursorWithValue: {
|
||||
|
||||
interface IDBDatabase extends EventTarget {
|
||||
readonly name: string;
|
||||
readonly objectStoreNames: DOMStringList;
|
||||
readonly objectStoreNames: string[];
|
||||
onabort: (this: this, ev: Event) => any;
|
||||
onerror: (this: this, ev: ErrorEvent) => any;
|
||||
version: number;
|
||||
@@ -407,7 +407,7 @@ declare var IDBKeyRange: {
|
||||
}
|
||||
|
||||
interface IDBObjectStore {
|
||||
readonly indexNames: DOMStringList;
|
||||
readonly indexNames: string[];
|
||||
keyPath: string | string[];
|
||||
readonly name: string;
|
||||
readonly transaction: IDBTransaction;
|
||||
@@ -740,6 +740,7 @@ interface XMLHttpRequest extends EventTarget, XMLHttpRequestEventTarget {
|
||||
readonly upload: XMLHttpRequestUpload;
|
||||
withCredentials: boolean;
|
||||
msCaching?: string;
|
||||
readonly responseURL: string;
|
||||
abort(): void;
|
||||
getAllResponseHeaders(): string;
|
||||
getResponseHeader(header: string): string | null;
|
||||
@@ -902,6 +903,7 @@ declare var WorkerLocation: {
|
||||
}
|
||||
|
||||
interface WorkerNavigator extends Object, NavigatorID, NavigatorOnLine {
|
||||
readonly hardwareConcurrency: number;
|
||||
addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void;
|
||||
}
|
||||
|
||||
|
||||
@@ -298,6 +298,9 @@ namespace ts.server {
|
||||
|
||||
setCompilerOptionsForInferredProjects(projectCompilerOptions: protocol.ExternalProjectCompilerOptions): void {
|
||||
this.compilerOptionsForInferredProjects = convertCompilerOptions(projectCompilerOptions);
|
||||
// always set 'allowNonTsExtensions' for inferred projects since user cannot configure it from the outside
|
||||
// previously we did not expose a way for user to change these settings and this option was enabled by default
|
||||
this.compilerOptionsForInferredProjects.allowNonTsExtensions = true;
|
||||
this.compileOnSaveForInferredProjects = projectCompilerOptions.compileOnSave;
|
||||
for (const proj of this.inferredProjects) {
|
||||
proj.setCompilerOptions(this.compilerOptionsForInferredProjects);
|
||||
@@ -1008,7 +1011,7 @@ namespace ts.server {
|
||||
const useExistingProject = this.useSingleInferredProject && this.inferredProjects.length;
|
||||
const project = useExistingProject
|
||||
? this.inferredProjects[0]
|
||||
: new InferredProject(this, this.documentRegistry, /*languageServiceEnabled*/ true, this.compilerOptionsForInferredProjects, /*compileOnSaveEnabled*/ this.compileOnSaveForInferredProjects);
|
||||
: new InferredProject(this, this.documentRegistry, /*languageServiceEnabled*/ true, this.compilerOptionsForInferredProjects);
|
||||
|
||||
project.addRoot(root);
|
||||
|
||||
|
||||
@@ -151,7 +151,7 @@ namespace ts.server {
|
||||
m => m.resolvedTypeReferenceDirective, r => r.resolvedFileName, /*logChanges*/ false);
|
||||
}
|
||||
|
||||
resolveModuleNames(moduleNames: string[], containingFile: string): ResolvedModule[] {
|
||||
resolveModuleNames(moduleNames: string[], containingFile: string): ResolvedModuleFull[] {
|
||||
return this.resolveNamesWithLocalCache(moduleNames, containingFile, this.resolvedModuleNames, this.resolveModuleName,
|
||||
m => m.resolvedModule, r => r.resolvedFileName, /*logChanges*/ true);
|
||||
}
|
||||
|
||||
@@ -666,14 +666,14 @@ namespace ts.server {
|
||||
// Used to keep track of what directories are watched for this project
|
||||
directoriesWatchedForTsconfig: string[] = [];
|
||||
|
||||
constructor(projectService: ProjectService, documentRegistry: ts.DocumentRegistry, languageServiceEnabled: boolean, compilerOptions: CompilerOptions, public compileOnSaveEnabled: boolean) {
|
||||
constructor(projectService: ProjectService, documentRegistry: ts.DocumentRegistry, languageServiceEnabled: boolean, compilerOptions: CompilerOptions) {
|
||||
super(ProjectKind.Inferred,
|
||||
projectService,
|
||||
documentRegistry,
|
||||
/*files*/ undefined,
|
||||
languageServiceEnabled,
|
||||
compilerOptions,
|
||||
compileOnSaveEnabled);
|
||||
/*compileOnSaveEnabled*/ false);
|
||||
|
||||
this.inferredProjectName = makeInferredProjectName(InferredProject.NextId);
|
||||
InferredProject.NextId++;
|
||||
|
||||
@@ -467,7 +467,7 @@ namespace ts {
|
||||
public languageVariant: LanguageVariant;
|
||||
public identifiers: Map<string>;
|
||||
public nameTable: Map<number>;
|
||||
public resolvedModules: Map<ResolvedModule>;
|
||||
public resolvedModules: Map<ResolvedModuleFull>;
|
||||
public resolvedTypeReferenceDirectiveNames: Map<ResolvedTypeReferenceDirective>;
|
||||
public imports: LiteralExpression[];
|
||||
public moduleAugmentations: LiteralExpression[];
|
||||
|
||||
@@ -316,7 +316,7 @@ namespace ts {
|
||||
private loggingEnabled = false;
|
||||
private tracingEnabled = false;
|
||||
|
||||
public resolveModuleNames: (moduleName: string[], containingFile: string) => ResolvedModule[];
|
||||
public resolveModuleNames: (moduleName: string[], containingFile: string) => ResolvedModuleFull[];
|
||||
public resolveTypeReferenceDirectives: (typeDirectiveNames: string[], containingFile: string) => ResolvedTypeReferenceDirective[];
|
||||
public directoryExists: (directoryName: string) => boolean;
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
tests/cases/conformance/statements/for-ofStatements/ES5For-of12.ts(1,7): error TS2364: Invalid left-hand side of assignment expression.
|
||||
tests/cases/conformance/statements/for-ofStatements/ES5For-of12.ts(1,7): error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
|
||||
|
||||
|
||||
==== tests/cases/conformance/statements/for-ofStatements/ES5For-of12.ts (1 errors) ====
|
||||
for ([""] of [[""]]) { }
|
||||
~~
|
||||
!!! error TS2364: Invalid left-hand side of assignment expression.
|
||||
!!! error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
|
||||
@@ -6,7 +6,7 @@ tests/cases/compiler/abstractPropertyNegative.ts(13,7): error TS2515: Non-abstra
|
||||
tests/cases/compiler/abstractPropertyNegative.ts(13,7): error TS2515: Non-abstract class 'C' does not implement inherited abstract member 'readonlyProp' from class 'B'.
|
||||
tests/cases/compiler/abstractPropertyNegative.ts(15,5): error TS1244: Abstract methods can only appear within an abstract class.
|
||||
tests/cases/compiler/abstractPropertyNegative.ts(16,37): error TS1005: '{' expected.
|
||||
tests/cases/compiler/abstractPropertyNegative.ts(19,1): error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
|
||||
tests/cases/compiler/abstractPropertyNegative.ts(19,3): error TS2540: Cannot assign to 'ro' because it is a constant or a read-only property.
|
||||
tests/cases/compiler/abstractPropertyNegative.ts(24,7): error TS2415: Class 'WrongTypePropertyImpl' incorrectly extends base class 'WrongTypeProperty'.
|
||||
Types of property 'num' are incompatible.
|
||||
Type 'string' is not assignable to type 'number'.
|
||||
@@ -58,8 +58,8 @@ tests/cases/compiler/abstractPropertyNegative.ts(41,18): error TS2676: Accessors
|
||||
}
|
||||
let c = new C();
|
||||
c.ro = "error: lhs of assignment can't be readonly";
|
||||
~~~~
|
||||
!!! error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
|
||||
~~
|
||||
!!! error TS2540: Cannot assign to 'ro' because it is a constant or a read-only property.
|
||||
|
||||
abstract class WrongTypeProperty {
|
||||
abstract num: number;
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
tests/cases/compiler/arithAssignTyping.ts(3,1): error TS2364: Invalid left-hand side of assignment expression.
|
||||
tests/cases/compiler/arithAssignTyping.ts(4,1): error TS2365: Operator '+=' cannot be applied to types 'typeof f' and '1'.
|
||||
tests/cases/compiler/arithAssignTyping.ts(5,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/compiler/arithAssignTyping.ts(6,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/compiler/arithAssignTyping.ts(7,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/compiler/arithAssignTyping.ts(8,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/compiler/arithAssignTyping.ts(9,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/compiler/arithAssignTyping.ts(10,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/compiler/arithAssignTyping.ts(11,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/compiler/arithAssignTyping.ts(12,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/compiler/arithAssignTyping.ts(13,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/compiler/arithAssignTyping.ts(14,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/compiler/arithAssignTyping.ts(3,1): error TS2539: Cannot assign to 'f' because it is not a variable.
|
||||
tests/cases/compiler/arithAssignTyping.ts(4,1): error TS2539: Cannot assign to 'f' because it is not a variable.
|
||||
tests/cases/compiler/arithAssignTyping.ts(5,1): error TS2539: Cannot assign to 'f' because it is not a variable.
|
||||
tests/cases/compiler/arithAssignTyping.ts(6,1): error TS2539: Cannot assign to 'f' because it is not a variable.
|
||||
tests/cases/compiler/arithAssignTyping.ts(7,1): error TS2539: Cannot assign to 'f' because it is not a variable.
|
||||
tests/cases/compiler/arithAssignTyping.ts(8,1): error TS2539: Cannot assign to 'f' because it is not a variable.
|
||||
tests/cases/compiler/arithAssignTyping.ts(9,1): error TS2539: Cannot assign to 'f' because it is not a variable.
|
||||
tests/cases/compiler/arithAssignTyping.ts(10,1): error TS2539: Cannot assign to 'f' because it is not a variable.
|
||||
tests/cases/compiler/arithAssignTyping.ts(11,1): error TS2539: Cannot assign to 'f' because it is not a variable.
|
||||
tests/cases/compiler/arithAssignTyping.ts(12,1): error TS2539: Cannot assign to 'f' because it is not a variable.
|
||||
tests/cases/compiler/arithAssignTyping.ts(13,1): error TS2539: Cannot assign to 'f' because it is not a variable.
|
||||
tests/cases/compiler/arithAssignTyping.ts(14,1): error TS2539: Cannot assign to 'f' because it is not a variable.
|
||||
|
||||
|
||||
==== tests/cases/compiler/arithAssignTyping.ts (12 errors) ====
|
||||
@@ -17,37 +17,37 @@ tests/cases/compiler/arithAssignTyping.ts(14,1): error TS2362: The left-hand sid
|
||||
|
||||
f += ''; // error
|
||||
~
|
||||
!!! error TS2364: Invalid left-hand side of assignment expression.
|
||||
!!! error TS2539: Cannot assign to 'f' because it is not a variable.
|
||||
f += 1; // error
|
||||
~~~~~~
|
||||
!!! error TS2365: Operator '+=' cannot be applied to types 'typeof f' and '1'.
|
||||
~
|
||||
!!! error TS2539: Cannot assign to 'f' because it is not a variable.
|
||||
f -= 1; // error
|
||||
~
|
||||
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
!!! error TS2539: Cannot assign to 'f' because it is not a variable.
|
||||
f *= 1; // error
|
||||
~
|
||||
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
!!! error TS2539: Cannot assign to 'f' because it is not a variable.
|
||||
f /= 1; // error
|
||||
~
|
||||
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
!!! error TS2539: Cannot assign to 'f' because it is not a variable.
|
||||
f %= 1; // error
|
||||
~
|
||||
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
!!! error TS2539: Cannot assign to 'f' because it is not a variable.
|
||||
f &= 1; // error
|
||||
~
|
||||
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
!!! error TS2539: Cannot assign to 'f' because it is not a variable.
|
||||
f |= 1; // error
|
||||
~
|
||||
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
!!! error TS2539: Cannot assign to 'f' because it is not a variable.
|
||||
f <<= 1; // error
|
||||
~
|
||||
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
!!! error TS2539: Cannot assign to 'f' because it is not a variable.
|
||||
f >>= 1; // error
|
||||
~
|
||||
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
!!! error TS2539: Cannot assign to 'f' because it is not a variable.
|
||||
f >>>= 1; // error
|
||||
~
|
||||
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
!!! error TS2539: Cannot assign to 'f' because it is not a variable.
|
||||
f ^= 1; // error
|
||||
~
|
||||
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
!!! error TS2539: Cannot assign to 'f' because it is not a variable.
|
||||
@@ -1,4 +1,4 @@
|
||||
tests/cases/conformance/types/any/assignAnyToEveryType.ts(41,1): error TS2364: Invalid left-hand side of assignment expression.
|
||||
tests/cases/conformance/types/any/assignAnyToEveryType.ts(41,1): error TS2539: Cannot assign to 'M' because it is not a variable.
|
||||
|
||||
|
||||
==== tests/cases/conformance/types/any/assignAnyToEveryType.ts (1 errors) ====
|
||||
@@ -44,7 +44,7 @@ tests/cases/conformance/types/any/assignAnyToEveryType.ts(41,1): error TS2364: I
|
||||
|
||||
M = x;
|
||||
~
|
||||
!!! error TS2364: Invalid left-hand side of assignment expression.
|
||||
!!! error TS2539: Cannot assign to 'M' because it is not a variable.
|
||||
|
||||
function k<T>(a: T) {
|
||||
a = x;
|
||||
|
||||
@@ -1,22 +1,22 @@
|
||||
tests/cases/compiler/assignToEnum.ts(2,1): error TS2364: Invalid left-hand side of assignment expression.
|
||||
tests/cases/compiler/assignToEnum.ts(3,1): error TS2364: Invalid left-hand side of assignment expression.
|
||||
tests/cases/compiler/assignToEnum.ts(4,1): error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
|
||||
tests/cases/compiler/assignToEnum.ts(5,1): error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
|
||||
tests/cases/compiler/assignToEnum.ts(2,1): error TS2539: Cannot assign to 'A' because it is not a variable.
|
||||
tests/cases/compiler/assignToEnum.ts(3,1): error TS2539: Cannot assign to 'A' because it is not a variable.
|
||||
tests/cases/compiler/assignToEnum.ts(4,3): error TS2540: Cannot assign to 'foo' because it is a constant or a read-only property.
|
||||
tests/cases/compiler/assignToEnum.ts(5,3): error TS2540: Cannot assign to 'foo' because it is a constant or a read-only property.
|
||||
|
||||
|
||||
==== tests/cases/compiler/assignToEnum.ts (4 errors) ====
|
||||
enum A { foo, bar }
|
||||
A = undefined; // invalid LHS
|
||||
~
|
||||
!!! error TS2364: Invalid left-hand side of assignment expression.
|
||||
!!! error TS2539: Cannot assign to 'A' because it is not a variable.
|
||||
A = A.bar; // invalid LHS
|
||||
~
|
||||
!!! error TS2364: Invalid left-hand side of assignment expression.
|
||||
!!! error TS2539: Cannot assign to 'A' because it is not a variable.
|
||||
A.foo = 1; // invalid LHS
|
||||
~~~~~
|
||||
!!! error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
|
||||
~~~
|
||||
!!! error TS2540: Cannot assign to 'foo' because it is a constant or a read-only property.
|
||||
A.foo = A.bar; // invalid LHS
|
||||
~~~~~
|
||||
!!! error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
|
||||
~~~
|
||||
!!! error TS2540: Cannot assign to 'foo' because it is a constant or a read-only property.
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
tests/cases/compiler/assignToExistingClass.ts(8,13): error TS2364: Invalid left-hand side of assignment expression.
|
||||
tests/cases/compiler/assignToExistingClass.ts(8,13): error TS2539: Cannot assign to 'Mocked' because it is not a variable.
|
||||
|
||||
|
||||
==== tests/cases/compiler/assignToExistingClass.ts (1 errors) ====
|
||||
@@ -11,7 +11,7 @@ tests/cases/compiler/assignToExistingClass.ts(8,13): error TS2364: Invalid left-
|
||||
willThrowError() {
|
||||
Mocked = Mocked || function () { // => Error: Invalid left-hand side of assignment expression.
|
||||
~~~~~~
|
||||
!!! error TS2364: Invalid left-hand side of assignment expression.
|
||||
!!! error TS2539: Cannot assign to 'Mocked' because it is not a variable.
|
||||
return { myProp: "test" };
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
tests/cases/compiler/assignToInvalidLHS.ts(4,9): error TS2364: Invalid left-hand side of assignment expression.
|
||||
tests/cases/compiler/assignToInvalidLHS.ts(4,9): error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
|
||||
|
||||
|
||||
==== tests/cases/compiler/assignToInvalidLHS.ts (1 errors) ====
|
||||
@@ -7,4 +7,4 @@ tests/cases/compiler/assignToInvalidLHS.ts(4,9): error TS2364: Invalid left-hand
|
||||
// Below is actually valid JavaScript (see http://es5.github.com/#x8.7 ), even though will always fail at runtime with 'invalid left-hand side'
|
||||
var x = new y = 5;
|
||||
~~~~~
|
||||
!!! error TS2364: Invalid left-hand side of assignment expression.
|
||||
!!! error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
|
||||
@@ -1,42 +1,42 @@
|
||||
tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(6,21): error TS2364: Invalid left-hand side of assignment expression.
|
||||
tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(7,13): error TS2364: Invalid left-hand side of assignment expression.
|
||||
tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(8,21): error TS2364: Invalid left-hand side of assignment expression.
|
||||
tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(11,18): error TS2364: Invalid left-hand side of assignment expression.
|
||||
tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(13,1): error TS2364: Invalid left-hand side of assignment expression.
|
||||
tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(17,1): error TS2364: Invalid left-hand side of assignment expression.
|
||||
tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(19,1): error TS2364: Invalid left-hand side of assignment expression.
|
||||
tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(22,1): error TS2364: Invalid left-hand side of assignment expression.
|
||||
tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(24,1): error TS2364: Invalid left-hand side of assignment expression.
|
||||
tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(27,1): error TS2364: Invalid left-hand side of assignment expression.
|
||||
tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(28,1): error TS2364: Invalid left-hand side of assignment expression.
|
||||
tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(29,1): error TS2364: Invalid left-hand side of assignment expression.
|
||||
tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(30,1): error TS2364: Invalid left-hand side of assignment expression.
|
||||
tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(31,1): error TS2364: Invalid left-hand side of assignment expression.
|
||||
tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(32,1): error TS2364: Invalid left-hand side of assignment expression.
|
||||
tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(6,21): error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
|
||||
tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(7,13): error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
|
||||
tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(8,21): error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
|
||||
tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(11,18): error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
|
||||
tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(13,1): error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
|
||||
tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(17,1): error TS2539: Cannot assign to 'M' because it is not a variable.
|
||||
tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(19,1): error TS2539: Cannot assign to 'C' because it is not a variable.
|
||||
tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(22,1): error TS2539: Cannot assign to 'E' because it is not a variable.
|
||||
tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(24,1): error TS2539: Cannot assign to 'foo' because it is not a variable.
|
||||
tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(27,1): error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
|
||||
tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(28,1): error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
|
||||
tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(29,1): error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
|
||||
tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(30,1): error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
|
||||
tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(31,1): error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
|
||||
tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(32,1): error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
|
||||
tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(35,3): error TS7028: Unused label.
|
||||
tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(35,9): error TS1128: Declaration or statement expected.
|
||||
tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(38,2): error TS2364: Invalid left-hand side of assignment expression.
|
||||
tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(38,6): error TS2364: Invalid left-hand side of assignment expression.
|
||||
tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(38,2): error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
|
||||
tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(38,6): error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
|
||||
tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(42,36): error TS1034: 'super' must be followed by an argument list or member access.
|
||||
tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(44,19): error TS1034: 'super' must be followed by an argument list or member access.
|
||||
tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(46,27): error TS1034: 'super' must be followed by an argument list or member access.
|
||||
tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(50,20): error TS1128: Declaration or statement expected.
|
||||
tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(51,11): error TS1005: ';' expected.
|
||||
tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(54,1): error TS2364: Invalid left-hand side of assignment expression.
|
||||
tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(57,1): error TS2364: Invalid left-hand side of assignment expression.
|
||||
tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(58,1): error TS2364: Invalid left-hand side of assignment expression.
|
||||
tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(59,1): error TS2364: Invalid left-hand side of assignment expression.
|
||||
tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(60,1): error TS2364: Invalid left-hand side of assignment expression.
|
||||
tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(61,1): error TS2364: Invalid left-hand side of assignment expression.
|
||||
tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(62,1): error TS2364: Invalid left-hand side of assignment expression.
|
||||
tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(63,1): error TS2364: Invalid left-hand side of assignment expression.
|
||||
tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(64,1): error TS2364: Invalid left-hand side of assignment expression.
|
||||
tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(65,1): error TS2364: Invalid left-hand side of assignment expression.
|
||||
tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(66,1): error TS2364: Invalid left-hand side of assignment expression.
|
||||
tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(67,1): error TS2364: Invalid left-hand side of assignment expression.
|
||||
tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(68,1): error TS2364: Invalid left-hand side of assignment expression.
|
||||
tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(69,1): error TS2364: Invalid left-hand side of assignment expression.
|
||||
tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(70,1): error TS2364: Invalid left-hand side of assignment expression.
|
||||
tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(54,1): error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
|
||||
tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(57,1): error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
|
||||
tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(58,2): error TS2539: Cannot assign to 'M' because it is not a variable.
|
||||
tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(59,2): error TS2539: Cannot assign to 'C' because it is not a variable.
|
||||
tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(60,2): error TS2539: Cannot assign to 'E' because it is not a variable.
|
||||
tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(61,2): error TS2539: Cannot assign to 'foo' because it is not a variable.
|
||||
tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(62,1): error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
|
||||
tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(63,1): error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
|
||||
tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(64,1): error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
|
||||
tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(65,1): error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
|
||||
tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(66,1): error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
|
||||
tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(67,1): error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
|
||||
tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(68,1): error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
|
||||
tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(69,1): error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
|
||||
tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(70,1): error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
|
||||
|
||||
|
||||
==== tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts (39 errors) ====
|
||||
@@ -47,61 +47,61 @@ tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(7
|
||||
class C {
|
||||
constructor() { this = value; }
|
||||
~~~~
|
||||
!!! error TS2364: Invalid left-hand side of assignment expression.
|
||||
!!! error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
|
||||
foo() { this = value; }
|
||||
~~~~
|
||||
!!! error TS2364: Invalid left-hand side of assignment expression.
|
||||
!!! error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
|
||||
static sfoo() { this = value; }
|
||||
~~~~
|
||||
!!! error TS2364: Invalid left-hand side of assignment expression.
|
||||
!!! error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
|
||||
}
|
||||
|
||||
function foo() { this = value; }
|
||||
~~~~
|
||||
!!! error TS2364: Invalid left-hand side of assignment expression.
|
||||
!!! error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
|
||||
|
||||
this = value;
|
||||
~~~~
|
||||
!!! error TS2364: Invalid left-hand side of assignment expression.
|
||||
!!! error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
|
||||
|
||||
// identifiers: module, class, enum, function
|
||||
module M { export var a; }
|
||||
M = value;
|
||||
~
|
||||
!!! error TS2364: Invalid left-hand side of assignment expression.
|
||||
!!! error TS2539: Cannot assign to 'M' because it is not a variable.
|
||||
|
||||
C = value;
|
||||
~
|
||||
!!! error TS2364: Invalid left-hand side of assignment expression.
|
||||
!!! error TS2539: Cannot assign to 'C' because it is not a variable.
|
||||
|
||||
enum E { }
|
||||
E = value;
|
||||
~
|
||||
!!! error TS2364: Invalid left-hand side of assignment expression.
|
||||
!!! error TS2539: Cannot assign to 'E' because it is not a variable.
|
||||
|
||||
foo = value;
|
||||
~~~
|
||||
!!! error TS2364: Invalid left-hand side of assignment expression.
|
||||
!!! error TS2539: Cannot assign to 'foo' because it is not a variable.
|
||||
|
||||
// literals
|
||||
null = value;
|
||||
~~~~
|
||||
!!! error TS2364: Invalid left-hand side of assignment expression.
|
||||
!!! error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
|
||||
true = value;
|
||||
~~~~
|
||||
!!! error TS2364: Invalid left-hand side of assignment expression.
|
||||
!!! error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
|
||||
false = value;
|
||||
~~~~~
|
||||
!!! error TS2364: Invalid left-hand side of assignment expression.
|
||||
!!! error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
|
||||
0 = value;
|
||||
~
|
||||
!!! error TS2364: Invalid left-hand side of assignment expression.
|
||||
!!! error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
|
||||
'' = value;
|
||||
~~
|
||||
!!! error TS2364: Invalid left-hand side of assignment expression.
|
||||
!!! error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
|
||||
/d+/ = value;
|
||||
~~~~
|
||||
!!! error TS2364: Invalid left-hand side of assignment expression.
|
||||
!!! error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
|
||||
|
||||
// object literals
|
||||
{ a: 0} = value;
|
||||
@@ -113,9 +113,9 @@ tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(7
|
||||
// array literals
|
||||
['', ''] = value;
|
||||
~~
|
||||
!!! error TS2364: Invalid left-hand side of assignment expression.
|
||||
!!! error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
|
||||
~~
|
||||
!!! error TS2364: Invalid left-hand side of assignment expression.
|
||||
!!! error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
|
||||
|
||||
// super
|
||||
class Derived extends C {
|
||||
@@ -143,48 +143,48 @@ tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(7
|
||||
// function calls
|
||||
foo() = value;
|
||||
~~~~~
|
||||
!!! error TS2364: Invalid left-hand side of assignment expression.
|
||||
!!! error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
|
||||
|
||||
// parentheses, the containted expression is value
|
||||
(this) = value;
|
||||
~~~~~~
|
||||
!!! error TS2364: Invalid left-hand side of assignment expression.
|
||||
!!! error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
|
||||
(M) = value;
|
||||
~~~
|
||||
!!! error TS2364: Invalid left-hand side of assignment expression.
|
||||
~
|
||||
!!! error TS2539: Cannot assign to 'M' because it is not a variable.
|
||||
(C) = value;
|
||||
~~~
|
||||
!!! error TS2364: Invalid left-hand side of assignment expression.
|
||||
~
|
||||
!!! error TS2539: Cannot assign to 'C' because it is not a variable.
|
||||
(E) = value;
|
||||
~~~
|
||||
!!! error TS2364: Invalid left-hand side of assignment expression.
|
||||
~
|
||||
!!! error TS2539: Cannot assign to 'E' because it is not a variable.
|
||||
(foo) = value;
|
||||
~~~~~
|
||||
!!! error TS2364: Invalid left-hand side of assignment expression.
|
||||
~~~
|
||||
!!! error TS2539: Cannot assign to 'foo' because it is not a variable.
|
||||
(null) = value;
|
||||
~~~~~~
|
||||
!!! error TS2364: Invalid left-hand side of assignment expression.
|
||||
!!! error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
|
||||
(true) = value;
|
||||
~~~~~~
|
||||
!!! error TS2364: Invalid left-hand side of assignment expression.
|
||||
!!! error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
|
||||
(0) = value;
|
||||
~~~
|
||||
!!! error TS2364: Invalid left-hand side of assignment expression.
|
||||
!!! error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
|
||||
('') = value;
|
||||
~~~~
|
||||
!!! error TS2364: Invalid left-hand side of assignment expression.
|
||||
!!! error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
|
||||
(/d+/) = value;
|
||||
~~~~~~
|
||||
!!! error TS2364: Invalid left-hand side of assignment expression.
|
||||
!!! error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
|
||||
({}) = value;
|
||||
~~~~
|
||||
!!! error TS2364: Invalid left-hand side of assignment expression.
|
||||
!!! error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
|
||||
([]) = value;
|
||||
~~~~
|
||||
!!! error TS2364: Invalid left-hand side of assignment expression.
|
||||
!!! error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
|
||||
(function baz() { }) = value;
|
||||
~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2364: Invalid left-hand side of assignment expression.
|
||||
!!! error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
|
||||
(foo()) = value;
|
||||
~~~~~~~
|
||||
!!! error TS2364: Invalid left-hand side of assignment expression.
|
||||
!!! error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
|
||||
@@ -1,12 +1,12 @@
|
||||
tests/cases/compiler/assignmentToFunction.ts(2,1): error TS2364: Invalid left-hand side of assignment expression.
|
||||
tests/cases/compiler/assignmentToFunction.ts(8,9): error TS2364: Invalid left-hand side of assignment expression.
|
||||
tests/cases/compiler/assignmentToFunction.ts(2,1): error TS2539: Cannot assign to 'fn' because it is not a variable.
|
||||
tests/cases/compiler/assignmentToFunction.ts(8,9): error TS2539: Cannot assign to 'bar' because it is not a variable.
|
||||
|
||||
|
||||
==== tests/cases/compiler/assignmentToFunction.ts (2 errors) ====
|
||||
function fn() { }
|
||||
fn = () => 3;
|
||||
~~
|
||||
!!! error TS2364: Invalid left-hand side of assignment expression.
|
||||
!!! error TS2539: Cannot assign to 'fn' because it is not a variable.
|
||||
|
||||
module foo {
|
||||
function xyz() {
|
||||
@@ -14,6 +14,6 @@ tests/cases/compiler/assignmentToFunction.ts(8,9): error TS2364: Invalid left-ha
|
||||
}
|
||||
bar = null;
|
||||
~~~
|
||||
!!! error TS2364: Invalid left-hand side of assignment expression.
|
||||
!!! error TS2539: Cannot assign to 'bar' because it is not a variable.
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
tests/cases/compiler/assignmentToParenthesizedExpression1.ts(2,1): error TS2364: Invalid left-hand side of assignment expression.
|
||||
tests/cases/compiler/assignmentToParenthesizedExpression1.ts(2,1): error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
|
||||
tests/cases/compiler/assignmentToParenthesizedExpression1.ts(2,2): error TS2695: Left side of comma operator is unused and has no side effects.
|
||||
|
||||
|
||||
@@ -6,6 +6,6 @@ tests/cases/compiler/assignmentToParenthesizedExpression1.ts(2,2): error TS2695:
|
||||
var x;
|
||||
(1, x)=0;
|
||||
~~~~~~
|
||||
!!! error TS2364: Invalid left-hand side of assignment expression.
|
||||
!!! error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
|
||||
~
|
||||
!!! error TS2695: Left side of comma operator is unused and has no side effects.
|
||||
@@ -3,9 +3,9 @@ tests/cases/conformance/expressions/valuesAndReferences/assignmentToParenthesize
|
||||
tests/cases/conformance/expressions/valuesAndReferences/assignmentToParenthesizedIdentifiers.ts(13,1): error TS2322: Type '""' is not assignable to type 'number'.
|
||||
tests/cases/conformance/expressions/valuesAndReferences/assignmentToParenthesizedIdentifiers.ts(14,1): error TS2322: Type '""' is not assignable to type 'number'.
|
||||
tests/cases/conformance/expressions/valuesAndReferences/assignmentToParenthesizedIdentifiers.ts(15,1): error TS2322: Type '""' is not assignable to type 'number'.
|
||||
tests/cases/conformance/expressions/valuesAndReferences/assignmentToParenthesizedIdentifiers.ts(17,1): error TS2364: Invalid left-hand side of assignment expression.
|
||||
tests/cases/conformance/expressions/valuesAndReferences/assignmentToParenthesizedIdentifiers.ts(18,1): error TS2364: Invalid left-hand side of assignment expression.
|
||||
tests/cases/conformance/expressions/valuesAndReferences/assignmentToParenthesizedIdentifiers.ts(25,5): error TS2364: Invalid left-hand side of assignment expression.
|
||||
tests/cases/conformance/expressions/valuesAndReferences/assignmentToParenthesizedIdentifiers.ts(17,1): error TS2539: Cannot assign to 'M' because it is not a variable.
|
||||
tests/cases/conformance/expressions/valuesAndReferences/assignmentToParenthesizedIdentifiers.ts(18,2): error TS2539: Cannot assign to 'M' because it is not a variable.
|
||||
tests/cases/conformance/expressions/valuesAndReferences/assignmentToParenthesizedIdentifiers.ts(25,5): error TS2539: Cannot assign to 'M3' because it is not a variable.
|
||||
tests/cases/conformance/expressions/valuesAndReferences/assignmentToParenthesizedIdentifiers.ts(31,1): error TS2322: Type '{ x: string; }' is not assignable to type 'typeof M3'.
|
||||
Types of property 'x' are incompatible.
|
||||
Type 'string' is not assignable to type 'number'.
|
||||
@@ -15,8 +15,8 @@ tests/cases/conformance/expressions/valuesAndReferences/assignmentToParenthesize
|
||||
tests/cases/conformance/expressions/valuesAndReferences/assignmentToParenthesizedIdentifiers.ts(33,1): error TS2322: Type '{ x: string; }' is not assignable to type 'typeof M3'.
|
||||
Types of property 'x' are incompatible.
|
||||
Type 'string' is not assignable to type 'number'.
|
||||
tests/cases/conformance/expressions/valuesAndReferences/assignmentToParenthesizedIdentifiers.ts(37,1): error TS2364: Invalid left-hand side of assignment expression.
|
||||
tests/cases/conformance/expressions/valuesAndReferences/assignmentToParenthesizedIdentifiers.ts(38,1): error TS2364: Invalid left-hand side of assignment expression.
|
||||
tests/cases/conformance/expressions/valuesAndReferences/assignmentToParenthesizedIdentifiers.ts(37,1): error TS2539: Cannot assign to 'fn' because it is not a variable.
|
||||
tests/cases/conformance/expressions/valuesAndReferences/assignmentToParenthesizedIdentifiers.ts(38,2): error TS2539: Cannot assign to 'fn' because it is not a variable.
|
||||
tests/cases/conformance/expressions/valuesAndReferences/assignmentToParenthesizedIdentifiers.ts(43,5): error TS2322: Type '""' is not assignable to type 'number'.
|
||||
tests/cases/conformance/expressions/valuesAndReferences/assignmentToParenthesizedIdentifiers.ts(44,5): error TS2322: Type '""' is not assignable to type 'number'.
|
||||
tests/cases/conformance/expressions/valuesAndReferences/assignmentToParenthesizedIdentifiers.ts(48,5): error TS2322: Type '""' is not assignable to type 'number'.
|
||||
@@ -24,10 +24,10 @@ tests/cases/conformance/expressions/valuesAndReferences/assignmentToParenthesize
|
||||
tests/cases/conformance/expressions/valuesAndReferences/assignmentToParenthesizedIdentifiers.ts(54,5): error TS2322: Type '""' is not assignable to type 'number'.
|
||||
tests/cases/conformance/expressions/valuesAndReferences/assignmentToParenthesizedIdentifiers.ts(55,5): error TS2322: Type '""' is not assignable to type 'number'.
|
||||
tests/cases/conformance/expressions/valuesAndReferences/assignmentToParenthesizedIdentifiers.ts(56,5): error TS2322: Type '""' is not assignable to type 'number'.
|
||||
tests/cases/conformance/expressions/valuesAndReferences/assignmentToParenthesizedIdentifiers.ts(62,1): error TS2364: Invalid left-hand side of assignment expression.
|
||||
tests/cases/conformance/expressions/valuesAndReferences/assignmentToParenthesizedIdentifiers.ts(63,1): error TS2364: Invalid left-hand side of assignment expression.
|
||||
tests/cases/conformance/expressions/valuesAndReferences/assignmentToParenthesizedIdentifiers.ts(69,1): error TS2364: Invalid left-hand side of assignment expression.
|
||||
tests/cases/conformance/expressions/valuesAndReferences/assignmentToParenthesizedIdentifiers.ts(70,1): error TS2364: Invalid left-hand side of assignment expression.
|
||||
tests/cases/conformance/expressions/valuesAndReferences/assignmentToParenthesizedIdentifiers.ts(62,1): error TS2539: Cannot assign to 'E' because it is not a variable.
|
||||
tests/cases/conformance/expressions/valuesAndReferences/assignmentToParenthesizedIdentifiers.ts(63,2): error TS2539: Cannot assign to 'E' because it is not a variable.
|
||||
tests/cases/conformance/expressions/valuesAndReferences/assignmentToParenthesizedIdentifiers.ts(69,1): error TS2539: Cannot assign to 'C' because it is not a variable.
|
||||
tests/cases/conformance/expressions/valuesAndReferences/assignmentToParenthesizedIdentifiers.ts(70,2): error TS2539: Cannot assign to 'C' because it is not a variable.
|
||||
|
||||
|
||||
==== tests/cases/conformance/expressions/valuesAndReferences/assignmentToParenthesizedIdentifiers.ts (24 errors) ====
|
||||
@@ -59,10 +59,10 @@ tests/cases/conformance/expressions/valuesAndReferences/assignmentToParenthesize
|
||||
|
||||
M = { y: 3 }; // Error
|
||||
~
|
||||
!!! error TS2364: Invalid left-hand side of assignment expression.
|
||||
!!! error TS2539: Cannot assign to 'M' because it is not a variable.
|
||||
(M) = { y: 3 }; // Error
|
||||
~~~
|
||||
!!! error TS2364: Invalid left-hand side of assignment expression.
|
||||
~
|
||||
!!! error TS2539: Cannot assign to 'M' because it is not a variable.
|
||||
|
||||
module M2 {
|
||||
export module M3 {
|
||||
@@ -71,7 +71,7 @@ tests/cases/conformance/expressions/valuesAndReferences/assignmentToParenthesize
|
||||
|
||||
M3 = { x: 3 }; // Error
|
||||
~~
|
||||
!!! error TS2364: Invalid left-hand side of assignment expression.
|
||||
!!! error TS2539: Cannot assign to 'M3' because it is not a variable.
|
||||
}
|
||||
M2.M3 = { x: 3 }; // OK
|
||||
(M2).M3 = { x: 3 }; // OK
|
||||
@@ -97,10 +97,10 @@ tests/cases/conformance/expressions/valuesAndReferences/assignmentToParenthesize
|
||||
function fn() { }
|
||||
fn = () => 3; // Bug 823548: Should be error (fn is not a reference)
|
||||
~~
|
||||
!!! error TS2364: Invalid left-hand side of assignment expression.
|
||||
!!! error TS2539: Cannot assign to 'fn' because it is not a variable.
|
||||
(fn) = () => 3; // Should be error
|
||||
~~~~
|
||||
!!! error TS2364: Invalid left-hand side of assignment expression.
|
||||
~~
|
||||
!!! error TS2539: Cannot assign to 'fn' because it is not a variable.
|
||||
|
||||
function fn2(x: number, y: { t: number }) {
|
||||
x = 3;
|
||||
@@ -140,10 +140,10 @@ tests/cases/conformance/expressions/valuesAndReferences/assignmentToParenthesize
|
||||
}
|
||||
E = undefined; // Error
|
||||
~
|
||||
!!! error TS2364: Invalid left-hand side of assignment expression.
|
||||
!!! error TS2539: Cannot assign to 'E' because it is not a variable.
|
||||
(E) = undefined; // Error
|
||||
~~~
|
||||
!!! error TS2364: Invalid left-hand side of assignment expression.
|
||||
~
|
||||
!!! error TS2539: Cannot assign to 'E' because it is not a variable.
|
||||
|
||||
class C {
|
||||
|
||||
@@ -151,8 +151,8 @@ tests/cases/conformance/expressions/valuesAndReferences/assignmentToParenthesize
|
||||
|
||||
C = undefined; // Error
|
||||
~
|
||||
!!! error TS2364: Invalid left-hand side of assignment expression.
|
||||
!!! error TS2539: Cannot assign to 'C' because it is not a variable.
|
||||
(C) = undefined; // Error
|
||||
~~~
|
||||
!!! error TS2364: Invalid left-hand side of assignment expression.
|
||||
~
|
||||
!!! error TS2539: Cannot assign to 'C' because it is not a variable.
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
tests/cases/compiler/assignmentToReferenceTypes.ts(5,1): error TS2304: Cannot find name 'M'.
|
||||
tests/cases/compiler/assignmentToReferenceTypes.ts(9,1): error TS2364: Invalid left-hand side of assignment expression.
|
||||
tests/cases/compiler/assignmentToReferenceTypes.ts(13,1): error TS2364: Invalid left-hand side of assignment expression.
|
||||
tests/cases/compiler/assignmentToReferenceTypes.ts(16,1): error TS2364: Invalid left-hand side of assignment expression.
|
||||
tests/cases/compiler/assignmentToReferenceTypes.ts(9,1): error TS2539: Cannot assign to 'C' because it is not a variable.
|
||||
tests/cases/compiler/assignmentToReferenceTypes.ts(13,1): error TS2539: Cannot assign to 'E' because it is not a variable.
|
||||
tests/cases/compiler/assignmentToReferenceTypes.ts(16,1): error TS2539: Cannot assign to 'f' because it is not a variable.
|
||||
|
||||
|
||||
==== tests/cases/compiler/assignmentToReferenceTypes.ts (4 errors) ====
|
||||
@@ -17,18 +17,18 @@ tests/cases/compiler/assignmentToReferenceTypes.ts(16,1): error TS2364: Invalid
|
||||
}
|
||||
C = null;
|
||||
~
|
||||
!!! error TS2364: Invalid left-hand side of assignment expression.
|
||||
!!! error TS2539: Cannot assign to 'C' because it is not a variable.
|
||||
|
||||
enum E {
|
||||
}
|
||||
E = null;
|
||||
~
|
||||
!!! error TS2364: Invalid left-hand side of assignment expression.
|
||||
!!! error TS2539: Cannot assign to 'E' because it is not a variable.
|
||||
|
||||
function f() { }
|
||||
f = null;
|
||||
~
|
||||
!!! error TS2364: Invalid left-hand side of assignment expression.
|
||||
!!! error TS2539: Cannot assign to 'f' because it is not a variable.
|
||||
|
||||
var x = 1;
|
||||
x = null;
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
tests/cases/conformance/expressions/valuesAndReferences/assignments.ts(11,1): error TS2304: Cannot find name 'M'.
|
||||
tests/cases/conformance/expressions/valuesAndReferences/assignments.ts(14,1): error TS2364: Invalid left-hand side of assignment expression.
|
||||
tests/cases/conformance/expressions/valuesAndReferences/assignments.ts(17,1): error TS2364: Invalid left-hand side of assignment expression.
|
||||
tests/cases/conformance/expressions/valuesAndReferences/assignments.ts(18,1): error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
|
||||
tests/cases/conformance/expressions/valuesAndReferences/assignments.ts(21,1): error TS2364: Invalid left-hand side of assignment expression.
|
||||
tests/cases/conformance/expressions/valuesAndReferences/assignments.ts(14,1): error TS2539: Cannot assign to 'C' because it is not a variable.
|
||||
tests/cases/conformance/expressions/valuesAndReferences/assignments.ts(17,1): error TS2539: Cannot assign to 'E' because it is not a variable.
|
||||
tests/cases/conformance/expressions/valuesAndReferences/assignments.ts(18,3): error TS2540: Cannot assign to 'A' because it is a constant or a read-only property.
|
||||
tests/cases/conformance/expressions/valuesAndReferences/assignments.ts(21,1): error TS2539: Cannot assign to 'fn' because it is not a variable.
|
||||
tests/cases/conformance/expressions/valuesAndReferences/assignments.ts(31,1): error TS2693: 'I' only refers to a type, but is being used as a value here.
|
||||
|
||||
|
||||
@@ -24,20 +24,20 @@ tests/cases/conformance/expressions/valuesAndReferences/assignments.ts(31,1): er
|
||||
class C { }
|
||||
C = null; // Error
|
||||
~
|
||||
!!! error TS2364: Invalid left-hand side of assignment expression.
|
||||
!!! error TS2539: Cannot assign to 'C' because it is not a variable.
|
||||
|
||||
enum E { A }
|
||||
E = null; // Error
|
||||
~
|
||||
!!! error TS2364: Invalid left-hand side of assignment expression.
|
||||
!!! error TS2539: Cannot assign to 'E' because it is not a variable.
|
||||
E.A = null; // OK per spec, Error per implementation (509581)
|
||||
~~~
|
||||
!!! error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
|
||||
~
|
||||
!!! error TS2540: Cannot assign to 'A' because it is a constant or a read-only property.
|
||||
|
||||
function fn() { }
|
||||
fn = null; // Should be error
|
||||
~~
|
||||
!!! error TS2364: Invalid left-hand side of assignment expression.
|
||||
!!! error TS2539: Cannot assign to 'fn' because it is not a variable.
|
||||
|
||||
var v;
|
||||
v = null; // OK
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
tests/cases/conformance/async/es5/asyncAliasReturnType_es5.ts(3,21): error TS1055: Type 'PromiseAlias' is not a valid async function return type in ES5/ES3 because it does not refer to a Promise-compatible constructor value.
|
||||
|
||||
|
||||
==== tests/cases/conformance/async/es5/asyncAliasReturnType_es5.ts (1 errors) ====
|
||||
type PromiseAlias<T> = Promise<T>;
|
||||
|
||||
async function f(): PromiseAlias<void> {
|
||||
~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS1055: Type 'PromiseAlias' is not a valid async function return type in ES5/ES3 because it does not refer to a Promise-compatible constructor value.
|
||||
}
|
||||
@@ -77,6 +77,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
||||
}
|
||||
};
|
||||
var _this = this;
|
||||
var missing_1 = require("missing");
|
||||
function f0() {
|
||||
return __awaiter(this, void 0, void 0, function () { return __generator(this, function (_a) {
|
||||
return [2 /*return*/];
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclaration15_es5.ts(6,23): error TS1055: Type '{}' is not a valid async function return type.
|
||||
tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclaration15_es5.ts(7,23): error TS1055: Type 'any' is not a valid async function return type.
|
||||
tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclaration15_es5.ts(8,23): error TS1055: Type 'number' is not a valid async function return type.
|
||||
tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclaration15_es5.ts(9,23): error TS1055: Type 'PromiseLike' is not a valid async function return type.
|
||||
tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclaration15_es5.ts(10,23): error TS1055: Type 'typeof Thenable' is not a valid async function return type.
|
||||
tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclaration15_es5.ts(10,23): error TS1055: Type 'typeof Thenable' is not a valid async function return type.
|
||||
tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclaration15_es5.ts(6,23): error TS1055: Type '{}' is not a valid async function return type in ES5/ES3 because it does not refer to a Promise-compatible constructor value.
|
||||
tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclaration15_es5.ts(7,23): error TS1055: Type 'any' is not a valid async function return type in ES5/ES3 because it does not refer to a Promise-compatible constructor value.
|
||||
tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclaration15_es5.ts(8,23): error TS1055: Type 'number' is not a valid async function return type in ES5/ES3 because it does not refer to a Promise-compatible constructor value.
|
||||
tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclaration15_es5.ts(9,23): error TS1055: Type 'PromiseLike' is not a valid async function return type in ES5/ES3 because it does not refer to a Promise-compatible constructor value.
|
||||
tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclaration15_es5.ts(10,23): error TS1055: Type 'typeof Thenable' is not a valid async function return type in ES5/ES3 because it does not refer to a Promise-compatible constructor value.
|
||||
tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclaration15_es5.ts(10,23): error TS1055: Type 'typeof Thenable' is not a valid async function return type in ES5/ES3 because it does not refer to a Promise-compatible constructor value.
|
||||
Type 'Thenable' is not assignable to type 'PromiseLike<any>'.
|
||||
Types of property 'then' are incompatible.
|
||||
Type '() => void' is not assignable to type '{ (onfulfilled?: (value: any) => any, onrejected?: (reason: any) => any): PromiseLike<any>; <TResult>(onfulfilled: (value: any) => any, onrejected: (reason: any) => TResult | PromiseLike<TResult>): PromiseLike<any>; <TResult>(onfulfilled: (value: any) => TResult | PromiseLike<TResult>, onrejected?: (reason: any) => TResult | PromiseLike<TResult>): PromiseLike<TResult>; <TResult1, TResult2>(onfulfilled: (value: any) => TResult1 | PromiseLike<TResult1>, onrejected: (reason: any) => TResult2 | PromiseLike<TResult2>): PromiseLike<TResult1 | TResult2>; }'.
|
||||
@@ -20,21 +20,21 @@ tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclaration1
|
||||
async function fn1() { } // valid: Promise<void>
|
||||
async function fn2(): { } { } // error
|
||||
~~~
|
||||
!!! error TS1055: Type '{}' is not a valid async function return type.
|
||||
!!! error TS1055: Type '{}' is not a valid async function return type in ES5/ES3 because it does not refer to a Promise-compatible constructor value.
|
||||
async function fn3(): any { } // error
|
||||
~~~
|
||||
!!! error TS1055: Type 'any' is not a valid async function return type.
|
||||
!!! error TS1055: Type 'any' is not a valid async function return type in ES5/ES3 because it does not refer to a Promise-compatible constructor value.
|
||||
async function fn4(): number { } // error
|
||||
~~~~~~
|
||||
!!! error TS1055: Type 'number' is not a valid async function return type.
|
||||
!!! error TS1055: Type 'number' is not a valid async function return type in ES5/ES3 because it does not refer to a Promise-compatible constructor value.
|
||||
async function fn5(): PromiseLike<void> { } // error
|
||||
~~~~~~~~~~~~~~~~~
|
||||
!!! error TS1055: Type 'PromiseLike' is not a valid async function return type.
|
||||
!!! error TS1055: Type 'PromiseLike' is not a valid async function return type in ES5/ES3 because it does not refer to a Promise-compatible constructor value.
|
||||
async function fn6(): Thenable { } // error
|
||||
~~~~~~~~
|
||||
!!! error TS1055: Type 'typeof Thenable' is not a valid async function return type.
|
||||
!!! error TS1055: Type 'typeof Thenable' is not a valid async function return type in ES5/ES3 because it does not refer to a Promise-compatible constructor value.
|
||||
~~~~~~~~
|
||||
!!! error TS1055: Type 'typeof Thenable' is not a valid async function return type.
|
||||
!!! error TS1055: Type 'typeof Thenable' is not a valid async function return type in ES5/ES3 because it does not refer to a Promise-compatible constructor value.
|
||||
!!! error TS1055: Type 'Thenable' is not assignable to type 'PromiseLike<any>'.
|
||||
!!! error TS1055: Types of property 'then' are incompatible.
|
||||
!!! error TS1055: Type '() => void' is not assignable to type '{ (onfulfilled?: (value: any) => any, onrejected?: (reason: any) => any): PromiseLike<any>; <TResult>(onfulfilled: (value: any) => any, onrejected: (reason: any) => TResult | PromiseLike<TResult>): PromiseLike<any>; <TResult>(onfulfilled: (value: any) => TResult | PromiseLike<TResult>, onrejected?: (reason: any) => TResult | PromiseLike<TResult>): PromiseLike<TResult>; <TResult1, TResult2>(onfulfilled: (value: any) => TResult1 | PromiseLike<TResult1>, onrejected: (reason: any) => TResult2 | PromiseLike<TResult2>): PromiseLike<TResult1 | TResult2>; }'.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
error TS2318: Cannot find global type 'Promise'.
|
||||
tests/cases/compiler/asyncFunctionNoReturnType.ts(1,1): error TS1057: An async function or method must have a valid awaitable return type.
|
||||
tests/cases/compiler/asyncFunctionNoReturnType.ts(1,1): error TS2697: An async function or method must return a 'Promise'. Make sure you have a declaration for 'Promise' or include 'ES2015' in your `--lib` option.
|
||||
tests/cases/compiler/asyncFunctionNoReturnType.ts(1,1): error TS7030: Not all code paths return a value.
|
||||
tests/cases/compiler/asyncFunctionNoReturnType.ts(2,9): error TS2304: Cannot find name 'window'.
|
||||
tests/cases/compiler/asyncFunctionNoReturnType.ts(3,9): error TS7030: Not all code paths return a value.
|
||||
@@ -9,7 +9,7 @@ tests/cases/compiler/asyncFunctionNoReturnType.ts(3,9): error TS7030: Not all co
|
||||
==== tests/cases/compiler/asyncFunctionNoReturnType.ts (4 errors) ====
|
||||
async () => {
|
||||
~~~~~~~~~~~~~
|
||||
!!! error TS1057: An async function or method must have a valid awaitable return type.
|
||||
!!! error TS2697: An async function or method must return a 'Promise'. Make sure you have a declaration for 'Promise' or include 'ES2015' in your `--lib` option.
|
||||
~~~~~~~~~~~~~
|
||||
!!! error TS7030: Not all code paths return a value.
|
||||
if (window)
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
//// [asyncIIFE.ts]
|
||||
|
||||
function f1() {
|
||||
(async () => {
|
||||
await 10
|
||||
throw new Error();
|
||||
})();
|
||||
|
||||
var x = 1;
|
||||
}
|
||||
|
||||
|
||||
//// [asyncIIFE.js]
|
||||
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());
|
||||
});
|
||||
};
|
||||
function f1() {
|
||||
(() => __awaiter(this, void 0, void 0, function* () {
|
||||
yield 10;
|
||||
throw new Error();
|
||||
}))();
|
||||
var x = 1;
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
=== tests/cases/compiler/asyncIIFE.ts ===
|
||||
|
||||
function f1() {
|
||||
>f1 : Symbol(f1, Decl(asyncIIFE.ts, 0, 0))
|
||||
|
||||
(async () => {
|
||||
await 10
|
||||
throw new Error();
|
||||
>Error : Symbol(Error, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
|
||||
|
||||
})();
|
||||
|
||||
var x = 1;
|
||||
>x : Symbol(x, Decl(asyncIIFE.ts, 7, 7))
|
||||
}
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
=== tests/cases/compiler/asyncIIFE.ts ===
|
||||
|
||||
function f1() {
|
||||
>f1 : () => void
|
||||
|
||||
(async () => {
|
||||
>(async () => { await 10 throw new Error(); })() : Promise<never>
|
||||
>(async () => { await 10 throw new Error(); }) : () => Promise<never>
|
||||
>async () => { await 10 throw new Error(); } : () => Promise<never>
|
||||
|
||||
await 10
|
||||
>await 10 : 10
|
||||
>10 : 10
|
||||
|
||||
throw new Error();
|
||||
>new Error() : Error
|
||||
>Error : ErrorConstructor
|
||||
|
||||
})();
|
||||
|
||||
var x = 1;
|
||||
>x : number
|
||||
>1 : 1
|
||||
}
|
||||
|
||||
@@ -1,37 +1,37 @@
|
||||
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(8,9): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(9,9): error TS2364: Invalid left-hand side of assignment expression.
|
||||
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(9,9): error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
|
||||
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(12,9): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(13,9): error TS2364: Invalid left-hand side of assignment expression.
|
||||
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(13,9): error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
|
||||
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(16,9): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(17,9): error TS2364: Invalid left-hand side of assignment expression.
|
||||
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(22,5): error TS2364: Invalid left-hand side of assignment expression.
|
||||
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(23,5): error TS2364: Invalid left-hand side of assignment expression.
|
||||
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(26,1): error TS2364: Invalid left-hand side of assignment expression.
|
||||
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(27,1): error TS2364: Invalid left-hand side of assignment expression.
|
||||
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(31,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(32,1): error TS2364: Invalid left-hand side of assignment expression.
|
||||
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(34,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(35,1): error TS2364: Invalid left-hand side of assignment expression.
|
||||
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(38,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(39,1): error TS2364: Invalid left-hand side of assignment expression.
|
||||
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(41,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(42,1): error TS2364: Invalid left-hand side of assignment expression.
|
||||
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(45,1): error TS2364: Invalid left-hand side of assignment expression.
|
||||
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(46,1): error TS2364: Invalid left-hand side of assignment expression.
|
||||
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(17,9): error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
|
||||
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(22,5): error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
|
||||
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(23,5): error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
|
||||
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(26,1): error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
|
||||
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(27,1): error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
|
||||
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(31,1): error TS2539: Cannot assign to 'M' because it is not a variable.
|
||||
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(32,1): error TS2539: Cannot assign to 'M' because it is not a variable.
|
||||
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(34,1): error TS2539: Cannot assign to 'C' because it is not a variable.
|
||||
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(35,1): error TS2539: Cannot assign to 'C' because it is not a variable.
|
||||
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(38,1): error TS2539: Cannot assign to 'E' because it is not a variable.
|
||||
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(39,1): error TS2539: Cannot assign to 'E' because it is not a variable.
|
||||
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(41,1): error TS2539: Cannot assign to 'foo' because it is not a variable.
|
||||
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(42,1): error TS2539: Cannot assign to 'foo' because it is not a variable.
|
||||
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(45,1): error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
|
||||
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(46,1): error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
|
||||
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(47,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(48,1): error TS2364: Invalid left-hand side of assignment expression.
|
||||
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(48,1): error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
|
||||
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(49,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(50,1): error TS2364: Invalid left-hand side of assignment expression.
|
||||
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(51,1): error TS2364: Invalid left-hand side of assignment expression.
|
||||
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(52,1): error TS2364: Invalid left-hand side of assignment expression.
|
||||
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(50,1): error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
|
||||
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(51,1): error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
|
||||
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(52,1): error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
|
||||
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(53,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(54,1): error TS2364: Invalid left-hand side of assignment expression.
|
||||
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(54,1): error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
|
||||
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(55,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(56,1): error TS2364: Invalid left-hand side of assignment expression.
|
||||
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(56,1): error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
|
||||
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(59,9): error TS1128: Declaration or statement expected.
|
||||
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(60,9): error TS1128: Declaration or statement expected.
|
||||
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(63,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(64,1): error TS2364: Invalid left-hand side of assignment expression.
|
||||
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(64,1): error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
|
||||
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(70,15): error TS1034: 'super' must be followed by an argument list or member access.
|
||||
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(71,15): error TS1034: 'super' must be followed by an argument list or member access.
|
||||
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(75,15): error TS1034: 'super' must be followed by an argument list or member access.
|
||||
@@ -43,35 +43,35 @@ tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsVa
|
||||
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(88,11): error TS1005: ';' expected.
|
||||
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(89,11): error TS1005: ';' expected.
|
||||
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(92,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(93,1): error TS2364: Invalid left-hand side of assignment expression.
|
||||
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(96,1): error TS2364: Invalid left-hand side of assignment expression.
|
||||
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(97,1): error TS2364: Invalid left-hand side of assignment expression.
|
||||
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(98,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(99,1): error TS2364: Invalid left-hand side of assignment expression.
|
||||
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(100,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(101,1): error TS2364: Invalid left-hand side of assignment expression.
|
||||
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(102,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(103,1): error TS2364: Invalid left-hand side of assignment expression.
|
||||
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(104,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(105,1): error TS2364: Invalid left-hand side of assignment expression.
|
||||
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(106,1): error TS2364: Invalid left-hand side of assignment expression.
|
||||
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(107,1): error TS2364: Invalid left-hand side of assignment expression.
|
||||
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(93,1): error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
|
||||
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(96,1): error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
|
||||
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(97,1): error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
|
||||
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(98,2): error TS2539: Cannot assign to 'M' because it is not a variable.
|
||||
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(99,2): error TS2539: Cannot assign to 'M' because it is not a variable.
|
||||
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(100,2): error TS2539: Cannot assign to 'C' because it is not a variable.
|
||||
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(101,2): error TS2539: Cannot assign to 'C' because it is not a variable.
|
||||
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(102,2): error TS2539: Cannot assign to 'E' because it is not a variable.
|
||||
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(103,2): error TS2539: Cannot assign to 'E' because it is not a variable.
|
||||
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(104,2): error TS2539: Cannot assign to 'foo' because it is not a variable.
|
||||
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(105,2): error TS2539: Cannot assign to 'foo' because it is not a variable.
|
||||
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(106,1): error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
|
||||
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(107,1): error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
|
||||
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(108,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(109,1): error TS2364: Invalid left-hand side of assignment expression.
|
||||
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(110,1): error TS2364: Invalid left-hand side of assignment expression.
|
||||
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(111,1): error TS2364: Invalid left-hand side of assignment expression.
|
||||
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(109,1): error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
|
||||
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(110,1): error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
|
||||
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(111,1): error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
|
||||
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(112,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(113,1): error TS2364: Invalid left-hand side of assignment expression.
|
||||
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(113,1): error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
|
||||
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(114,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(115,1): error TS2364: Invalid left-hand side of assignment expression.
|
||||
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(115,1): error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
|
||||
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(116,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(117,1): error TS2364: Invalid left-hand side of assignment expression.
|
||||
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(117,1): error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
|
||||
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(118,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(119,1): error TS2364: Invalid left-hand side of assignment expression.
|
||||
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(119,1): error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
|
||||
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(120,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(121,1): error TS2364: Invalid left-hand side of assignment expression.
|
||||
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(121,1): error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
|
||||
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(122,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(123,1): error TS2364: Invalid left-hand side of assignment expression.
|
||||
tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts(123,1): error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
|
||||
|
||||
|
||||
==== tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts (74 errors) ====
|
||||
@@ -87,7 +87,7 @@ tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsVa
|
||||
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
this += value;
|
||||
~~~~
|
||||
!!! error TS2364: Invalid left-hand side of assignment expression.
|
||||
!!! error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
|
||||
}
|
||||
foo() {
|
||||
this *= value;
|
||||
@@ -95,7 +95,7 @@ tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsVa
|
||||
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
this += value;
|
||||
~~~~
|
||||
!!! error TS2364: Invalid left-hand side of assignment expression.
|
||||
!!! error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
|
||||
}
|
||||
static sfoo() {
|
||||
this *= value;
|
||||
@@ -103,94 +103,94 @@ tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsVa
|
||||
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
this += value;
|
||||
~~~~
|
||||
!!! error TS2364: Invalid left-hand side of assignment expression.
|
||||
!!! error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
|
||||
}
|
||||
}
|
||||
|
||||
function foo() {
|
||||
this *= value;
|
||||
~~~~
|
||||
!!! error TS2364: Invalid left-hand side of assignment expression.
|
||||
!!! error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
|
||||
this += value;
|
||||
~~~~
|
||||
!!! error TS2364: Invalid left-hand side of assignment expression.
|
||||
!!! error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
|
||||
}
|
||||
|
||||
this *= value;
|
||||
~~~~
|
||||
!!! error TS2364: Invalid left-hand side of assignment expression.
|
||||
!!! error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
|
||||
this += value;
|
||||
~~~~
|
||||
!!! error TS2364: Invalid left-hand side of assignment expression.
|
||||
!!! error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
|
||||
|
||||
// identifiers: module, class, enum, function
|
||||
module M { export var a; }
|
||||
M *= value;
|
||||
~
|
||||
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
!!! error TS2539: Cannot assign to 'M' because it is not a variable.
|
||||
M += value;
|
||||
~
|
||||
!!! error TS2364: Invalid left-hand side of assignment expression.
|
||||
!!! error TS2539: Cannot assign to 'M' because it is not a variable.
|
||||
|
||||
C *= value;
|
||||
~
|
||||
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
!!! error TS2539: Cannot assign to 'C' because it is not a variable.
|
||||
C += value;
|
||||
~
|
||||
!!! error TS2364: Invalid left-hand side of assignment expression.
|
||||
!!! error TS2539: Cannot assign to 'C' because it is not a variable.
|
||||
|
||||
enum E { }
|
||||
E *= value;
|
||||
~
|
||||
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
!!! error TS2539: Cannot assign to 'E' because it is not a variable.
|
||||
E += value;
|
||||
~
|
||||
!!! error TS2364: Invalid left-hand side of assignment expression.
|
||||
!!! error TS2539: Cannot assign to 'E' because it is not a variable.
|
||||
|
||||
foo *= value;
|
||||
~~~
|
||||
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
!!! error TS2539: Cannot assign to 'foo' because it is not a variable.
|
||||
foo += value;
|
||||
~~~
|
||||
!!! error TS2364: Invalid left-hand side of assignment expression.
|
||||
!!! error TS2539: Cannot assign to 'foo' because it is not a variable.
|
||||
|
||||
// literals
|
||||
null *= value;
|
||||
~~~~
|
||||
!!! error TS2364: Invalid left-hand side of assignment expression.
|
||||
!!! error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
|
||||
null += value;
|
||||
~~~~
|
||||
!!! error TS2364: Invalid left-hand side of assignment expression.
|
||||
!!! error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
|
||||
true *= value;
|
||||
~~~~
|
||||
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
true += value;
|
||||
~~~~
|
||||
!!! error TS2364: Invalid left-hand side of assignment expression.
|
||||
!!! error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
|
||||
false *= value;
|
||||
~~~~~
|
||||
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
false += value;
|
||||
~~~~~
|
||||
!!! error TS2364: Invalid left-hand side of assignment expression.
|
||||
!!! error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
|
||||
0 *= value;
|
||||
~
|
||||
!!! error TS2364: Invalid left-hand side of assignment expression.
|
||||
!!! error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
|
||||
0 += value;
|
||||
~
|
||||
!!! error TS2364: Invalid left-hand side of assignment expression.
|
||||
!!! error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
|
||||
'' *= value;
|
||||
~~
|
||||
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
'' += value;
|
||||
~~
|
||||
!!! error TS2364: Invalid left-hand side of assignment expression.
|
||||
!!! error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
|
||||
/d+/ *= value;
|
||||
~~~~
|
||||
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
/d+/ += value;
|
||||
~~~~
|
||||
!!! error TS2364: Invalid left-hand side of assignment expression.
|
||||
!!! error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
|
||||
|
||||
// object literals
|
||||
{ a: 0} *= value;
|
||||
@@ -206,7 +206,7 @@ tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsVa
|
||||
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
['', ''] += value;
|
||||
~~~~~~~~
|
||||
!!! error TS2364: Invalid left-hand side of assignment expression.
|
||||
!!! error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
|
||||
|
||||
// super
|
||||
class Derived extends C {
|
||||
@@ -259,90 +259,90 @@ tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsVa
|
||||
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
foo() += value;
|
||||
~~~~~
|
||||
!!! error TS2364: Invalid left-hand side of assignment expression.
|
||||
!!! error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
|
||||
|
||||
// parentheses, the containted expression is value
|
||||
(this) *= value;
|
||||
~~~~~~
|
||||
!!! error TS2364: Invalid left-hand side of assignment expression.
|
||||
!!! error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
|
||||
(this) += value;
|
||||
~~~~~~
|
||||
!!! error TS2364: Invalid left-hand side of assignment expression.
|
||||
!!! error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
|
||||
(M) *= value;
|
||||
~~~
|
||||
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
~
|
||||
!!! error TS2539: Cannot assign to 'M' because it is not a variable.
|
||||
(M) += value;
|
||||
~~~
|
||||
!!! error TS2364: Invalid left-hand side of assignment expression.
|
||||
~
|
||||
!!! error TS2539: Cannot assign to 'M' because it is not a variable.
|
||||
(C) *= value;
|
||||
~~~
|
||||
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
~
|
||||
!!! error TS2539: Cannot assign to 'C' because it is not a variable.
|
||||
(C) += value;
|
||||
~~~
|
||||
!!! error TS2364: Invalid left-hand side of assignment expression.
|
||||
~
|
||||
!!! error TS2539: Cannot assign to 'C' because it is not a variable.
|
||||
(E) *= value;
|
||||
~~~
|
||||
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
~
|
||||
!!! error TS2539: Cannot assign to 'E' because it is not a variable.
|
||||
(E) += value;
|
||||
~~~
|
||||
!!! error TS2364: Invalid left-hand side of assignment expression.
|
||||
~
|
||||
!!! error TS2539: Cannot assign to 'E' because it is not a variable.
|
||||
(foo) *= value;
|
||||
~~~~~
|
||||
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
~~~
|
||||
!!! error TS2539: Cannot assign to 'foo' because it is not a variable.
|
||||
(foo) += value;
|
||||
~~~~~
|
||||
!!! error TS2364: Invalid left-hand side of assignment expression.
|
||||
~~~
|
||||
!!! error TS2539: Cannot assign to 'foo' because it is not a variable.
|
||||
(null) *= value;
|
||||
~~~~~~
|
||||
!!! error TS2364: Invalid left-hand side of assignment expression.
|
||||
!!! error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
|
||||
(null) += value;
|
||||
~~~~~~
|
||||
!!! error TS2364: Invalid left-hand side of assignment expression.
|
||||
!!! error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
|
||||
(true) *= value;
|
||||
~~~~~~
|
||||
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
(true) += value;
|
||||
~~~~~~
|
||||
!!! error TS2364: Invalid left-hand side of assignment expression.
|
||||
!!! error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
|
||||
(0) *= value;
|
||||
~~~
|
||||
!!! error TS2364: Invalid left-hand side of assignment expression.
|
||||
!!! error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
|
||||
(0) += value;
|
||||
~~~
|
||||
!!! error TS2364: Invalid left-hand side of assignment expression.
|
||||
!!! error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
|
||||
('') *= value;
|
||||
~~~~
|
||||
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
('') += value;
|
||||
~~~~
|
||||
!!! error TS2364: Invalid left-hand side of assignment expression.
|
||||
!!! error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
|
||||
(/d+/) *= value;
|
||||
~~~~~~
|
||||
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
(/d+/) += value;
|
||||
~~~~~~
|
||||
!!! error TS2364: Invalid left-hand side of assignment expression.
|
||||
!!! error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
|
||||
({}) *= value;
|
||||
~~~~
|
||||
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
({}) += value;
|
||||
~~~~
|
||||
!!! error TS2364: Invalid left-hand side of assignment expression.
|
||||
!!! error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
|
||||
([]) *= value;
|
||||
~~~~
|
||||
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
([]) += value;
|
||||
~~~~
|
||||
!!! error TS2364: Invalid left-hand side of assignment expression.
|
||||
!!! error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
|
||||
(function baz1() { }) *= value;
|
||||
~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
(function baz2() { }) += value;
|
||||
~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2364: Invalid left-hand side of assignment expression.
|
||||
!!! error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
|
||||
(foo()) *= value;
|
||||
~~~~~~~
|
||||
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
(foo()) += value;
|
||||
~~~~~~~
|
||||
!!! error TS2364: Invalid left-hand side of assignment expression.
|
||||
!!! error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
|
||||
@@ -1,16 +1,16 @@
|
||||
tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSIsValue.ts(7,9): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSIsValue.ts(10,9): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSIsValue.ts(13,9): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSIsValue.ts(18,5): error TS2364: Invalid left-hand side of assignment expression.
|
||||
tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSIsValue.ts(21,1): error TS2364: Invalid left-hand side of assignment expression.
|
||||
tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSIsValue.ts(25,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSIsValue.ts(27,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSIsValue.ts(30,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSIsValue.ts(32,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSIsValue.ts(35,1): error TS2364: Invalid left-hand side of assignment expression.
|
||||
tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSIsValue.ts(18,5): error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
|
||||
tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSIsValue.ts(21,1): error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
|
||||
tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSIsValue.ts(25,1): error TS2539: Cannot assign to 'M' because it is not a variable.
|
||||
tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSIsValue.ts(27,1): error TS2539: Cannot assign to 'C' because it is not a variable.
|
||||
tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSIsValue.ts(30,1): error TS2539: Cannot assign to 'E' because it is not a variable.
|
||||
tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSIsValue.ts(32,1): error TS2539: Cannot assign to 'foo' because it is not a variable.
|
||||
tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSIsValue.ts(35,1): error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
|
||||
tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSIsValue.ts(36,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSIsValue.ts(37,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSIsValue.ts(38,1): error TS2364: Invalid left-hand side of assignment expression.
|
||||
tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSIsValue.ts(38,1): error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
|
||||
tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSIsValue.ts(39,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSIsValue.ts(40,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSIsValue.ts(43,3): error TS7028: Unused label.
|
||||
@@ -22,14 +22,14 @@ tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignm
|
||||
tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSIsValue.ts(65,21): error TS1128: Declaration or statement expected.
|
||||
tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSIsValue.ts(66,11): error TS1005: ';' expected.
|
||||
tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSIsValue.ts(69,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSIsValue.ts(72,1): error TS2364: Invalid left-hand side of assignment expression.
|
||||
tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSIsValue.ts(73,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSIsValue.ts(74,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSIsValue.ts(75,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSIsValue.ts(76,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSIsValue.ts(77,1): error TS2364: Invalid left-hand side of assignment expression.
|
||||
tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSIsValue.ts(72,1): error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
|
||||
tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSIsValue.ts(73,2): error TS2539: Cannot assign to 'M' because it is not a variable.
|
||||
tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSIsValue.ts(74,2): error TS2539: Cannot assign to 'C' because it is not a variable.
|
||||
tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSIsValue.ts(75,2): error TS2539: Cannot assign to 'E' because it is not a variable.
|
||||
tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSIsValue.ts(76,2): error TS2539: Cannot assign to 'foo' because it is not a variable.
|
||||
tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSIsValue.ts(77,1): error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
|
||||
tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSIsValue.ts(78,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSIsValue.ts(79,1): error TS2364: Invalid left-hand side of assignment expression.
|
||||
tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSIsValue.ts(79,1): error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
|
||||
tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSIsValue.ts(80,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSIsValue.ts(81,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSIsValue.ts(82,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
@@ -64,36 +64,36 @@ tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignm
|
||||
function foo() {
|
||||
this **= value;
|
||||
~~~~
|
||||
!!! error TS2364: Invalid left-hand side of assignment expression.
|
||||
!!! error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
|
||||
}
|
||||
|
||||
this **= value;
|
||||
~~~~
|
||||
!!! error TS2364: Invalid left-hand side of assignment expression.
|
||||
!!! error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
|
||||
|
||||
// identifiers: module, class, enum, function
|
||||
module M { export var a; }
|
||||
M **= value;
|
||||
~
|
||||
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
!!! error TS2539: Cannot assign to 'M' because it is not a variable.
|
||||
|
||||
C **= value;
|
||||
~
|
||||
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
!!! error TS2539: Cannot assign to 'C' because it is not a variable.
|
||||
|
||||
enum E { }
|
||||
E **= value;
|
||||
~
|
||||
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
!!! error TS2539: Cannot assign to 'E' because it is not a variable.
|
||||
|
||||
foo **= value;
|
||||
~~~
|
||||
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
!!! error TS2539: Cannot assign to 'foo' because it is not a variable.
|
||||
|
||||
// literals
|
||||
null **= value;
|
||||
~~~~
|
||||
!!! error TS2364: Invalid left-hand side of assignment expression.
|
||||
!!! error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
|
||||
true **= value;
|
||||
~~~~
|
||||
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
@@ -102,7 +102,7 @@ tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignm
|
||||
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
0 **= value;
|
||||
~
|
||||
!!! error TS2364: Invalid left-hand side of assignment expression.
|
||||
!!! error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
|
||||
'' **= value;
|
||||
~~
|
||||
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
@@ -160,28 +160,28 @@ tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignm
|
||||
// parentheses, the containted expression is value
|
||||
(this) **= value;
|
||||
~~~~~~
|
||||
!!! error TS2364: Invalid left-hand side of assignment expression.
|
||||
!!! error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
|
||||
(M) **= value;
|
||||
~~~
|
||||
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
~
|
||||
!!! error TS2539: Cannot assign to 'M' because it is not a variable.
|
||||
(C) **= value;
|
||||
~~~
|
||||
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
~
|
||||
!!! error TS2539: Cannot assign to 'C' because it is not a variable.
|
||||
(E) **= value;
|
||||
~~~
|
||||
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
~
|
||||
!!! error TS2539: Cannot assign to 'E' because it is not a variable.
|
||||
(foo) **= value;
|
||||
~~~~~
|
||||
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
~~~
|
||||
!!! error TS2539: Cannot assign to 'foo' because it is not a variable.
|
||||
(null) **= value;
|
||||
~~~~~~
|
||||
!!! error TS2364: Invalid left-hand side of assignment expression.
|
||||
!!! error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
|
||||
(true) **= value;
|
||||
~~~~~~
|
||||
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
(0) **= value;
|
||||
~~~
|
||||
!!! error TS2364: Invalid left-hand side of assignment expression.
|
||||
!!! error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
|
||||
('') **= value;
|
||||
~~~~
|
||||
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
tests/cases/compiler/concatClassAndString.ts(4,1): error TS2364: Invalid left-hand side of assignment expression.
|
||||
tests/cases/compiler/concatClassAndString.ts(4,1): error TS2539: Cannot assign to 'f' because it is not a variable.
|
||||
|
||||
|
||||
==== tests/cases/compiler/concatClassAndString.ts (1 errors) ====
|
||||
@@ -7,5 +7,5 @@ tests/cases/compiler/concatClassAndString.ts(4,1): error TS2364: Invalid left-ha
|
||||
|
||||
f += '';
|
||||
~
|
||||
!!! error TS2364: Invalid left-hand side of assignment expression.
|
||||
!!! error TS2539: Cannot assign to 'f' because it is not a variable.
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
tests/cases/compiler/file2.ts(1,1): error TS2449: The operand of an increment or decrement operator cannot be a constant or a read-only property.
|
||||
tests/cases/compiler/file2.ts(1,1): error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
|
||||
|
||||
|
||||
==== tests/cases/compiler/file1.ts (0 errors) ====
|
||||
@@ -8,4 +8,4 @@ tests/cases/compiler/file2.ts(1,1): error TS2449: The operand of an increment or
|
||||
==== tests/cases/compiler/file2.ts (1 errors) ====
|
||||
x++;
|
||||
~
|
||||
!!! error TS2449: The operand of an increment or decrement operator cannot be a constant or a read-only property.
|
||||
!!! error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
|
||||
@@ -1,20 +1,20 @@
|
||||
tests/cases/compiler/constDeclarations-access2.ts(5,1): error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
|
||||
tests/cases/compiler/constDeclarations-access2.ts(6,1): error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
|
||||
tests/cases/compiler/constDeclarations-access2.ts(7,1): error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
|
||||
tests/cases/compiler/constDeclarations-access2.ts(8,1): error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
|
||||
tests/cases/compiler/constDeclarations-access2.ts(9,1): error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
|
||||
tests/cases/compiler/constDeclarations-access2.ts(10,1): error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
|
||||
tests/cases/compiler/constDeclarations-access2.ts(11,1): error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
|
||||
tests/cases/compiler/constDeclarations-access2.ts(12,1): error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
|
||||
tests/cases/compiler/constDeclarations-access2.ts(13,1): error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
|
||||
tests/cases/compiler/constDeclarations-access2.ts(14,1): error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
|
||||
tests/cases/compiler/constDeclarations-access2.ts(15,1): error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
|
||||
tests/cases/compiler/constDeclarations-access2.ts(16,1): error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
|
||||
tests/cases/compiler/constDeclarations-access2.ts(18,1): error TS2449: The operand of an increment or decrement operator cannot be a constant or a read-only property.
|
||||
tests/cases/compiler/constDeclarations-access2.ts(19,1): error TS2449: The operand of an increment or decrement operator cannot be a constant or a read-only property.
|
||||
tests/cases/compiler/constDeclarations-access2.ts(20,3): error TS2449: The operand of an increment or decrement operator cannot be a constant or a read-only property.
|
||||
tests/cases/compiler/constDeclarations-access2.ts(21,3): error TS2449: The operand of an increment or decrement operator cannot be a constant or a read-only property.
|
||||
tests/cases/compiler/constDeclarations-access2.ts(23,3): error TS2449: The operand of an increment or decrement operator cannot be a constant or a read-only property.
|
||||
tests/cases/compiler/constDeclarations-access2.ts(5,1): error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
|
||||
tests/cases/compiler/constDeclarations-access2.ts(6,1): error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
|
||||
tests/cases/compiler/constDeclarations-access2.ts(7,1): error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
|
||||
tests/cases/compiler/constDeclarations-access2.ts(8,1): error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
|
||||
tests/cases/compiler/constDeclarations-access2.ts(9,1): error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
|
||||
tests/cases/compiler/constDeclarations-access2.ts(10,1): error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
|
||||
tests/cases/compiler/constDeclarations-access2.ts(11,1): error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
|
||||
tests/cases/compiler/constDeclarations-access2.ts(12,1): error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
|
||||
tests/cases/compiler/constDeclarations-access2.ts(13,1): error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
|
||||
tests/cases/compiler/constDeclarations-access2.ts(14,1): error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
|
||||
tests/cases/compiler/constDeclarations-access2.ts(15,1): error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
|
||||
tests/cases/compiler/constDeclarations-access2.ts(16,1): error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
|
||||
tests/cases/compiler/constDeclarations-access2.ts(18,1): error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
|
||||
tests/cases/compiler/constDeclarations-access2.ts(19,1): error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
|
||||
tests/cases/compiler/constDeclarations-access2.ts(20,3): error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
|
||||
tests/cases/compiler/constDeclarations-access2.ts(21,3): error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
|
||||
tests/cases/compiler/constDeclarations-access2.ts(23,5): error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
|
||||
|
||||
|
||||
==== tests/cases/compiler/constDeclarations-access2.ts (17 errors) ====
|
||||
@@ -24,57 +24,57 @@ tests/cases/compiler/constDeclarations-access2.ts(23,3): error TS2449: The opera
|
||||
// Errors
|
||||
x = 1;
|
||||
~
|
||||
!!! error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
|
||||
!!! error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
|
||||
x += 2;
|
||||
~
|
||||
!!! error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
|
||||
!!! error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
|
||||
x -= 3;
|
||||
~
|
||||
!!! error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
|
||||
!!! error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
|
||||
x *= 4;
|
||||
~
|
||||
!!! error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
|
||||
!!! error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
|
||||
x /= 5;
|
||||
~
|
||||
!!! error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
|
||||
!!! error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
|
||||
x %= 6;
|
||||
~
|
||||
!!! error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
|
||||
!!! error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
|
||||
x <<= 7;
|
||||
~
|
||||
!!! error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
|
||||
!!! error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
|
||||
x >>= 8;
|
||||
~
|
||||
!!! error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
|
||||
!!! error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
|
||||
x >>>= 9;
|
||||
~
|
||||
!!! error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
|
||||
!!! error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
|
||||
x &= 10;
|
||||
~
|
||||
!!! error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
|
||||
!!! error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
|
||||
x |= 11;
|
||||
~
|
||||
!!! error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
|
||||
!!! error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
|
||||
x ^= 12;
|
||||
~
|
||||
!!! error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
|
||||
!!! error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
|
||||
|
||||
x++;
|
||||
~
|
||||
!!! error TS2449: The operand of an increment or decrement operator cannot be a constant or a read-only property.
|
||||
!!! error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
|
||||
x--;
|
||||
~
|
||||
!!! error TS2449: The operand of an increment or decrement operator cannot be a constant or a read-only property.
|
||||
!!! error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
|
||||
++x;
|
||||
~
|
||||
!!! error TS2449: The operand of an increment or decrement operator cannot be a constant or a read-only property.
|
||||
!!! error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
|
||||
--x;
|
||||
~
|
||||
!!! error TS2449: The operand of an increment or decrement operator cannot be a constant or a read-only property.
|
||||
!!! error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
|
||||
|
||||
++((x));
|
||||
~~~~~
|
||||
!!! error TS2449: The operand of an increment or decrement operator cannot be a constant or a read-only property.
|
||||
~
|
||||
!!! error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
|
||||
|
||||
// OK
|
||||
var a = x + 1;
|
||||
|
||||
@@ -1,21 +1,21 @@
|
||||
tests/cases/compiler/constDeclarations-access3.ts(8,1): error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
|
||||
tests/cases/compiler/constDeclarations-access3.ts(9,1): error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
|
||||
tests/cases/compiler/constDeclarations-access3.ts(10,1): error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
|
||||
tests/cases/compiler/constDeclarations-access3.ts(11,1): error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
|
||||
tests/cases/compiler/constDeclarations-access3.ts(12,1): error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
|
||||
tests/cases/compiler/constDeclarations-access3.ts(13,1): error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
|
||||
tests/cases/compiler/constDeclarations-access3.ts(14,1): error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
|
||||
tests/cases/compiler/constDeclarations-access3.ts(15,1): error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
|
||||
tests/cases/compiler/constDeclarations-access3.ts(16,1): error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
|
||||
tests/cases/compiler/constDeclarations-access3.ts(17,1): error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
|
||||
tests/cases/compiler/constDeclarations-access3.ts(18,1): error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
|
||||
tests/cases/compiler/constDeclarations-access3.ts(19,1): error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
|
||||
tests/cases/compiler/constDeclarations-access3.ts(21,1): error TS2449: The operand of an increment or decrement operator cannot be a constant or a read-only property.
|
||||
tests/cases/compiler/constDeclarations-access3.ts(22,1): error TS2449: The operand of an increment or decrement operator cannot be a constant or a read-only property.
|
||||
tests/cases/compiler/constDeclarations-access3.ts(23,3): error TS2449: The operand of an increment or decrement operator cannot be a constant or a read-only property.
|
||||
tests/cases/compiler/constDeclarations-access3.ts(24,3): error TS2449: The operand of an increment or decrement operator cannot be a constant or a read-only property.
|
||||
tests/cases/compiler/constDeclarations-access3.ts(26,3): error TS2449: The operand of an increment or decrement operator cannot be a constant or a read-only property.
|
||||
tests/cases/compiler/constDeclarations-access3.ts(28,1): error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
|
||||
tests/cases/compiler/constDeclarations-access3.ts(8,3): error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
|
||||
tests/cases/compiler/constDeclarations-access3.ts(9,3): error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
|
||||
tests/cases/compiler/constDeclarations-access3.ts(10,3): error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
|
||||
tests/cases/compiler/constDeclarations-access3.ts(11,3): error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
|
||||
tests/cases/compiler/constDeclarations-access3.ts(12,3): error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
|
||||
tests/cases/compiler/constDeclarations-access3.ts(13,3): error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
|
||||
tests/cases/compiler/constDeclarations-access3.ts(14,3): error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
|
||||
tests/cases/compiler/constDeclarations-access3.ts(15,3): error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
|
||||
tests/cases/compiler/constDeclarations-access3.ts(16,3): error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
|
||||
tests/cases/compiler/constDeclarations-access3.ts(17,3): error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
|
||||
tests/cases/compiler/constDeclarations-access3.ts(18,3): error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
|
||||
tests/cases/compiler/constDeclarations-access3.ts(19,3): error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
|
||||
tests/cases/compiler/constDeclarations-access3.ts(21,3): error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
|
||||
tests/cases/compiler/constDeclarations-access3.ts(22,3): error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
|
||||
tests/cases/compiler/constDeclarations-access3.ts(23,5): error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
|
||||
tests/cases/compiler/constDeclarations-access3.ts(24,5): error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
|
||||
tests/cases/compiler/constDeclarations-access3.ts(26,7): error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
|
||||
tests/cases/compiler/constDeclarations-access3.ts(28,3): error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
|
||||
|
||||
|
||||
==== tests/cases/compiler/constDeclarations-access3.ts (18 errors) ====
|
||||
@@ -27,62 +27,62 @@ tests/cases/compiler/constDeclarations-access3.ts(28,1): error TS2450: Left-hand
|
||||
|
||||
// Errors
|
||||
M.x = 1;
|
||||
~~~
|
||||
!!! error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
|
||||
~
|
||||
!!! error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
|
||||
M.x += 2;
|
||||
~~~
|
||||
!!! error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
|
||||
~
|
||||
!!! error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
|
||||
M.x -= 3;
|
||||
~~~
|
||||
!!! error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
|
||||
~
|
||||
!!! error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
|
||||
M.x *= 4;
|
||||
~~~
|
||||
!!! error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
|
||||
~
|
||||
!!! error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
|
||||
M.x /= 5;
|
||||
~~~
|
||||
!!! error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
|
||||
~
|
||||
!!! error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
|
||||
M.x %= 6;
|
||||
~~~
|
||||
!!! error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
|
||||
~
|
||||
!!! error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
|
||||
M.x <<= 7;
|
||||
~~~
|
||||
!!! error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
|
||||
~
|
||||
!!! error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
|
||||
M.x >>= 8;
|
||||
~~~
|
||||
!!! error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
|
||||
~
|
||||
!!! error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
|
||||
M.x >>>= 9;
|
||||
~~~
|
||||
!!! error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
|
||||
~
|
||||
!!! error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
|
||||
M.x &= 10;
|
||||
~~~
|
||||
!!! error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
|
||||
~
|
||||
!!! error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
|
||||
M.x |= 11;
|
||||
~~~
|
||||
!!! error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
|
||||
~
|
||||
!!! error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
|
||||
M.x ^= 12;
|
||||
~~~
|
||||
!!! error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
|
||||
~
|
||||
!!! error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
|
||||
|
||||
M.x++;
|
||||
~~~
|
||||
!!! error TS2449: The operand of an increment or decrement operator cannot be a constant or a read-only property.
|
||||
~
|
||||
!!! error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
|
||||
M.x--;
|
||||
~~~
|
||||
!!! error TS2449: The operand of an increment or decrement operator cannot be a constant or a read-only property.
|
||||
~
|
||||
!!! error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
|
||||
++M.x;
|
||||
~~~
|
||||
!!! error TS2449: The operand of an increment or decrement operator cannot be a constant or a read-only property.
|
||||
~
|
||||
!!! error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
|
||||
--M.x;
|
||||
~~~
|
||||
!!! error TS2449: The operand of an increment or decrement operator cannot be a constant or a read-only property.
|
||||
~
|
||||
!!! error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
|
||||
|
||||
++((M.x));
|
||||
~~~~~~~
|
||||
!!! error TS2449: The operand of an increment or decrement operator cannot be a constant or a read-only property.
|
||||
~
|
||||
!!! error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
|
||||
|
||||
M["x"] = 0;
|
||||
~~~~~~
|
||||
!!! error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
|
||||
~~~
|
||||
!!! error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
|
||||
|
||||
// OK
|
||||
var a = M.x + 1;
|
||||
|
||||
@@ -1,21 +1,21 @@
|
||||
tests/cases/compiler/constDeclarations-access4.ts(8,1): error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
|
||||
tests/cases/compiler/constDeclarations-access4.ts(9,1): error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
|
||||
tests/cases/compiler/constDeclarations-access4.ts(10,1): error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
|
||||
tests/cases/compiler/constDeclarations-access4.ts(11,1): error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
|
||||
tests/cases/compiler/constDeclarations-access4.ts(12,1): error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
|
||||
tests/cases/compiler/constDeclarations-access4.ts(13,1): error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
|
||||
tests/cases/compiler/constDeclarations-access4.ts(14,1): error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
|
||||
tests/cases/compiler/constDeclarations-access4.ts(15,1): error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
|
||||
tests/cases/compiler/constDeclarations-access4.ts(16,1): error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
|
||||
tests/cases/compiler/constDeclarations-access4.ts(17,1): error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
|
||||
tests/cases/compiler/constDeclarations-access4.ts(18,1): error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
|
||||
tests/cases/compiler/constDeclarations-access4.ts(19,1): error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
|
||||
tests/cases/compiler/constDeclarations-access4.ts(21,1): error TS2449: The operand of an increment or decrement operator cannot be a constant or a read-only property.
|
||||
tests/cases/compiler/constDeclarations-access4.ts(22,1): error TS2449: The operand of an increment or decrement operator cannot be a constant or a read-only property.
|
||||
tests/cases/compiler/constDeclarations-access4.ts(23,3): error TS2449: The operand of an increment or decrement operator cannot be a constant or a read-only property.
|
||||
tests/cases/compiler/constDeclarations-access4.ts(24,3): error TS2449: The operand of an increment or decrement operator cannot be a constant or a read-only property.
|
||||
tests/cases/compiler/constDeclarations-access4.ts(26,3): error TS2449: The operand of an increment or decrement operator cannot be a constant or a read-only property.
|
||||
tests/cases/compiler/constDeclarations-access4.ts(28,1): error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
|
||||
tests/cases/compiler/constDeclarations-access4.ts(8,3): error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
|
||||
tests/cases/compiler/constDeclarations-access4.ts(9,3): error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
|
||||
tests/cases/compiler/constDeclarations-access4.ts(10,3): error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
|
||||
tests/cases/compiler/constDeclarations-access4.ts(11,3): error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
|
||||
tests/cases/compiler/constDeclarations-access4.ts(12,3): error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
|
||||
tests/cases/compiler/constDeclarations-access4.ts(13,3): error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
|
||||
tests/cases/compiler/constDeclarations-access4.ts(14,3): error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
|
||||
tests/cases/compiler/constDeclarations-access4.ts(15,3): error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
|
||||
tests/cases/compiler/constDeclarations-access4.ts(16,3): error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
|
||||
tests/cases/compiler/constDeclarations-access4.ts(17,3): error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
|
||||
tests/cases/compiler/constDeclarations-access4.ts(18,3): error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
|
||||
tests/cases/compiler/constDeclarations-access4.ts(19,3): error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
|
||||
tests/cases/compiler/constDeclarations-access4.ts(21,3): error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
|
||||
tests/cases/compiler/constDeclarations-access4.ts(22,3): error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
|
||||
tests/cases/compiler/constDeclarations-access4.ts(23,5): error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
|
||||
tests/cases/compiler/constDeclarations-access4.ts(24,5): error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
|
||||
tests/cases/compiler/constDeclarations-access4.ts(26,7): error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
|
||||
tests/cases/compiler/constDeclarations-access4.ts(28,3): error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
|
||||
|
||||
|
||||
==== tests/cases/compiler/constDeclarations-access4.ts (18 errors) ====
|
||||
@@ -27,62 +27,62 @@ tests/cases/compiler/constDeclarations-access4.ts(28,1): error TS2450: Left-hand
|
||||
|
||||
// Errors
|
||||
M.x = 1;
|
||||
~~~
|
||||
!!! error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
|
||||
~
|
||||
!!! error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
|
||||
M.x += 2;
|
||||
~~~
|
||||
!!! error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
|
||||
~
|
||||
!!! error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
|
||||
M.x -= 3;
|
||||
~~~
|
||||
!!! error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
|
||||
~
|
||||
!!! error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
|
||||
M.x *= 4;
|
||||
~~~
|
||||
!!! error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
|
||||
~
|
||||
!!! error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
|
||||
M.x /= 5;
|
||||
~~~
|
||||
!!! error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
|
||||
~
|
||||
!!! error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
|
||||
M.x %= 6;
|
||||
~~~
|
||||
!!! error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
|
||||
~
|
||||
!!! error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
|
||||
M.x <<= 7;
|
||||
~~~
|
||||
!!! error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
|
||||
~
|
||||
!!! error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
|
||||
M.x >>= 8;
|
||||
~~~
|
||||
!!! error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
|
||||
~
|
||||
!!! error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
|
||||
M.x >>>= 9;
|
||||
~~~
|
||||
!!! error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
|
||||
~
|
||||
!!! error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
|
||||
M.x &= 10;
|
||||
~~~
|
||||
!!! error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
|
||||
~
|
||||
!!! error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
|
||||
M.x |= 11;
|
||||
~~~
|
||||
!!! error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
|
||||
~
|
||||
!!! error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
|
||||
M.x ^= 12;
|
||||
~~~
|
||||
!!! error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
|
||||
~
|
||||
!!! error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
|
||||
|
||||
M.x++;
|
||||
~~~
|
||||
!!! error TS2449: The operand of an increment or decrement operator cannot be a constant or a read-only property.
|
||||
~
|
||||
!!! error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
|
||||
M.x--;
|
||||
~~~
|
||||
!!! error TS2449: The operand of an increment or decrement operator cannot be a constant or a read-only property.
|
||||
~
|
||||
!!! error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
|
||||
++M.x;
|
||||
~~~
|
||||
!!! error TS2449: The operand of an increment or decrement operator cannot be a constant or a read-only property.
|
||||
~
|
||||
!!! error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
|
||||
--M.x;
|
||||
~~~
|
||||
!!! error TS2449: The operand of an increment or decrement operator cannot be a constant or a read-only property.
|
||||
~
|
||||
!!! error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
|
||||
|
||||
++((M.x));
|
||||
~~~~~~~
|
||||
!!! error TS2449: The operand of an increment or decrement operator cannot be a constant or a read-only property.
|
||||
~
|
||||
!!! error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
|
||||
|
||||
M["x"] = 0;
|
||||
~~~~~~
|
||||
!!! error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
|
||||
~~~
|
||||
!!! error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
|
||||
|
||||
// OK
|
||||
var a = M.x + 1;
|
||||
|
||||
@@ -1,21 +1,21 @@
|
||||
tests/cases/compiler/constDeclarations_access_2.ts(4,1): error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
|
||||
tests/cases/compiler/constDeclarations_access_2.ts(5,1): error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
|
||||
tests/cases/compiler/constDeclarations_access_2.ts(6,1): error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
|
||||
tests/cases/compiler/constDeclarations_access_2.ts(7,1): error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
|
||||
tests/cases/compiler/constDeclarations_access_2.ts(8,1): error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
|
||||
tests/cases/compiler/constDeclarations_access_2.ts(9,1): error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
|
||||
tests/cases/compiler/constDeclarations_access_2.ts(10,1): error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
|
||||
tests/cases/compiler/constDeclarations_access_2.ts(11,1): error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
|
||||
tests/cases/compiler/constDeclarations_access_2.ts(12,1): error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
|
||||
tests/cases/compiler/constDeclarations_access_2.ts(13,1): error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
|
||||
tests/cases/compiler/constDeclarations_access_2.ts(14,1): error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
|
||||
tests/cases/compiler/constDeclarations_access_2.ts(15,1): error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
|
||||
tests/cases/compiler/constDeclarations_access_2.ts(17,1): error TS2449: The operand of an increment or decrement operator cannot be a constant or a read-only property.
|
||||
tests/cases/compiler/constDeclarations_access_2.ts(18,1): error TS2449: The operand of an increment or decrement operator cannot be a constant or a read-only property.
|
||||
tests/cases/compiler/constDeclarations_access_2.ts(19,3): error TS2449: The operand of an increment or decrement operator cannot be a constant or a read-only property.
|
||||
tests/cases/compiler/constDeclarations_access_2.ts(20,3): error TS2449: The operand of an increment or decrement operator cannot be a constant or a read-only property.
|
||||
tests/cases/compiler/constDeclarations_access_2.ts(22,3): error TS2449: The operand of an increment or decrement operator cannot be a constant or a read-only property.
|
||||
tests/cases/compiler/constDeclarations_access_2.ts(24,1): error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
|
||||
tests/cases/compiler/constDeclarations_access_2.ts(4,3): error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
|
||||
tests/cases/compiler/constDeclarations_access_2.ts(5,3): error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
|
||||
tests/cases/compiler/constDeclarations_access_2.ts(6,3): error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
|
||||
tests/cases/compiler/constDeclarations_access_2.ts(7,3): error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
|
||||
tests/cases/compiler/constDeclarations_access_2.ts(8,3): error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
|
||||
tests/cases/compiler/constDeclarations_access_2.ts(9,3): error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
|
||||
tests/cases/compiler/constDeclarations_access_2.ts(10,3): error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
|
||||
tests/cases/compiler/constDeclarations_access_2.ts(11,3): error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
|
||||
tests/cases/compiler/constDeclarations_access_2.ts(12,3): error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
|
||||
tests/cases/compiler/constDeclarations_access_2.ts(13,3): error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
|
||||
tests/cases/compiler/constDeclarations_access_2.ts(14,3): error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
|
||||
tests/cases/compiler/constDeclarations_access_2.ts(15,3): error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
|
||||
tests/cases/compiler/constDeclarations_access_2.ts(17,3): error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
|
||||
tests/cases/compiler/constDeclarations_access_2.ts(18,3): error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
|
||||
tests/cases/compiler/constDeclarations_access_2.ts(19,5): error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
|
||||
tests/cases/compiler/constDeclarations_access_2.ts(20,5): error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
|
||||
tests/cases/compiler/constDeclarations_access_2.ts(22,7): error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
|
||||
tests/cases/compiler/constDeclarations_access_2.ts(24,3): error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
|
||||
|
||||
|
||||
==== tests/cases/compiler/constDeclarations_access_2.ts (18 errors) ====
|
||||
@@ -23,62 +23,62 @@ tests/cases/compiler/constDeclarations_access_2.ts(24,1): error TS2450: Left-han
|
||||
import m = require('constDeclarations_access_1');
|
||||
// Errors
|
||||
m.x = 1;
|
||||
~~~
|
||||
!!! error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
|
||||
~
|
||||
!!! error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
|
||||
m.x += 2;
|
||||
~~~
|
||||
!!! error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
|
||||
~
|
||||
!!! error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
|
||||
m.x -= 3;
|
||||
~~~
|
||||
!!! error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
|
||||
~
|
||||
!!! error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
|
||||
m.x *= 4;
|
||||
~~~
|
||||
!!! error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
|
||||
~
|
||||
!!! error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
|
||||
m.x /= 5;
|
||||
~~~
|
||||
!!! error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
|
||||
~
|
||||
!!! error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
|
||||
m.x %= 6;
|
||||
~~~
|
||||
!!! error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
|
||||
~
|
||||
!!! error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
|
||||
m.x <<= 7;
|
||||
~~~
|
||||
!!! error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
|
||||
~
|
||||
!!! error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
|
||||
m.x >>= 8;
|
||||
~~~
|
||||
!!! error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
|
||||
~
|
||||
!!! error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
|
||||
m.x >>>= 9;
|
||||
~~~
|
||||
!!! error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
|
||||
~
|
||||
!!! error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
|
||||
m.x &= 10;
|
||||
~~~
|
||||
!!! error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
|
||||
~
|
||||
!!! error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
|
||||
m.x |= 11;
|
||||
~~~
|
||||
!!! error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
|
||||
~
|
||||
!!! error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
|
||||
m.x ^= 12;
|
||||
~~~
|
||||
!!! error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
|
||||
~
|
||||
!!! error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
|
||||
m
|
||||
m.x++;
|
||||
~~~
|
||||
!!! error TS2449: The operand of an increment or decrement operator cannot be a constant or a read-only property.
|
||||
~
|
||||
!!! error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
|
||||
m.x--;
|
||||
~~~
|
||||
!!! error TS2449: The operand of an increment or decrement operator cannot be a constant or a read-only property.
|
||||
~
|
||||
!!! error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
|
||||
++m.x;
|
||||
~~~
|
||||
!!! error TS2449: The operand of an increment or decrement operator cannot be a constant or a read-only property.
|
||||
~
|
||||
!!! error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
|
||||
--m.x;
|
||||
~~~
|
||||
!!! error TS2449: The operand of an increment or decrement operator cannot be a constant or a read-only property.
|
||||
~
|
||||
!!! error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
|
||||
|
||||
++((m.x));
|
||||
~~~~~~~
|
||||
!!! error TS2449: The operand of an increment or decrement operator cannot be a constant or a read-only property.
|
||||
~
|
||||
!!! error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
|
||||
|
||||
m["x"] = 0;
|
||||
~~~~~~
|
||||
!!! error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
|
||||
~~~
|
||||
!!! error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
|
||||
|
||||
// OK
|
||||
var a = m.x + 1;
|
||||
|
||||
@@ -5,7 +5,7 @@ tests/cases/compiler/constDeclarations-errors.ts(5,11): error TS1155: 'const' de
|
||||
tests/cases/compiler/constDeclarations-errors.ts(5,15): error TS1155: 'const' declarations must be initialized
|
||||
tests/cases/compiler/constDeclarations-errors.ts(5,27): error TS1155: 'const' declarations must be initialized
|
||||
tests/cases/compiler/constDeclarations-errors.ts(10,19): error TS2365: Operator '<' cannot be applied to types '0' and '1'.
|
||||
tests/cases/compiler/constDeclarations-errors.ts(10,27): error TS2449: The operand of an increment or decrement operator cannot be a constant or a read-only property.
|
||||
tests/cases/compiler/constDeclarations-errors.ts(10,27): error TS2540: Cannot assign to 'c8' because it is a constant or a read-only property.
|
||||
tests/cases/compiler/constDeclarations-errors.ts(13,11): error TS1155: 'const' declarations must be initialized
|
||||
tests/cases/compiler/constDeclarations-errors.ts(16,20): error TS1155: 'const' declarations must be initialized
|
||||
tests/cases/compiler/constDeclarations-errors.ts(16,25): error TS2365: Operator '<' cannot be applied to types '0' and '1'.
|
||||
@@ -37,7 +37,7 @@ tests/cases/compiler/constDeclarations-errors.ts(16,25): error TS2365: Operator
|
||||
~~~~~~
|
||||
!!! error TS2365: Operator '<' cannot be applied to types '0' and '1'.
|
||||
~~
|
||||
!!! error TS2449: The operand of an increment or decrement operator cannot be a constant or a read-only property.
|
||||
!!! error TS2540: Cannot assign to 'c8' because it is a constant or a read-only property.
|
||||
|
||||
// error, can not be unintalized
|
||||
for(const c9; c9 < 1;) { }
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
tests/cases/compiler/constEnumBadPropertyNames.ts(2,11): error TS2479: Property 'B' does not exist on 'const' enum 'E'.
|
||||
tests/cases/compiler/constEnumBadPropertyNames.ts(2,11): error TS2339: Property 'B' does not exist on type 'typeof E'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/constEnumBadPropertyNames.ts (1 errors) ====
|
||||
const enum E { A }
|
||||
var x = E["B"]
|
||||
~~~
|
||||
!!! error TS2479: Property 'B' does not exist on 'const' enum 'E'.
|
||||
!!! error TS2339: Property 'B' does not exist on type 'typeof E'.
|
||||
@@ -1,7 +1,7 @@
|
||||
tests/cases/conformance/constEnums/constEnumPropertyAccess2.ts(14,9): error TS2475: 'const' enums can only be used in property or index access expressions or the right hand side of an import declaration or export assignment.
|
||||
tests/cases/conformance/constEnums/constEnumPropertyAccess2.ts(15,12): error TS2476: A const enum member can only be accessed using a string literal.
|
||||
tests/cases/conformance/constEnums/constEnumPropertyAccess2.ts(17,1): error TS2322: Type '"string"' is not assignable to type 'G'.
|
||||
tests/cases/conformance/constEnums/constEnumPropertyAccess2.ts(19,1): error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
|
||||
tests/cases/conformance/constEnums/constEnumPropertyAccess2.ts(19,3): error TS2540: Cannot assign to 'B' because it is a constant or a read-only property.
|
||||
|
||||
|
||||
==== tests/cases/conformance/constEnums/constEnumPropertyAccess2.ts (4 errors) ====
|
||||
@@ -30,6 +30,6 @@ tests/cases/conformance/constEnums/constEnumPropertyAccess2.ts(19,1): error TS24
|
||||
!!! error TS2322: Type '"string"' is not assignable to type 'G'.
|
||||
function foo(x: G) { }
|
||||
G.B = 3;
|
||||
~~~
|
||||
!!! error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
|
||||
~
|
||||
!!! error TS2540: Cannot assign to 'B' because it is a constant or a read-only property.
|
||||
|
||||
@@ -76,16 +76,16 @@ enum numbersNotConst {
|
||||
}
|
||||
|
||||
let s3 = test[numbersNotConst.zero];
|
||||
>s3 : any
|
||||
>test[numbersNotConst.zero] : any
|
||||
>s3 : string
|
||||
>test[numbersNotConst.zero] : string
|
||||
>test : indexAccess
|
||||
>numbersNotConst.zero : numbersNotConst.zero
|
||||
>numbersNotConst : typeof numbersNotConst
|
||||
>zero : numbersNotConst.zero
|
||||
|
||||
let n3 = test[numbersNotConst.one];
|
||||
>n3 : any
|
||||
>test[numbersNotConst.one] : any
|
||||
>n3 : number
|
||||
>test[numbersNotConst.one] : number
|
||||
>test : indexAccess
|
||||
>numbersNotConst.one : numbersNotConst.one
|
||||
>numbersNotConst : typeof numbersNotConst
|
||||
|
||||
@@ -25,7 +25,7 @@ tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(59,5): error TS1
|
||||
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(70,13): error TS1109: Expression expected.
|
||||
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(73,37): error TS1127: Invalid character.
|
||||
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(82,13): error TS1109: Expression expected.
|
||||
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(90,23): error TS2364: Invalid left-hand side of assignment expression.
|
||||
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(90,23): error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
|
||||
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(91,13): error TS1109: Expression expected.
|
||||
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(106,29): error TS1109: Expression expected.
|
||||
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(107,13): error TS1109: Expression expected.
|
||||
@@ -236,7 +236,7 @@ tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(262,1): error TS
|
||||
//
|
||||
var any = 0 ^=
|
||||
~
|
||||
!!! error TS2364: Invalid left-hand side of assignment expression.
|
||||
!!! error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
|
||||
var bool = 0;
|
||||
~~~
|
||||
!!! error TS1109: Expression expected.
|
||||
|
||||
@@ -0,0 +1,59 @@
|
||||
//// [contextualTypingOfTooShortOverloads.ts]
|
||||
// small repro from #11875
|
||||
var use: Overload;
|
||||
use((req, res) => {});
|
||||
|
||||
interface Overload {
|
||||
(handler1: (req1: string) => void): void;
|
||||
(handler2: (req2: number, res2: number) => void): void;
|
||||
}
|
||||
// larger repro from #11875
|
||||
let app: MyApp;
|
||||
app.use((err: any, req, res, next) => { return; });
|
||||
|
||||
|
||||
interface MyApp {
|
||||
use: IRouterHandler<this> & IRouterMatcher<this>;
|
||||
}
|
||||
|
||||
interface IRouterHandler<T> {
|
||||
(...handlers: RequestHandler[]): T;
|
||||
(...handlers: RequestHandlerParams[]): T;
|
||||
}
|
||||
|
||||
interface IRouterMatcher<T> {
|
||||
(path: PathParams, ...handlers: RequestHandler[]): T;
|
||||
(path: PathParams, ...handlers: RequestHandlerParams[]): T;
|
||||
}
|
||||
|
||||
type PathParams = string | RegExp | (string | RegExp)[];
|
||||
type RequestHandlerParams = RequestHandler | ErrorRequestHandler | (RequestHandler | ErrorRequestHandler)[];
|
||||
|
||||
interface RequestHandler {
|
||||
(req: Request, res: Response, next: NextFunction): any;
|
||||
}
|
||||
|
||||
interface ErrorRequestHandler {
|
||||
(err: any, req: Request, res: Response, next: NextFunction): any;
|
||||
}
|
||||
|
||||
interface Request {
|
||||
method: string;
|
||||
}
|
||||
|
||||
interface Response {
|
||||
statusCode: number;
|
||||
}
|
||||
|
||||
interface NextFunction {
|
||||
(err?: any): void;
|
||||
}
|
||||
|
||||
|
||||
//// [contextualTypingOfTooShortOverloads.js]
|
||||
// small repro from #11875
|
||||
var use;
|
||||
use(function (req, res) { });
|
||||
// larger repro from #11875
|
||||
var app;
|
||||
app.use(function (err, req, res, next) { return; });
|
||||
@@ -0,0 +1,139 @@
|
||||
=== tests/cases/compiler/contextualTypingOfTooShortOverloads.ts ===
|
||||
// small repro from #11875
|
||||
var use: Overload;
|
||||
>use : Symbol(use, Decl(contextualTypingOfTooShortOverloads.ts, 1, 3))
|
||||
>Overload : Symbol(Overload, Decl(contextualTypingOfTooShortOverloads.ts, 2, 22))
|
||||
|
||||
use((req, res) => {});
|
||||
>use : Symbol(use, Decl(contextualTypingOfTooShortOverloads.ts, 1, 3))
|
||||
>req : Symbol(req, Decl(contextualTypingOfTooShortOverloads.ts, 2, 5))
|
||||
>res : Symbol(res, Decl(contextualTypingOfTooShortOverloads.ts, 2, 9))
|
||||
|
||||
interface Overload {
|
||||
>Overload : Symbol(Overload, Decl(contextualTypingOfTooShortOverloads.ts, 2, 22))
|
||||
|
||||
(handler1: (req1: string) => void): void;
|
||||
>handler1 : Symbol(handler1, Decl(contextualTypingOfTooShortOverloads.ts, 5, 5))
|
||||
>req1 : Symbol(req1, Decl(contextualTypingOfTooShortOverloads.ts, 5, 16))
|
||||
|
||||
(handler2: (req2: number, res2: number) => void): void;
|
||||
>handler2 : Symbol(handler2, Decl(contextualTypingOfTooShortOverloads.ts, 6, 5))
|
||||
>req2 : Symbol(req2, Decl(contextualTypingOfTooShortOverloads.ts, 6, 16))
|
||||
>res2 : Symbol(res2, Decl(contextualTypingOfTooShortOverloads.ts, 6, 29))
|
||||
}
|
||||
// larger repro from #11875
|
||||
let app: MyApp;
|
||||
>app : Symbol(app, Decl(contextualTypingOfTooShortOverloads.ts, 9, 3))
|
||||
>MyApp : Symbol(MyApp, Decl(contextualTypingOfTooShortOverloads.ts, 10, 51))
|
||||
|
||||
app.use((err: any, req, res, next) => { return; });
|
||||
>app.use : Symbol(MyApp.use, Decl(contextualTypingOfTooShortOverloads.ts, 13, 17))
|
||||
>app : Symbol(app, Decl(contextualTypingOfTooShortOverloads.ts, 9, 3))
|
||||
>use : Symbol(MyApp.use, Decl(contextualTypingOfTooShortOverloads.ts, 13, 17))
|
||||
>err : Symbol(err, Decl(contextualTypingOfTooShortOverloads.ts, 10, 9))
|
||||
>req : Symbol(req, Decl(contextualTypingOfTooShortOverloads.ts, 10, 18))
|
||||
>res : Symbol(res, Decl(contextualTypingOfTooShortOverloads.ts, 10, 23))
|
||||
>next : Symbol(next, Decl(contextualTypingOfTooShortOverloads.ts, 10, 28))
|
||||
|
||||
|
||||
interface MyApp {
|
||||
>MyApp : Symbol(MyApp, Decl(contextualTypingOfTooShortOverloads.ts, 10, 51))
|
||||
|
||||
use: IRouterHandler<this> & IRouterMatcher<this>;
|
||||
>use : Symbol(MyApp.use, Decl(contextualTypingOfTooShortOverloads.ts, 13, 17))
|
||||
>IRouterHandler : Symbol(IRouterHandler, Decl(contextualTypingOfTooShortOverloads.ts, 15, 1))
|
||||
>IRouterMatcher : Symbol(IRouterMatcher, Decl(contextualTypingOfTooShortOverloads.ts, 20, 1))
|
||||
}
|
||||
|
||||
interface IRouterHandler<T> {
|
||||
>IRouterHandler : Symbol(IRouterHandler, Decl(contextualTypingOfTooShortOverloads.ts, 15, 1))
|
||||
>T : Symbol(T, Decl(contextualTypingOfTooShortOverloads.ts, 17, 25))
|
||||
|
||||
(...handlers: RequestHandler[]): T;
|
||||
>handlers : Symbol(handlers, Decl(contextualTypingOfTooShortOverloads.ts, 18, 5))
|
||||
>RequestHandler : Symbol(RequestHandler, Decl(contextualTypingOfTooShortOverloads.ts, 28, 108))
|
||||
>T : Symbol(T, Decl(contextualTypingOfTooShortOverloads.ts, 17, 25))
|
||||
|
||||
(...handlers: RequestHandlerParams[]): T;
|
||||
>handlers : Symbol(handlers, Decl(contextualTypingOfTooShortOverloads.ts, 19, 5))
|
||||
>RequestHandlerParams : Symbol(RequestHandlerParams, Decl(contextualTypingOfTooShortOverloads.ts, 27, 56))
|
||||
>T : Symbol(T, Decl(contextualTypingOfTooShortOverloads.ts, 17, 25))
|
||||
}
|
||||
|
||||
interface IRouterMatcher<T> {
|
||||
>IRouterMatcher : Symbol(IRouterMatcher, Decl(contextualTypingOfTooShortOverloads.ts, 20, 1))
|
||||
>T : Symbol(T, Decl(contextualTypingOfTooShortOverloads.ts, 22, 25))
|
||||
|
||||
(path: PathParams, ...handlers: RequestHandler[]): T;
|
||||
>path : Symbol(path, Decl(contextualTypingOfTooShortOverloads.ts, 23, 5))
|
||||
>PathParams : Symbol(PathParams, Decl(contextualTypingOfTooShortOverloads.ts, 25, 1))
|
||||
>handlers : Symbol(handlers, Decl(contextualTypingOfTooShortOverloads.ts, 23, 22))
|
||||
>RequestHandler : Symbol(RequestHandler, Decl(contextualTypingOfTooShortOverloads.ts, 28, 108))
|
||||
>T : Symbol(T, Decl(contextualTypingOfTooShortOverloads.ts, 22, 25))
|
||||
|
||||
(path: PathParams, ...handlers: RequestHandlerParams[]): T;
|
||||
>path : Symbol(path, Decl(contextualTypingOfTooShortOverloads.ts, 24, 5))
|
||||
>PathParams : Symbol(PathParams, Decl(contextualTypingOfTooShortOverloads.ts, 25, 1))
|
||||
>handlers : Symbol(handlers, Decl(contextualTypingOfTooShortOverloads.ts, 24, 22))
|
||||
>RequestHandlerParams : Symbol(RequestHandlerParams, Decl(contextualTypingOfTooShortOverloads.ts, 27, 56))
|
||||
>T : Symbol(T, Decl(contextualTypingOfTooShortOverloads.ts, 22, 25))
|
||||
}
|
||||
|
||||
type PathParams = string | RegExp | (string | RegExp)[];
|
||||
>PathParams : Symbol(PathParams, Decl(contextualTypingOfTooShortOverloads.ts, 25, 1))
|
||||
>RegExp : Symbol(RegExp, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
|
||||
>RegExp : Symbol(RegExp, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
|
||||
|
||||
type RequestHandlerParams = RequestHandler | ErrorRequestHandler | (RequestHandler | ErrorRequestHandler)[];
|
||||
>RequestHandlerParams : Symbol(RequestHandlerParams, Decl(contextualTypingOfTooShortOverloads.ts, 27, 56))
|
||||
>RequestHandler : Symbol(RequestHandler, Decl(contextualTypingOfTooShortOverloads.ts, 28, 108))
|
||||
>ErrorRequestHandler : Symbol(ErrorRequestHandler, Decl(contextualTypingOfTooShortOverloads.ts, 32, 1))
|
||||
>RequestHandler : Symbol(RequestHandler, Decl(contextualTypingOfTooShortOverloads.ts, 28, 108))
|
||||
>ErrorRequestHandler : Symbol(ErrorRequestHandler, Decl(contextualTypingOfTooShortOverloads.ts, 32, 1))
|
||||
|
||||
interface RequestHandler {
|
||||
>RequestHandler : Symbol(RequestHandler, Decl(contextualTypingOfTooShortOverloads.ts, 28, 108))
|
||||
|
||||
(req: Request, res: Response, next: NextFunction): any;
|
||||
>req : Symbol(req, Decl(contextualTypingOfTooShortOverloads.ts, 31, 5))
|
||||
>Request : Symbol(Request, Decl(contextualTypingOfTooShortOverloads.ts, 36, 1))
|
||||
>res : Symbol(res, Decl(contextualTypingOfTooShortOverloads.ts, 31, 18))
|
||||
>Response : Symbol(Response, Decl(contextualTypingOfTooShortOverloads.ts, 40, 1))
|
||||
>next : Symbol(next, Decl(contextualTypingOfTooShortOverloads.ts, 31, 33))
|
||||
>NextFunction : Symbol(NextFunction, Decl(contextualTypingOfTooShortOverloads.ts, 44, 1))
|
||||
}
|
||||
|
||||
interface ErrorRequestHandler {
|
||||
>ErrorRequestHandler : Symbol(ErrorRequestHandler, Decl(contextualTypingOfTooShortOverloads.ts, 32, 1))
|
||||
|
||||
(err: any, req: Request, res: Response, next: NextFunction): any;
|
||||
>err : Symbol(err, Decl(contextualTypingOfTooShortOverloads.ts, 35, 5))
|
||||
>req : Symbol(req, Decl(contextualTypingOfTooShortOverloads.ts, 35, 14))
|
||||
>Request : Symbol(Request, Decl(contextualTypingOfTooShortOverloads.ts, 36, 1))
|
||||
>res : Symbol(res, Decl(contextualTypingOfTooShortOverloads.ts, 35, 28))
|
||||
>Response : Symbol(Response, Decl(contextualTypingOfTooShortOverloads.ts, 40, 1))
|
||||
>next : Symbol(next, Decl(contextualTypingOfTooShortOverloads.ts, 35, 43))
|
||||
>NextFunction : Symbol(NextFunction, Decl(contextualTypingOfTooShortOverloads.ts, 44, 1))
|
||||
}
|
||||
|
||||
interface Request {
|
||||
>Request : Symbol(Request, Decl(contextualTypingOfTooShortOverloads.ts, 36, 1))
|
||||
|
||||
method: string;
|
||||
>method : Symbol(Request.method, Decl(contextualTypingOfTooShortOverloads.ts, 38, 19))
|
||||
}
|
||||
|
||||
interface Response {
|
||||
>Response : Symbol(Response, Decl(contextualTypingOfTooShortOverloads.ts, 40, 1))
|
||||
|
||||
statusCode: number;
|
||||
>statusCode : Symbol(Response.statusCode, Decl(contextualTypingOfTooShortOverloads.ts, 42, 20))
|
||||
}
|
||||
|
||||
interface NextFunction {
|
||||
>NextFunction : Symbol(NextFunction, Decl(contextualTypingOfTooShortOverloads.ts, 44, 1))
|
||||
|
||||
(err?: any): void;
|
||||
>err : Symbol(err, Decl(contextualTypingOfTooShortOverloads.ts, 47, 5))
|
||||
}
|
||||
|
||||
@@ -0,0 +1,143 @@
|
||||
=== tests/cases/compiler/contextualTypingOfTooShortOverloads.ts ===
|
||||
// small repro from #11875
|
||||
var use: Overload;
|
||||
>use : Overload
|
||||
>Overload : Overload
|
||||
|
||||
use((req, res) => {});
|
||||
>use((req, res) => {}) : void
|
||||
>use : Overload
|
||||
>(req, res) => {} : (req: any, res: any) => void
|
||||
>req : any
|
||||
>res : any
|
||||
|
||||
interface Overload {
|
||||
>Overload : Overload
|
||||
|
||||
(handler1: (req1: string) => void): void;
|
||||
>handler1 : (req1: string) => void
|
||||
>req1 : string
|
||||
|
||||
(handler2: (req2: number, res2: number) => void): void;
|
||||
>handler2 : (req2: number, res2: number) => void
|
||||
>req2 : number
|
||||
>res2 : number
|
||||
}
|
||||
// larger repro from #11875
|
||||
let app: MyApp;
|
||||
>app : MyApp
|
||||
>MyApp : MyApp
|
||||
|
||||
app.use((err: any, req, res, next) => { return; });
|
||||
>app.use((err: any, req, res, next) => { return; }) : MyApp
|
||||
>app.use : IRouterHandler<MyApp> & IRouterMatcher<MyApp>
|
||||
>app : MyApp
|
||||
>use : IRouterHandler<MyApp> & IRouterMatcher<MyApp>
|
||||
>(err: any, req, res, next) => { return; } : (err: any, req: any, res: any, next: any) => void
|
||||
>err : any
|
||||
>req : any
|
||||
>res : any
|
||||
>next : any
|
||||
|
||||
|
||||
interface MyApp {
|
||||
>MyApp : MyApp
|
||||
|
||||
use: IRouterHandler<this> & IRouterMatcher<this>;
|
||||
>use : IRouterHandler<this> & IRouterMatcher<this>
|
||||
>IRouterHandler : IRouterHandler<T>
|
||||
>IRouterMatcher : IRouterMatcher<T>
|
||||
}
|
||||
|
||||
interface IRouterHandler<T> {
|
||||
>IRouterHandler : IRouterHandler<T>
|
||||
>T : T
|
||||
|
||||
(...handlers: RequestHandler[]): T;
|
||||
>handlers : RequestHandler[]
|
||||
>RequestHandler : RequestHandler
|
||||
>T : T
|
||||
|
||||
(...handlers: RequestHandlerParams[]): T;
|
||||
>handlers : RequestHandlerParams[]
|
||||
>RequestHandlerParams : RequestHandlerParams
|
||||
>T : T
|
||||
}
|
||||
|
||||
interface IRouterMatcher<T> {
|
||||
>IRouterMatcher : IRouterMatcher<T>
|
||||
>T : T
|
||||
|
||||
(path: PathParams, ...handlers: RequestHandler[]): T;
|
||||
>path : PathParams
|
||||
>PathParams : PathParams
|
||||
>handlers : RequestHandler[]
|
||||
>RequestHandler : RequestHandler
|
||||
>T : T
|
||||
|
||||
(path: PathParams, ...handlers: RequestHandlerParams[]): T;
|
||||
>path : PathParams
|
||||
>PathParams : PathParams
|
||||
>handlers : RequestHandlerParams[]
|
||||
>RequestHandlerParams : RequestHandlerParams
|
||||
>T : T
|
||||
}
|
||||
|
||||
type PathParams = string | RegExp | (string | RegExp)[];
|
||||
>PathParams : PathParams
|
||||
>RegExp : RegExp
|
||||
>RegExp : RegExp
|
||||
|
||||
type RequestHandlerParams = RequestHandler | ErrorRequestHandler | (RequestHandler | ErrorRequestHandler)[];
|
||||
>RequestHandlerParams : RequestHandlerParams
|
||||
>RequestHandler : RequestHandler
|
||||
>ErrorRequestHandler : ErrorRequestHandler
|
||||
>RequestHandler : RequestHandler
|
||||
>ErrorRequestHandler : ErrorRequestHandler
|
||||
|
||||
interface RequestHandler {
|
||||
>RequestHandler : RequestHandler
|
||||
|
||||
(req: Request, res: Response, next: NextFunction): any;
|
||||
>req : Request
|
||||
>Request : Request
|
||||
>res : Response
|
||||
>Response : Response
|
||||
>next : NextFunction
|
||||
>NextFunction : NextFunction
|
||||
}
|
||||
|
||||
interface ErrorRequestHandler {
|
||||
>ErrorRequestHandler : ErrorRequestHandler
|
||||
|
||||
(err: any, req: Request, res: Response, next: NextFunction): any;
|
||||
>err : any
|
||||
>req : Request
|
||||
>Request : Request
|
||||
>res : Response
|
||||
>Response : Response
|
||||
>next : NextFunction
|
||||
>NextFunction : NextFunction
|
||||
}
|
||||
|
||||
interface Request {
|
||||
>Request : Request
|
||||
|
||||
method: string;
|
||||
>method : string
|
||||
}
|
||||
|
||||
interface Response {
|
||||
>Response : Response
|
||||
|
||||
statusCode: number;
|
||||
>statusCode : number
|
||||
}
|
||||
|
||||
interface NextFunction {
|
||||
>NextFunction : NextFunction
|
||||
|
||||
(err?: any): void;
|
||||
>err : any
|
||||
}
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
tests/cases/compiler/decrementAndIncrementOperators.ts(4,1): error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer.
|
||||
tests/cases/compiler/decrementAndIncrementOperators.ts(6,1): error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer.
|
||||
tests/cases/compiler/decrementAndIncrementOperators.ts(7,1): error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer.
|
||||
tests/cases/compiler/decrementAndIncrementOperators.ts(9,3): error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer.
|
||||
tests/cases/compiler/decrementAndIncrementOperators.ts(10,3): error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer.
|
||||
tests/cases/compiler/decrementAndIncrementOperators.ts(12,1): error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer.
|
||||
tests/cases/compiler/decrementAndIncrementOperators.ts(13,1): error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer.
|
||||
tests/cases/compiler/decrementAndIncrementOperators.ts(15,3): error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer.
|
||||
tests/cases/compiler/decrementAndIncrementOperators.ts(16,3): error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer.
|
||||
tests/cases/compiler/decrementAndIncrementOperators.ts(18,1): error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer.
|
||||
tests/cases/compiler/decrementAndIncrementOperators.ts(19,1): error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer.
|
||||
tests/cases/compiler/decrementAndIncrementOperators.ts(21,3): error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer.
|
||||
tests/cases/compiler/decrementAndIncrementOperators.ts(22,3): error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer.
|
||||
tests/cases/compiler/decrementAndIncrementOperators.ts(4,1): error TS2357: The operand of an increment or decrement operator must be a variable or a property access.
|
||||
tests/cases/compiler/decrementAndIncrementOperators.ts(6,1): error TS2357: The operand of an increment or decrement operator must be a variable or a property access.
|
||||
tests/cases/compiler/decrementAndIncrementOperators.ts(7,1): error TS2357: The operand of an increment or decrement operator must be a variable or a property access.
|
||||
tests/cases/compiler/decrementAndIncrementOperators.ts(9,3): error TS2357: The operand of an increment or decrement operator must be a variable or a property access.
|
||||
tests/cases/compiler/decrementAndIncrementOperators.ts(10,3): error TS2357: The operand of an increment or decrement operator must be a variable or a property access.
|
||||
tests/cases/compiler/decrementAndIncrementOperators.ts(12,1): error TS2357: The operand of an increment or decrement operator must be a variable or a property access.
|
||||
tests/cases/compiler/decrementAndIncrementOperators.ts(13,1): error TS2357: The operand of an increment or decrement operator must be a variable or a property access.
|
||||
tests/cases/compiler/decrementAndIncrementOperators.ts(15,3): error TS2357: The operand of an increment or decrement operator must be a variable or a property access.
|
||||
tests/cases/compiler/decrementAndIncrementOperators.ts(16,3): error TS2357: The operand of an increment or decrement operator must be a variable or a property access.
|
||||
tests/cases/compiler/decrementAndIncrementOperators.ts(18,1): error TS2357: The operand of an increment or decrement operator must be a variable or a property access.
|
||||
tests/cases/compiler/decrementAndIncrementOperators.ts(19,1): error TS2357: The operand of an increment or decrement operator must be a variable or a property access.
|
||||
tests/cases/compiler/decrementAndIncrementOperators.ts(21,3): error TS2357: The operand of an increment or decrement operator must be a variable or a property access.
|
||||
tests/cases/compiler/decrementAndIncrementOperators.ts(22,3): error TS2357: The operand of an increment or decrement operator must be a variable or a property access.
|
||||
|
||||
|
||||
==== tests/cases/compiler/decrementAndIncrementOperators.ts (13 errors) ====
|
||||
@@ -19,49 +19,49 @@ tests/cases/compiler/decrementAndIncrementOperators.ts(22,3): error TS2357: The
|
||||
// errors
|
||||
1 ++;
|
||||
~
|
||||
!!! error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer.
|
||||
!!! error TS2357: The operand of an increment or decrement operator must be a variable or a property access.
|
||||
|
||||
(1)++;
|
||||
~~~
|
||||
!!! error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer.
|
||||
!!! error TS2357: The operand of an increment or decrement operator must be a variable or a property access.
|
||||
(1)--;
|
||||
~~~
|
||||
!!! error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer.
|
||||
!!! error TS2357: The operand of an increment or decrement operator must be a variable or a property access.
|
||||
|
||||
++(1);
|
||||
~~~
|
||||
!!! error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer.
|
||||
!!! error TS2357: The operand of an increment or decrement operator must be a variable or a property access.
|
||||
--(1);
|
||||
~~~
|
||||
!!! error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer.
|
||||
!!! error TS2357: The operand of an increment or decrement operator must be a variable or a property access.
|
||||
|
||||
(1 + 2)++;
|
||||
~~~~~~~
|
||||
!!! error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer.
|
||||
!!! error TS2357: The operand of an increment or decrement operator must be a variable or a property access.
|
||||
(1 + 2)--;
|
||||
~~~~~~~
|
||||
!!! error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer.
|
||||
!!! error TS2357: The operand of an increment or decrement operator must be a variable or a property access.
|
||||
|
||||
++(1 + 2);
|
||||
~~~~~~~
|
||||
!!! error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer.
|
||||
!!! error TS2357: The operand of an increment or decrement operator must be a variable or a property access.
|
||||
--(1 + 2);
|
||||
~~~~~~~
|
||||
!!! error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer.
|
||||
!!! error TS2357: The operand of an increment or decrement operator must be a variable or a property access.
|
||||
|
||||
(x + x)++;
|
||||
~~~~~~~
|
||||
!!! error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer.
|
||||
!!! error TS2357: The operand of an increment or decrement operator must be a variable or a property access.
|
||||
(x + x)--;
|
||||
~~~~~~~
|
||||
!!! error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer.
|
||||
!!! error TS2357: The operand of an increment or decrement operator must be a variable or a property access.
|
||||
|
||||
++(x + x);
|
||||
~~~~~~~
|
||||
!!! error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer.
|
||||
!!! error TS2357: The operand of an increment or decrement operator must be a variable or a property access.
|
||||
--(x + x);
|
||||
~~~~~~~
|
||||
!!! error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer.
|
||||
!!! error TS2357: The operand of an increment or decrement operator must be a variable or a property access.
|
||||
|
||||
//OK
|
||||
x++;
|
||||
|
||||
+32
-32
@@ -1,36 +1,36 @@
|
||||
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(24,25): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(25,25): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(26,25): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(25,25): error TS2539: Cannot assign to 'A' because it is not a variable.
|
||||
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(26,25): error TS2539: Cannot assign to 'M' because it is not a variable.
|
||||
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(27,25): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(28,25): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(30,23): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(31,23): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(32,23): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(31,23): error TS2539: Cannot assign to 'A' because it is not a variable.
|
||||
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(32,23): error TS2539: Cannot assign to 'M' because it is not a variable.
|
||||
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(33,23): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(34,24): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(37,26): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(38,26): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(39,26): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(39,26): error TS2539: Cannot assign to 'undefined' because it is not a variable.
|
||||
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(41,24): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(42,24): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(43,24): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(46,26): error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer.
|
||||
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(47,26): error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer.
|
||||
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(48,26): error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer.
|
||||
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(43,24): error TS2539: Cannot assign to 'undefined' because it is not a variable.
|
||||
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(46,26): error TS2357: The operand of an increment or decrement operator must be a variable or a property access.
|
||||
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(47,26): error TS2357: The operand of an increment or decrement operator must be a variable or a property access.
|
||||
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(48,26): error TS2357: The operand of an increment or decrement operator must be a variable or a property access.
|
||||
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(48,27): error TS2365: Operator '+' cannot be applied to types 'undefined' and 'undefined'.
|
||||
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(49,26): error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer.
|
||||
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(49,26): error TS2357: The operand of an increment or decrement operator must be a variable or a property access.
|
||||
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(49,27): error TS2365: Operator '+' cannot be applied to types 'null' and 'null'.
|
||||
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(50,26): error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer.
|
||||
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(50,26): error TS2357: The operand of an increment or decrement operator must be a variable or a property access.
|
||||
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(50,27): error TS2365: Operator '+' cannot be applied to types 'undefined' and 'undefined'.
|
||||
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(51,26): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(52,26): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(54,24): error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer.
|
||||
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(55,24): error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer.
|
||||
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(56,24): error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer.
|
||||
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(54,24): error TS2357: The operand of an increment or decrement operator must be a variable or a property access.
|
||||
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(55,24): error TS2357: The operand of an increment or decrement operator must be a variable or a property access.
|
||||
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(56,24): error TS2357: The operand of an increment or decrement operator must be a variable or a property access.
|
||||
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(56,25): error TS2365: Operator '+' cannot be applied to types 'undefined' and 'undefined'.
|
||||
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(57,24): error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer.
|
||||
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(57,24): error TS2357: The operand of an increment or decrement operator must be a variable or a property access.
|
||||
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(57,25): error TS2365: Operator '+' cannot be applied to types 'null' and 'null'.
|
||||
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(58,24): error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer.
|
||||
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(58,24): error TS2357: The operand of an increment or decrement operator must be a variable or a property access.
|
||||
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(58,25): error TS2365: Operator '+' cannot be applied to types 'undefined' and 'undefined'.
|
||||
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(59,24): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(60,24): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type.
|
||||
@@ -79,10 +79,10 @@ tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOp
|
||||
!!! error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type.
|
||||
var ResultIsNumber2 = --A;
|
||||
~
|
||||
!!! error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type.
|
||||
!!! error TS2539: Cannot assign to 'A' because it is not a variable.
|
||||
var ResultIsNumber3 = --M;
|
||||
~
|
||||
!!! error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type.
|
||||
!!! error TS2539: Cannot assign to 'M' because it is not a variable.
|
||||
var ResultIsNumber4 = --obj;
|
||||
~~~
|
||||
!!! error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type.
|
||||
@@ -95,10 +95,10 @@ tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOp
|
||||
!!! error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type.
|
||||
var ResultIsNumber7 = A--;
|
||||
~
|
||||
!!! error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type.
|
||||
!!! error TS2539: Cannot assign to 'A' because it is not a variable.
|
||||
var ResultIsNumber8 = M--;
|
||||
~
|
||||
!!! error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type.
|
||||
!!! error TS2539: Cannot assign to 'M' because it is not a variable.
|
||||
var ResultIsNumber9 = obj--;
|
||||
~~~
|
||||
!!! error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type.
|
||||
@@ -115,7 +115,7 @@ tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOp
|
||||
!!! error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type.
|
||||
var ResultIsNumber13 = --undefined;
|
||||
~~~~~~~~~
|
||||
!!! error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type.
|
||||
!!! error TS2539: Cannot assign to 'undefined' because it is not a variable.
|
||||
|
||||
var ResultIsNumber14 = null--;
|
||||
~~~~
|
||||
@@ -125,28 +125,28 @@ tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOp
|
||||
!!! error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type.
|
||||
var ResultIsNumber16 = undefined--;
|
||||
~~~~~~~~~
|
||||
!!! error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type.
|
||||
!!! error TS2539: Cannot assign to 'undefined' because it is not a variable.
|
||||
|
||||
// any type expressions
|
||||
var ResultIsNumber17 = --foo();
|
||||
~~~~~
|
||||
!!! error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer.
|
||||
!!! error TS2357: The operand of an increment or decrement operator must be a variable or a property access.
|
||||
var ResultIsNumber18 = --A.foo();
|
||||
~~~~~~~
|
||||
!!! error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer.
|
||||
!!! error TS2357: The operand of an increment or decrement operator must be a variable or a property access.
|
||||
var ResultIsNumber19 = --(null + undefined);
|
||||
~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer.
|
||||
!!! error TS2357: The operand of an increment or decrement operator must be a variable or a property access.
|
||||
~~~~~~~~~~~~~~~~
|
||||
!!! error TS2365: Operator '+' cannot be applied to types 'undefined' and 'undefined'.
|
||||
var ResultIsNumber20 = --(null + null);
|
||||
~~~~~~~~~~~~~
|
||||
!!! error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer.
|
||||
!!! error TS2357: The operand of an increment or decrement operator must be a variable or a property access.
|
||||
~~~~~~~~~~~
|
||||
!!! error TS2365: Operator '+' cannot be applied to types 'null' and 'null'.
|
||||
var ResultIsNumber21 = --(undefined + undefined);
|
||||
~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer.
|
||||
!!! error TS2357: The operand of an increment or decrement operator must be a variable or a property access.
|
||||
~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2365: Operator '+' cannot be applied to types 'undefined' and 'undefined'.
|
||||
var ResultIsNumber22 = --obj1.x;
|
||||
@@ -158,23 +158,23 @@ tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOp
|
||||
|
||||
var ResultIsNumber24 = foo()--;
|
||||
~~~~~
|
||||
!!! error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer.
|
||||
!!! error TS2357: The operand of an increment or decrement operator must be a variable or a property access.
|
||||
var ResultIsNumber25 = A.foo()--;
|
||||
~~~~~~~
|
||||
!!! error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer.
|
||||
!!! error TS2357: The operand of an increment or decrement operator must be a variable or a property access.
|
||||
var ResultIsNumber26 = (null + undefined)--;
|
||||
~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer.
|
||||
!!! error TS2357: The operand of an increment or decrement operator must be a variable or a property access.
|
||||
~~~~~~~~~~~~~~~~
|
||||
!!! error TS2365: Operator '+' cannot be applied to types 'undefined' and 'undefined'.
|
||||
var ResultIsNumber27 = (null + null)--;
|
||||
~~~~~~~~~~~~~
|
||||
!!! error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer.
|
||||
!!! error TS2357: The operand of an increment or decrement operator must be a variable or a property access.
|
||||
~~~~~~~~~~~
|
||||
!!! error TS2365: Operator '+' cannot be applied to types 'null' and 'null'.
|
||||
var ResultIsNumber28 = (undefined + undefined)--;
|
||||
~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer.
|
||||
!!! error TS2357: The operand of an increment or decrement operator must be a variable or a property access.
|
||||
~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2365: Operator '+' cannot be applied to types 'undefined' and 'undefined'.
|
||||
var ResultIsNumber29 = obj1.x--;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithEnumType.ts(6,25): error TS2449: The operand of an increment or decrement operator cannot be a constant or a read-only property.
|
||||
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithEnumType.ts(7,23): error TS2449: The operand of an increment or decrement operator cannot be a constant or a read-only property.
|
||||
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithEnumType.ts(10,3): error TS2449: The operand of an increment or decrement operator cannot be a constant or a read-only property.
|
||||
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithEnumType.ts(12,1): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithEnumType.ts(6,31): error TS2540: Cannot assign to 'A' because it is a constant or a read-only property.
|
||||
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithEnumType.ts(7,29): error TS2540: Cannot assign to 'A' because it is a constant or a read-only property.
|
||||
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithEnumType.ts(10,9): error TS2540: Cannot assign to 'A' because it is a constant or a read-only property.
|
||||
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithEnumType.ts(12,1): error TS2542: Index signature in type 'typeof ENUM1' only permits reading.
|
||||
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithEnumType.ts(12,7): error TS2304: Cannot find name 'A'.
|
||||
|
||||
|
||||
@@ -12,19 +12,19 @@ tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOp
|
||||
|
||||
// expression
|
||||
var ResultIsNumber1 = --ENUM1["A"];
|
||||
~~~~~~~~~~
|
||||
!!! error TS2449: The operand of an increment or decrement operator cannot be a constant or a read-only property.
|
||||
~~~
|
||||
!!! error TS2540: Cannot assign to 'A' because it is a constant or a read-only property.
|
||||
var ResultIsNumber2 = ENUM1.A--;
|
||||
~~~~~~~
|
||||
!!! error TS2449: The operand of an increment or decrement operator cannot be a constant or a read-only property.
|
||||
~
|
||||
!!! error TS2540: Cannot assign to 'A' because it is a constant or a read-only property.
|
||||
|
||||
// miss assignment operator
|
||||
--ENUM1["A"];
|
||||
~~~~~~~~~~
|
||||
!!! error TS2449: The operand of an increment or decrement operator cannot be a constant or a read-only property.
|
||||
~~~
|
||||
!!! error TS2540: Cannot assign to 'A' because it is a constant or a read-only property.
|
||||
|
||||
ENUM1[A]--;
|
||||
~~~~~~~~
|
||||
!!! error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type.
|
||||
!!! error TS2542: Index signature in type 'typeof ENUM1' only permits reading.
|
||||
~
|
||||
!!! error TS2304: Cannot find name 'A'.
|
||||
+20
-20
@@ -1,15 +1,15 @@
|
||||
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithEnumTypeInvalidOperations.ts(7,25): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithEnumTypeInvalidOperations.ts(8,25): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithEnumTypeInvalidOperations.ts(10,23): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithEnumTypeInvalidOperations.ts(11,23): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithEnumTypeInvalidOperations.ts(14,25): error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer.
|
||||
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithEnumTypeInvalidOperations.ts(7,25): error TS2539: Cannot assign to 'ENUM' because it is not a variable.
|
||||
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithEnumTypeInvalidOperations.ts(8,25): error TS2539: Cannot assign to 'ENUM1' because it is not a variable.
|
||||
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithEnumTypeInvalidOperations.ts(10,23): error TS2539: Cannot assign to 'ENUM' because it is not a variable.
|
||||
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithEnumTypeInvalidOperations.ts(11,23): error TS2539: Cannot assign to 'ENUM1' because it is not a variable.
|
||||
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithEnumTypeInvalidOperations.ts(14,25): error TS2357: The operand of an increment or decrement operator must be a variable or a property access.
|
||||
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithEnumTypeInvalidOperations.ts(14,43): error TS2339: Property 'B' does not exist on type 'typeof ENUM'.
|
||||
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithEnumTypeInvalidOperations.ts(15,23): error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer.
|
||||
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithEnumTypeInvalidOperations.ts(15,23): error TS2357: The operand of an increment or decrement operator must be a variable or a property access.
|
||||
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithEnumTypeInvalidOperations.ts(15,29): error TS2339: Property 'A' does not exist on type 'typeof ENUM'.
|
||||
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithEnumTypeInvalidOperations.ts(18,3): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithEnumTypeInvalidOperations.ts(19,3): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithEnumTypeInvalidOperations.ts(21,1): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithEnumTypeInvalidOperations.ts(22,1): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithEnumTypeInvalidOperations.ts(18,3): error TS2539: Cannot assign to 'ENUM' because it is not a variable.
|
||||
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithEnumTypeInvalidOperations.ts(19,3): error TS2539: Cannot assign to 'ENUM1' because it is not a variable.
|
||||
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithEnumTypeInvalidOperations.ts(21,1): error TS2539: Cannot assign to 'ENUM' because it is not a variable.
|
||||
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithEnumTypeInvalidOperations.ts(22,1): error TS2539: Cannot assign to 'ENUM1' because it is not a variable.
|
||||
|
||||
|
||||
==== tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithEnumTypeInvalidOperations.ts (12 errors) ====
|
||||
@@ -21,41 +21,41 @@ tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOp
|
||||
// enum type var
|
||||
var ResultIsNumber1 = --ENUM;
|
||||
~~~~
|
||||
!!! error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type.
|
||||
!!! error TS2539: Cannot assign to 'ENUM' because it is not a variable.
|
||||
var ResultIsNumber2 = --ENUM1;
|
||||
~~~~~
|
||||
!!! error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type.
|
||||
!!! error TS2539: Cannot assign to 'ENUM1' because it is not a variable.
|
||||
|
||||
var ResultIsNumber3 = ENUM--;
|
||||
~~~~
|
||||
!!! error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type.
|
||||
!!! error TS2539: Cannot assign to 'ENUM' because it is not a variable.
|
||||
var ResultIsNumber4 = ENUM1--;
|
||||
~~~~~
|
||||
!!! error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type.
|
||||
!!! error TS2539: Cannot assign to 'ENUM1' because it is not a variable.
|
||||
|
||||
// enum type expressions
|
||||
var ResultIsNumber5 = --(ENUM["A"] + ENUM.B);
|
||||
~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer.
|
||||
!!! error TS2357: The operand of an increment or decrement operator must be a variable or a property access.
|
||||
~
|
||||
!!! error TS2339: Property 'B' does not exist on type 'typeof ENUM'.
|
||||
var ResultIsNumber6 = (ENUM.A + ENUM["B"])--;
|
||||
~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer.
|
||||
!!! error TS2357: The operand of an increment or decrement operator must be a variable or a property access.
|
||||
~
|
||||
!!! error TS2339: Property 'A' does not exist on type 'typeof ENUM'.
|
||||
|
||||
// miss assignment operator
|
||||
--ENUM;
|
||||
~~~~
|
||||
!!! error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type.
|
||||
!!! error TS2539: Cannot assign to 'ENUM' because it is not a variable.
|
||||
--ENUM1;
|
||||
~~~~~
|
||||
!!! error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type.
|
||||
!!! error TS2539: Cannot assign to 'ENUM1' because it is not a variable.
|
||||
|
||||
ENUM--;
|
||||
~~~~
|
||||
!!! error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type.
|
||||
!!! error TS2539: Cannot assign to 'ENUM' because it is not a variable.
|
||||
ENUM1--;
|
||||
~~~~~
|
||||
!!! error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type.
|
||||
!!! error TS2539: Cannot assign to 'ENUM1' because it is not a variable.
|
||||
+24
-24
@@ -1,23 +1,23 @@
|
||||
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithNumberTypeInvalidOperations.ts(18,25): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithNumberTypeInvalidOperations.ts(19,23): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithNumberTypeInvalidOperations.ts(22,25): error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer.
|
||||
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithNumberTypeInvalidOperations.ts(22,25): error TS2357: The operand of an increment or decrement operator must be a variable or a property access.
|
||||
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithNumberTypeInvalidOperations.ts(23,25): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithNumberTypeInvalidOperations.ts(24,25): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithNumberTypeInvalidOperations.ts(26,23): error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer.
|
||||
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithNumberTypeInvalidOperations.ts(26,23): error TS2357: The operand of an increment or decrement operator must be a variable or a property access.
|
||||
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithNumberTypeInvalidOperations.ts(27,23): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithNumberTypeInvalidOperations.ts(28,23): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithNumberTypeInvalidOperations.ts(31,25): error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer.
|
||||
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithNumberTypeInvalidOperations.ts(32,26): error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer.
|
||||
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithNumberTypeInvalidOperations.ts(33,26): error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer.
|
||||
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithNumberTypeInvalidOperations.ts(35,24): error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer.
|
||||
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithNumberTypeInvalidOperations.ts(36,24): error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer.
|
||||
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithNumberTypeInvalidOperations.ts(37,24): error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer.
|
||||
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithNumberTypeInvalidOperations.ts(40,3): error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer.
|
||||
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithNumberTypeInvalidOperations.ts(31,25): error TS2357: The operand of an increment or decrement operator must be a variable or a property access.
|
||||
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithNumberTypeInvalidOperations.ts(32,26): error TS2357: The operand of an increment or decrement operator must be a variable or a property access.
|
||||
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithNumberTypeInvalidOperations.ts(33,26): error TS2357: The operand of an increment or decrement operator must be a variable or a property access.
|
||||
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithNumberTypeInvalidOperations.ts(35,24): error TS2357: The operand of an increment or decrement operator must be a variable or a property access.
|
||||
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithNumberTypeInvalidOperations.ts(36,24): error TS2357: The operand of an increment or decrement operator must be a variable or a property access.
|
||||
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithNumberTypeInvalidOperations.ts(37,24): error TS2357: The operand of an increment or decrement operator must be a variable or a property access.
|
||||
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithNumberTypeInvalidOperations.ts(40,3): error TS2357: The operand of an increment or decrement operator must be a variable or a property access.
|
||||
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithNumberTypeInvalidOperations.ts(41,3): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithNumberTypeInvalidOperations.ts(42,3): error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer.
|
||||
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithNumberTypeInvalidOperations.ts(44,1): error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer.
|
||||
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithNumberTypeInvalidOperations.ts(42,3): error TS2357: The operand of an increment or decrement operator must be a variable or a property access.
|
||||
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithNumberTypeInvalidOperations.ts(44,1): error TS2357: The operand of an increment or decrement operator must be a variable or a property access.
|
||||
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithNumberTypeInvalidOperations.ts(45,1): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithNumberTypeInvalidOperations.ts(46,1): error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer.
|
||||
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithNumberTypeInvalidOperations.ts(46,1): error TS2357: The operand of an increment or decrement operator must be a variable or a property access.
|
||||
|
||||
|
||||
==== tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithNumberTypeInvalidOperations.ts (20 errors) ====
|
||||
@@ -48,7 +48,7 @@ tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOp
|
||||
// number type literal
|
||||
var ResultIsNumber3 = --1;
|
||||
~
|
||||
!!! error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer.
|
||||
!!! error TS2357: The operand of an increment or decrement operator must be a variable or a property access.
|
||||
var ResultIsNumber4 = --{ x: 1, y: 2};
|
||||
~~~~~~~~~~~~~
|
||||
!!! error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type.
|
||||
@@ -58,7 +58,7 @@ tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOp
|
||||
|
||||
var ResultIsNumber6 = 1--;
|
||||
~
|
||||
!!! error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer.
|
||||
!!! error TS2357: The operand of an increment or decrement operator must be a variable or a property access.
|
||||
var ResultIsNumber7 = { x: 1, y: 2 }--;
|
||||
~~~~~~~~~~~~~~
|
||||
!!! error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type.
|
||||
@@ -69,41 +69,41 @@ tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOp
|
||||
// number type expressions
|
||||
var ResultIsNumber9 = --foo();
|
||||
~~~~~
|
||||
!!! error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer.
|
||||
!!! error TS2357: The operand of an increment or decrement operator must be a variable or a property access.
|
||||
var ResultIsNumber10 = --A.foo();
|
||||
~~~~~~~
|
||||
!!! error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer.
|
||||
!!! error TS2357: The operand of an increment or decrement operator must be a variable or a property access.
|
||||
var ResultIsNumber11 = --(NUMBER + NUMBER);
|
||||
~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer.
|
||||
!!! error TS2357: The operand of an increment or decrement operator must be a variable or a property access.
|
||||
|
||||
var ResultIsNumber12 = foo()--;
|
||||
~~~~~
|
||||
!!! error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer.
|
||||
!!! error TS2357: The operand of an increment or decrement operator must be a variable or a property access.
|
||||
var ResultIsNumber13 = A.foo()--;
|
||||
~~~~~~~
|
||||
!!! error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer.
|
||||
!!! error TS2357: The operand of an increment or decrement operator must be a variable or a property access.
|
||||
var ResultIsNumber14 = (NUMBER + NUMBER)--;
|
||||
~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer.
|
||||
!!! error TS2357: The operand of an increment or decrement operator must be a variable or a property access.
|
||||
|
||||
// miss assignment operator
|
||||
--1;
|
||||
~
|
||||
!!! error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer.
|
||||
!!! error TS2357: The operand of an increment or decrement operator must be a variable or a property access.
|
||||
--NUMBER1;
|
||||
~~~~~~~
|
||||
!!! error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type.
|
||||
--foo();
|
||||
~~~~~
|
||||
!!! error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer.
|
||||
!!! error TS2357: The operand of an increment or decrement operator must be a variable or a property access.
|
||||
|
||||
1--;
|
||||
~
|
||||
!!! error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer.
|
||||
!!! error TS2357: The operand of an increment or decrement operator must be a variable or a property access.
|
||||
NUMBER1--;
|
||||
~~~~~~~
|
||||
!!! error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type.
|
||||
foo()--;
|
||||
~~~~~
|
||||
!!! error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer.
|
||||
!!! error TS2357: The operand of an increment or decrement operator must be a variable or a property access.
|
||||
@@ -0,0 +1,26 @@
|
||||
//// [doWhileUnreachableCode.ts]
|
||||
function test() {
|
||||
let foo = 0;
|
||||
testLoop: do {
|
||||
foo++;
|
||||
continue testLoop;
|
||||
} while (function() {
|
||||
var x = 1;
|
||||
return false;
|
||||
}());
|
||||
|
||||
return foo;
|
||||
}
|
||||
|
||||
//// [doWhileUnreachableCode.js]
|
||||
function test() {
|
||||
var foo = 0;
|
||||
testLoop: do {
|
||||
foo++;
|
||||
continue testLoop;
|
||||
} while (function () {
|
||||
var x = 1;
|
||||
return false;
|
||||
}());
|
||||
return foo;
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
=== tests/cases/compiler/doWhileUnreachableCode.ts ===
|
||||
function test() {
|
||||
>test : Symbol(test, Decl(doWhileUnreachableCode.ts, 0, 0))
|
||||
|
||||
let foo = 0;
|
||||
>foo : Symbol(foo, Decl(doWhileUnreachableCode.ts, 1, 7))
|
||||
|
||||
testLoop: do {
|
||||
foo++;
|
||||
>foo : Symbol(foo, Decl(doWhileUnreachableCode.ts, 1, 7))
|
||||
|
||||
continue testLoop;
|
||||
} while (function() {
|
||||
var x = 1;
|
||||
>x : Symbol(x, Decl(doWhileUnreachableCode.ts, 6, 11))
|
||||
|
||||
return false;
|
||||
}());
|
||||
|
||||
return foo;
|
||||
>foo : Symbol(foo, Decl(doWhileUnreachableCode.ts, 1, 7))
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
=== tests/cases/compiler/doWhileUnreachableCode.ts ===
|
||||
function test() {
|
||||
>test : () => number
|
||||
|
||||
let foo = 0;
|
||||
>foo : number
|
||||
>0 : 0
|
||||
|
||||
testLoop: do {
|
||||
>testLoop : any
|
||||
|
||||
foo++;
|
||||
>foo++ : number
|
||||
>foo : number
|
||||
|
||||
continue testLoop;
|
||||
>testLoop : any
|
||||
|
||||
} while (function() {
|
||||
>function() { var x = 1; return false; }() : boolean
|
||||
>function() { var x = 1; return false; } : () => boolean
|
||||
|
||||
var x = 1;
|
||||
>x : number
|
||||
>1 : 1
|
||||
|
||||
return false;
|
||||
>false : false
|
||||
|
||||
}());
|
||||
|
||||
return foo;
|
||||
>foo : number
|
||||
}
|
||||
@@ -209,11 +209,11 @@ function f4(a: Choice.Yes, b: YesNo) {
|
||||
|
||||
a++;
|
||||
>a++ : number
|
||||
>a : Choice.Yes
|
||||
>a : Choice
|
||||
|
||||
b++;
|
||||
>b++ : number
|
||||
>b : YesNo
|
||||
>b : Choice
|
||||
}
|
||||
|
||||
declare function g(x: Choice.Yes): string;
|
||||
|
||||
@@ -210,7 +210,7 @@ function f4(a: Choice.Yes, b: UnknownYesNo) {
|
||||
|
||||
a++;
|
||||
>a++ : number
|
||||
>a : Choice.Yes
|
||||
>a : Choice
|
||||
|
||||
b++;
|
||||
>b++ : number
|
||||
|
||||
@@ -1,23 +1,23 @@
|
||||
tests/cases/compiler/f2.ts(7,1): error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
|
||||
tests/cases/compiler/f2.ts(8,1): error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
|
||||
tests/cases/compiler/f2.ts(7,7): error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
|
||||
tests/cases/compiler/f2.ts(8,7): error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
|
||||
tests/cases/compiler/f2.ts(9,7): error TS2339: Property 'blah' does not exist on type 'typeof "tests/cases/compiler/f1"'.
|
||||
tests/cases/compiler/f2.ts(12,1): error TS2449: The operand of an increment or decrement operator cannot be a constant or a read-only property.
|
||||
tests/cases/compiler/f2.ts(13,1): error TS2449: The operand of an increment or decrement operator cannot be a constant or a read-only property.
|
||||
tests/cases/compiler/f2.ts(17,1): error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
|
||||
tests/cases/compiler/f2.ts(18,1): error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
|
||||
tests/cases/compiler/f2.ts(12,7): error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
|
||||
tests/cases/compiler/f2.ts(13,7): error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
|
||||
tests/cases/compiler/f2.ts(17,8): error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
|
||||
tests/cases/compiler/f2.ts(18,8): error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
|
||||
tests/cases/compiler/f2.ts(19,8): error TS2339: Property 'blah' does not exist on type 'typeof "tests/cases/compiler/f1"'.
|
||||
tests/cases/compiler/f2.ts(22,1): error TS2449: The operand of an increment or decrement operator cannot be a constant or a read-only property.
|
||||
tests/cases/compiler/f2.ts(23,1): error TS2449: The operand of an increment or decrement operator cannot be a constant or a read-only property.
|
||||
tests/cases/compiler/f2.ts(27,6): error TS2405: The left-hand side of a 'for...in' statement must be of type 'string' or 'any'.
|
||||
tests/cases/compiler/f2.ts(28,6): error TS2485: The left-hand side of a 'for...of' statement cannot be a constant or a read-only property.
|
||||
tests/cases/compiler/f2.ts(29,6): error TS2405: The left-hand side of a 'for...in' statement must be of type 'string' or 'any'.
|
||||
tests/cases/compiler/f2.ts(30,6): error TS2485: The left-hand side of a 'for...of' statement cannot be a constant or a read-only property.
|
||||
tests/cases/compiler/f2.ts(22,8): error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
|
||||
tests/cases/compiler/f2.ts(23,8): error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
|
||||
tests/cases/compiler/f2.ts(27,12): error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
|
||||
tests/cases/compiler/f2.ts(28,12): error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
|
||||
tests/cases/compiler/f2.ts(29,12): error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
|
||||
tests/cases/compiler/f2.ts(30,12): error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
|
||||
tests/cases/compiler/f2.ts(31,12): error TS2339: Property 'blah' does not exist on type 'typeof "tests/cases/compiler/f1"'.
|
||||
tests/cases/compiler/f2.ts(32,12): error TS2339: Property 'blah' does not exist on type 'typeof "tests/cases/compiler/f1"'.
|
||||
tests/cases/compiler/f2.ts(36,6): error TS2405: The left-hand side of a 'for...in' statement must be of type 'string' or 'any'.
|
||||
tests/cases/compiler/f2.ts(37,6): error TS2485: The left-hand side of a 'for...of' statement cannot be a constant or a read-only property.
|
||||
tests/cases/compiler/f2.ts(38,6): error TS2405: The left-hand side of a 'for...in' statement must be of type 'string' or 'any'.
|
||||
tests/cases/compiler/f2.ts(39,6): error TS2485: The left-hand side of a 'for...of' statement cannot be a constant or a read-only property.
|
||||
tests/cases/compiler/f2.ts(36,13): error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
|
||||
tests/cases/compiler/f2.ts(37,13): error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
|
||||
tests/cases/compiler/f2.ts(38,13): error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
|
||||
tests/cases/compiler/f2.ts(39,13): error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
|
||||
tests/cases/compiler/f2.ts(40,13): error TS2339: Property 'blah' does not exist on type 'typeof "tests/cases/compiler/f1"'.
|
||||
tests/cases/compiler/f2.ts(41,13): error TS2339: Property 'blah' does not exist on type 'typeof "tests/cases/compiler/f1"'.
|
||||
|
||||
@@ -33,57 +33,57 @@ tests/cases/compiler/f2.ts(41,13): error TS2339: Property 'blah' does not exist
|
||||
var n = 'baz';
|
||||
|
||||
stuff.x = 0;
|
||||
~~~~~~~
|
||||
!!! error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
|
||||
~
|
||||
!!! error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
|
||||
stuff['x'] = 1;
|
||||
~~~~~~~~~~
|
||||
!!! error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
|
||||
~~~
|
||||
!!! error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
|
||||
stuff.blah = 2;
|
||||
~~~~
|
||||
!!! error TS2339: Property 'blah' does not exist on type 'typeof "tests/cases/compiler/f1"'.
|
||||
stuff[n] = 3;
|
||||
|
||||
stuff.x++;
|
||||
~~~~~~~
|
||||
!!! error TS2449: The operand of an increment or decrement operator cannot be a constant or a read-only property.
|
||||
~
|
||||
!!! error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
|
||||
stuff['x']++;
|
||||
~~~~~~~~~~
|
||||
!!! error TS2449: The operand of an increment or decrement operator cannot be a constant or a read-only property.
|
||||
~~~
|
||||
!!! error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
|
||||
stuff['blah']++;
|
||||
stuff[n]++;
|
||||
|
||||
(stuff.x) = 0;
|
||||
~~~~~~~~~
|
||||
!!! error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
|
||||
~
|
||||
!!! error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
|
||||
(stuff['x']) = 1;
|
||||
~~~~~~~~~~~~
|
||||
!!! error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
|
||||
~~~
|
||||
!!! error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
|
||||
(stuff.blah) = 2;
|
||||
~~~~
|
||||
!!! error TS2339: Property 'blah' does not exist on type 'typeof "tests/cases/compiler/f1"'.
|
||||
(stuff[n]) = 3;
|
||||
|
||||
(stuff.x)++;
|
||||
~~~~~~~~~
|
||||
!!! error TS2449: The operand of an increment or decrement operator cannot be a constant or a read-only property.
|
||||
~
|
||||
!!! error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
|
||||
(stuff['x'])++;
|
||||
~~~~~~~~~~~~
|
||||
!!! error TS2449: The operand of an increment or decrement operator cannot be a constant or a read-only property.
|
||||
~~~
|
||||
!!! error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
|
||||
(stuff['blah'])++;
|
||||
(stuff[n])++;
|
||||
|
||||
for (stuff.x in []) {}
|
||||
~~~~~~~
|
||||
!!! error TS2405: The left-hand side of a 'for...in' statement must be of type 'string' or 'any'.
|
||||
~
|
||||
!!! error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
|
||||
for (stuff.x of []) {}
|
||||
~~~~~~~
|
||||
!!! error TS2485: The left-hand side of a 'for...of' statement cannot be a constant or a read-only property.
|
||||
~
|
||||
!!! error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
|
||||
for (stuff['x'] in []) {}
|
||||
~~~~~~~~~~
|
||||
!!! error TS2405: The left-hand side of a 'for...in' statement must be of type 'string' or 'any'.
|
||||
~~~
|
||||
!!! error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
|
||||
for (stuff['x'] of []) {}
|
||||
~~~~~~~~~~
|
||||
!!! error TS2485: The left-hand side of a 'for...of' statement cannot be a constant or a read-only property.
|
||||
~~~
|
||||
!!! error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
|
||||
for (stuff.blah in []) {}
|
||||
~~~~
|
||||
!!! error TS2339: Property 'blah' does not exist on type 'typeof "tests/cases/compiler/f1"'.
|
||||
@@ -94,17 +94,17 @@ tests/cases/compiler/f2.ts(41,13): error TS2339: Property 'blah' does not exist
|
||||
for (stuff[n] of []) {}
|
||||
|
||||
for ((stuff.x) in []) {}
|
||||
~~~~~~~~~
|
||||
!!! error TS2405: The left-hand side of a 'for...in' statement must be of type 'string' or 'any'.
|
||||
~
|
||||
!!! error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
|
||||
for ((stuff.x) of []) {}
|
||||
~~~~~~~~~
|
||||
!!! error TS2485: The left-hand side of a 'for...of' statement cannot be a constant or a read-only property.
|
||||
~
|
||||
!!! error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
|
||||
for ((stuff['x']) in []) {}
|
||||
~~~~~~~~~~~~
|
||||
!!! error TS2405: The left-hand side of a 'for...in' statement must be of type 'string' or 'any'.
|
||||
~~~
|
||||
!!! error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
|
||||
for ((stuff['x']) of []) {}
|
||||
~~~~~~~~~~~~
|
||||
!!! error TS2485: The left-hand side of a 'for...of' statement cannot be a constant or a read-only property.
|
||||
~~~
|
||||
!!! error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
|
||||
for ((stuff.blah) in []) {}
|
||||
~~~~
|
||||
!!! error TS2339: Property 'blah' does not exist on type 'typeof "tests/cases/compiler/f1"'.
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
tests/cases/conformance/statements/for-inStatements/for-inStatementsArrayErrors.ts(5,14): error TS7015: Element implicitly has an 'any' type because index expression is not of type 'number'.
|
||||
tests/cases/conformance/statements/for-inStatements/for-inStatementsArrayErrors.ts(5,16): error TS7015: Element implicitly has an 'any' type because index expression is not of type 'number'.
|
||||
tests/cases/conformance/statements/for-inStatements/for-inStatementsArrayErrors.ts(6,16): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/statements/for-inStatements/for-inStatementsArrayErrors.ts(7,9): error TS2365: Operator '===' cannot be applied to types 'string' and 'number'.
|
||||
tests/cases/conformance/statements/for-inStatements/for-inStatementsArrayErrors.ts(9,16): error TS2339: Property 'unknownProperty' does not exist on type 'string'.
|
||||
@@ -12,7 +12,7 @@ tests/cases/conformance/statements/for-inStatements/for-inStatementsArrayErrors.
|
||||
|
||||
for (let x in a) {
|
||||
let a1 = a[x + 1];
|
||||
~~~~~~~~
|
||||
~~~~~
|
||||
!!! error TS7015: Element implicitly has an 'any' type because index expression is not of type 'number'.
|
||||
let a2 = a[x - 1];
|
||||
~
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
tests/cases/conformance/es6/for-ofStatements/for-of2.ts(1,7): error TS1155: 'const' declarations must be initialized
|
||||
tests/cases/conformance/es6/for-ofStatements/for-of2.ts(2,6): error TS2485: The left-hand side of a 'for...of' statement cannot be a constant or a read-only property.
|
||||
tests/cases/conformance/es6/for-ofStatements/for-of2.ts(2,6): error TS2540: Cannot assign to 'v' because it is a constant or a read-only property.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/for-ofStatements/for-of2.ts (2 errors) ====
|
||||
@@ -8,4 +8,4 @@ tests/cases/conformance/es6/for-ofStatements/for-of2.ts(2,6): error TS2485: The
|
||||
!!! error TS1155: 'const' declarations must be initialized
|
||||
for (v of []) { }
|
||||
~
|
||||
!!! error TS2485: The left-hand side of a 'for...of' statement cannot be a constant or a read-only property.
|
||||
!!! error TS2540: Cannot assign to 'v' because it is a constant or a read-only property.
|
||||
@@ -1,8 +1,8 @@
|
||||
tests/cases/conformance/es6/for-ofStatements/for-of3.ts(2,6): error TS2487: Invalid left-hand side in 'for...of' statement.
|
||||
tests/cases/conformance/es6/for-ofStatements/for-of3.ts(2,6): error TS2487: The left-hand side of a 'for...of' statement must be a variable or a property access.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/for-ofStatements/for-of3.ts (1 errors) ====
|
||||
var v: any;
|
||||
for (v++ of []) { }
|
||||
~~~
|
||||
!!! error TS2487: Invalid left-hand side in 'for...of' statement.
|
||||
!!! error TS2487: The left-hand side of a 'for...of' statement must be a variable or a property access.
|
||||
@@ -1,7 +1,7 @@
|
||||
tests/cases/conformance/externalModules/b.ts(6,1): error TS2364: Invalid left-hand side of assignment expression.
|
||||
tests/cases/conformance/externalModules/b.ts(7,1): error TS2364: Invalid left-hand side of assignment expression.
|
||||
tests/cases/conformance/externalModules/b.ts(8,1): error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
|
||||
tests/cases/conformance/externalModules/b.ts(9,1): error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
|
||||
tests/cases/conformance/externalModules/b.ts(6,1): error TS2539: Cannot assign to 'x' because it is not a variable.
|
||||
tests/cases/conformance/externalModules/b.ts(7,1): error TS2539: Cannot assign to 'y' because it is not a variable.
|
||||
tests/cases/conformance/externalModules/b.ts(8,4): error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
|
||||
tests/cases/conformance/externalModules/b.ts(9,4): error TS2540: Cannot assign to 'y' because it is a constant or a read-only property.
|
||||
|
||||
|
||||
==== tests/cases/conformance/externalModules/b.ts (4 errors) ====
|
||||
@@ -12,16 +12,16 @@ tests/cases/conformance/externalModules/b.ts(9,1): error TS2450: Left-hand side
|
||||
|
||||
x = 1; // Error
|
||||
~
|
||||
!!! error TS2364: Invalid left-hand side of assignment expression.
|
||||
!!! error TS2539: Cannot assign to 'x' because it is not a variable.
|
||||
y = 1; // Error
|
||||
~
|
||||
!!! error TS2364: Invalid left-hand side of assignment expression.
|
||||
!!! error TS2539: Cannot assign to 'y' because it is not a variable.
|
||||
a1.x = 1; // Error
|
||||
~~~~
|
||||
!!! error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
|
||||
~
|
||||
!!! error TS2540: Cannot assign to 'x' because it is a constant or a read-only property.
|
||||
a1.y = 1; // Error
|
||||
~~~~
|
||||
!!! error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
|
||||
~
|
||||
!!! error TS2540: Cannot assign to 'y' because it is a constant or a read-only property.
|
||||
a2.x = 1;
|
||||
a2.y = 1;
|
||||
a3.x = 1;
|
||||
|
||||
+32
-32
@@ -1,36 +1,36 @@
|
||||
tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(24,25): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(25,25): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(26,25): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(25,25): error TS2539: Cannot assign to 'A' because it is not a variable.
|
||||
tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(26,25): error TS2539: Cannot assign to 'M' because it is not a variable.
|
||||
tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(27,25): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(28,25): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(30,23): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(31,23): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(32,23): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(31,23): error TS2539: Cannot assign to 'A' because it is not a variable.
|
||||
tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(32,23): error TS2539: Cannot assign to 'M' because it is not a variable.
|
||||
tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(33,23): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(34,24): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(37,26): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(38,26): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(39,26): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(39,26): error TS2539: Cannot assign to 'undefined' because it is not a variable.
|
||||
tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(41,24): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(42,24): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(43,24): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(46,26): error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer.
|
||||
tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(47,26): error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer.
|
||||
tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(48,26): error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer.
|
||||
tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(43,24): error TS2539: Cannot assign to 'undefined' because it is not a variable.
|
||||
tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(46,26): error TS2357: The operand of an increment or decrement operator must be a variable or a property access.
|
||||
tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(47,26): error TS2357: The operand of an increment or decrement operator must be a variable or a property access.
|
||||
tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(48,26): error TS2357: The operand of an increment or decrement operator must be a variable or a property access.
|
||||
tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(48,27): error TS2365: Operator '+' cannot be applied to types 'undefined' and 'undefined'.
|
||||
tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(49,26): error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer.
|
||||
tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(49,26): error TS2357: The operand of an increment or decrement operator must be a variable or a property access.
|
||||
tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(49,27): error TS2365: Operator '+' cannot be applied to types 'null' and 'null'.
|
||||
tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(50,26): error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer.
|
||||
tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(50,26): error TS2357: The operand of an increment or decrement operator must be a variable or a property access.
|
||||
tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(50,27): error TS2365: Operator '+' cannot be applied to types 'undefined' and 'undefined'.
|
||||
tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(51,26): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(52,26): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(54,24): error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer.
|
||||
tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(55,24): error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer.
|
||||
tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(56,24): error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer.
|
||||
tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(54,24): error TS2357: The operand of an increment or decrement operator must be a variable or a property access.
|
||||
tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(55,24): error TS2357: The operand of an increment or decrement operator must be a variable or a property access.
|
||||
tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(56,24): error TS2357: The operand of an increment or decrement operator must be a variable or a property access.
|
||||
tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(56,25): error TS2365: Operator '+' cannot be applied to types 'undefined' and 'undefined'.
|
||||
tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(57,24): error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer.
|
||||
tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(57,24): error TS2357: The operand of an increment or decrement operator must be a variable or a property access.
|
||||
tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(57,25): error TS2365: Operator '+' cannot be applied to types 'null' and 'null'.
|
||||
tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(58,24): error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer.
|
||||
tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(58,24): error TS2357: The operand of an increment or decrement operator must be a variable or a property access.
|
||||
tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(58,25): error TS2365: Operator '+' cannot be applied to types 'undefined' and 'undefined'.
|
||||
tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(59,24): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(60,24): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type.
|
||||
@@ -74,10 +74,10 @@ tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOp
|
||||
!!! error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type.
|
||||
var ResultIsNumber2 = ++A;
|
||||
~
|
||||
!!! error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type.
|
||||
!!! error TS2539: Cannot assign to 'A' because it is not a variable.
|
||||
var ResultIsNumber3 = ++M;
|
||||
~
|
||||
!!! error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type.
|
||||
!!! error TS2539: Cannot assign to 'M' because it is not a variable.
|
||||
var ResultIsNumber4 = ++obj;
|
||||
~~~
|
||||
!!! error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type.
|
||||
@@ -90,10 +90,10 @@ tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOp
|
||||
!!! error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type.
|
||||
var ResultIsNumber7 = A++;
|
||||
~
|
||||
!!! error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type.
|
||||
!!! error TS2539: Cannot assign to 'A' because it is not a variable.
|
||||
var ResultIsNumber8 = M++;
|
||||
~
|
||||
!!! error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type.
|
||||
!!! error TS2539: Cannot assign to 'M' because it is not a variable.
|
||||
var ResultIsNumber9 = obj++;
|
||||
~~~
|
||||
!!! error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type.
|
||||
@@ -110,7 +110,7 @@ tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOp
|
||||
!!! error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type.
|
||||
var ResultIsNumber13 = ++undefined;
|
||||
~~~~~~~~~
|
||||
!!! error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type.
|
||||
!!! error TS2539: Cannot assign to 'undefined' because it is not a variable.
|
||||
|
||||
var ResultIsNumber14 = null++;
|
||||
~~~~
|
||||
@@ -120,28 +120,28 @@ tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOp
|
||||
!!! error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type.
|
||||
var ResultIsNumber16 = undefined++;
|
||||
~~~~~~~~~
|
||||
!!! error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type.
|
||||
!!! error TS2539: Cannot assign to 'undefined' because it is not a variable.
|
||||
|
||||
// any type expressions
|
||||
var ResultIsNumber17 = ++foo();
|
||||
~~~~~
|
||||
!!! error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer.
|
||||
!!! error TS2357: The operand of an increment or decrement operator must be a variable or a property access.
|
||||
var ResultIsNumber18 = ++A.foo();
|
||||
~~~~~~~
|
||||
!!! error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer.
|
||||
!!! error TS2357: The operand of an increment or decrement operator must be a variable or a property access.
|
||||
var ResultIsNumber19 = ++(null + undefined);
|
||||
~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer.
|
||||
!!! error TS2357: The operand of an increment or decrement operator must be a variable or a property access.
|
||||
~~~~~~~~~~~~~~~~
|
||||
!!! error TS2365: Operator '+' cannot be applied to types 'undefined' and 'undefined'.
|
||||
var ResultIsNumber20 = ++(null + null);
|
||||
~~~~~~~~~~~~~
|
||||
!!! error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer.
|
||||
!!! error TS2357: The operand of an increment or decrement operator must be a variable or a property access.
|
||||
~~~~~~~~~~~
|
||||
!!! error TS2365: Operator '+' cannot be applied to types 'null' and 'null'.
|
||||
var ResultIsNumber21 = ++(undefined + undefined);
|
||||
~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer.
|
||||
!!! error TS2357: The operand of an increment or decrement operator must be a variable or a property access.
|
||||
~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2365: Operator '+' cannot be applied to types 'undefined' and 'undefined'.
|
||||
var ResultIsNumber22 = ++obj1.x;
|
||||
@@ -153,23 +153,23 @@ tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOp
|
||||
|
||||
var ResultIsNumber24 = foo()++;
|
||||
~~~~~
|
||||
!!! error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer.
|
||||
!!! error TS2357: The operand of an increment or decrement operator must be a variable or a property access.
|
||||
var ResultIsNumber25 = A.foo()++;
|
||||
~~~~~~~
|
||||
!!! error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer.
|
||||
!!! error TS2357: The operand of an increment or decrement operator must be a variable or a property access.
|
||||
var ResultIsNumber26 = (null + undefined)++;
|
||||
~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer.
|
||||
!!! error TS2357: The operand of an increment or decrement operator must be a variable or a property access.
|
||||
~~~~~~~~~~~~~~~~
|
||||
!!! error TS2365: Operator '+' cannot be applied to types 'undefined' and 'undefined'.
|
||||
var ResultIsNumber27 = (null + null)++;
|
||||
~~~~~~~~~~~~~
|
||||
!!! error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer.
|
||||
!!! error TS2357: The operand of an increment or decrement operator must be a variable or a property access.
|
||||
~~~~~~~~~~~
|
||||
!!! error TS2365: Operator '+' cannot be applied to types 'null' and 'null'.
|
||||
var ResultIsNumber28 = (undefined + undefined)++;
|
||||
~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer.
|
||||
!!! error TS2357: The operand of an increment or decrement operator must be a variable or a property access.
|
||||
~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2365: Operator '+' cannot be applied to types 'undefined' and 'undefined'.
|
||||
var ResultIsNumber29 = obj1.x++;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithEnumType.ts(6,25): error TS2449: The operand of an increment or decrement operator cannot be a constant or a read-only property.
|
||||
tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithEnumType.ts(7,23): error TS2449: The operand of an increment or decrement operator cannot be a constant or a read-only property.
|
||||
tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithEnumType.ts(10,3): error TS2449: The operand of an increment or decrement operator cannot be a constant or a read-only property.
|
||||
tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithEnumType.ts(12,1): error TS2449: The operand of an increment or decrement operator cannot be a constant or a read-only property.
|
||||
tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithEnumType.ts(6,31): error TS2540: Cannot assign to 'B' because it is a constant or a read-only property.
|
||||
tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithEnumType.ts(7,29): error TS2540: Cannot assign to 'B' because it is a constant or a read-only property.
|
||||
tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithEnumType.ts(10,9): error TS2540: Cannot assign to 'B' because it is a constant or a read-only property.
|
||||
tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithEnumType.ts(12,7): error TS2540: Cannot assign to 'B' because it is a constant or a read-only property.
|
||||
|
||||
|
||||
==== tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithEnumType.ts (4 errors) ====
|
||||
@@ -11,17 +11,17 @@ tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOp
|
||||
|
||||
// expression
|
||||
var ResultIsNumber1 = ++ENUM1["B"];
|
||||
~~~~~~~~~~
|
||||
!!! error TS2449: The operand of an increment or decrement operator cannot be a constant or a read-only property.
|
||||
~~~
|
||||
!!! error TS2540: Cannot assign to 'B' because it is a constant or a read-only property.
|
||||
var ResultIsNumber2 = ENUM1.B++;
|
||||
~~~~~~~
|
||||
!!! error TS2449: The operand of an increment or decrement operator cannot be a constant or a read-only property.
|
||||
~
|
||||
!!! error TS2540: Cannot assign to 'B' because it is a constant or a read-only property.
|
||||
|
||||
// miss assignment operator
|
||||
++ENUM1["B"];
|
||||
~~~~~~~~~~
|
||||
!!! error TS2449: The operand of an increment or decrement operator cannot be a constant or a read-only property.
|
||||
~~~
|
||||
!!! error TS2540: Cannot assign to 'B' because it is a constant or a read-only property.
|
||||
|
||||
ENUM1.B++;
|
||||
~~~~~~~
|
||||
!!! error TS2449: The operand of an increment or decrement operator cannot be a constant or a read-only property.
|
||||
~
|
||||
!!! error TS2540: Cannot assign to 'B' because it is a constant or a read-only property.
|
||||
+16
-16
@@ -1,13 +1,13 @@
|
||||
tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithEnumTypeInvalidOperations.ts(7,25): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithEnumTypeInvalidOperations.ts(8,25): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithEnumTypeInvalidOperations.ts(10,23): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithEnumTypeInvalidOperations.ts(11,23): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithEnumTypeInvalidOperations.ts(7,25): error TS2539: Cannot assign to 'ENUM' because it is not a variable.
|
||||
tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithEnumTypeInvalidOperations.ts(8,25): error TS2539: Cannot assign to 'ENUM1' because it is not a variable.
|
||||
tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithEnumTypeInvalidOperations.ts(10,23): error TS2539: Cannot assign to 'ENUM' because it is not a variable.
|
||||
tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithEnumTypeInvalidOperations.ts(11,23): error TS2539: Cannot assign to 'ENUM1' because it is not a variable.
|
||||
tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithEnumTypeInvalidOperations.ts(14,25): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithEnumTypeInvalidOperations.ts(15,23): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithEnumTypeInvalidOperations.ts(18,3): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithEnumTypeInvalidOperations.ts(19,3): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithEnumTypeInvalidOperations.ts(21,1): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithEnumTypeInvalidOperations.ts(22,1): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithEnumTypeInvalidOperations.ts(18,3): error TS2539: Cannot assign to 'ENUM' because it is not a variable.
|
||||
tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithEnumTypeInvalidOperations.ts(19,3): error TS2539: Cannot assign to 'ENUM1' because it is not a variable.
|
||||
tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithEnumTypeInvalidOperations.ts(21,1): error TS2539: Cannot assign to 'ENUM' because it is not a variable.
|
||||
tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithEnumTypeInvalidOperations.ts(22,1): error TS2539: Cannot assign to 'ENUM1' because it is not a variable.
|
||||
|
||||
|
||||
==== tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithEnumTypeInvalidOperations.ts (10 errors) ====
|
||||
@@ -19,17 +19,17 @@ tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOp
|
||||
// enum type var
|
||||
var ResultIsNumber1 = ++ENUM;
|
||||
~~~~
|
||||
!!! error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type.
|
||||
!!! error TS2539: Cannot assign to 'ENUM' because it is not a variable.
|
||||
var ResultIsNumber2 = ++ENUM1;
|
||||
~~~~~
|
||||
!!! error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type.
|
||||
!!! error TS2539: Cannot assign to 'ENUM1' because it is not a variable.
|
||||
|
||||
var ResultIsNumber3 = ENUM++;
|
||||
~~~~
|
||||
!!! error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type.
|
||||
!!! error TS2539: Cannot assign to 'ENUM' because it is not a variable.
|
||||
var ResultIsNumber4 = ENUM1++;
|
||||
~~~~~
|
||||
!!! error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type.
|
||||
!!! error TS2539: Cannot assign to 'ENUM1' because it is not a variable.
|
||||
|
||||
// enum type expressions
|
||||
var ResultIsNumber5 = ++(ENUM[1] + ENUM[2]);
|
||||
@@ -42,14 +42,14 @@ tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOp
|
||||
// miss assignment operator
|
||||
++ENUM;
|
||||
~~~~
|
||||
!!! error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type.
|
||||
!!! error TS2539: Cannot assign to 'ENUM' because it is not a variable.
|
||||
++ENUM1;
|
||||
~~~~~
|
||||
!!! error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type.
|
||||
!!! error TS2539: Cannot assign to 'ENUM1' because it is not a variable.
|
||||
|
||||
ENUM++;
|
||||
~~~~
|
||||
!!! error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type.
|
||||
!!! error TS2539: Cannot assign to 'ENUM' because it is not a variable.
|
||||
ENUM1++;
|
||||
~~~~~
|
||||
!!! error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type.
|
||||
!!! error TS2539: Cannot assign to 'ENUM1' because it is not a variable.
|
||||
+24
-24
@@ -1,23 +1,23 @@
|
||||
tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithNumberTypeInvalidOperations.ts(18,25): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithNumberTypeInvalidOperations.ts(19,23): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithNumberTypeInvalidOperations.ts(22,25): error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer.
|
||||
tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithNumberTypeInvalidOperations.ts(22,25): error TS2357: The operand of an increment or decrement operator must be a variable or a property access.
|
||||
tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithNumberTypeInvalidOperations.ts(23,25): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithNumberTypeInvalidOperations.ts(24,25): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithNumberTypeInvalidOperations.ts(26,23): error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer.
|
||||
tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithNumberTypeInvalidOperations.ts(26,23): error TS2357: The operand of an increment or decrement operator must be a variable or a property access.
|
||||
tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithNumberTypeInvalidOperations.ts(27,23): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithNumberTypeInvalidOperations.ts(28,23): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithNumberTypeInvalidOperations.ts(31,25): error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer.
|
||||
tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithNumberTypeInvalidOperations.ts(32,26): error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer.
|
||||
tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithNumberTypeInvalidOperations.ts(33,26): error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer.
|
||||
tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithNumberTypeInvalidOperations.ts(35,24): error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer.
|
||||
tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithNumberTypeInvalidOperations.ts(36,24): error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer.
|
||||
tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithNumberTypeInvalidOperations.ts(37,24): error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer.
|
||||
tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithNumberTypeInvalidOperations.ts(40,3): error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer.
|
||||
tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithNumberTypeInvalidOperations.ts(31,25): error TS2357: The operand of an increment or decrement operator must be a variable or a property access.
|
||||
tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithNumberTypeInvalidOperations.ts(32,26): error TS2357: The operand of an increment or decrement operator must be a variable or a property access.
|
||||
tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithNumberTypeInvalidOperations.ts(33,26): error TS2357: The operand of an increment or decrement operator must be a variable or a property access.
|
||||
tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithNumberTypeInvalidOperations.ts(35,24): error TS2357: The operand of an increment or decrement operator must be a variable or a property access.
|
||||
tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithNumberTypeInvalidOperations.ts(36,24): error TS2357: The operand of an increment or decrement operator must be a variable or a property access.
|
||||
tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithNumberTypeInvalidOperations.ts(37,24): error TS2357: The operand of an increment or decrement operator must be a variable or a property access.
|
||||
tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithNumberTypeInvalidOperations.ts(40,3): error TS2357: The operand of an increment or decrement operator must be a variable or a property access.
|
||||
tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithNumberTypeInvalidOperations.ts(41,3): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithNumberTypeInvalidOperations.ts(42,3): error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer.
|
||||
tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithNumberTypeInvalidOperations.ts(44,1): error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer.
|
||||
tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithNumberTypeInvalidOperations.ts(42,3): error TS2357: The operand of an increment or decrement operator must be a variable or a property access.
|
||||
tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithNumberTypeInvalidOperations.ts(44,1): error TS2357: The operand of an increment or decrement operator must be a variable or a property access.
|
||||
tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithNumberTypeInvalidOperations.ts(45,1): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithNumberTypeInvalidOperations.ts(46,1): error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer.
|
||||
tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithNumberTypeInvalidOperations.ts(46,1): error TS2357: The operand of an increment or decrement operator must be a variable or a property access.
|
||||
|
||||
|
||||
==== tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithNumberTypeInvalidOperations.ts (20 errors) ====
|
||||
@@ -48,7 +48,7 @@ tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOp
|
||||
// number type literal
|
||||
var ResultIsNumber3 = ++1;
|
||||
~
|
||||
!!! error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer.
|
||||
!!! error TS2357: The operand of an increment or decrement operator must be a variable or a property access.
|
||||
var ResultIsNumber4 = ++{ x: 1, y: 2};
|
||||
~~~~~~~~~~~~~
|
||||
!!! error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type.
|
||||
@@ -58,7 +58,7 @@ tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOp
|
||||
|
||||
var ResultIsNumber6 = 1++;
|
||||
~
|
||||
!!! error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer.
|
||||
!!! error TS2357: The operand of an increment or decrement operator must be a variable or a property access.
|
||||
var ResultIsNumber7 = { x: 1, y: 2 }++;
|
||||
~~~~~~~~~~~~~~
|
||||
!!! error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type.
|
||||
@@ -69,41 +69,41 @@ tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOp
|
||||
// number type expressions
|
||||
var ResultIsNumber9 = ++foo();
|
||||
~~~~~
|
||||
!!! error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer.
|
||||
!!! error TS2357: The operand of an increment or decrement operator must be a variable or a property access.
|
||||
var ResultIsNumber10 = ++A.foo();
|
||||
~~~~~~~
|
||||
!!! error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer.
|
||||
!!! error TS2357: The operand of an increment or decrement operator must be a variable or a property access.
|
||||
var ResultIsNumber11 = ++(NUMBER + NUMBER);
|
||||
~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer.
|
||||
!!! error TS2357: The operand of an increment or decrement operator must be a variable or a property access.
|
||||
|
||||
var ResultIsNumber12 = foo()++;
|
||||
~~~~~
|
||||
!!! error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer.
|
||||
!!! error TS2357: The operand of an increment or decrement operator must be a variable or a property access.
|
||||
var ResultIsNumber13 = A.foo()++;
|
||||
~~~~~~~
|
||||
!!! error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer.
|
||||
!!! error TS2357: The operand of an increment or decrement operator must be a variable or a property access.
|
||||
var ResultIsNumber14 = (NUMBER + NUMBER)++;
|
||||
~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer.
|
||||
!!! error TS2357: The operand of an increment or decrement operator must be a variable or a property access.
|
||||
|
||||
// miss assignment operator
|
||||
++1;
|
||||
~
|
||||
!!! error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer.
|
||||
!!! error TS2357: The operand of an increment or decrement operator must be a variable or a property access.
|
||||
++NUMBER1;
|
||||
~~~~~~~
|
||||
!!! error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type.
|
||||
++foo();
|
||||
~~~~~
|
||||
!!! error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer.
|
||||
!!! error TS2357: The operand of an increment or decrement operator must be a variable or a property access.
|
||||
|
||||
1++;
|
||||
~
|
||||
!!! error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer.
|
||||
!!! error TS2357: The operand of an increment or decrement operator must be a variable or a property access.
|
||||
NUMBER1++;
|
||||
~~~~~~~
|
||||
!!! error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type.
|
||||
foo()++;
|
||||
~~~~~
|
||||
!!! error TS2357: The operand of an increment or decrement operator must be a variable, property or indexer.
|
||||
!!! error TS2357: The operand of an increment or decrement operator must be a variable or a property access.
|
||||
@@ -5,7 +5,7 @@ tests/cases/compiler/indexTypeCheck.ts(22,2): error TS2413: Numeric index type '
|
||||
tests/cases/compiler/indexTypeCheck.ts(27,2): error TS2413: Numeric index type 'number' is not assignable to string index type 'string'.
|
||||
tests/cases/compiler/indexTypeCheck.ts(32,3): error TS1096: An index signature must have exactly one parameter.
|
||||
tests/cases/compiler/indexTypeCheck.ts(36,3): error TS1023: An index signature parameter type must be 'string' or 'number'.
|
||||
tests/cases/compiler/indexTypeCheck.ts(51,1): error TS2342: An index expression argument must be of type 'string', 'number', 'symbol', or 'any'.
|
||||
tests/cases/compiler/indexTypeCheck.ts(51,8): error TS2538: Type 'Blue' cannot be used as an index type.
|
||||
|
||||
|
||||
==== tests/cases/compiler/indexTypeCheck.ts (8 errors) ====
|
||||
@@ -74,8 +74,8 @@ tests/cases/compiler/indexTypeCheck.ts(51,1): error TS2342: An index expression
|
||||
s[<any>{}]; // ok
|
||||
|
||||
yellow[blue]; // error
|
||||
~~~~~~~~~~~~
|
||||
!!! error TS2342: An index expression argument must be of type 'string', 'number', 'symbol', or 'any'.
|
||||
~~~~
|
||||
!!! error TS2538: Type 'Blue' cannot be used as an index type.
|
||||
|
||||
var x:number[];
|
||||
x[0];
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
tests/cases/compiler/indexWithUndefinedAndNull.ts(9,21): error TS2538: Type 'undefined' cannot be used as an index type.
|
||||
tests/cases/compiler/indexWithUndefinedAndNull.ts(10,9): error TS2538: Type 'null' cannot be used as an index type.
|
||||
tests/cases/compiler/indexWithUndefinedAndNull.ts(11,21): error TS2538: Type 'undefined' cannot be used as an index type.
|
||||
tests/cases/compiler/indexWithUndefinedAndNull.ts(12,9): error TS2538: Type 'null' cannot be used as an index type.
|
||||
|
||||
|
||||
==== tests/cases/compiler/indexWithUndefinedAndNull.ts (4 errors) ====
|
||||
interface N {
|
||||
[n: number]: string;
|
||||
}
|
||||
interface S {
|
||||
[s: string]: number;
|
||||
}
|
||||
let n: N;
|
||||
let s: S;
|
||||
let str: string = n[undefined];
|
||||
~~~~~~~~~
|
||||
!!! error TS2538: Type 'undefined' cannot be used as an index type.
|
||||
str = n[null];
|
||||
~~~~
|
||||
!!! error TS2538: Type 'null' cannot be used as an index type.
|
||||
let num: number = s[undefined];
|
||||
~~~~~~~~~
|
||||
!!! error TS2538: Type 'undefined' cannot be used as an index type.
|
||||
num = s[null];
|
||||
~~~~
|
||||
!!! error TS2538: Type 'null' cannot be used as an index type.
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
tests/cases/compiler/indexWithUndefinedAndNullStrictNullChecks.ts(9,19): error TS2454: Variable 'n' is used before being assigned.
|
||||
tests/cases/compiler/indexWithUndefinedAndNullStrictNullChecks.ts(9,19): error TS2342: An index expression argument must be of type 'string', 'number', 'symbol', or 'any'.
|
||||
tests/cases/compiler/indexWithUndefinedAndNullStrictNullChecks.ts(9,21): error TS2538: Type 'undefined' cannot be used as an index type.
|
||||
tests/cases/compiler/indexWithUndefinedAndNullStrictNullChecks.ts(10,7): error TS2454: Variable 'n' is used before being assigned.
|
||||
tests/cases/compiler/indexWithUndefinedAndNullStrictNullChecks.ts(10,7): error TS2342: An index expression argument must be of type 'string', 'number', 'symbol', or 'any'.
|
||||
tests/cases/compiler/indexWithUndefinedAndNullStrictNullChecks.ts(10,9): error TS2538: Type 'null' cannot be used as an index type.
|
||||
tests/cases/compiler/indexWithUndefinedAndNullStrictNullChecks.ts(11,19): error TS2454: Variable 's' is used before being assigned.
|
||||
tests/cases/compiler/indexWithUndefinedAndNullStrictNullChecks.ts(11,19): error TS2342: An index expression argument must be of type 'string', 'number', 'symbol', or 'any'.
|
||||
tests/cases/compiler/indexWithUndefinedAndNullStrictNullChecks.ts(11,21): error TS2538: Type 'undefined' cannot be used as an index type.
|
||||
tests/cases/compiler/indexWithUndefinedAndNullStrictNullChecks.ts(12,7): error TS2454: Variable 's' is used before being assigned.
|
||||
tests/cases/compiler/indexWithUndefinedAndNullStrictNullChecks.ts(12,7): error TS2342: An index expression argument must be of type 'string', 'number', 'symbol', or 'any'.
|
||||
tests/cases/compiler/indexWithUndefinedAndNullStrictNullChecks.ts(12,9): error TS2538: Type 'null' cannot be used as an index type.
|
||||
|
||||
|
||||
==== tests/cases/compiler/indexWithUndefinedAndNullStrictNullChecks.ts (8 errors) ====
|
||||
@@ -20,21 +20,21 @@ tests/cases/compiler/indexWithUndefinedAndNullStrictNullChecks.ts(12,7): error T
|
||||
let str: string = n[undefined];
|
||||
~
|
||||
!!! error TS2454: Variable 'n' is used before being assigned.
|
||||
~~~~~~~~~~~~
|
||||
!!! error TS2342: An index expression argument must be of type 'string', 'number', 'symbol', or 'any'.
|
||||
~~~~~~~~~
|
||||
!!! error TS2538: Type 'undefined' cannot be used as an index type.
|
||||
str = n[null];
|
||||
~
|
||||
!!! error TS2454: Variable 'n' is used before being assigned.
|
||||
~~~~~~~
|
||||
!!! error TS2342: An index expression argument must be of type 'string', 'number', 'symbol', or 'any'.
|
||||
~~~~
|
||||
!!! error TS2538: Type 'null' cannot be used as an index type.
|
||||
let num: number = s[undefined];
|
||||
~
|
||||
!!! error TS2454: Variable 's' is used before being assigned.
|
||||
~~~~~~~~~~~~
|
||||
!!! error TS2342: An index expression argument must be of type 'string', 'number', 'symbol', or 'any'.
|
||||
~~~~~~~~~
|
||||
!!! error TS2538: Type 'undefined' cannot be used as an index type.
|
||||
num = s[null];
|
||||
~
|
||||
!!! error TS2454: Variable 's' is used before being assigned.
|
||||
~~~~~~~
|
||||
!!! error TS2342: An index expression argument must be of type 'string', 'number', 'symbol', or 'any'.
|
||||
~~~~
|
||||
!!! error TS2538: Type 'null' cannot be used as an index type.
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
tests/cases/conformance/types/spread/interfaceSpread.ts(2,5): error TS2697: Interface declaration cannot contain a spread property.
|
||||
tests/cases/conformance/types/spread/interfaceSpread.ts(2,5): error TS2698: Interface declaration cannot contain a spread property.
|
||||
tests/cases/conformance/types/spread/interfaceSpread.ts(7,10): error TS2339: Property 'jam' does not exist on type 'Congealed<{ jam: number; }, { peanutButter: number; }>'.
|
||||
tests/cases/conformance/types/spread/interfaceSpread.ts(8,10): error TS2339: Property 'peanutButter' does not exist on type 'Congealed<{ jam: number; }, { peanutButter: number; }>'.
|
||||
|
||||
@@ -7,7 +7,7 @@ tests/cases/conformance/types/spread/interfaceSpread.ts(8,10): error TS2339: Pro
|
||||
interface Congealed<T, U> {
|
||||
...T
|
||||
~~~~
|
||||
!!! error TS2697: Interface declaration cannot contain a spread property.
|
||||
!!! error TS2698: Interface declaration cannot contain a spread property.
|
||||
...U
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
tests/cases/conformance/types/intersection/intersectionTypeReadonly.ts(17,1): error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
|
||||
tests/cases/conformance/types/intersection/intersectionTypeReadonly.ts(19,1): error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
|
||||
tests/cases/conformance/types/intersection/intersectionTypeReadonly.ts(21,1): error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
|
||||
tests/cases/conformance/types/intersection/intersectionTypeReadonly.ts(23,1): error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
|
||||
tests/cases/conformance/types/intersection/intersectionTypeReadonly.ts(25,1): error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
|
||||
tests/cases/conformance/types/intersection/intersectionTypeReadonly.ts(17,6): error TS2540: Cannot assign to 'value' because it is a constant or a read-only property.
|
||||
tests/cases/conformance/types/intersection/intersectionTypeReadonly.ts(19,11): error TS2540: Cannot assign to 'value' because it is a constant or a read-only property.
|
||||
tests/cases/conformance/types/intersection/intersectionTypeReadonly.ts(21,9): error TS2540: Cannot assign to 'value' because it is a constant or a read-only property.
|
||||
tests/cases/conformance/types/intersection/intersectionTypeReadonly.ts(23,15): error TS2540: Cannot assign to 'value' because it is a constant or a read-only property.
|
||||
tests/cases/conformance/types/intersection/intersectionTypeReadonly.ts(25,15): error TS2540: Cannot assign to 'value' because it is a constant or a read-only property.
|
||||
|
||||
|
||||
==== tests/cases/conformance/types/intersection/intersectionTypeReadonly.ts (5 errors) ====
|
||||
@@ -23,22 +23,22 @@ tests/cases/conformance/types/intersection/intersectionTypeReadonly.ts(25,1): er
|
||||
}
|
||||
let base: Base;
|
||||
base.value = 12 // error, lhs can't be a readonly property
|
||||
~~~~~~~~~~
|
||||
!!! error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
|
||||
~~~~~
|
||||
!!! error TS2540: Cannot assign to 'value' because it is a constant or a read-only property.
|
||||
let identical: Base & Identical;
|
||||
identical.value = 12; // error, lhs can't be a readonly property
|
||||
~~~~~~~~~~~~~~~
|
||||
!!! error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
|
||||
~~~~~
|
||||
!!! error TS2540: Cannot assign to 'value' because it is a constant or a read-only property.
|
||||
let mutable: Base & Mutable;
|
||||
mutable.value = 12; // error, lhs can't be a readonly property
|
||||
~~~~~~~~~~~~~
|
||||
!!! error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
|
||||
~~~~~
|
||||
!!! error TS2540: Cannot assign to 'value' because it is a constant or a read-only property.
|
||||
let differentType: Base & DifferentType;
|
||||
differentType.value = 12; // error, lhs can't be a readonly property
|
||||
~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
|
||||
~~~~~
|
||||
!!! error TS2540: Cannot assign to 'value' because it is a constant or a read-only property.
|
||||
let differentName: Base & DifferentName;
|
||||
differentName.value = 12; // error, property 'value' doesn't exist
|
||||
~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
|
||||
~~~~~
|
||||
!!! error TS2540: Cannot assign to 'value' because it is a constant or a read-only property.
|
||||
|
||||
@@ -5,9 +5,9 @@ tests/cases/conformance/types/primitives/boolean/invalidBooleanAssignments.ts(9,
|
||||
tests/cases/conformance/types/primitives/boolean/invalidBooleanAssignments.ts(12,5): error TS2322: Type 'true' is not assignable to type 'C'.
|
||||
tests/cases/conformance/types/primitives/boolean/invalidBooleanAssignments.ts(15,5): error TS2322: Type 'true' is not assignable to type 'I'.
|
||||
tests/cases/conformance/types/primitives/boolean/invalidBooleanAssignments.ts(17,5): error TS2322: Type 'true' is not assignable to type '() => string'.
|
||||
tests/cases/conformance/types/primitives/boolean/invalidBooleanAssignments.ts(21,1): error TS2364: Invalid left-hand side of assignment expression.
|
||||
tests/cases/conformance/types/primitives/boolean/invalidBooleanAssignments.ts(21,1): error TS2539: Cannot assign to 'M' because it is not a variable.
|
||||
tests/cases/conformance/types/primitives/boolean/invalidBooleanAssignments.ts(24,5): error TS2322: Type 'boolean' is not assignable to type 'T'.
|
||||
tests/cases/conformance/types/primitives/boolean/invalidBooleanAssignments.ts(26,1): error TS2364: Invalid left-hand side of assignment expression.
|
||||
tests/cases/conformance/types/primitives/boolean/invalidBooleanAssignments.ts(26,1): error TS2539: Cannot assign to 'i' because it is not a variable.
|
||||
|
||||
|
||||
==== tests/cases/conformance/types/primitives/boolean/invalidBooleanAssignments.ts (10 errors) ====
|
||||
@@ -47,7 +47,7 @@ tests/cases/conformance/types/primitives/boolean/invalidBooleanAssignments.ts(26
|
||||
module M { export var a = 1; }
|
||||
M = x;
|
||||
~
|
||||
!!! error TS2364: Invalid left-hand side of assignment expression.
|
||||
!!! error TS2539: Cannot assign to 'M' because it is not a variable.
|
||||
|
||||
function i<T>(a: T) {
|
||||
a = x;
|
||||
@@ -56,4 +56,4 @@ tests/cases/conformance/types/primitives/boolean/invalidBooleanAssignments.ts(26
|
||||
}
|
||||
i = x;
|
||||
~
|
||||
!!! error TS2364: Invalid left-hand side of assignment expression.
|
||||
!!! error TS2539: Cannot assign to 'i' because it is not a variable.
|
||||
@@ -5,9 +5,9 @@ tests/cases/conformance/types/primitives/number/invalidNumberAssignments.ts(9,5)
|
||||
tests/cases/conformance/types/primitives/number/invalidNumberAssignments.ts(12,5): error TS2322: Type 'number' is not assignable to type 'I'.
|
||||
tests/cases/conformance/types/primitives/number/invalidNumberAssignments.ts(14,5): error TS2322: Type '1' is not assignable to type '{ baz: string; }'.
|
||||
tests/cases/conformance/types/primitives/number/invalidNumberAssignments.ts(15,5): error TS2322: Type '1' is not assignable to type '{ 0: number; }'.
|
||||
tests/cases/conformance/types/primitives/number/invalidNumberAssignments.ts(18,1): error TS2364: Invalid left-hand side of assignment expression.
|
||||
tests/cases/conformance/types/primitives/number/invalidNumberAssignments.ts(18,1): error TS2539: Cannot assign to 'M' because it is not a variable.
|
||||
tests/cases/conformance/types/primitives/number/invalidNumberAssignments.ts(21,5): error TS2322: Type 'number' is not assignable to type 'T'.
|
||||
tests/cases/conformance/types/primitives/number/invalidNumberAssignments.ts(23,1): error TS2364: Invalid left-hand side of assignment expression.
|
||||
tests/cases/conformance/types/primitives/number/invalidNumberAssignments.ts(23,1): error TS2539: Cannot assign to 'i' because it is not a variable.
|
||||
|
||||
|
||||
==== tests/cases/conformance/types/primitives/number/invalidNumberAssignments.ts (10 errors) ====
|
||||
@@ -44,7 +44,7 @@ tests/cases/conformance/types/primitives/number/invalidNumberAssignments.ts(23,1
|
||||
module M { export var x = 1; }
|
||||
M = x;
|
||||
~
|
||||
!!! error TS2364: Invalid left-hand side of assignment expression.
|
||||
!!! error TS2539: Cannot assign to 'M' because it is not a variable.
|
||||
|
||||
function i<T>(a: T) {
|
||||
a = x;
|
||||
@@ -53,4 +53,4 @@ tests/cases/conformance/types/primitives/number/invalidNumberAssignments.ts(23,1
|
||||
}
|
||||
i = x;
|
||||
~
|
||||
!!! error TS2364: Invalid left-hand side of assignment expression.
|
||||
!!! error TS2539: Cannot assign to 'i' because it is not a variable.
|
||||
@@ -5,9 +5,9 @@ tests/cases/conformance/types/primitives/string/invalidStringAssignments.ts(9,5)
|
||||
tests/cases/conformance/types/primitives/string/invalidStringAssignments.ts(12,5): error TS2322: Type 'string' is not assignable to type 'I'.
|
||||
tests/cases/conformance/types/primitives/string/invalidStringAssignments.ts(14,5): error TS2322: Type '1' is not assignable to type '{ baz: string; }'.
|
||||
tests/cases/conformance/types/primitives/string/invalidStringAssignments.ts(15,5): error TS2322: Type '1' is not assignable to type '{ 0: number; }'.
|
||||
tests/cases/conformance/types/primitives/string/invalidStringAssignments.ts(18,1): error TS2364: Invalid left-hand side of assignment expression.
|
||||
tests/cases/conformance/types/primitives/string/invalidStringAssignments.ts(18,1): error TS2539: Cannot assign to 'M' because it is not a variable.
|
||||
tests/cases/conformance/types/primitives/string/invalidStringAssignments.ts(21,5): error TS2322: Type 'string' is not assignable to type 'T'.
|
||||
tests/cases/conformance/types/primitives/string/invalidStringAssignments.ts(23,1): error TS2364: Invalid left-hand side of assignment expression.
|
||||
tests/cases/conformance/types/primitives/string/invalidStringAssignments.ts(23,1): error TS2539: Cannot assign to 'i' because it is not a variable.
|
||||
tests/cases/conformance/types/primitives/string/invalidStringAssignments.ts(26,5): error TS2322: Type 'string' is not assignable to type 'E'.
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@ tests/cases/conformance/types/primitives/string/invalidStringAssignments.ts(26,5
|
||||
module M { export var x = 1; }
|
||||
M = x;
|
||||
~
|
||||
!!! error TS2364: Invalid left-hand side of assignment expression.
|
||||
!!! error TS2539: Cannot assign to 'M' because it is not a variable.
|
||||
|
||||
function i<T>(a: T) {
|
||||
a = x;
|
||||
@@ -54,7 +54,7 @@ tests/cases/conformance/types/primitives/string/invalidStringAssignments.ts(26,5
|
||||
}
|
||||
i = x;
|
||||
~
|
||||
!!! error TS2364: Invalid left-hand side of assignment expression.
|
||||
!!! error TS2539: Cannot assign to 'i' because it is not a variable.
|
||||
|
||||
enum E { A }
|
||||
var j: E = x;
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
tests/cases/conformance/types/primitives/undefined/invalidUndefinedAssignments.ts(4,1): error TS2364: Invalid left-hand side of assignment expression.
|
||||
tests/cases/conformance/types/primitives/undefined/invalidUndefinedAssignments.ts(5,1): error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
|
||||
tests/cases/conformance/types/primitives/undefined/invalidUndefinedAssignments.ts(9,1): error TS2364: Invalid left-hand side of assignment expression.
|
||||
tests/cases/conformance/types/primitives/undefined/invalidUndefinedAssignments.ts(4,1): error TS2539: Cannot assign to 'E' because it is not a variable.
|
||||
tests/cases/conformance/types/primitives/undefined/invalidUndefinedAssignments.ts(5,3): error TS2540: Cannot assign to 'A' because it is a constant or a read-only property.
|
||||
tests/cases/conformance/types/primitives/undefined/invalidUndefinedAssignments.ts(9,1): error TS2539: Cannot assign to 'C' because it is not a variable.
|
||||
tests/cases/conformance/types/primitives/undefined/invalidUndefinedAssignments.ts(14,1): error TS2693: 'I' only refers to a type, but is being used as a value here.
|
||||
tests/cases/conformance/types/primitives/undefined/invalidUndefinedAssignments.ts(17,1): error TS2364: Invalid left-hand side of assignment expression.
|
||||
tests/cases/conformance/types/primitives/undefined/invalidUndefinedAssignments.ts(21,1): error TS2364: Invalid left-hand side of assignment expression.
|
||||
tests/cases/conformance/types/primitives/undefined/invalidUndefinedAssignments.ts(17,1): error TS2539: Cannot assign to 'M' because it is not a variable.
|
||||
tests/cases/conformance/types/primitives/undefined/invalidUndefinedAssignments.ts(21,1): error TS2539: Cannot assign to 'i' because it is not a variable.
|
||||
|
||||
|
||||
==== tests/cases/conformance/types/primitives/undefined/invalidUndefinedAssignments.ts (6 errors) ====
|
||||
@@ -12,16 +12,16 @@ tests/cases/conformance/types/primitives/undefined/invalidUndefinedAssignments.t
|
||||
enum E { A }
|
||||
E = x;
|
||||
~
|
||||
!!! error TS2364: Invalid left-hand side of assignment expression.
|
||||
!!! error TS2539: Cannot assign to 'E' because it is not a variable.
|
||||
E.A = x;
|
||||
~~~
|
||||
!!! error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
|
||||
~
|
||||
!!! error TS2540: Cannot assign to 'A' because it is a constant or a read-only property.
|
||||
|
||||
class C { foo: string }
|
||||
var f: C;
|
||||
C = x;
|
||||
~
|
||||
!!! error TS2364: Invalid left-hand side of assignment expression.
|
||||
!!! error TS2539: Cannot assign to 'C' because it is not a variable.
|
||||
|
||||
interface I { foo: string }
|
||||
var g: I;
|
||||
@@ -33,10 +33,10 @@ tests/cases/conformance/types/primitives/undefined/invalidUndefinedAssignments.t
|
||||
module M { export var x = 1; }
|
||||
M = x;
|
||||
~
|
||||
!!! error TS2364: Invalid left-hand side of assignment expression.
|
||||
!!! error TS2539: Cannot assign to 'M' because it is not a variable.
|
||||
|
||||
function i<T>(a: T) { }
|
||||
// BUG 767030
|
||||
i = x;
|
||||
~
|
||||
!!! error TS2364: Invalid left-hand side of assignment expression.
|
||||
!!! error TS2539: Cannot assign to 'i' because it is not a variable.
|
||||
@@ -5,9 +5,9 @@ tests/cases/conformance/types/primitives/void/invalidVoidAssignments.ts(9,5): er
|
||||
tests/cases/conformance/types/primitives/void/invalidVoidAssignments.ts(12,5): error TS2322: Type 'void' is not assignable to type 'I'.
|
||||
tests/cases/conformance/types/primitives/void/invalidVoidAssignments.ts(14,5): error TS2322: Type '1' is not assignable to type '{ baz: string; }'.
|
||||
tests/cases/conformance/types/primitives/void/invalidVoidAssignments.ts(15,5): error TS2322: Type '1' is not assignable to type '{ 0: number; }'.
|
||||
tests/cases/conformance/types/primitives/void/invalidVoidAssignments.ts(18,1): error TS2364: Invalid left-hand side of assignment expression.
|
||||
tests/cases/conformance/types/primitives/void/invalidVoidAssignments.ts(18,1): error TS2539: Cannot assign to 'M' because it is not a variable.
|
||||
tests/cases/conformance/types/primitives/void/invalidVoidAssignments.ts(21,5): error TS2322: Type 'void' is not assignable to type 'T'.
|
||||
tests/cases/conformance/types/primitives/void/invalidVoidAssignments.ts(23,1): error TS2364: Invalid left-hand side of assignment expression.
|
||||
tests/cases/conformance/types/primitives/void/invalidVoidAssignments.ts(23,1): error TS2539: Cannot assign to 'i' because it is not a variable.
|
||||
tests/cases/conformance/types/primitives/void/invalidVoidAssignments.ts(26,1): error TS2322: Type 'typeof E' is not assignable to type 'void'.
|
||||
tests/cases/conformance/types/primitives/void/invalidVoidAssignments.ts(27,1): error TS2322: Type 'E' is not assignable to type 'void'.
|
||||
tests/cases/conformance/types/primitives/void/invalidVoidAssignments.ts(29,1): error TS2322: Type '{ f(): void; }' is not assignable to type 'void'.
|
||||
@@ -47,7 +47,7 @@ tests/cases/conformance/types/primitives/void/invalidVoidAssignments.ts(29,1): e
|
||||
module M { export var x = 1; }
|
||||
M = x;
|
||||
~
|
||||
!!! error TS2364: Invalid left-hand side of assignment expression.
|
||||
!!! error TS2539: Cannot assign to 'M' because it is not a variable.
|
||||
|
||||
function i<T>(a: T) {
|
||||
a = x;
|
||||
@@ -56,7 +56,7 @@ tests/cases/conformance/types/primitives/void/invalidVoidAssignments.ts(29,1): e
|
||||
}
|
||||
i = x;
|
||||
~
|
||||
!!! error TS2364: Invalid left-hand side of assignment expression.
|
||||
!!! error TS2539: Cannot assign to 'i' because it is not a variable.
|
||||
|
||||
enum E { A }
|
||||
x = E;
|
||||
|
||||
@@ -0,0 +1,350 @@
|
||||
//// [keyofAndIndexedAccess.ts]
|
||||
|
||||
class Shape {
|
||||
name: string;
|
||||
width: number;
|
||||
height: number;
|
||||
visible: boolean;
|
||||
}
|
||||
|
||||
class Item {
|
||||
name: string;
|
||||
price: number;
|
||||
}
|
||||
|
||||
class Options {
|
||||
visible: "yes" | "no";
|
||||
}
|
||||
|
||||
type Dictionary<T> = { [x: string]: T };
|
||||
|
||||
const enum E { A, B, C }
|
||||
|
||||
type K00 = keyof any; // string | number
|
||||
type K01 = keyof string; // number | "toString" | "charAt" | ...
|
||||
type K02 = keyof number; // "toString" | "toFixed" | "toExponential" | ...
|
||||
type K03 = keyof boolean; // "valueOf"
|
||||
type K04 = keyof void; // never
|
||||
type K05 = keyof undefined; // never
|
||||
type K06 = keyof null; // never
|
||||
type K07 = keyof never; // never
|
||||
|
||||
type K10 = keyof Shape; // "name" | "width" | "height" | "visible"
|
||||
type K11 = keyof Shape[]; // number | "length" | "toString" | ...
|
||||
type K12 = keyof Dictionary<Shape>; // string | number
|
||||
type K13 = keyof {}; // never
|
||||
type K14 = keyof Object; // "constructor" | "toString" | ...
|
||||
type K15 = keyof E; // "toString" | "toFixed" | "toExponential" | ...
|
||||
type K16 = keyof [string, number]; // number | "0" | "1" | "length" | "toString" | ...
|
||||
type K17 = keyof (Shape | Item); // "name"
|
||||
type K18 = keyof (Shape & Item); // "name" | "width" | "height" | "visible" | "price"
|
||||
|
||||
type KeyOf<T> = keyof T;
|
||||
|
||||
type K20 = KeyOf<Shape>; // "name" | "width" | "height" | "visible"
|
||||
type K21 = KeyOf<Dictionary<Shape>>; // string | number
|
||||
|
||||
type NAME = "name";
|
||||
type WIDTH_OR_HEIGHT = "width" | "height";
|
||||
|
||||
type Q10 = Shape["name"]; // string
|
||||
type Q11 = Shape["width" | "height"]; // number
|
||||
type Q12 = Shape["name" | "visible"]; // string | boolean
|
||||
|
||||
type Q20 = Shape[NAME]; // string
|
||||
type Q21 = Shape[WIDTH_OR_HEIGHT]; // number
|
||||
|
||||
type Q30 = [string, number][0]; // string
|
||||
type Q31 = [string, number][1]; // number
|
||||
type Q32 = [string, number][2]; // string | number
|
||||
type Q33 = [string, number][E.A]; // string
|
||||
type Q34 = [string, number][E.B]; // number
|
||||
type Q35 = [string, number][E.C]; // string | number
|
||||
type Q36 = [string, number]["0"]; // string
|
||||
type Q37 = [string, number]["1"]; // string
|
||||
|
||||
type Q40 = (Shape | Options)["visible"]; // boolean | "yes" | "no"
|
||||
type Q41 = (Shape & Options)["visible"]; // true & "yes" | true & "no" | false & "yes" | false & "no"
|
||||
|
||||
type Q50 = Dictionary<Shape>["howdy"]; // Shape
|
||||
type Q51 = Dictionary<Shape>[123]; // Shape
|
||||
type Q52 = Dictionary<Shape>[E.B]; // Shape
|
||||
|
||||
declare let cond: boolean;
|
||||
|
||||
function getProperty<T, K extends keyof T>(obj: T, key: K) {
|
||||
return obj[key];
|
||||
}
|
||||
|
||||
function setProperty<T, K extends keyof T>(obj: T, key: K, value: T[K]) {
|
||||
obj[key] = value;
|
||||
}
|
||||
|
||||
function f10(shape: Shape) {
|
||||
let name = getProperty(shape, "name"); // string
|
||||
let widthOrHeight = getProperty(shape, cond ? "width" : "height"); // number
|
||||
let nameOrVisible = getProperty(shape, cond ? "name" : "visible"); // string | boolean
|
||||
setProperty(shape, "name", "rectangle");
|
||||
setProperty(shape, cond ? "width" : "height", 10);
|
||||
setProperty(shape, cond ? "name" : "visible", true); // Technically not safe
|
||||
}
|
||||
|
||||
function f11(a: Shape[]) {
|
||||
let len = getProperty(a, "length"); // number
|
||||
let shape = getProperty(a, 1000); // Shape
|
||||
setProperty(a, 1000, getProperty(a, 1001));
|
||||
}
|
||||
|
||||
function f12(t: [Shape, boolean]) {
|
||||
let len = getProperty(t, "length");
|
||||
let s1 = getProperty(t, 0); // Shape
|
||||
let s2 = getProperty(t, "0"); // Shape
|
||||
let b1 = getProperty(t, 1); // boolean
|
||||
let b2 = getProperty(t, "1"); // boolean
|
||||
let x1 = getProperty(t, 2); // Shape | boolean
|
||||
}
|
||||
|
||||
function f13(foo: any, bar: any) {
|
||||
let x = getProperty(foo, "x"); // any
|
||||
let y = getProperty(foo, 100); // any
|
||||
let z = getProperty(foo, bar); // any
|
||||
}
|
||||
|
||||
class Component<PropType> {
|
||||
props: PropType;
|
||||
getProperty<K extends keyof PropType>(key: K) {
|
||||
return this.props[key];
|
||||
}
|
||||
setProperty<K extends keyof PropType>(key: K, value: PropType[K]) {
|
||||
this.props[key] = value;
|
||||
}
|
||||
}
|
||||
|
||||
function f20(component: Component<Shape>) {
|
||||
let name = component.getProperty("name"); // string
|
||||
let widthOrHeight = component.getProperty(cond ? "width" : "height"); // number
|
||||
let nameOrVisible = component.getProperty(cond ? "name" : "visible"); // string | boolean
|
||||
component.setProperty("name", "rectangle");
|
||||
component.setProperty(cond ? "width" : "height", 10)
|
||||
component.setProperty(cond ? "name" : "visible", true); // Technically not safe
|
||||
}
|
||||
|
||||
function pluck<T, K extends keyof T>(array: T[], key: K) {
|
||||
return array.map(x => x[key]);
|
||||
}
|
||||
|
||||
function f30(shapes: Shape[]) {
|
||||
let names = pluck(shapes, "name"); // string[]
|
||||
let widths = pluck(shapes, "width"); // number[]
|
||||
let nameOrVisibles = pluck(shapes, cond ? "name" : "visible"); // (string | boolean)[]
|
||||
}
|
||||
|
||||
function f31<K extends keyof Shape>(key: K) {
|
||||
const shape: Shape = { name: "foo", width: 5, height: 10, visible: true };
|
||||
return shape[key]; // Shape[K]
|
||||
}
|
||||
|
||||
function f32<K extends "width" | "height">(key: K) {
|
||||
const shape: Shape = { name: "foo", width: 5, height: 10, visible: true };
|
||||
return shape[key]; // Shape[K]
|
||||
}
|
||||
|
||||
class C {
|
||||
public x: string;
|
||||
protected y: string;
|
||||
private z: string;
|
||||
}
|
||||
|
||||
// Indexed access expressions have always permitted access to private and protected members.
|
||||
// For consistency we also permit such access in indexed access types.
|
||||
function f40(c: C) {
|
||||
type X = C["x"];
|
||||
type Y = C["y"];
|
||||
type Z = C["z"];
|
||||
let x: X = c["x"];
|
||||
let y: Y = c["y"];
|
||||
let z: Z = c["z"];
|
||||
}
|
||||
|
||||
//// [keyofAndIndexedAccess.js]
|
||||
var Shape = (function () {
|
||||
function Shape() {
|
||||
}
|
||||
return Shape;
|
||||
}());
|
||||
var Item = (function () {
|
||||
function Item() {
|
||||
}
|
||||
return Item;
|
||||
}());
|
||||
var Options = (function () {
|
||||
function Options() {
|
||||
}
|
||||
return Options;
|
||||
}());
|
||||
function getProperty(obj, key) {
|
||||
return obj[key];
|
||||
}
|
||||
function setProperty(obj, key, value) {
|
||||
obj[key] = value;
|
||||
}
|
||||
function f10(shape) {
|
||||
var name = getProperty(shape, "name"); // string
|
||||
var widthOrHeight = getProperty(shape, cond ? "width" : "height"); // number
|
||||
var nameOrVisible = getProperty(shape, cond ? "name" : "visible"); // string | boolean
|
||||
setProperty(shape, "name", "rectangle");
|
||||
setProperty(shape, cond ? "width" : "height", 10);
|
||||
setProperty(shape, cond ? "name" : "visible", true); // Technically not safe
|
||||
}
|
||||
function f11(a) {
|
||||
var len = getProperty(a, "length"); // number
|
||||
var shape = getProperty(a, 1000); // Shape
|
||||
setProperty(a, 1000, getProperty(a, 1001));
|
||||
}
|
||||
function f12(t) {
|
||||
var len = getProperty(t, "length");
|
||||
var s1 = getProperty(t, 0); // Shape
|
||||
var s2 = getProperty(t, "0"); // Shape
|
||||
var b1 = getProperty(t, 1); // boolean
|
||||
var b2 = getProperty(t, "1"); // boolean
|
||||
var x1 = getProperty(t, 2); // Shape | boolean
|
||||
}
|
||||
function f13(foo, bar) {
|
||||
var x = getProperty(foo, "x"); // any
|
||||
var y = getProperty(foo, 100); // any
|
||||
var z = getProperty(foo, bar); // any
|
||||
}
|
||||
var Component = (function () {
|
||||
function Component() {
|
||||
}
|
||||
Component.prototype.getProperty = function (key) {
|
||||
return this.props[key];
|
||||
};
|
||||
Component.prototype.setProperty = function (key, value) {
|
||||
this.props[key] = value;
|
||||
};
|
||||
return Component;
|
||||
}());
|
||||
function f20(component) {
|
||||
var name = component.getProperty("name"); // string
|
||||
var widthOrHeight = component.getProperty(cond ? "width" : "height"); // number
|
||||
var nameOrVisible = component.getProperty(cond ? "name" : "visible"); // string | boolean
|
||||
component.setProperty("name", "rectangle");
|
||||
component.setProperty(cond ? "width" : "height", 10);
|
||||
component.setProperty(cond ? "name" : "visible", true); // Technically not safe
|
||||
}
|
||||
function pluck(array, key) {
|
||||
return array.map(function (x) { return x[key]; });
|
||||
}
|
||||
function f30(shapes) {
|
||||
var names = pluck(shapes, "name"); // string[]
|
||||
var widths = pluck(shapes, "width"); // number[]
|
||||
var nameOrVisibles = pluck(shapes, cond ? "name" : "visible"); // (string | boolean)[]
|
||||
}
|
||||
function f31(key) {
|
||||
var shape = { name: "foo", width: 5, height: 10, visible: true };
|
||||
return shape[key]; // Shape[K]
|
||||
}
|
||||
function f32(key) {
|
||||
var shape = { name: "foo", width: 5, height: 10, visible: true };
|
||||
return shape[key]; // Shape[K]
|
||||
}
|
||||
var C = (function () {
|
||||
function C() {
|
||||
}
|
||||
return C;
|
||||
}());
|
||||
// Indexed access expressions have always permitted access to private and protected members.
|
||||
// For consistency we also permit such access in indexed access types.
|
||||
function f40(c) {
|
||||
var x = c["x"];
|
||||
var y = c["y"];
|
||||
var z = c["z"];
|
||||
}
|
||||
|
||||
|
||||
//// [keyofAndIndexedAccess.d.ts]
|
||||
declare class Shape {
|
||||
name: string;
|
||||
width: number;
|
||||
height: number;
|
||||
visible: boolean;
|
||||
}
|
||||
declare class Item {
|
||||
name: string;
|
||||
price: number;
|
||||
}
|
||||
declare class Options {
|
||||
visible: "yes" | "no";
|
||||
}
|
||||
declare type Dictionary<T> = {
|
||||
[x: string]: T;
|
||||
};
|
||||
declare const enum E {
|
||||
A = 0,
|
||||
B = 1,
|
||||
C = 2,
|
||||
}
|
||||
declare type K00 = keyof any;
|
||||
declare type K01 = keyof string;
|
||||
declare type K02 = keyof number;
|
||||
declare type K03 = keyof boolean;
|
||||
declare type K04 = keyof void;
|
||||
declare type K05 = keyof undefined;
|
||||
declare type K06 = keyof null;
|
||||
declare type K07 = keyof never;
|
||||
declare type K10 = keyof Shape;
|
||||
declare type K11 = keyof Shape[];
|
||||
declare type K12 = keyof Dictionary<Shape>;
|
||||
declare type K13 = keyof {};
|
||||
declare type K14 = keyof Object;
|
||||
declare type K15 = keyof E;
|
||||
declare type K16 = keyof [string, number];
|
||||
declare type K17 = keyof (Shape | Item);
|
||||
declare type K18 = keyof (Shape & Item);
|
||||
declare type KeyOf<T> = keyof T;
|
||||
declare type K20 = KeyOf<Shape>;
|
||||
declare type K21 = KeyOf<Dictionary<Shape>>;
|
||||
declare type NAME = "name";
|
||||
declare type WIDTH_OR_HEIGHT = "width" | "height";
|
||||
declare type Q10 = Shape["name"];
|
||||
declare type Q11 = Shape["width" | "height"];
|
||||
declare type Q12 = Shape["name" | "visible"];
|
||||
declare type Q20 = Shape[NAME];
|
||||
declare type Q21 = Shape[WIDTH_OR_HEIGHT];
|
||||
declare type Q30 = [string, number][0];
|
||||
declare type Q31 = [string, number][1];
|
||||
declare type Q32 = [string, number][2];
|
||||
declare type Q33 = [string, number][E.A];
|
||||
declare type Q34 = [string, number][E.B];
|
||||
declare type Q35 = [string, number][E.C];
|
||||
declare type Q36 = [string, number]["0"];
|
||||
declare type Q37 = [string, number]["1"];
|
||||
declare type Q40 = (Shape | Options)["visible"];
|
||||
declare type Q41 = (Shape & Options)["visible"];
|
||||
declare type Q50 = Dictionary<Shape>["howdy"];
|
||||
declare type Q51 = Dictionary<Shape>[123];
|
||||
declare type Q52 = Dictionary<Shape>[E.B];
|
||||
declare let cond: boolean;
|
||||
declare function getProperty<T, K extends keyof T>(obj: T, key: K): T[K];
|
||||
declare function setProperty<T, K extends keyof T>(obj: T, key: K, value: T[K]): void;
|
||||
declare function f10(shape: Shape): void;
|
||||
declare function f11(a: Shape[]): void;
|
||||
declare function f12(t: [Shape, boolean]): void;
|
||||
declare function f13(foo: any, bar: any): void;
|
||||
declare class Component<PropType> {
|
||||
props: PropType;
|
||||
getProperty<K extends keyof PropType>(key: K): PropType[K];
|
||||
setProperty<K extends keyof PropType>(key: K, value: PropType[K]): void;
|
||||
}
|
||||
declare function f20(component: Component<Shape>): void;
|
||||
declare function pluck<T, K extends keyof T>(array: T[], key: K): T[K][];
|
||||
declare function f30(shapes: Shape[]): void;
|
||||
declare function f31<K extends keyof Shape>(key: K): Shape[K];
|
||||
declare function f32<K extends "width" | "height">(key: K): Shape[K];
|
||||
declare class C {
|
||||
x: string;
|
||||
protected y: string;
|
||||
private z;
|
||||
}
|
||||
declare function f40(c: C): void;
|
||||
@@ -0,0 +1,577 @@
|
||||
=== tests/cases/conformance/types/keyof/keyofAndIndexedAccess.ts ===
|
||||
|
||||
class Shape {
|
||||
>Shape : Symbol(Shape, Decl(keyofAndIndexedAccess.ts, 0, 0))
|
||||
|
||||
name: string;
|
||||
>name : Symbol(Shape.name, Decl(keyofAndIndexedAccess.ts, 1, 13))
|
||||
|
||||
width: number;
|
||||
>width : Symbol(Shape.width, Decl(keyofAndIndexedAccess.ts, 2, 17))
|
||||
|
||||
height: number;
|
||||
>height : Symbol(Shape.height, Decl(keyofAndIndexedAccess.ts, 3, 18))
|
||||
|
||||
visible: boolean;
|
||||
>visible : Symbol(Shape.visible, Decl(keyofAndIndexedAccess.ts, 4, 19))
|
||||
}
|
||||
|
||||
class Item {
|
||||
>Item : Symbol(Item, Decl(keyofAndIndexedAccess.ts, 6, 1))
|
||||
|
||||
name: string;
|
||||
>name : Symbol(Item.name, Decl(keyofAndIndexedAccess.ts, 8, 12))
|
||||
|
||||
price: number;
|
||||
>price : Symbol(Item.price, Decl(keyofAndIndexedAccess.ts, 9, 17))
|
||||
}
|
||||
|
||||
class Options {
|
||||
>Options : Symbol(Options, Decl(keyofAndIndexedAccess.ts, 11, 1))
|
||||
|
||||
visible: "yes" | "no";
|
||||
>visible : Symbol(Options.visible, Decl(keyofAndIndexedAccess.ts, 13, 15))
|
||||
}
|
||||
|
||||
type Dictionary<T> = { [x: string]: T };
|
||||
>Dictionary : Symbol(Dictionary, Decl(keyofAndIndexedAccess.ts, 15, 1))
|
||||
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 17, 16))
|
||||
>x : Symbol(x, Decl(keyofAndIndexedAccess.ts, 17, 24))
|
||||
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 17, 16))
|
||||
|
||||
const enum E { A, B, C }
|
||||
>E : Symbol(E, Decl(keyofAndIndexedAccess.ts, 17, 40))
|
||||
>A : Symbol(E.A, Decl(keyofAndIndexedAccess.ts, 19, 14))
|
||||
>B : Symbol(E.B, Decl(keyofAndIndexedAccess.ts, 19, 17))
|
||||
>C : Symbol(E.C, Decl(keyofAndIndexedAccess.ts, 19, 20))
|
||||
|
||||
type K00 = keyof any; // string | number
|
||||
>K00 : Symbol(K00, Decl(keyofAndIndexedAccess.ts, 19, 24))
|
||||
|
||||
type K01 = keyof string; // number | "toString" | "charAt" | ...
|
||||
>K01 : Symbol(K01, Decl(keyofAndIndexedAccess.ts, 21, 21))
|
||||
|
||||
type K02 = keyof number; // "toString" | "toFixed" | "toExponential" | ...
|
||||
>K02 : Symbol(K02, Decl(keyofAndIndexedAccess.ts, 22, 24))
|
||||
|
||||
type K03 = keyof boolean; // "valueOf"
|
||||
>K03 : Symbol(K03, Decl(keyofAndIndexedAccess.ts, 23, 24))
|
||||
|
||||
type K04 = keyof void; // never
|
||||
>K04 : Symbol(K04, Decl(keyofAndIndexedAccess.ts, 24, 25))
|
||||
|
||||
type K05 = keyof undefined; // never
|
||||
>K05 : Symbol(K05, Decl(keyofAndIndexedAccess.ts, 25, 22))
|
||||
|
||||
type K06 = keyof null; // never
|
||||
>K06 : Symbol(K06, Decl(keyofAndIndexedAccess.ts, 26, 27))
|
||||
|
||||
type K07 = keyof never; // never
|
||||
>K07 : Symbol(K07, Decl(keyofAndIndexedAccess.ts, 27, 22))
|
||||
|
||||
type K10 = keyof Shape; // "name" | "width" | "height" | "visible"
|
||||
>K10 : Symbol(K10, Decl(keyofAndIndexedAccess.ts, 28, 23))
|
||||
>Shape : Symbol(Shape, Decl(keyofAndIndexedAccess.ts, 0, 0))
|
||||
|
||||
type K11 = keyof Shape[]; // number | "length" | "toString" | ...
|
||||
>K11 : Symbol(K11, Decl(keyofAndIndexedAccess.ts, 30, 23))
|
||||
>Shape : Symbol(Shape, Decl(keyofAndIndexedAccess.ts, 0, 0))
|
||||
|
||||
type K12 = keyof Dictionary<Shape>; // string | number
|
||||
>K12 : Symbol(K12, Decl(keyofAndIndexedAccess.ts, 31, 25))
|
||||
>Dictionary : Symbol(Dictionary, Decl(keyofAndIndexedAccess.ts, 15, 1))
|
||||
>Shape : Symbol(Shape, Decl(keyofAndIndexedAccess.ts, 0, 0))
|
||||
|
||||
type K13 = keyof {}; // never
|
||||
>K13 : Symbol(K13, Decl(keyofAndIndexedAccess.ts, 32, 35))
|
||||
|
||||
type K14 = keyof Object; // "constructor" | "toString" | ...
|
||||
>K14 : Symbol(K14, Decl(keyofAndIndexedAccess.ts, 33, 20))
|
||||
>Object : Symbol(Object, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
|
||||
|
||||
type K15 = keyof E; // "toString" | "toFixed" | "toExponential" | ...
|
||||
>K15 : Symbol(K15, Decl(keyofAndIndexedAccess.ts, 34, 24))
|
||||
>E : Symbol(E, Decl(keyofAndIndexedAccess.ts, 17, 40))
|
||||
|
||||
type K16 = keyof [string, number]; // number | "0" | "1" | "length" | "toString" | ...
|
||||
>K16 : Symbol(K16, Decl(keyofAndIndexedAccess.ts, 35, 19))
|
||||
|
||||
type K17 = keyof (Shape | Item); // "name"
|
||||
>K17 : Symbol(K17, Decl(keyofAndIndexedAccess.ts, 36, 34))
|
||||
>Shape : Symbol(Shape, Decl(keyofAndIndexedAccess.ts, 0, 0))
|
||||
>Item : Symbol(Item, Decl(keyofAndIndexedAccess.ts, 6, 1))
|
||||
|
||||
type K18 = keyof (Shape & Item); // "name" | "width" | "height" | "visible" | "price"
|
||||
>K18 : Symbol(K18, Decl(keyofAndIndexedAccess.ts, 37, 32))
|
||||
>Shape : Symbol(Shape, Decl(keyofAndIndexedAccess.ts, 0, 0))
|
||||
>Item : Symbol(Item, Decl(keyofAndIndexedAccess.ts, 6, 1))
|
||||
|
||||
type KeyOf<T> = keyof T;
|
||||
>KeyOf : Symbol(KeyOf, Decl(keyofAndIndexedAccess.ts, 38, 32))
|
||||
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 40, 11))
|
||||
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 40, 11))
|
||||
|
||||
type K20 = KeyOf<Shape>; // "name" | "width" | "height" | "visible"
|
||||
>K20 : Symbol(K20, Decl(keyofAndIndexedAccess.ts, 40, 24))
|
||||
>KeyOf : Symbol(KeyOf, Decl(keyofAndIndexedAccess.ts, 38, 32))
|
||||
>Shape : Symbol(Shape, Decl(keyofAndIndexedAccess.ts, 0, 0))
|
||||
|
||||
type K21 = KeyOf<Dictionary<Shape>>; // string | number
|
||||
>K21 : Symbol(K21, Decl(keyofAndIndexedAccess.ts, 42, 24))
|
||||
>KeyOf : Symbol(KeyOf, Decl(keyofAndIndexedAccess.ts, 38, 32))
|
||||
>Dictionary : Symbol(Dictionary, Decl(keyofAndIndexedAccess.ts, 15, 1))
|
||||
>Shape : Symbol(Shape, Decl(keyofAndIndexedAccess.ts, 0, 0))
|
||||
|
||||
type NAME = "name";
|
||||
>NAME : Symbol(NAME, Decl(keyofAndIndexedAccess.ts, 43, 36))
|
||||
|
||||
type WIDTH_OR_HEIGHT = "width" | "height";
|
||||
>WIDTH_OR_HEIGHT : Symbol(WIDTH_OR_HEIGHT, Decl(keyofAndIndexedAccess.ts, 45, 19))
|
||||
|
||||
type Q10 = Shape["name"]; // string
|
||||
>Q10 : Symbol(Q10, Decl(keyofAndIndexedAccess.ts, 46, 42))
|
||||
>Shape : Symbol(Shape, Decl(keyofAndIndexedAccess.ts, 0, 0))
|
||||
|
||||
type Q11 = Shape["width" | "height"]; // number
|
||||
>Q11 : Symbol(Q11, Decl(keyofAndIndexedAccess.ts, 48, 25))
|
||||
>Shape : Symbol(Shape, Decl(keyofAndIndexedAccess.ts, 0, 0))
|
||||
|
||||
type Q12 = Shape["name" | "visible"]; // string | boolean
|
||||
>Q12 : Symbol(Q12, Decl(keyofAndIndexedAccess.ts, 49, 37))
|
||||
>Shape : Symbol(Shape, Decl(keyofAndIndexedAccess.ts, 0, 0))
|
||||
|
||||
type Q20 = Shape[NAME]; // string
|
||||
>Q20 : Symbol(Q20, Decl(keyofAndIndexedAccess.ts, 50, 37))
|
||||
>Shape : Symbol(Shape, Decl(keyofAndIndexedAccess.ts, 0, 0))
|
||||
>NAME : Symbol(NAME, Decl(keyofAndIndexedAccess.ts, 43, 36))
|
||||
|
||||
type Q21 = Shape[WIDTH_OR_HEIGHT]; // number
|
||||
>Q21 : Symbol(Q21, Decl(keyofAndIndexedAccess.ts, 52, 23))
|
||||
>Shape : Symbol(Shape, Decl(keyofAndIndexedAccess.ts, 0, 0))
|
||||
>WIDTH_OR_HEIGHT : Symbol(WIDTH_OR_HEIGHT, Decl(keyofAndIndexedAccess.ts, 45, 19))
|
||||
|
||||
type Q30 = [string, number][0]; // string
|
||||
>Q30 : Symbol(Q30, Decl(keyofAndIndexedAccess.ts, 53, 34))
|
||||
|
||||
type Q31 = [string, number][1]; // number
|
||||
>Q31 : Symbol(Q31, Decl(keyofAndIndexedAccess.ts, 55, 31))
|
||||
|
||||
type Q32 = [string, number][2]; // string | number
|
||||
>Q32 : Symbol(Q32, Decl(keyofAndIndexedAccess.ts, 56, 31))
|
||||
|
||||
type Q33 = [string, number][E.A]; // string
|
||||
>Q33 : Symbol(Q33, Decl(keyofAndIndexedAccess.ts, 57, 31))
|
||||
>E : Symbol(E, Decl(keyofAndIndexedAccess.ts, 17, 40))
|
||||
>A : Symbol(E.A, Decl(keyofAndIndexedAccess.ts, 19, 14))
|
||||
|
||||
type Q34 = [string, number][E.B]; // number
|
||||
>Q34 : Symbol(Q34, Decl(keyofAndIndexedAccess.ts, 58, 33))
|
||||
>E : Symbol(E, Decl(keyofAndIndexedAccess.ts, 17, 40))
|
||||
>B : Symbol(E.B, Decl(keyofAndIndexedAccess.ts, 19, 17))
|
||||
|
||||
type Q35 = [string, number][E.C]; // string | number
|
||||
>Q35 : Symbol(Q35, Decl(keyofAndIndexedAccess.ts, 59, 33))
|
||||
>E : Symbol(E, Decl(keyofAndIndexedAccess.ts, 17, 40))
|
||||
>C : Symbol(E.C, Decl(keyofAndIndexedAccess.ts, 19, 20))
|
||||
|
||||
type Q36 = [string, number]["0"]; // string
|
||||
>Q36 : Symbol(Q36, Decl(keyofAndIndexedAccess.ts, 60, 33))
|
||||
|
||||
type Q37 = [string, number]["1"]; // string
|
||||
>Q37 : Symbol(Q37, Decl(keyofAndIndexedAccess.ts, 61, 33))
|
||||
|
||||
type Q40 = (Shape | Options)["visible"]; // boolean | "yes" | "no"
|
||||
>Q40 : Symbol(Q40, Decl(keyofAndIndexedAccess.ts, 62, 33))
|
||||
>Shape : Symbol(Shape, Decl(keyofAndIndexedAccess.ts, 0, 0))
|
||||
>Options : Symbol(Options, Decl(keyofAndIndexedAccess.ts, 11, 1))
|
||||
|
||||
type Q41 = (Shape & Options)["visible"]; // true & "yes" | true & "no" | false & "yes" | false & "no"
|
||||
>Q41 : Symbol(Q41, Decl(keyofAndIndexedAccess.ts, 64, 40))
|
||||
>Shape : Symbol(Shape, Decl(keyofAndIndexedAccess.ts, 0, 0))
|
||||
>Options : Symbol(Options, Decl(keyofAndIndexedAccess.ts, 11, 1))
|
||||
|
||||
type Q50 = Dictionary<Shape>["howdy"]; // Shape
|
||||
>Q50 : Symbol(Q50, Decl(keyofAndIndexedAccess.ts, 65, 40))
|
||||
>Dictionary : Symbol(Dictionary, Decl(keyofAndIndexedAccess.ts, 15, 1))
|
||||
>Shape : Symbol(Shape, Decl(keyofAndIndexedAccess.ts, 0, 0))
|
||||
|
||||
type Q51 = Dictionary<Shape>[123]; // Shape
|
||||
>Q51 : Symbol(Q51, Decl(keyofAndIndexedAccess.ts, 67, 38))
|
||||
>Dictionary : Symbol(Dictionary, Decl(keyofAndIndexedAccess.ts, 15, 1))
|
||||
>Shape : Symbol(Shape, Decl(keyofAndIndexedAccess.ts, 0, 0))
|
||||
|
||||
type Q52 = Dictionary<Shape>[E.B]; // Shape
|
||||
>Q52 : Symbol(Q52, Decl(keyofAndIndexedAccess.ts, 68, 34))
|
||||
>Dictionary : Symbol(Dictionary, Decl(keyofAndIndexedAccess.ts, 15, 1))
|
||||
>Shape : Symbol(Shape, Decl(keyofAndIndexedAccess.ts, 0, 0))
|
||||
>E : Symbol(E, Decl(keyofAndIndexedAccess.ts, 17, 40))
|
||||
>B : Symbol(E.B, Decl(keyofAndIndexedAccess.ts, 19, 17))
|
||||
|
||||
declare let cond: boolean;
|
||||
>cond : Symbol(cond, Decl(keyofAndIndexedAccess.ts, 71, 11))
|
||||
|
||||
function getProperty<T, K extends keyof T>(obj: T, key: K) {
|
||||
>getProperty : Symbol(getProperty, Decl(keyofAndIndexedAccess.ts, 71, 26))
|
||||
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 73, 21))
|
||||
>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 73, 23))
|
||||
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 73, 21))
|
||||
>obj : Symbol(obj, Decl(keyofAndIndexedAccess.ts, 73, 43))
|
||||
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 73, 21))
|
||||
>key : Symbol(key, Decl(keyofAndIndexedAccess.ts, 73, 50))
|
||||
>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 73, 23))
|
||||
|
||||
return obj[key];
|
||||
>obj : Symbol(obj, Decl(keyofAndIndexedAccess.ts, 73, 43))
|
||||
>key : Symbol(key, Decl(keyofAndIndexedAccess.ts, 73, 50))
|
||||
}
|
||||
|
||||
function setProperty<T, K extends keyof T>(obj: T, key: K, value: T[K]) {
|
||||
>setProperty : Symbol(setProperty, Decl(keyofAndIndexedAccess.ts, 75, 1))
|
||||
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 77, 21))
|
||||
>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 77, 23))
|
||||
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 77, 21))
|
||||
>obj : Symbol(obj, Decl(keyofAndIndexedAccess.ts, 77, 43))
|
||||
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 77, 21))
|
||||
>key : Symbol(key, Decl(keyofAndIndexedAccess.ts, 77, 50))
|
||||
>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 77, 23))
|
||||
>value : Symbol(value, Decl(keyofAndIndexedAccess.ts, 77, 58))
|
||||
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 77, 21))
|
||||
>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 77, 23))
|
||||
|
||||
obj[key] = value;
|
||||
>obj : Symbol(obj, Decl(keyofAndIndexedAccess.ts, 77, 43))
|
||||
>key : Symbol(key, Decl(keyofAndIndexedAccess.ts, 77, 50))
|
||||
>value : Symbol(value, Decl(keyofAndIndexedAccess.ts, 77, 58))
|
||||
}
|
||||
|
||||
function f10(shape: Shape) {
|
||||
>f10 : Symbol(f10, Decl(keyofAndIndexedAccess.ts, 79, 1))
|
||||
>shape : Symbol(shape, Decl(keyofAndIndexedAccess.ts, 81, 13))
|
||||
>Shape : Symbol(Shape, Decl(keyofAndIndexedAccess.ts, 0, 0))
|
||||
|
||||
let name = getProperty(shape, "name"); // string
|
||||
>name : Symbol(name, Decl(keyofAndIndexedAccess.ts, 82, 7))
|
||||
>getProperty : Symbol(getProperty, Decl(keyofAndIndexedAccess.ts, 71, 26))
|
||||
>shape : Symbol(shape, Decl(keyofAndIndexedAccess.ts, 81, 13))
|
||||
|
||||
let widthOrHeight = getProperty(shape, cond ? "width" : "height"); // number
|
||||
>widthOrHeight : Symbol(widthOrHeight, Decl(keyofAndIndexedAccess.ts, 83, 7))
|
||||
>getProperty : Symbol(getProperty, Decl(keyofAndIndexedAccess.ts, 71, 26))
|
||||
>shape : Symbol(shape, Decl(keyofAndIndexedAccess.ts, 81, 13))
|
||||
>cond : Symbol(cond, Decl(keyofAndIndexedAccess.ts, 71, 11))
|
||||
|
||||
let nameOrVisible = getProperty(shape, cond ? "name" : "visible"); // string | boolean
|
||||
>nameOrVisible : Symbol(nameOrVisible, Decl(keyofAndIndexedAccess.ts, 84, 7))
|
||||
>getProperty : Symbol(getProperty, Decl(keyofAndIndexedAccess.ts, 71, 26))
|
||||
>shape : Symbol(shape, Decl(keyofAndIndexedAccess.ts, 81, 13))
|
||||
>cond : Symbol(cond, Decl(keyofAndIndexedAccess.ts, 71, 11))
|
||||
|
||||
setProperty(shape, "name", "rectangle");
|
||||
>setProperty : Symbol(setProperty, Decl(keyofAndIndexedAccess.ts, 75, 1))
|
||||
>shape : Symbol(shape, Decl(keyofAndIndexedAccess.ts, 81, 13))
|
||||
|
||||
setProperty(shape, cond ? "width" : "height", 10);
|
||||
>setProperty : Symbol(setProperty, Decl(keyofAndIndexedAccess.ts, 75, 1))
|
||||
>shape : Symbol(shape, Decl(keyofAndIndexedAccess.ts, 81, 13))
|
||||
>cond : Symbol(cond, Decl(keyofAndIndexedAccess.ts, 71, 11))
|
||||
|
||||
setProperty(shape, cond ? "name" : "visible", true); // Technically not safe
|
||||
>setProperty : Symbol(setProperty, Decl(keyofAndIndexedAccess.ts, 75, 1))
|
||||
>shape : Symbol(shape, Decl(keyofAndIndexedAccess.ts, 81, 13))
|
||||
>cond : Symbol(cond, Decl(keyofAndIndexedAccess.ts, 71, 11))
|
||||
}
|
||||
|
||||
function f11(a: Shape[]) {
|
||||
>f11 : Symbol(f11, Decl(keyofAndIndexedAccess.ts, 88, 1))
|
||||
>a : Symbol(a, Decl(keyofAndIndexedAccess.ts, 90, 13))
|
||||
>Shape : Symbol(Shape, Decl(keyofAndIndexedAccess.ts, 0, 0))
|
||||
|
||||
let len = getProperty(a, "length"); // number
|
||||
>len : Symbol(len, Decl(keyofAndIndexedAccess.ts, 91, 7))
|
||||
>getProperty : Symbol(getProperty, Decl(keyofAndIndexedAccess.ts, 71, 26))
|
||||
>a : Symbol(a, Decl(keyofAndIndexedAccess.ts, 90, 13))
|
||||
|
||||
let shape = getProperty(a, 1000); // Shape
|
||||
>shape : Symbol(shape, Decl(keyofAndIndexedAccess.ts, 92, 7))
|
||||
>getProperty : Symbol(getProperty, Decl(keyofAndIndexedAccess.ts, 71, 26))
|
||||
>a : Symbol(a, Decl(keyofAndIndexedAccess.ts, 90, 13))
|
||||
|
||||
setProperty(a, 1000, getProperty(a, 1001));
|
||||
>setProperty : Symbol(setProperty, Decl(keyofAndIndexedAccess.ts, 75, 1))
|
||||
>a : Symbol(a, Decl(keyofAndIndexedAccess.ts, 90, 13))
|
||||
>getProperty : Symbol(getProperty, Decl(keyofAndIndexedAccess.ts, 71, 26))
|
||||
>a : Symbol(a, Decl(keyofAndIndexedAccess.ts, 90, 13))
|
||||
}
|
||||
|
||||
function f12(t: [Shape, boolean]) {
|
||||
>f12 : Symbol(f12, Decl(keyofAndIndexedAccess.ts, 94, 1))
|
||||
>t : Symbol(t, Decl(keyofAndIndexedAccess.ts, 96, 13))
|
||||
>Shape : Symbol(Shape, Decl(keyofAndIndexedAccess.ts, 0, 0))
|
||||
|
||||
let len = getProperty(t, "length");
|
||||
>len : Symbol(len, Decl(keyofAndIndexedAccess.ts, 97, 7))
|
||||
>getProperty : Symbol(getProperty, Decl(keyofAndIndexedAccess.ts, 71, 26))
|
||||
>t : Symbol(t, Decl(keyofAndIndexedAccess.ts, 96, 13))
|
||||
|
||||
let s1 = getProperty(t, 0); // Shape
|
||||
>s1 : Symbol(s1, Decl(keyofAndIndexedAccess.ts, 98, 7))
|
||||
>getProperty : Symbol(getProperty, Decl(keyofAndIndexedAccess.ts, 71, 26))
|
||||
>t : Symbol(t, Decl(keyofAndIndexedAccess.ts, 96, 13))
|
||||
|
||||
let s2 = getProperty(t, "0"); // Shape
|
||||
>s2 : Symbol(s2, Decl(keyofAndIndexedAccess.ts, 99, 7))
|
||||
>getProperty : Symbol(getProperty, Decl(keyofAndIndexedAccess.ts, 71, 26))
|
||||
>t : Symbol(t, Decl(keyofAndIndexedAccess.ts, 96, 13))
|
||||
|
||||
let b1 = getProperty(t, 1); // boolean
|
||||
>b1 : Symbol(b1, Decl(keyofAndIndexedAccess.ts, 100, 7))
|
||||
>getProperty : Symbol(getProperty, Decl(keyofAndIndexedAccess.ts, 71, 26))
|
||||
>t : Symbol(t, Decl(keyofAndIndexedAccess.ts, 96, 13))
|
||||
|
||||
let b2 = getProperty(t, "1"); // boolean
|
||||
>b2 : Symbol(b2, Decl(keyofAndIndexedAccess.ts, 101, 7))
|
||||
>getProperty : Symbol(getProperty, Decl(keyofAndIndexedAccess.ts, 71, 26))
|
||||
>t : Symbol(t, Decl(keyofAndIndexedAccess.ts, 96, 13))
|
||||
|
||||
let x1 = getProperty(t, 2); // Shape | boolean
|
||||
>x1 : Symbol(x1, Decl(keyofAndIndexedAccess.ts, 102, 7))
|
||||
>getProperty : Symbol(getProperty, Decl(keyofAndIndexedAccess.ts, 71, 26))
|
||||
>t : Symbol(t, Decl(keyofAndIndexedAccess.ts, 96, 13))
|
||||
}
|
||||
|
||||
function f13(foo: any, bar: any) {
|
||||
>f13 : Symbol(f13, Decl(keyofAndIndexedAccess.ts, 103, 1))
|
||||
>foo : Symbol(foo, Decl(keyofAndIndexedAccess.ts, 105, 13))
|
||||
>bar : Symbol(bar, Decl(keyofAndIndexedAccess.ts, 105, 22))
|
||||
|
||||
let x = getProperty(foo, "x"); // any
|
||||
>x : Symbol(x, Decl(keyofAndIndexedAccess.ts, 106, 7))
|
||||
>getProperty : Symbol(getProperty, Decl(keyofAndIndexedAccess.ts, 71, 26))
|
||||
>foo : Symbol(foo, Decl(keyofAndIndexedAccess.ts, 105, 13))
|
||||
|
||||
let y = getProperty(foo, 100); // any
|
||||
>y : Symbol(y, Decl(keyofAndIndexedAccess.ts, 107, 7))
|
||||
>getProperty : Symbol(getProperty, Decl(keyofAndIndexedAccess.ts, 71, 26))
|
||||
>foo : Symbol(foo, Decl(keyofAndIndexedAccess.ts, 105, 13))
|
||||
|
||||
let z = getProperty(foo, bar); // any
|
||||
>z : Symbol(z, Decl(keyofAndIndexedAccess.ts, 108, 7))
|
||||
>getProperty : Symbol(getProperty, Decl(keyofAndIndexedAccess.ts, 71, 26))
|
||||
>foo : Symbol(foo, Decl(keyofAndIndexedAccess.ts, 105, 13))
|
||||
>bar : Symbol(bar, Decl(keyofAndIndexedAccess.ts, 105, 22))
|
||||
}
|
||||
|
||||
class Component<PropType> {
|
||||
>Component : Symbol(Component, Decl(keyofAndIndexedAccess.ts, 109, 1))
|
||||
>PropType : Symbol(PropType, Decl(keyofAndIndexedAccess.ts, 111, 16))
|
||||
|
||||
props: PropType;
|
||||
>props : Symbol(Component.props, Decl(keyofAndIndexedAccess.ts, 111, 27))
|
||||
>PropType : Symbol(PropType, Decl(keyofAndIndexedAccess.ts, 111, 16))
|
||||
|
||||
getProperty<K extends keyof PropType>(key: K) {
|
||||
>getProperty : Symbol(Component.getProperty, Decl(keyofAndIndexedAccess.ts, 112, 20))
|
||||
>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 113, 16))
|
||||
>PropType : Symbol(PropType, Decl(keyofAndIndexedAccess.ts, 111, 16))
|
||||
>key : Symbol(key, Decl(keyofAndIndexedAccess.ts, 113, 42))
|
||||
>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 113, 16))
|
||||
|
||||
return this.props[key];
|
||||
>this.props : Symbol(Component.props, Decl(keyofAndIndexedAccess.ts, 111, 27))
|
||||
>this : Symbol(Component, Decl(keyofAndIndexedAccess.ts, 109, 1))
|
||||
>props : Symbol(Component.props, Decl(keyofAndIndexedAccess.ts, 111, 27))
|
||||
>key : Symbol(key, Decl(keyofAndIndexedAccess.ts, 113, 42))
|
||||
}
|
||||
setProperty<K extends keyof PropType>(key: K, value: PropType[K]) {
|
||||
>setProperty : Symbol(Component.setProperty, Decl(keyofAndIndexedAccess.ts, 115, 5))
|
||||
>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 116, 16))
|
||||
>PropType : Symbol(PropType, Decl(keyofAndIndexedAccess.ts, 111, 16))
|
||||
>key : Symbol(key, Decl(keyofAndIndexedAccess.ts, 116, 42))
|
||||
>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 116, 16))
|
||||
>value : Symbol(value, Decl(keyofAndIndexedAccess.ts, 116, 49))
|
||||
>PropType : Symbol(PropType, Decl(keyofAndIndexedAccess.ts, 111, 16))
|
||||
>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 116, 16))
|
||||
|
||||
this.props[key] = value;
|
||||
>this.props : Symbol(Component.props, Decl(keyofAndIndexedAccess.ts, 111, 27))
|
||||
>this : Symbol(Component, Decl(keyofAndIndexedAccess.ts, 109, 1))
|
||||
>props : Symbol(Component.props, Decl(keyofAndIndexedAccess.ts, 111, 27))
|
||||
>key : Symbol(key, Decl(keyofAndIndexedAccess.ts, 116, 42))
|
||||
>value : Symbol(value, Decl(keyofAndIndexedAccess.ts, 116, 49))
|
||||
}
|
||||
}
|
||||
|
||||
function f20(component: Component<Shape>) {
|
||||
>f20 : Symbol(f20, Decl(keyofAndIndexedAccess.ts, 119, 1))
|
||||
>component : Symbol(component, Decl(keyofAndIndexedAccess.ts, 121, 13))
|
||||
>Component : Symbol(Component, Decl(keyofAndIndexedAccess.ts, 109, 1))
|
||||
>Shape : Symbol(Shape, Decl(keyofAndIndexedAccess.ts, 0, 0))
|
||||
|
||||
let name = component.getProperty("name"); // string
|
||||
>name : Symbol(name, Decl(keyofAndIndexedAccess.ts, 122, 7))
|
||||
>component.getProperty : Symbol(Component.getProperty, Decl(keyofAndIndexedAccess.ts, 112, 20))
|
||||
>component : Symbol(component, Decl(keyofAndIndexedAccess.ts, 121, 13))
|
||||
>getProperty : Symbol(Component.getProperty, Decl(keyofAndIndexedAccess.ts, 112, 20))
|
||||
|
||||
let widthOrHeight = component.getProperty(cond ? "width" : "height"); // number
|
||||
>widthOrHeight : Symbol(widthOrHeight, Decl(keyofAndIndexedAccess.ts, 123, 7))
|
||||
>component.getProperty : Symbol(Component.getProperty, Decl(keyofAndIndexedAccess.ts, 112, 20))
|
||||
>component : Symbol(component, Decl(keyofAndIndexedAccess.ts, 121, 13))
|
||||
>getProperty : Symbol(Component.getProperty, Decl(keyofAndIndexedAccess.ts, 112, 20))
|
||||
>cond : Symbol(cond, Decl(keyofAndIndexedAccess.ts, 71, 11))
|
||||
|
||||
let nameOrVisible = component.getProperty(cond ? "name" : "visible"); // string | boolean
|
||||
>nameOrVisible : Symbol(nameOrVisible, Decl(keyofAndIndexedAccess.ts, 124, 7))
|
||||
>component.getProperty : Symbol(Component.getProperty, Decl(keyofAndIndexedAccess.ts, 112, 20))
|
||||
>component : Symbol(component, Decl(keyofAndIndexedAccess.ts, 121, 13))
|
||||
>getProperty : Symbol(Component.getProperty, Decl(keyofAndIndexedAccess.ts, 112, 20))
|
||||
>cond : Symbol(cond, Decl(keyofAndIndexedAccess.ts, 71, 11))
|
||||
|
||||
component.setProperty("name", "rectangle");
|
||||
>component.setProperty : Symbol(Component.setProperty, Decl(keyofAndIndexedAccess.ts, 115, 5))
|
||||
>component : Symbol(component, Decl(keyofAndIndexedAccess.ts, 121, 13))
|
||||
>setProperty : Symbol(Component.setProperty, Decl(keyofAndIndexedAccess.ts, 115, 5))
|
||||
|
||||
component.setProperty(cond ? "width" : "height", 10)
|
||||
>component.setProperty : Symbol(Component.setProperty, Decl(keyofAndIndexedAccess.ts, 115, 5))
|
||||
>component : Symbol(component, Decl(keyofAndIndexedAccess.ts, 121, 13))
|
||||
>setProperty : Symbol(Component.setProperty, Decl(keyofAndIndexedAccess.ts, 115, 5))
|
||||
>cond : Symbol(cond, Decl(keyofAndIndexedAccess.ts, 71, 11))
|
||||
|
||||
component.setProperty(cond ? "name" : "visible", true); // Technically not safe
|
||||
>component.setProperty : Symbol(Component.setProperty, Decl(keyofAndIndexedAccess.ts, 115, 5))
|
||||
>component : Symbol(component, Decl(keyofAndIndexedAccess.ts, 121, 13))
|
||||
>setProperty : Symbol(Component.setProperty, Decl(keyofAndIndexedAccess.ts, 115, 5))
|
||||
>cond : Symbol(cond, Decl(keyofAndIndexedAccess.ts, 71, 11))
|
||||
}
|
||||
|
||||
function pluck<T, K extends keyof T>(array: T[], key: K) {
|
||||
>pluck : Symbol(pluck, Decl(keyofAndIndexedAccess.ts, 128, 1))
|
||||
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 130, 15))
|
||||
>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 130, 17))
|
||||
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 130, 15))
|
||||
>array : Symbol(array, Decl(keyofAndIndexedAccess.ts, 130, 37))
|
||||
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 130, 15))
|
||||
>key : Symbol(key, Decl(keyofAndIndexedAccess.ts, 130, 48))
|
||||
>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 130, 17))
|
||||
|
||||
return array.map(x => x[key]);
|
||||
>array.map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
|
||||
>array : Symbol(array, Decl(keyofAndIndexedAccess.ts, 130, 37))
|
||||
>map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
|
||||
>x : Symbol(x, Decl(keyofAndIndexedAccess.ts, 131, 21))
|
||||
>x : Symbol(x, Decl(keyofAndIndexedAccess.ts, 131, 21))
|
||||
>key : Symbol(key, Decl(keyofAndIndexedAccess.ts, 130, 48))
|
||||
}
|
||||
|
||||
function f30(shapes: Shape[]) {
|
||||
>f30 : Symbol(f30, Decl(keyofAndIndexedAccess.ts, 132, 1))
|
||||
>shapes : Symbol(shapes, Decl(keyofAndIndexedAccess.ts, 134, 13))
|
||||
>Shape : Symbol(Shape, Decl(keyofAndIndexedAccess.ts, 0, 0))
|
||||
|
||||
let names = pluck(shapes, "name"); // string[]
|
||||
>names : Symbol(names, Decl(keyofAndIndexedAccess.ts, 135, 7))
|
||||
>pluck : Symbol(pluck, Decl(keyofAndIndexedAccess.ts, 128, 1))
|
||||
>shapes : Symbol(shapes, Decl(keyofAndIndexedAccess.ts, 134, 13))
|
||||
|
||||
let widths = pluck(shapes, "width"); // number[]
|
||||
>widths : Symbol(widths, Decl(keyofAndIndexedAccess.ts, 136, 7))
|
||||
>pluck : Symbol(pluck, Decl(keyofAndIndexedAccess.ts, 128, 1))
|
||||
>shapes : Symbol(shapes, Decl(keyofAndIndexedAccess.ts, 134, 13))
|
||||
|
||||
let nameOrVisibles = pluck(shapes, cond ? "name" : "visible"); // (string | boolean)[]
|
||||
>nameOrVisibles : Symbol(nameOrVisibles, Decl(keyofAndIndexedAccess.ts, 137, 7))
|
||||
>pluck : Symbol(pluck, Decl(keyofAndIndexedAccess.ts, 128, 1))
|
||||
>shapes : Symbol(shapes, Decl(keyofAndIndexedAccess.ts, 134, 13))
|
||||
>cond : Symbol(cond, Decl(keyofAndIndexedAccess.ts, 71, 11))
|
||||
}
|
||||
|
||||
function f31<K extends keyof Shape>(key: K) {
|
||||
>f31 : Symbol(f31, Decl(keyofAndIndexedAccess.ts, 138, 1))
|
||||
>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 140, 13))
|
||||
>Shape : Symbol(Shape, Decl(keyofAndIndexedAccess.ts, 0, 0))
|
||||
>key : Symbol(key, Decl(keyofAndIndexedAccess.ts, 140, 36))
|
||||
>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 140, 13))
|
||||
|
||||
const shape: Shape = { name: "foo", width: 5, height: 10, visible: true };
|
||||
>shape : Symbol(shape, Decl(keyofAndIndexedAccess.ts, 141, 9))
|
||||
>Shape : Symbol(Shape, Decl(keyofAndIndexedAccess.ts, 0, 0))
|
||||
>name : Symbol(name, Decl(keyofAndIndexedAccess.ts, 141, 26))
|
||||
>width : Symbol(width, Decl(keyofAndIndexedAccess.ts, 141, 39))
|
||||
>height : Symbol(height, Decl(keyofAndIndexedAccess.ts, 141, 49))
|
||||
>visible : Symbol(visible, Decl(keyofAndIndexedAccess.ts, 141, 61))
|
||||
|
||||
return shape[key]; // Shape[K]
|
||||
>shape : Symbol(shape, Decl(keyofAndIndexedAccess.ts, 141, 9))
|
||||
>key : Symbol(key, Decl(keyofAndIndexedAccess.ts, 140, 36))
|
||||
}
|
||||
|
||||
function f32<K extends "width" | "height">(key: K) {
|
||||
>f32 : Symbol(f32, Decl(keyofAndIndexedAccess.ts, 143, 1))
|
||||
>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 145, 13))
|
||||
>key : Symbol(key, Decl(keyofAndIndexedAccess.ts, 145, 43))
|
||||
>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 145, 13))
|
||||
|
||||
const shape: Shape = { name: "foo", width: 5, height: 10, visible: true };
|
||||
>shape : Symbol(shape, Decl(keyofAndIndexedAccess.ts, 146, 9))
|
||||
>Shape : Symbol(Shape, Decl(keyofAndIndexedAccess.ts, 0, 0))
|
||||
>name : Symbol(name, Decl(keyofAndIndexedAccess.ts, 146, 26))
|
||||
>width : Symbol(width, Decl(keyofAndIndexedAccess.ts, 146, 39))
|
||||
>height : Symbol(height, Decl(keyofAndIndexedAccess.ts, 146, 49))
|
||||
>visible : Symbol(visible, Decl(keyofAndIndexedAccess.ts, 146, 61))
|
||||
|
||||
return shape[key]; // Shape[K]
|
||||
>shape : Symbol(shape, Decl(keyofAndIndexedAccess.ts, 146, 9))
|
||||
>key : Symbol(key, Decl(keyofAndIndexedAccess.ts, 145, 43))
|
||||
}
|
||||
|
||||
class C {
|
||||
>C : Symbol(C, Decl(keyofAndIndexedAccess.ts, 148, 1))
|
||||
|
||||
public x: string;
|
||||
>x : Symbol(C.x, Decl(keyofAndIndexedAccess.ts, 150, 9))
|
||||
|
||||
protected y: string;
|
||||
>y : Symbol(C.y, Decl(keyofAndIndexedAccess.ts, 151, 21))
|
||||
|
||||
private z: string;
|
||||
>z : Symbol(C.z, Decl(keyofAndIndexedAccess.ts, 152, 24))
|
||||
}
|
||||
|
||||
// Indexed access expressions have always permitted access to private and protected members.
|
||||
// For consistency we also permit such access in indexed access types.
|
||||
function f40(c: C) {
|
||||
>f40 : Symbol(f40, Decl(keyofAndIndexedAccess.ts, 154, 1))
|
||||
>c : Symbol(c, Decl(keyofAndIndexedAccess.ts, 158, 13))
|
||||
>C : Symbol(C, Decl(keyofAndIndexedAccess.ts, 148, 1))
|
||||
|
||||
type X = C["x"];
|
||||
>X : Symbol(X, Decl(keyofAndIndexedAccess.ts, 158, 20))
|
||||
>C : Symbol(C, Decl(keyofAndIndexedAccess.ts, 148, 1))
|
||||
|
||||
type Y = C["y"];
|
||||
>Y : Symbol(Y, Decl(keyofAndIndexedAccess.ts, 159, 20))
|
||||
>C : Symbol(C, Decl(keyofAndIndexedAccess.ts, 148, 1))
|
||||
|
||||
type Z = C["z"];
|
||||
>Z : Symbol(Z, Decl(keyofAndIndexedAccess.ts, 160, 20))
|
||||
>C : Symbol(C, Decl(keyofAndIndexedAccess.ts, 148, 1))
|
||||
|
||||
let x: X = c["x"];
|
||||
>x : Symbol(x, Decl(keyofAndIndexedAccess.ts, 162, 7))
|
||||
>X : Symbol(X, Decl(keyofAndIndexedAccess.ts, 158, 20))
|
||||
>c : Symbol(c, Decl(keyofAndIndexedAccess.ts, 158, 13))
|
||||
>"x" : Symbol(C.x, Decl(keyofAndIndexedAccess.ts, 150, 9))
|
||||
|
||||
let y: Y = c["y"];
|
||||
>y : Symbol(y, Decl(keyofAndIndexedAccess.ts, 163, 7))
|
||||
>Y : Symbol(Y, Decl(keyofAndIndexedAccess.ts, 159, 20))
|
||||
>c : Symbol(c, Decl(keyofAndIndexedAccess.ts, 158, 13))
|
||||
>"y" : Symbol(C.y, Decl(keyofAndIndexedAccess.ts, 151, 21))
|
||||
|
||||
let z: Z = c["z"];
|
||||
>z : Symbol(z, Decl(keyofAndIndexedAccess.ts, 164, 7))
|
||||
>Z : Symbol(Z, Decl(keyofAndIndexedAccess.ts, 160, 20))
|
||||
>c : Symbol(c, Decl(keyofAndIndexedAccess.ts, 158, 13))
|
||||
>"z" : Symbol(C.z, Decl(keyofAndIndexedAccess.ts, 152, 24))
|
||||
}
|
||||
@@ -0,0 +1,681 @@
|
||||
=== tests/cases/conformance/types/keyof/keyofAndIndexedAccess.ts ===
|
||||
|
||||
class Shape {
|
||||
>Shape : Shape
|
||||
|
||||
name: string;
|
||||
>name : string
|
||||
|
||||
width: number;
|
||||
>width : number
|
||||
|
||||
height: number;
|
||||
>height : number
|
||||
|
||||
visible: boolean;
|
||||
>visible : boolean
|
||||
}
|
||||
|
||||
class Item {
|
||||
>Item : Item
|
||||
|
||||
name: string;
|
||||
>name : string
|
||||
|
||||
price: number;
|
||||
>price : number
|
||||
}
|
||||
|
||||
class Options {
|
||||
>Options : Options
|
||||
|
||||
visible: "yes" | "no";
|
||||
>visible : "yes" | "no"
|
||||
}
|
||||
|
||||
type Dictionary<T> = { [x: string]: T };
|
||||
>Dictionary : { [x: string]: T; }
|
||||
>T : T
|
||||
>x : string
|
||||
>T : T
|
||||
|
||||
const enum E { A, B, C }
|
||||
>E : E
|
||||
>A : E.A
|
||||
>B : E.B
|
||||
>C : E.C
|
||||
|
||||
type K00 = keyof any; // string | number
|
||||
>K00 : string | number
|
||||
|
||||
type K01 = keyof string; // number | "toString" | "charAt" | ...
|
||||
>K01 : number | "length" | "toString" | "concat" | "slice" | "indexOf" | "lastIndexOf" | "charAt" | "charCodeAt" | "localeCompare" | "match" | "replace" | "search" | "split" | "substring" | "toLowerCase" | "toLocaleLowerCase" | "toUpperCase" | "toLocaleUpperCase" | "trim" | "substr" | "valueOf"
|
||||
|
||||
type K02 = keyof number; // "toString" | "toFixed" | "toExponential" | ...
|
||||
>K02 : "toString" | "toLocaleString" | "valueOf" | "toFixed" | "toExponential" | "toPrecision"
|
||||
|
||||
type K03 = keyof boolean; // "valueOf"
|
||||
>K03 : "valueOf"
|
||||
|
||||
type K04 = keyof void; // never
|
||||
>K04 : never
|
||||
|
||||
type K05 = keyof undefined; // never
|
||||
>K05 : never
|
||||
|
||||
type K06 = keyof null; // never
|
||||
>K06 : never
|
||||
>null : null
|
||||
|
||||
type K07 = keyof never; // never
|
||||
>K07 : never
|
||||
|
||||
type K10 = keyof Shape; // "name" | "width" | "height" | "visible"
|
||||
>K10 : "name" | "width" | "height" | "visible"
|
||||
>Shape : Shape
|
||||
|
||||
type K11 = keyof Shape[]; // number | "length" | "toString" | ...
|
||||
>K11 : number | "length" | "toString" | "toLocaleString" | "push" | "pop" | "concat" | "join" | "reverse" | "shift" | "slice" | "sort" | "splice" | "unshift" | "indexOf" | "lastIndexOf" | "every" | "some" | "forEach" | "map" | "filter" | "reduce" | "reduceRight"
|
||||
>Shape : Shape
|
||||
|
||||
type K12 = keyof Dictionary<Shape>; // string | number
|
||||
>K12 : string | number
|
||||
>Dictionary : { [x: string]: T; }
|
||||
>Shape : Shape
|
||||
|
||||
type K13 = keyof {}; // never
|
||||
>K13 : never
|
||||
|
||||
type K14 = keyof Object; // "constructor" | "toString" | ...
|
||||
>K14 : "toString" | "toLocaleString" | "valueOf" | "constructor" | "hasOwnProperty" | "isPrototypeOf" | "propertyIsEnumerable"
|
||||
>Object : Object
|
||||
|
||||
type K15 = keyof E; // "toString" | "toFixed" | "toExponential" | ...
|
||||
>K15 : "toString" | "toLocaleString" | "valueOf" | "toFixed" | "toExponential" | "toPrecision"
|
||||
>E : E
|
||||
|
||||
type K16 = keyof [string, number]; // number | "0" | "1" | "length" | "toString" | ...
|
||||
>K16 : number | "0" | "1" | "length" | "toString" | "toLocaleString" | "push" | "pop" | "concat" | "join" | "reverse" | "shift" | "slice" | "sort" | "splice" | "unshift" | "indexOf" | "lastIndexOf" | "every" | "some" | "forEach" | "map" | "filter" | "reduce" | "reduceRight"
|
||||
|
||||
type K17 = keyof (Shape | Item); // "name"
|
||||
>K17 : "name"
|
||||
>Shape : Shape
|
||||
>Item : Item
|
||||
|
||||
type K18 = keyof (Shape & Item); // "name" | "width" | "height" | "visible" | "price"
|
||||
>K18 : "name" | "width" | "height" | "visible" | "price"
|
||||
>Shape : Shape
|
||||
>Item : Item
|
||||
|
||||
type KeyOf<T> = keyof T;
|
||||
>KeyOf : keyof T
|
||||
>T : T
|
||||
>T : T
|
||||
|
||||
type K20 = KeyOf<Shape>; // "name" | "width" | "height" | "visible"
|
||||
>K20 : "name" | "width" | "height" | "visible"
|
||||
>KeyOf : keyof T
|
||||
>Shape : Shape
|
||||
|
||||
type K21 = KeyOf<Dictionary<Shape>>; // string | number
|
||||
>K21 : string | number
|
||||
>KeyOf : keyof T
|
||||
>Dictionary : { [x: string]: T; }
|
||||
>Shape : Shape
|
||||
|
||||
type NAME = "name";
|
||||
>NAME : "name"
|
||||
|
||||
type WIDTH_OR_HEIGHT = "width" | "height";
|
||||
>WIDTH_OR_HEIGHT : "width" | "height"
|
||||
|
||||
type Q10 = Shape["name"]; // string
|
||||
>Q10 : string
|
||||
>Shape : Shape
|
||||
|
||||
type Q11 = Shape["width" | "height"]; // number
|
||||
>Q11 : number
|
||||
>Shape : Shape
|
||||
|
||||
type Q12 = Shape["name" | "visible"]; // string | boolean
|
||||
>Q12 : string | boolean
|
||||
>Shape : Shape
|
||||
|
||||
type Q20 = Shape[NAME]; // string
|
||||
>Q20 : string
|
||||
>Shape : Shape
|
||||
>NAME : "name"
|
||||
|
||||
type Q21 = Shape[WIDTH_OR_HEIGHT]; // number
|
||||
>Q21 : number
|
||||
>Shape : Shape
|
||||
>WIDTH_OR_HEIGHT : "width" | "height"
|
||||
|
||||
type Q30 = [string, number][0]; // string
|
||||
>Q30 : string
|
||||
|
||||
type Q31 = [string, number][1]; // number
|
||||
>Q31 : number
|
||||
|
||||
type Q32 = [string, number][2]; // string | number
|
||||
>Q32 : string | number
|
||||
|
||||
type Q33 = [string, number][E.A]; // string
|
||||
>Q33 : string
|
||||
>E : any
|
||||
>A : E.A
|
||||
|
||||
type Q34 = [string, number][E.B]; // number
|
||||
>Q34 : number
|
||||
>E : any
|
||||
>B : E.B
|
||||
|
||||
type Q35 = [string, number][E.C]; // string | number
|
||||
>Q35 : string | number
|
||||
>E : any
|
||||
>C : E.C
|
||||
|
||||
type Q36 = [string, number]["0"]; // string
|
||||
>Q36 : string
|
||||
|
||||
type Q37 = [string, number]["1"]; // string
|
||||
>Q37 : number
|
||||
|
||||
type Q40 = (Shape | Options)["visible"]; // boolean | "yes" | "no"
|
||||
>Q40 : boolean | "yes" | "no"
|
||||
>Shape : Shape
|
||||
>Options : Options
|
||||
|
||||
type Q41 = (Shape & Options)["visible"]; // true & "yes" | true & "no" | false & "yes" | false & "no"
|
||||
>Q41 : (true & "yes") | (true & "no") | (false & "yes") | (false & "no")
|
||||
>Shape : Shape
|
||||
>Options : Options
|
||||
|
||||
type Q50 = Dictionary<Shape>["howdy"]; // Shape
|
||||
>Q50 : Shape
|
||||
>Dictionary : { [x: string]: T; }
|
||||
>Shape : Shape
|
||||
|
||||
type Q51 = Dictionary<Shape>[123]; // Shape
|
||||
>Q51 : Shape
|
||||
>Dictionary : { [x: string]: T; }
|
||||
>Shape : Shape
|
||||
|
||||
type Q52 = Dictionary<Shape>[E.B]; // Shape
|
||||
>Q52 : Shape
|
||||
>Dictionary : { [x: string]: T; }
|
||||
>Shape : Shape
|
||||
>E : any
|
||||
>B : E.B
|
||||
|
||||
declare let cond: boolean;
|
||||
>cond : boolean
|
||||
|
||||
function getProperty<T, K extends keyof T>(obj: T, key: K) {
|
||||
>getProperty : <T, K extends keyof T>(obj: T, key: K) => T[K]
|
||||
>T : T
|
||||
>K : K
|
||||
>T : T
|
||||
>obj : T
|
||||
>T : T
|
||||
>key : K
|
||||
>K : K
|
||||
|
||||
return obj[key];
|
||||
>obj[key] : T[K]
|
||||
>obj : T
|
||||
>key : K
|
||||
}
|
||||
|
||||
function setProperty<T, K extends keyof T>(obj: T, key: K, value: T[K]) {
|
||||
>setProperty : <T, K extends keyof T>(obj: T, key: K, value: T[K]) => void
|
||||
>T : T
|
||||
>K : K
|
||||
>T : T
|
||||
>obj : T
|
||||
>T : T
|
||||
>key : K
|
||||
>K : K
|
||||
>value : T[K]
|
||||
>T : T
|
||||
>K : K
|
||||
|
||||
obj[key] = value;
|
||||
>obj[key] = value : T[K]
|
||||
>obj[key] : T[K]
|
||||
>obj : T
|
||||
>key : K
|
||||
>value : T[K]
|
||||
}
|
||||
|
||||
function f10(shape: Shape) {
|
||||
>f10 : (shape: Shape) => void
|
||||
>shape : Shape
|
||||
>Shape : Shape
|
||||
|
||||
let name = getProperty(shape, "name"); // string
|
||||
>name : string
|
||||
>getProperty(shape, "name") : string
|
||||
>getProperty : <T, K extends keyof T>(obj: T, key: K) => T[K]
|
||||
>shape : Shape
|
||||
>"name" : "name"
|
||||
|
||||
let widthOrHeight = getProperty(shape, cond ? "width" : "height"); // number
|
||||
>widthOrHeight : number
|
||||
>getProperty(shape, cond ? "width" : "height") : number
|
||||
>getProperty : <T, K extends keyof T>(obj: T, key: K) => T[K]
|
||||
>shape : Shape
|
||||
>cond ? "width" : "height" : "width" | "height"
|
||||
>cond : boolean
|
||||
>"width" : "width"
|
||||
>"height" : "height"
|
||||
|
||||
let nameOrVisible = getProperty(shape, cond ? "name" : "visible"); // string | boolean
|
||||
>nameOrVisible : string | boolean
|
||||
>getProperty(shape, cond ? "name" : "visible") : string | boolean
|
||||
>getProperty : <T, K extends keyof T>(obj: T, key: K) => T[K]
|
||||
>shape : Shape
|
||||
>cond ? "name" : "visible" : "name" | "visible"
|
||||
>cond : boolean
|
||||
>"name" : "name"
|
||||
>"visible" : "visible"
|
||||
|
||||
setProperty(shape, "name", "rectangle");
|
||||
>setProperty(shape, "name", "rectangle") : void
|
||||
>setProperty : <T, K extends keyof T>(obj: T, key: K, value: T[K]) => void
|
||||
>shape : Shape
|
||||
>"name" : "name"
|
||||
>"rectangle" : "rectangle"
|
||||
|
||||
setProperty(shape, cond ? "width" : "height", 10);
|
||||
>setProperty(shape, cond ? "width" : "height", 10) : void
|
||||
>setProperty : <T, K extends keyof T>(obj: T, key: K, value: T[K]) => void
|
||||
>shape : Shape
|
||||
>cond ? "width" : "height" : "width" | "height"
|
||||
>cond : boolean
|
||||
>"width" : "width"
|
||||
>"height" : "height"
|
||||
>10 : 10
|
||||
|
||||
setProperty(shape, cond ? "name" : "visible", true); // Technically not safe
|
||||
>setProperty(shape, cond ? "name" : "visible", true) : void
|
||||
>setProperty : <T, K extends keyof T>(obj: T, key: K, value: T[K]) => void
|
||||
>shape : Shape
|
||||
>cond ? "name" : "visible" : "name" | "visible"
|
||||
>cond : boolean
|
||||
>"name" : "name"
|
||||
>"visible" : "visible"
|
||||
>true : true
|
||||
}
|
||||
|
||||
function f11(a: Shape[]) {
|
||||
>f11 : (a: Shape[]) => void
|
||||
>a : Shape[]
|
||||
>Shape : Shape
|
||||
|
||||
let len = getProperty(a, "length"); // number
|
||||
>len : number
|
||||
>getProperty(a, "length") : number
|
||||
>getProperty : <T, K extends keyof T>(obj: T, key: K) => T[K]
|
||||
>a : Shape[]
|
||||
>"length" : "length"
|
||||
|
||||
let shape = getProperty(a, 1000); // Shape
|
||||
>shape : Shape
|
||||
>getProperty(a, 1000) : Shape
|
||||
>getProperty : <T, K extends keyof T>(obj: T, key: K) => T[K]
|
||||
>a : Shape[]
|
||||
>1000 : 1000
|
||||
|
||||
setProperty(a, 1000, getProperty(a, 1001));
|
||||
>setProperty(a, 1000, getProperty(a, 1001)) : void
|
||||
>setProperty : <T, K extends keyof T>(obj: T, key: K, value: T[K]) => void
|
||||
>a : Shape[]
|
||||
>1000 : 1000
|
||||
>getProperty(a, 1001) : Shape
|
||||
>getProperty : <T, K extends keyof T>(obj: T, key: K) => T[K]
|
||||
>a : Shape[]
|
||||
>1001 : 1001
|
||||
}
|
||||
|
||||
function f12(t: [Shape, boolean]) {
|
||||
>f12 : (t: [Shape, boolean]) => void
|
||||
>t : [Shape, boolean]
|
||||
>Shape : Shape
|
||||
|
||||
let len = getProperty(t, "length");
|
||||
>len : number
|
||||
>getProperty(t, "length") : number
|
||||
>getProperty : <T, K extends keyof T>(obj: T, key: K) => T[K]
|
||||
>t : [Shape, boolean]
|
||||
>"length" : "length"
|
||||
|
||||
let s1 = getProperty(t, 0); // Shape
|
||||
>s1 : Shape
|
||||
>getProperty(t, 0) : Shape
|
||||
>getProperty : <T, K extends keyof T>(obj: T, key: K) => T[K]
|
||||
>t : [Shape, boolean]
|
||||
>0 : 0
|
||||
|
||||
let s2 = getProperty(t, "0"); // Shape
|
||||
>s2 : Shape
|
||||
>getProperty(t, "0") : Shape
|
||||
>getProperty : <T, K extends keyof T>(obj: T, key: K) => T[K]
|
||||
>t : [Shape, boolean]
|
||||
>"0" : "0"
|
||||
|
||||
let b1 = getProperty(t, 1); // boolean
|
||||
>b1 : boolean
|
||||
>getProperty(t, 1) : boolean
|
||||
>getProperty : <T, K extends keyof T>(obj: T, key: K) => T[K]
|
||||
>t : [Shape, boolean]
|
||||
>1 : 1
|
||||
|
||||
let b2 = getProperty(t, "1"); // boolean
|
||||
>b2 : boolean
|
||||
>getProperty(t, "1") : boolean
|
||||
>getProperty : <T, K extends keyof T>(obj: T, key: K) => T[K]
|
||||
>t : [Shape, boolean]
|
||||
>"1" : "1"
|
||||
|
||||
let x1 = getProperty(t, 2); // Shape | boolean
|
||||
>x1 : boolean | Shape
|
||||
>getProperty(t, 2) : boolean | Shape
|
||||
>getProperty : <T, K extends keyof T>(obj: T, key: K) => T[K]
|
||||
>t : [Shape, boolean]
|
||||
>2 : 2
|
||||
}
|
||||
|
||||
function f13(foo: any, bar: any) {
|
||||
>f13 : (foo: any, bar: any) => void
|
||||
>foo : any
|
||||
>bar : any
|
||||
|
||||
let x = getProperty(foo, "x"); // any
|
||||
>x : any
|
||||
>getProperty(foo, "x") : any
|
||||
>getProperty : <T, K extends keyof T>(obj: T, key: K) => T[K]
|
||||
>foo : any
|
||||
>"x" : "x"
|
||||
|
||||
let y = getProperty(foo, 100); // any
|
||||
>y : any
|
||||
>getProperty(foo, 100) : any
|
||||
>getProperty : <T, K extends keyof T>(obj: T, key: K) => T[K]
|
||||
>foo : any
|
||||
>100 : 100
|
||||
|
||||
let z = getProperty(foo, bar); // any
|
||||
>z : any
|
||||
>getProperty(foo, bar) : any
|
||||
>getProperty : <T, K extends keyof T>(obj: T, key: K) => T[K]
|
||||
>foo : any
|
||||
>bar : any
|
||||
}
|
||||
|
||||
class Component<PropType> {
|
||||
>Component : Component<PropType>
|
||||
>PropType : PropType
|
||||
|
||||
props: PropType;
|
||||
>props : PropType
|
||||
>PropType : PropType
|
||||
|
||||
getProperty<K extends keyof PropType>(key: K) {
|
||||
>getProperty : <K extends keyof PropType>(key: K) => PropType[K]
|
||||
>K : K
|
||||
>PropType : PropType
|
||||
>key : K
|
||||
>K : K
|
||||
|
||||
return this.props[key];
|
||||
>this.props[key] : PropType[K]
|
||||
>this.props : PropType
|
||||
>this : this
|
||||
>props : PropType
|
||||
>key : K
|
||||
}
|
||||
setProperty<K extends keyof PropType>(key: K, value: PropType[K]) {
|
||||
>setProperty : <K extends keyof PropType>(key: K, value: PropType[K]) => void
|
||||
>K : K
|
||||
>PropType : PropType
|
||||
>key : K
|
||||
>K : K
|
||||
>value : PropType[K]
|
||||
>PropType : PropType
|
||||
>K : K
|
||||
|
||||
this.props[key] = value;
|
||||
>this.props[key] = value : PropType[K]
|
||||
>this.props[key] : PropType[K]
|
||||
>this.props : PropType
|
||||
>this : this
|
||||
>props : PropType
|
||||
>key : K
|
||||
>value : PropType[K]
|
||||
}
|
||||
}
|
||||
|
||||
function f20(component: Component<Shape>) {
|
||||
>f20 : (component: Component<Shape>) => void
|
||||
>component : Component<Shape>
|
||||
>Component : Component<PropType>
|
||||
>Shape : Shape
|
||||
|
||||
let name = component.getProperty("name"); // string
|
||||
>name : string
|
||||
>component.getProperty("name") : string
|
||||
>component.getProperty : <K extends "name" | "width" | "height" | "visible">(key: K) => Shape[K]
|
||||
>component : Component<Shape>
|
||||
>getProperty : <K extends "name" | "width" | "height" | "visible">(key: K) => Shape[K]
|
||||
>"name" : "name"
|
||||
|
||||
let widthOrHeight = component.getProperty(cond ? "width" : "height"); // number
|
||||
>widthOrHeight : number
|
||||
>component.getProperty(cond ? "width" : "height") : number
|
||||
>component.getProperty : <K extends "name" | "width" | "height" | "visible">(key: K) => Shape[K]
|
||||
>component : Component<Shape>
|
||||
>getProperty : <K extends "name" | "width" | "height" | "visible">(key: K) => Shape[K]
|
||||
>cond ? "width" : "height" : "width" | "height"
|
||||
>cond : boolean
|
||||
>"width" : "width"
|
||||
>"height" : "height"
|
||||
|
||||
let nameOrVisible = component.getProperty(cond ? "name" : "visible"); // string | boolean
|
||||
>nameOrVisible : string | boolean
|
||||
>component.getProperty(cond ? "name" : "visible") : string | boolean
|
||||
>component.getProperty : <K extends "name" | "width" | "height" | "visible">(key: K) => Shape[K]
|
||||
>component : Component<Shape>
|
||||
>getProperty : <K extends "name" | "width" | "height" | "visible">(key: K) => Shape[K]
|
||||
>cond ? "name" : "visible" : "name" | "visible"
|
||||
>cond : boolean
|
||||
>"name" : "name"
|
||||
>"visible" : "visible"
|
||||
|
||||
component.setProperty("name", "rectangle");
|
||||
>component.setProperty("name", "rectangle") : void
|
||||
>component.setProperty : <K extends "name" | "width" | "height" | "visible">(key: K, value: Shape[K]) => void
|
||||
>component : Component<Shape>
|
||||
>setProperty : <K extends "name" | "width" | "height" | "visible">(key: K, value: Shape[K]) => void
|
||||
>"name" : "name"
|
||||
>"rectangle" : "rectangle"
|
||||
|
||||
component.setProperty(cond ? "width" : "height", 10)
|
||||
>component.setProperty(cond ? "width" : "height", 10) : void
|
||||
>component.setProperty : <K extends "name" | "width" | "height" | "visible">(key: K, value: Shape[K]) => void
|
||||
>component : Component<Shape>
|
||||
>setProperty : <K extends "name" | "width" | "height" | "visible">(key: K, value: Shape[K]) => void
|
||||
>cond ? "width" : "height" : "width" | "height"
|
||||
>cond : boolean
|
||||
>"width" : "width"
|
||||
>"height" : "height"
|
||||
>10 : 10
|
||||
|
||||
component.setProperty(cond ? "name" : "visible", true); // Technically not safe
|
||||
>component.setProperty(cond ? "name" : "visible", true) : void
|
||||
>component.setProperty : <K extends "name" | "width" | "height" | "visible">(key: K, value: Shape[K]) => void
|
||||
>component : Component<Shape>
|
||||
>setProperty : <K extends "name" | "width" | "height" | "visible">(key: K, value: Shape[K]) => void
|
||||
>cond ? "name" : "visible" : "name" | "visible"
|
||||
>cond : boolean
|
||||
>"name" : "name"
|
||||
>"visible" : "visible"
|
||||
>true : true
|
||||
}
|
||||
|
||||
function pluck<T, K extends keyof T>(array: T[], key: K) {
|
||||
>pluck : <T, K extends keyof T>(array: T[], key: K) => T[K][]
|
||||
>T : T
|
||||
>K : K
|
||||
>T : T
|
||||
>array : T[]
|
||||
>T : T
|
||||
>key : K
|
||||
>K : K
|
||||
|
||||
return array.map(x => x[key]);
|
||||
>array.map(x => x[key]) : T[K][]
|
||||
>array.map : { <U>(this: [T, T, T, T, T], callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any): [U, U, U, U, U]; <U>(this: [T, T, T, T], callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any): [U, U, U, U]; <U>(this: [T, T, T], callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any): [U, U, U]; <U>(this: [T, T], callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any): [U, U]; <U>(callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any): U[]; }
|
||||
>array : T[]
|
||||
>map : { <U>(this: [T, T, T, T, T], callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any): [U, U, U, U, U]; <U>(this: [T, T, T, T], callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any): [U, U, U, U]; <U>(this: [T, T, T], callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any): [U, U, U]; <U>(this: [T, T], callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any): [U, U]; <U>(callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any): U[]; }
|
||||
>x => x[key] : (x: T) => T[K]
|
||||
>x : T
|
||||
>x[key] : T[K]
|
||||
>x : T
|
||||
>key : K
|
||||
}
|
||||
|
||||
function f30(shapes: Shape[]) {
|
||||
>f30 : (shapes: Shape[]) => void
|
||||
>shapes : Shape[]
|
||||
>Shape : Shape
|
||||
|
||||
let names = pluck(shapes, "name"); // string[]
|
||||
>names : string[]
|
||||
>pluck(shapes, "name") : string[]
|
||||
>pluck : <T, K extends keyof T>(array: T[], key: K) => T[K][]
|
||||
>shapes : Shape[]
|
||||
>"name" : "name"
|
||||
|
||||
let widths = pluck(shapes, "width"); // number[]
|
||||
>widths : number[]
|
||||
>pluck(shapes, "width") : number[]
|
||||
>pluck : <T, K extends keyof T>(array: T[], key: K) => T[K][]
|
||||
>shapes : Shape[]
|
||||
>"width" : "width"
|
||||
|
||||
let nameOrVisibles = pluck(shapes, cond ? "name" : "visible"); // (string | boolean)[]
|
||||
>nameOrVisibles : (string | boolean)[]
|
||||
>pluck(shapes, cond ? "name" : "visible") : (string | boolean)[]
|
||||
>pluck : <T, K extends keyof T>(array: T[], key: K) => T[K][]
|
||||
>shapes : Shape[]
|
||||
>cond ? "name" : "visible" : "name" | "visible"
|
||||
>cond : boolean
|
||||
>"name" : "name"
|
||||
>"visible" : "visible"
|
||||
}
|
||||
|
||||
function f31<K extends keyof Shape>(key: K) {
|
||||
>f31 : <K extends "name" | "width" | "height" | "visible">(key: K) => Shape[K]
|
||||
>K : K
|
||||
>Shape : Shape
|
||||
>key : K
|
||||
>K : K
|
||||
|
||||
const shape: Shape = { name: "foo", width: 5, height: 10, visible: true };
|
||||
>shape : Shape
|
||||
>Shape : Shape
|
||||
>{ name: "foo", width: 5, height: 10, visible: true } : { name: string; width: number; height: number; visible: true; }
|
||||
>name : string
|
||||
>"foo" : "foo"
|
||||
>width : number
|
||||
>5 : 5
|
||||
>height : number
|
||||
>10 : 10
|
||||
>visible : boolean
|
||||
>true : true
|
||||
|
||||
return shape[key]; // Shape[K]
|
||||
>shape[key] : Shape[K]
|
||||
>shape : Shape
|
||||
>key : K
|
||||
}
|
||||
|
||||
function f32<K extends "width" | "height">(key: K) {
|
||||
>f32 : <K extends "width" | "height">(key: K) => Shape[K]
|
||||
>K : K
|
||||
>key : K
|
||||
>K : K
|
||||
|
||||
const shape: Shape = { name: "foo", width: 5, height: 10, visible: true };
|
||||
>shape : Shape
|
||||
>Shape : Shape
|
||||
>{ name: "foo", width: 5, height: 10, visible: true } : { name: string; width: number; height: number; visible: true; }
|
||||
>name : string
|
||||
>"foo" : "foo"
|
||||
>width : number
|
||||
>5 : 5
|
||||
>height : number
|
||||
>10 : 10
|
||||
>visible : boolean
|
||||
>true : true
|
||||
|
||||
return shape[key]; // Shape[K]
|
||||
>shape[key] : Shape[K]
|
||||
>shape : Shape
|
||||
>key : K
|
||||
}
|
||||
|
||||
class C {
|
||||
>C : C
|
||||
|
||||
public x: string;
|
||||
>x : string
|
||||
|
||||
protected y: string;
|
||||
>y : string
|
||||
|
||||
private z: string;
|
||||
>z : string
|
||||
}
|
||||
|
||||
// Indexed access expressions have always permitted access to private and protected members.
|
||||
// For consistency we also permit such access in indexed access types.
|
||||
function f40(c: C) {
|
||||
>f40 : (c: C) => void
|
||||
>c : C
|
||||
>C : C
|
||||
|
||||
type X = C["x"];
|
||||
>X : string
|
||||
>C : C
|
||||
|
||||
type Y = C["y"];
|
||||
>Y : string
|
||||
>C : C
|
||||
|
||||
type Z = C["z"];
|
||||
>Z : string
|
||||
>C : C
|
||||
|
||||
let x: X = c["x"];
|
||||
>x : string
|
||||
>X : string
|
||||
>c["x"] : string
|
||||
>c : C
|
||||
>"x" : "x"
|
||||
|
||||
let y: Y = c["y"];
|
||||
>y : string
|
||||
>Y : string
|
||||
>c["y"] : string
|
||||
>c : C
|
||||
>"y" : "y"
|
||||
|
||||
let z: Z = c["z"];
|
||||
>z : string
|
||||
>Z : string
|
||||
>c["z"] : string
|
||||
>c : C
|
||||
>"z" : "z"
|
||||
}
|
||||
@@ -0,0 +1,138 @@
|
||||
tests/cases/conformance/types/keyof/keyofAndIndexedAccessErrors.ts(10,18): error TS2304: Cannot find name 'K0'.
|
||||
tests/cases/conformance/types/keyof/keyofAndIndexedAccessErrors.ts(20,18): error TS2339: Property 'foo' does not exist on type 'Shape'.
|
||||
tests/cases/conformance/types/keyof/keyofAndIndexedAccessErrors.ts(21,18): error TS2339: Property 'foo' does not exist on type 'Shape'.
|
||||
tests/cases/conformance/types/keyof/keyofAndIndexedAccessErrors.ts(22,18): error TS2538: Type 'any' cannot be used as an index type.
|
||||
tests/cases/conformance/types/keyof/keyofAndIndexedAccessErrors.ts(23,18): error TS2537: Type 'Shape' has no matching index signature for type 'string'.
|
||||
tests/cases/conformance/types/keyof/keyofAndIndexedAccessErrors.ts(24,18): error TS2537: Type 'Shape' has no matching index signature for type 'number'.
|
||||
tests/cases/conformance/types/keyof/keyofAndIndexedAccessErrors.ts(25,18): error TS2538: Type 'boolean' cannot be used as an index type.
|
||||
tests/cases/conformance/types/keyof/keyofAndIndexedAccessErrors.ts(26,18): error TS2538: Type 'void' cannot be used as an index type.
|
||||
tests/cases/conformance/types/keyof/keyofAndIndexedAccessErrors.ts(27,18): error TS2538: Type 'undefined' cannot be used as an index type.
|
||||
tests/cases/conformance/types/keyof/keyofAndIndexedAccessErrors.ts(28,18): error TS2538: Type '{ x: string; }' cannot be used as an index type.
|
||||
tests/cases/conformance/types/keyof/keyofAndIndexedAccessErrors.ts(29,18): error TS2537: Type 'Shape' has no matching index signature for type 'string'.
|
||||
tests/cases/conformance/types/keyof/keyofAndIndexedAccessErrors.ts(30,18): error TS2538: Type 'string & number' cannot be used as an index type.
|
||||
tests/cases/conformance/types/keyof/keyofAndIndexedAccessErrors.ts(31,18): error TS2537: Type 'Shape' has no matching index signature for type 'string'.
|
||||
tests/cases/conformance/types/keyof/keyofAndIndexedAccessErrors.ts(35,21): error TS2537: Type 'string[]' has no matching index signature for type 'string'.
|
||||
tests/cases/conformance/types/keyof/keyofAndIndexedAccessErrors.ts(36,21): error TS2538: Type 'boolean' cannot be used as an index type.
|
||||
tests/cases/conformance/types/keyof/keyofAndIndexedAccessErrors.ts(41,31): error TS2538: Type 'boolean' cannot be used as an index type.
|
||||
tests/cases/conformance/types/keyof/keyofAndIndexedAccessErrors.ts(46,16): error TS2538: Type 'boolean' cannot be used as an index type.
|
||||
tests/cases/conformance/types/keyof/keyofAndIndexedAccessErrors.ts(63,33): error TS2345: Argument of type '"size"' is not assignable to parameter of type '"name" | "width" | "height" | "visible"'.
|
||||
tests/cases/conformance/types/keyof/keyofAndIndexedAccessErrors.ts(64,33): error TS2345: Argument of type '"name" | "size"' is not assignable to parameter of type '"name" | "width" | "height" | "visible"'.
|
||||
Type '"size"' is not assignable to type '"name" | "width" | "height" | "visible"'.
|
||||
tests/cases/conformance/types/keyof/keyofAndIndexedAccessErrors.ts(66,24): error TS2345: Argument of type '"size"' is not assignable to parameter of type '"name" | "width" | "height" | "visible"'.
|
||||
tests/cases/conformance/types/keyof/keyofAndIndexedAccessErrors.ts(67,24): error TS2345: Argument of type '"name" | "size"' is not assignable to parameter of type '"name" | "width" | "height" | "visible"'.
|
||||
Type '"size"' is not assignable to type '"name" | "width" | "height" | "visible"'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/types/keyof/keyofAndIndexedAccessErrors.ts (21 errors) ====
|
||||
class Shape {
|
||||
name: string;
|
||||
width: number;
|
||||
height: number;
|
||||
visible: boolean;
|
||||
}
|
||||
|
||||
type Dictionary<T> = { [x: string]: T };
|
||||
|
||||
type T00 = keyof K0; // Error
|
||||
~~
|
||||
!!! error TS2304: Cannot find name 'K0'.
|
||||
|
||||
type T01 = keyof Object;
|
||||
type T02 = keyof keyof Object;
|
||||
type T03 = keyof keyof keyof Object;
|
||||
type T04 = keyof keyof keyof keyof Object;
|
||||
type T05 = keyof keyof keyof keyof keyof Object;
|
||||
type T06 = keyof keyof keyof keyof keyof keyof Object;
|
||||
|
||||
type T10 = Shape["name"];
|
||||
type T11 = Shape["foo"]; // Error
|
||||
~~~~~
|
||||
!!! error TS2339: Property 'foo' does not exist on type 'Shape'.
|
||||
type T12 = Shape["name" | "foo"]; // Error
|
||||
~~~~~~~~~~~~~~
|
||||
!!! error TS2339: Property 'foo' does not exist on type 'Shape'.
|
||||
type T13 = Shape[any]; // Error
|
||||
~~~
|
||||
!!! error TS2538: Type 'any' cannot be used as an index type.
|
||||
type T14 = Shape[string]; // Error
|
||||
~~~~~~
|
||||
!!! error TS2537: Type 'Shape' has no matching index signature for type 'string'.
|
||||
type T15 = Shape[number]; // Error
|
||||
~~~~~~
|
||||
!!! error TS2537: Type 'Shape' has no matching index signature for type 'number'.
|
||||
type T16 = Shape[boolean]; // Error
|
||||
~~~~~~~
|
||||
!!! error TS2538: Type 'boolean' cannot be used as an index type.
|
||||
type T17 = Shape[void]; // Error
|
||||
~~~~
|
||||
!!! error TS2538: Type 'void' cannot be used as an index type.
|
||||
type T18 = Shape[undefined]; // Error
|
||||
~~~~~~~~~
|
||||
!!! error TS2538: Type 'undefined' cannot be used as an index type.
|
||||
type T19 = Shape[{ x: string }]; // Error
|
||||
~~~~~~~~~~~~~
|
||||
!!! error TS2538: Type '{ x: string; }' cannot be used as an index type.
|
||||
type T20 = Shape[string | number]; // Error
|
||||
~~~~~~~~~~~~~~~
|
||||
!!! error TS2537: Type 'Shape' has no matching index signature for type 'string'.
|
||||
type T21 = Shape[string & number]; // Error
|
||||
~~~~~~~~~~~~~~~
|
||||
!!! error TS2538: Type 'string & number' cannot be used as an index type.
|
||||
type T22 = Shape[string | boolean]; // Error
|
||||
~~~~~~~~~~~~~~~~
|
||||
!!! error TS2537: Type 'Shape' has no matching index signature for type 'string'.
|
||||
|
||||
type T30 = string[]["length"];
|
||||
type T31 = string[][number];
|
||||
type T32 = string[][string]; // Error
|
||||
~~~~~~
|
||||
!!! error TS2537: Type 'string[]' has no matching index signature for type 'string'.
|
||||
type T33 = string[][boolean]; // Error
|
||||
~~~~~~~
|
||||
!!! error TS2538: Type 'boolean' cannot be used as an index type.
|
||||
|
||||
type T40 = Dictionary<string>[any];
|
||||
type T41 = Dictionary<string>[number];
|
||||
type T42 = Dictionary<string>[string];
|
||||
type T43 = Dictionary<string>[boolean]; // Error
|
||||
~~~~~~~
|
||||
!!! error TS2538: Type 'boolean' cannot be used as an index type.
|
||||
|
||||
type T50 = any[any];
|
||||
type T51 = any[number];
|
||||
type T52 = any[string];
|
||||
type T53 = any[boolean]; // Error
|
||||
~~~~~~~
|
||||
!!! error TS2538: Type 'boolean' cannot be used as an index type.
|
||||
|
||||
type T60 = {}["toString"];
|
||||
type T61 = []["toString"];
|
||||
|
||||
declare let cond: boolean;
|
||||
|
||||
function getProperty<T, K extends keyof T>(obj: T, key: K) {
|
||||
return obj[key];
|
||||
}
|
||||
|
||||
function setProperty<T, K extends keyof T>(obj: T, key: K, value: T[K]) {
|
||||
obj[key] = value;
|
||||
}
|
||||
|
||||
function f10(shape: Shape) {
|
||||
let x1 = getProperty(shape, "name");
|
||||
let x2 = getProperty(shape, "size"); // Error
|
||||
~~~~~~
|
||||
!!! error TS2345: Argument of type '"size"' is not assignable to parameter of type '"name" | "width" | "height" | "visible"'.
|
||||
let x3 = getProperty(shape, cond ? "name" : "size"); // Error
|
||||
~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2345: Argument of type '"name" | "size"' is not assignable to parameter of type '"name" | "width" | "height" | "visible"'.
|
||||
!!! error TS2345: Type '"size"' is not assignable to type '"name" | "width" | "height" | "visible"'.
|
||||
setProperty(shape, "name", "rectangle");
|
||||
setProperty(shape, "size", 10); // Error
|
||||
~~~~~~
|
||||
!!! error TS2345: Argument of type '"size"' is not assignable to parameter of type '"name" | "width" | "height" | "visible"'.
|
||||
setProperty(shape, cond ? "name" : "size", 10); // Error
|
||||
~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2345: Argument of type '"name" | "size"' is not assignable to parameter of type '"name" | "width" | "height" | "visible"'.
|
||||
!!! error TS2345: Type '"size"' is not assignable to type '"name" | "width" | "height" | "visible"'.
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
//// [keyofAndIndexedAccessErrors.ts]
|
||||
class Shape {
|
||||
name: string;
|
||||
width: number;
|
||||
height: number;
|
||||
visible: boolean;
|
||||
}
|
||||
|
||||
type Dictionary<T> = { [x: string]: T };
|
||||
|
||||
type T00 = keyof K0; // Error
|
||||
|
||||
type T01 = keyof Object;
|
||||
type T02 = keyof keyof Object;
|
||||
type T03 = keyof keyof keyof Object;
|
||||
type T04 = keyof keyof keyof keyof Object;
|
||||
type T05 = keyof keyof keyof keyof keyof Object;
|
||||
type T06 = keyof keyof keyof keyof keyof keyof Object;
|
||||
|
||||
type T10 = Shape["name"];
|
||||
type T11 = Shape["foo"]; // Error
|
||||
type T12 = Shape["name" | "foo"]; // Error
|
||||
type T13 = Shape[any]; // Error
|
||||
type T14 = Shape[string]; // Error
|
||||
type T15 = Shape[number]; // Error
|
||||
type T16 = Shape[boolean]; // Error
|
||||
type T17 = Shape[void]; // Error
|
||||
type T18 = Shape[undefined]; // Error
|
||||
type T19 = Shape[{ x: string }]; // Error
|
||||
type T20 = Shape[string | number]; // Error
|
||||
type T21 = Shape[string & number]; // Error
|
||||
type T22 = Shape[string | boolean]; // Error
|
||||
|
||||
type T30 = string[]["length"];
|
||||
type T31 = string[][number];
|
||||
type T32 = string[][string]; // Error
|
||||
type T33 = string[][boolean]; // Error
|
||||
|
||||
type T40 = Dictionary<string>[any];
|
||||
type T41 = Dictionary<string>[number];
|
||||
type T42 = Dictionary<string>[string];
|
||||
type T43 = Dictionary<string>[boolean]; // Error
|
||||
|
||||
type T50 = any[any];
|
||||
type T51 = any[number];
|
||||
type T52 = any[string];
|
||||
type T53 = any[boolean]; // Error
|
||||
|
||||
type T60 = {}["toString"];
|
||||
type T61 = []["toString"];
|
||||
|
||||
declare let cond: boolean;
|
||||
|
||||
function getProperty<T, K extends keyof T>(obj: T, key: K) {
|
||||
return obj[key];
|
||||
}
|
||||
|
||||
function setProperty<T, K extends keyof T>(obj: T, key: K, value: T[K]) {
|
||||
obj[key] = value;
|
||||
}
|
||||
|
||||
function f10(shape: Shape) {
|
||||
let x1 = getProperty(shape, "name");
|
||||
let x2 = getProperty(shape, "size"); // Error
|
||||
let x3 = getProperty(shape, cond ? "name" : "size"); // Error
|
||||
setProperty(shape, "name", "rectangle");
|
||||
setProperty(shape, "size", 10); // Error
|
||||
setProperty(shape, cond ? "name" : "size", 10); // Error
|
||||
}
|
||||
|
||||
//// [keyofAndIndexedAccessErrors.js]
|
||||
var Shape = (function () {
|
||||
function Shape() {
|
||||
}
|
||||
return Shape;
|
||||
}());
|
||||
function getProperty(obj, key) {
|
||||
return obj[key];
|
||||
}
|
||||
function setProperty(obj, key, value) {
|
||||
obj[key] = value;
|
||||
}
|
||||
function f10(shape) {
|
||||
var x1 = getProperty(shape, "name");
|
||||
var x2 = getProperty(shape, "size"); // Error
|
||||
var x3 = getProperty(shape, cond ? "name" : "size"); // Error
|
||||
setProperty(shape, "name", "rectangle");
|
||||
setProperty(shape, "size", 10); // Error
|
||||
setProperty(shape, cond ? "name" : "size", 10); // Error
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
/a.ts(1,17): error TS6143: Module './jsx' was resolved to '/jsx.jsx', but '--allowJs' is not set.
|
||||
|
||||
|
||||
==== /a.ts (1 errors) ====
|
||||
import jsx from "./jsx";
|
||||
~~~~~~~
|
||||
!!! error TS6143: Module './jsx' was resolved to '/jsx.jsx', but '--allowJs' is not set.
|
||||
|
||||
==== /jsx.jsx (0 errors) ====
|
||||
// Test the error message if we have `--jsx` but not `--allowJw`.
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user