Merge branch 'master' into release-2.1
This commit is contained in:
commit
7e8af628ed
12
Jakefile.js
12
Jakefile.js
|
@ -930,7 +930,7 @@ function runConsoleTests(defaultReporter, runInParallel) {
|
|||
}
|
||||
|
||||
if (tests && tests.toLocaleLowerCase() === "rwc") {
|
||||
testTimeout = 400000;
|
||||
testTimeout = 800000;
|
||||
}
|
||||
|
||||
colors = process.env.colors || process.env.color;
|
||||
|
@ -1086,12 +1086,10 @@ task("tests-debug", ["setDebugMode", "tests"]);
|
|||
// Makes the test results the new baseline
|
||||
desc("Makes the most recent test results the new baseline, overwriting the old baseline");
|
||||
task("baseline-accept", function () {
|
||||
acceptBaseline("");
|
||||
acceptBaseline(localBaseline, refBaseline);
|
||||
});
|
||||
|
||||
function acceptBaseline(containerFolder) {
|
||||
var sourceFolder = path.join(localBaseline, containerFolder);
|
||||
var targetFolder = path.join(refBaseline, containerFolder);
|
||||
function acceptBaseline(sourceFolder, targetFolder) {
|
||||
console.log('Accept baselines from ' + sourceFolder + ' to ' + targetFolder);
|
||||
var files = fs.readdirSync(sourceFolder);
|
||||
var deleteEnding = '.delete';
|
||||
|
@ -1115,12 +1113,12 @@ function acceptBaseline(containerFolder) {
|
|||
|
||||
desc("Makes the most recent rwc test results the new baseline, overwriting the old baseline");
|
||||
task("baseline-accept-rwc", function () {
|
||||
acceptBaseline("rwc");
|
||||
acceptBaseline(localRwcBaseline, refRwcBaseline);
|
||||
});
|
||||
|
||||
desc("Makes the most recent test262 test results the new baseline, overwriting the old baseline");
|
||||
task("baseline-accept-test262", function () {
|
||||
acceptBaseline("test262");
|
||||
acceptBaseline(localTest262Baseline, refTest262Baseline);
|
||||
});
|
||||
|
||||
|
||||
|
|
|
@ -75,8 +75,7 @@
|
|||
"through2": "latest",
|
||||
"travis-fold": "latest",
|
||||
"ts-node": "latest",
|
||||
"tsd": "latest",
|
||||
"tslint": "4.0.0-dev.0",
|
||||
"tslint": "4.0.0-dev.2",
|
||||
"typescript": "^2.1"
|
||||
},
|
||||
"scripts": {
|
||||
|
|
|
@ -1,26 +1,29 @@
|
|||
var Linter = require("tslint");
|
||||
var tslint = require("tslint");
|
||||
var fs = require("fs");
|
||||
|
||||
function getLinterOptions() {
|
||||
return {
|
||||
configuration: require("../tslint.json"),
|
||||
formatter: "prose",
|
||||
formattersDirectory: undefined,
|
||||
rulesDirectory: "built/local/tslint"
|
||||
};
|
||||
}
|
||||
|
||||
function lintFileContents(options, path, contents) {
|
||||
var ll = new Linter(path, contents, options);
|
||||
return ll.lint();
|
||||
function getLinterConfiguration() {
|
||||
return require("../tslint.json");
|
||||
}
|
||||
|
||||
function lintFileAsync(options, path, cb) {
|
||||
function lintFileContents(options, configuration, path, contents) {
|
||||
var ll = new tslint.Linter(options);
|
||||
ll.lint(path, contents, configuration);
|
||||
return ll.getResult();
|
||||
}
|
||||
|
||||
function lintFileAsync(options, configuration, path, cb) {
|
||||
fs.readFile(path, "utf8", function (err, contents) {
|
||||
if (err) {
|
||||
return cb(err);
|
||||
}
|
||||
var result = lintFileContents(options, path, contents);
|
||||
var result = lintFileContents(options, configuration, path, contents);
|
||||
cb(undefined, result);
|
||||
});
|
||||
}
|
||||
|
@ -30,7 +33,8 @@ process.on("message", function (data) {
|
|||
case "file":
|
||||
var target = data.name;
|
||||
var lintOptions = getLinterOptions();
|
||||
lintFileAsync(lintOptions, target, function (err, result) {
|
||||
var lintConfiguration = getLinterConfiguration();
|
||||
lintFileAsync(lintOptions, lintConfiguration, target, function (err, result) {
|
||||
if (err) {
|
||||
process.send({ kind: "error", error: err.toString() });
|
||||
return;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import * as Lint from "tslint/lib/lint";
|
||||
import * as Lint from "tslint/lib";
|
||||
import * as ts from "typescript";
|
||||
|
||||
export class Rule extends Lint.Rules.AbstractRule {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import * as Lint from "tslint/lib/lint";
|
||||
import * as Lint from "tslint/lib";
|
||||
import * as ts from "typescript";
|
||||
|
||||
const OPTION_CATCH = "check-catch";
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import * as Lint from "tslint/lib/lint";
|
||||
import * as Lint from "tslint/lib";
|
||||
import * as ts from "typescript";
|
||||
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import * as Lint from "tslint/lib/lint";
|
||||
import * as Lint from "tslint/lib";
|
||||
import * as ts from "typescript";
|
||||
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import * as Lint from "tslint/lib/lint";
|
||||
import * as Lint from "tslint/lib";
|
||||
import * as ts from "typescript";
|
||||
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import * as Lint from "tslint/lib/lint";
|
||||
import * as Lint from "tslint/lib";
|
||||
import * as ts from "typescript";
|
||||
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import * as Lint from "tslint/lib/lint";
|
||||
import * as Lint from "tslint/lib";
|
||||
import * as ts from "typescript";
|
||||
|
||||
export class Rule extends Lint.Rules.AbstractRule {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import * as Lint from "tslint/lib/lint";
|
||||
import * as Lint from "tslint/lib";
|
||||
import * as ts from "typescript";
|
||||
|
||||
|
||||
|
|
|
@ -599,8 +599,8 @@ namespace ts {
|
|||
// Binding of JsDocComment should be done before the current block scope container changes.
|
||||
// because the scope of JsDocComment should not be affected by whether the current node is a
|
||||
// container or not.
|
||||
if (isInJavaScriptFile(node) && node.jsDocComments) {
|
||||
forEach(node.jsDocComments, bind);
|
||||
if (isInJavaScriptFile(node) && node.jsDoc) {
|
||||
forEach(node.jsDoc, bind);
|
||||
}
|
||||
if (checkUnreachable(node)) {
|
||||
bindEachChild(node);
|
||||
|
|
|
@ -142,7 +142,6 @@ namespace ts {
|
|||
const voidType = createIntrinsicType(TypeFlags.Void, "void");
|
||||
const neverType = createIntrinsicType(TypeFlags.Never, "never");
|
||||
const silentNeverType = createIntrinsicType(TypeFlags.Never, "never");
|
||||
const stringOrNumberType = getUnionType([stringType, numberType]);
|
||||
|
||||
const emptyObjectType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined);
|
||||
|
||||
|
@ -3156,38 +3155,10 @@ namespace ts {
|
|||
}
|
||||
|
||||
function getTypeForVariableLikeDeclarationFromJSDocComment(declaration: VariableLikeDeclaration) {
|
||||
const jsDocType = getJSDocTypeForVariableLikeDeclarationFromJSDocComment(declaration);
|
||||
if (jsDocType) {
|
||||
return getTypeFromTypeNode(jsDocType);
|
||||
const jsdocType = getJSDocType(declaration);
|
||||
if (jsdocType) {
|
||||
return getTypeFromTypeNode(jsdocType);
|
||||
}
|
||||
}
|
||||
|
||||
function getJSDocTypeForVariableLikeDeclarationFromJSDocComment(declaration: VariableLikeDeclaration): JSDocType {
|
||||
// First, see if this node has an @type annotation on it directly.
|
||||
const typeTag = getJSDocTypeTag(declaration);
|
||||
if (typeTag && typeTag.typeExpression) {
|
||||
return typeTag.typeExpression.type;
|
||||
}
|
||||
|
||||
if (declaration.kind === SyntaxKind.VariableDeclaration &&
|
||||
declaration.parent.kind === SyntaxKind.VariableDeclarationList &&
|
||||
declaration.parent.parent.kind === SyntaxKind.VariableStatement) {
|
||||
|
||||
// @type annotation might have been on the variable statement, try that instead.
|
||||
const annotation = getJSDocTypeTag(declaration.parent.parent);
|
||||
if (annotation && annotation.typeExpression) {
|
||||
return annotation.typeExpression.type;
|
||||
}
|
||||
}
|
||||
else if (declaration.kind === SyntaxKind.Parameter) {
|
||||
// If it's a parameter, see if the parent has a jsdoc comment with an @param
|
||||
// annotation.
|
||||
const paramTag = getCorrespondingJSDocParameterTag(<ParameterDeclaration>declaration);
|
||||
if (paramTag && paramTag.typeExpression) {
|
||||
return paramTag.typeExpression.type;
|
||||
}
|
||||
}
|
||||
|
||||
return undefined;
|
||||
}
|
||||
|
||||
|
@ -3217,9 +3188,11 @@ namespace ts {
|
|||
}
|
||||
}
|
||||
|
||||
// A variable declared in a for..in statement is always of type string
|
||||
// A variable declared in a for..in statement is of type string, or of type keyof T when the
|
||||
// right hand expression is of a type parameter type.
|
||||
if (declaration.parent.parent.kind === SyntaxKind.ForInStatement) {
|
||||
return stringType;
|
||||
const indexType = getIndexType(checkNonNullExpression((<ForInStatement>declaration.parent.parent).expression));
|
||||
return indexType.flags & TypeFlags.Index ? indexType : stringType;
|
||||
}
|
||||
|
||||
if (declaration.parent.parent.kind === SyntaxKind.ForOfStatement) {
|
||||
|
@ -3455,9 +3428,9 @@ namespace ts {
|
|||
declaration.kind === SyntaxKind.PropertyAccessExpression && declaration.parent.kind === SyntaxKind.BinaryExpression) {
|
||||
// Use JS Doc type if present on parent expression statement
|
||||
if (declaration.flags & NodeFlags.JavaScriptFile) {
|
||||
const typeTag = getJSDocTypeTag(declaration.parent);
|
||||
if (typeTag && typeTag.typeExpression) {
|
||||
return links.type = getTypeFromTypeNode(typeTag.typeExpression.type);
|
||||
const jsdocType = getJSDocType(declaration.parent);
|
||||
if (jsdocType) {
|
||||
return links.type = getTypeFromTypeNode(jsdocType);
|
||||
}
|
||||
}
|
||||
const declaredTypes = map(symbol.declarations,
|
||||
|
@ -4688,7 +4661,6 @@ namespace ts {
|
|||
t.flags & TypeFlags.NumberLike ? globalNumberType :
|
||||
t.flags & TypeFlags.BooleanLike ? globalBooleanType :
|
||||
t.flags & TypeFlags.ESSymbol ? getGlobalESSymbolType() :
|
||||
t.flags & TypeFlags.Index ? stringOrNumberType :
|
||||
t;
|
||||
}
|
||||
|
||||
|
@ -4901,15 +4873,16 @@ namespace ts {
|
|||
if (node.type && node.type.kind === SyntaxKind.JSDocOptionalType) {
|
||||
return true;
|
||||
}
|
||||
const paramTags = getJSDocParameterTags(node);
|
||||
if (paramTags) {
|
||||
for (const paramTag of paramTags) {
|
||||
if (paramTag.isBracketed) {
|
||||
return true;
|
||||
}
|
||||
|
||||
const paramTag = getCorrespondingJSDocParameterTag(node);
|
||||
if (paramTag) {
|
||||
if (paramTag.isBracketed) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (paramTag.typeExpression) {
|
||||
return paramTag.typeExpression.type.kind === SyntaxKind.JSDocOptionalType;
|
||||
if (paramTag.typeExpression) {
|
||||
return paramTag.typeExpression.type.kind === SyntaxKind.JSDocOptionalType;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -5920,8 +5893,7 @@ namespace ts {
|
|||
function getIndexType(type: Type): Type {
|
||||
return type.flags & TypeFlags.TypeParameter ? getIndexTypeForTypeParameter(<TypeParameter>type) :
|
||||
getObjectFlags(type) & ObjectFlags.Mapped ? getConstraintTypeFromMappedType(<MappedType>type) :
|
||||
type.flags & TypeFlags.Any || getIndexInfoOfType(type, IndexKind.String) ? stringOrNumberType :
|
||||
getIndexInfoOfType(type, IndexKind.Number) ? getUnionType([numberType, getLiteralTypeFromPropertyNames(type)]) :
|
||||
type.flags & TypeFlags.Any || getIndexInfoOfType(type, IndexKind.String) ? stringType :
|
||||
getLiteralTypeFromPropertyNames(type);
|
||||
}
|
||||
|
||||
|
@ -6039,11 +6011,11 @@ namespace ts {
|
|||
const id = objectType.id + "," + indexType.id;
|
||||
return indexedAccessTypes[id] || (indexedAccessTypes[id] = createIndexedAccessType(objectType, indexType));
|
||||
}
|
||||
const apparentType = getApparentType(objectType);
|
||||
const apparentObjectType = getApparentType(objectType);
|
||||
if (indexType.flags & TypeFlags.Union && !(indexType.flags & TypeFlags.Primitive)) {
|
||||
const propTypes: Type[] = [];
|
||||
for (const t of (<UnionType>indexType).types) {
|
||||
const propType = getPropertyTypeForIndexType(apparentType, t, accessNode, /*cacheSymbol*/ false);
|
||||
const propType = getPropertyTypeForIndexType(apparentObjectType, t, accessNode, /*cacheSymbol*/ false);
|
||||
if (propType === unknownType) {
|
||||
return unknownType;
|
||||
}
|
||||
|
@ -6051,7 +6023,7 @@ namespace ts {
|
|||
}
|
||||
return getUnionType(propTypes);
|
||||
}
|
||||
return getPropertyTypeForIndexType(apparentType, indexType, accessNode, /*cacheSymbol*/ true);
|
||||
return getPropertyTypeForIndexType(apparentObjectType, indexType, accessNode, /*cacheSymbol*/ true);
|
||||
}
|
||||
|
||||
function getTypeFromIndexedAccessTypeNode(node: IndexedAccessTypeNode) {
|
||||
|
@ -7123,13 +7095,6 @@ namespace ts {
|
|||
|
||||
if (isSimpleTypeRelatedTo(source, target, relation, reportErrors ? reportError : undefined)) return Ternary.True;
|
||||
|
||||
if (source.flags & TypeFlags.Index) {
|
||||
// A keyof T is related to a union type containing both string and number
|
||||
if (maybeTypeOfKind(target, TypeFlags.String) && maybeTypeOfKind(target, TypeFlags.Number)) {
|
||||
return Ternary.True;
|
||||
}
|
||||
}
|
||||
|
||||
if (getObjectFlags(source) & ObjectFlags.ObjectLiteral && source.flags & TypeFlags.FreshLiteral) {
|
||||
if (hasExcessProperties(<FreshObjectLiteralType>source, target, reportErrors)) {
|
||||
if (reportErrors) {
|
||||
|
@ -10392,9 +10357,9 @@ namespace ts {
|
|||
}
|
||||
|
||||
function getTypeForThisExpressionFromJSDoc(node: Node) {
|
||||
const typeTag = getJSDocTypeTag(node);
|
||||
if (typeTag && typeTag.typeExpression && typeTag.typeExpression.type && typeTag.typeExpression.type.kind === SyntaxKind.JSDocFunctionType) {
|
||||
const jsDocFunctionType = <JSDocFunctionType>typeTag.typeExpression.type;
|
||||
const jsdocType = getJSDocType(node);
|
||||
if (jsdocType && jsdocType.kind === SyntaxKind.JSDocFunctionType) {
|
||||
const jsDocFunctionType = <JSDocFunctionType>jsdocType;
|
||||
if (jsDocFunctionType.parameters.length > 0 && jsDocFunctionType.parameters[0].type.kind === SyntaxKind.JSDocThisType) {
|
||||
return getTypeFromTypeNode(jsDocFunctionType.parameters[0].type);
|
||||
}
|
||||
|
@ -13628,7 +13593,7 @@ namespace ts {
|
|||
// the destructured type into the contained binding elements.
|
||||
function assignBindingElementTypes(node: VariableLikeDeclaration) {
|
||||
if (isBindingPattern(node.name)) {
|
||||
for (const element of (<BindingPattern>node.name).elements) {
|
||||
for (const element of node.name.elements) {
|
||||
if (!isOmittedExpression(element)) {
|
||||
if (element.name.kind === SyntaxKind.Identifier) {
|
||||
getSymbolLinks(getSymbolOfNode(element)).type = getTypeForBindingElement(element);
|
||||
|
@ -14256,7 +14221,7 @@ namespace ts {
|
|||
if (!isTypeAnyOrAllConstituentTypesHaveKind(leftType, TypeFlags.StringLike | TypeFlags.NumberLike | TypeFlags.ESSymbol)) {
|
||||
error(left, Diagnostics.The_left_hand_side_of_an_in_expression_must_be_of_type_any_string_number_or_symbol);
|
||||
}
|
||||
if (!isTypeAnyOrAllConstituentTypesHaveKind(rightType, TypeFlags.Object | TypeFlags.TypeParameter)) {
|
||||
if (!isTypeAnyOrAllConstituentTypesHaveKind(rightType, TypeFlags.Object | TypeFlags.TypeParameter | TypeFlags.IndexedAccess)) {
|
||||
error(right, Diagnostics.The_right_hand_side_of_an_in_expression_must_be_of_type_any_an_object_type_or_a_type_parameter);
|
||||
}
|
||||
return booleanType;
|
||||
|
@ -15650,7 +15615,7 @@ namespace ts {
|
|||
const type = <MappedType>getTypeFromMappedTypeNode(node);
|
||||
const constraintType = getConstraintTypeFromMappedType(type);
|
||||
const keyType = constraintType.flags & TypeFlags.TypeParameter ? getApparentTypeOfTypeParameter(<TypeParameter>constraintType) : constraintType;
|
||||
checkTypeAssignableTo(keyType, stringOrNumberType, node.typeParameter.constraint);
|
||||
checkTypeAssignableTo(keyType, stringType, node.typeParameter.constraint);
|
||||
}
|
||||
|
||||
function isPrivateWithinAmbient(node: Node): boolean {
|
||||
|
@ -17161,7 +17126,7 @@ namespace ts {
|
|||
const rightType = checkNonNullExpression(node.expression);
|
||||
// unknownType is returned i.e. if node.expression is identifier whose name cannot be resolved
|
||||
// in this case error about missing name is already reported - do not report extra one
|
||||
if (!isTypeAnyOrAllConstituentTypesHaveKind(rightType, TypeFlags.Object | TypeFlags.TypeParameter)) {
|
||||
if (!isTypeAnyOrAllConstituentTypesHaveKind(rightType, TypeFlags.Object | TypeFlags.TypeParameter | TypeFlags.IndexedAccess)) {
|
||||
error(node.expression, Diagnostics.The_right_hand_side_of_a_for_in_statement_must_be_of_type_any_an_object_type_or_a_type_parameter);
|
||||
}
|
||||
|
||||
|
|
|
@ -951,8 +951,8 @@ namespace ts {
|
|||
errors.push(createCompilerDiagnostic(Diagnostics.Unknown_option_excludes_Did_you_mean_exclude));
|
||||
}
|
||||
else {
|
||||
// By default, exclude common package folders and the outDir
|
||||
excludeSpecs = ["node_modules", "bower_components", "jspm_packages"];
|
||||
// If no includes were specified, exclude common package folders and the outDir
|
||||
excludeSpecs = includeSpecs ? [] : ["node_modules", "bower_components", "jspm_packages"];
|
||||
|
||||
const outDir = json["compilerOptions"] && json["compilerOptions"]["outDir"];
|
||||
if (outDir) {
|
||||
|
|
|
@ -371,7 +371,7 @@ namespace ts {
|
|||
|
||||
function writeJsDocComments(declaration: Node) {
|
||||
if (declaration) {
|
||||
const jsDocComments = getJsDocCommentsFromText(declaration, currentText);
|
||||
const jsDocComments = getJSDocCommentRanges(declaration, currentText);
|
||||
emitNewLineBeforeLeadingComments(currentLineMap, writer, declaration, jsDocComments);
|
||||
// jsDoc comments are emitted at /*leading comment1 */space/*leading comment*/space
|
||||
emitComments(currentText, currentLineMap, writer, jsDocComments, /*leadingSeparator*/ false, /*trailingSeparator*/ true, newLine, writeCommentRange);
|
||||
|
|
|
@ -681,7 +681,7 @@ namespace ts {
|
|||
|
||||
|
||||
function addJSDocComment<T extends Node>(node: T): T {
|
||||
const comments = getJsDocCommentsFromText(node, sourceFile.text);
|
||||
const comments = getJSDocCommentRanges(node, sourceFile.text);
|
||||
if (comments) {
|
||||
for (const comment of comments) {
|
||||
const jsDoc = JSDocParser.parseJSDocComment(node, comment.pos, comment.end - comment.pos);
|
||||
|
@ -689,10 +689,10 @@ namespace ts {
|
|||
continue;
|
||||
}
|
||||
|
||||
if (!node.jsDocComments) {
|
||||
node.jsDocComments = [];
|
||||
if (!node.jsDoc) {
|
||||
node.jsDoc = [];
|
||||
}
|
||||
node.jsDocComments.push(jsDoc);
|
||||
node.jsDoc.push(jsDoc);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -719,11 +719,11 @@ namespace ts {
|
|||
const saveParent = parent;
|
||||
parent = n;
|
||||
forEachChild(n, visitNode);
|
||||
if (n.jsDocComments) {
|
||||
for (const jsDocComment of n.jsDocComments) {
|
||||
jsDocComment.parent = n;
|
||||
parent = jsDocComment;
|
||||
forEachChild(jsDocComment, visitNode);
|
||||
if (n.jsDoc) {
|
||||
for (const jsDoc of n.jsDoc) {
|
||||
jsDoc.parent = n;
|
||||
parent = jsDoc;
|
||||
forEachChild(jsDoc, visitNode);
|
||||
}
|
||||
}
|
||||
parent = saveParent;
|
||||
|
@ -6954,8 +6954,8 @@ namespace ts {
|
|||
}
|
||||
|
||||
forEachChild(node, visitNode, visitArray);
|
||||
if (node.jsDocComments) {
|
||||
for (const jsDocComment of node.jsDocComments) {
|
||||
if (node.jsDoc) {
|
||||
for (const jsDocComment of node.jsDoc) {
|
||||
forEachChild(jsDocComment, visitNode, visitArray);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1306,7 +1306,9 @@ namespace ts {
|
|||
createAssignment(
|
||||
createElementAccess(
|
||||
expressionName,
|
||||
createSubtract(temp, createLiteral(restIndex))
|
||||
restIndex === 0
|
||||
? temp
|
||||
: createSubtract(temp, createLiteral(restIndex))
|
||||
),
|
||||
createElementAccess(createIdentifier("arguments"), temp)
|
||||
),
|
||||
|
|
|
@ -497,7 +497,8 @@ namespace ts {
|
|||
parent?: Node; // Parent node (initialized by binding)
|
||||
/* @internal */ original?: Node; // The original node if this is an updated node.
|
||||
/* @internal */ startsOnNewLine?: boolean; // Whether a synthesized node should start on a new line (used by transforms).
|
||||
/* @internal */ jsDocComments?: JSDoc[]; // JSDoc for the node, if it has any.
|
||||
/* @internal */ jsDoc?: JSDoc[]; // JSDoc that directly precedes this node
|
||||
/* @internal */ jsDocCache?: (JSDoc | JSDocTag)[]; // All JSDoc that applies to the node, including parent docs and @param tags
|
||||
/* @internal */ symbol?: Symbol; // Symbol declared by node (initialized by binding)
|
||||
/* @internal */ locals?: SymbolTable; // Locals associated with node (initialized by binding)
|
||||
/* @internal */ nextContainer?: Node; // Next container in declaration order (initialized by binding)
|
||||
|
@ -2789,7 +2790,7 @@ namespace ts {
|
|||
Intrinsic = Any | String | Number | Boolean | BooleanLiteral | ESSymbol | Void | Undefined | Null | Never,
|
||||
/* @internal */
|
||||
Primitive = String | Number | Boolean | Enum | ESSymbol | Void | Undefined | Null | Literal,
|
||||
StringLike = String | StringLiteral,
|
||||
StringLike = String | StringLiteral | Index,
|
||||
NumberLike = Number | NumberLiteral | Enum | EnumLiteral,
|
||||
BooleanLike = Boolean | BooleanLiteral,
|
||||
EnumLike = Enum | EnumLiteral,
|
||||
|
|
|
@ -239,7 +239,7 @@ namespace ts {
|
|||
return !nodeIsMissing(node);
|
||||
}
|
||||
|
||||
export function getTokenPosOfNode(node: Node, sourceFile?: SourceFile, includeJsDocComment?: boolean): number {
|
||||
export function getTokenPosOfNode(node: Node, sourceFile?: SourceFile, includeJsDoc?: boolean): number {
|
||||
// With nodes that have no width (i.e. 'Missing' nodes), we actually *don't*
|
||||
// want to skip trivia because this will launch us forward to the next token.
|
||||
if (nodeIsMissing(node)) {
|
||||
|
@ -250,8 +250,8 @@ namespace ts {
|
|||
return skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.pos, /*stopAfterLineBreak*/ false, /*stopAtComments*/ true);
|
||||
}
|
||||
|
||||
if (includeJsDocComment && node.jsDocComments && node.jsDocComments.length > 0) {
|
||||
return getTokenPosOfNode(node.jsDocComments[0]);
|
||||
if (includeJsDoc && node.jsDoc && node.jsDoc.length > 0) {
|
||||
return getTokenPosOfNode(node.jsDoc[0]);
|
||||
}
|
||||
|
||||
// For a syntax list, it is possible that one of its children has JSDocComment nodes, while
|
||||
|
@ -259,7 +259,7 @@ namespace ts {
|
|||
// trivia for the list, we may have skipped the JSDocComment as well. So we should process its
|
||||
// first child to determine the actual position of its first token.
|
||||
if (node.kind === SyntaxKind.SyntaxList && (<SyntaxList>node)._children.length > 0) {
|
||||
return getTokenPosOfNode((<SyntaxList>node)._children[0], sourceFile, includeJsDocComment);
|
||||
return getTokenPosOfNode((<SyntaxList>node)._children[0], sourceFile, includeJsDoc);
|
||||
}
|
||||
|
||||
return skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.pos);
|
||||
|
@ -624,25 +624,18 @@ namespace ts {
|
|||
return getLeadingCommentRanges(text, node.pos);
|
||||
}
|
||||
|
||||
export function getJsDocComments(node: Node, sourceFileOfNode: SourceFile) {
|
||||
return getJsDocCommentsFromText(node, sourceFileOfNode.text);
|
||||
}
|
||||
|
||||
export function getJsDocCommentsFromText(node: Node, text: string) {
|
||||
export function getJSDocCommentRanges(node: Node, text: string) {
|
||||
const commentRanges = (node.kind === SyntaxKind.Parameter ||
|
||||
node.kind === SyntaxKind.TypeParameter ||
|
||||
node.kind === SyntaxKind.FunctionExpression ||
|
||||
node.kind === SyntaxKind.ArrowFunction) ?
|
||||
concatenate(getTrailingCommentRanges(text, node.pos), getLeadingCommentRanges(text, node.pos)) :
|
||||
getLeadingCommentRangesOfNodeFromText(node, text);
|
||||
return filter(commentRanges, isJsDocComment);
|
||||
|
||||
function isJsDocComment(comment: CommentRange) {
|
||||
// True if the comment starts with '/**' but not if it is '/**/'
|
||||
return text.charCodeAt(comment.pos + 1) === CharacterCodes.asterisk &&
|
||||
text.charCodeAt(comment.pos + 2) === CharacterCodes.asterisk &&
|
||||
text.charCodeAt(comment.pos + 3) !== CharacterCodes.slash;
|
||||
}
|
||||
// True if the comment starts with '/**' but not if it is '/**/'
|
||||
return filter(commentRanges, comment =>
|
||||
text.charCodeAt(comment.pos + 1) === CharacterCodes.asterisk &&
|
||||
text.charCodeAt(comment.pos + 2) === CharacterCodes.asterisk &&
|
||||
text.charCodeAt(comment.pos + 3) !== CharacterCodes.slash);
|
||||
}
|
||||
|
||||
export let fullTripleSlashReferencePathRegEx = /^(\/\/\/\s*<reference\s+path\s*=\s*)('|")(.+?)\2.*?\/>/;
|
||||
|
@ -1423,57 +1416,42 @@ namespace ts {
|
|||
(<JSDocFunctionType>node).parameters[0].type.kind === SyntaxKind.JSDocConstructorType;
|
||||
}
|
||||
|
||||
function getJSDocTag(node: Node, kind: SyntaxKind, checkParentVariableStatement: boolean): JSDocTag {
|
||||
if (!node) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
const jsDocTags = getJSDocTags(node, checkParentVariableStatement);
|
||||
if (!jsDocTags) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
for (const tag of jsDocTags) {
|
||||
if (tag.kind === kind) {
|
||||
return tag;
|
||||
}
|
||||
}
|
||||
export function getCommentsFromJSDoc(node: Node): string[] {
|
||||
return map(getJSDocs(node), doc => doc.comment);
|
||||
}
|
||||
|
||||
function append<T>(previous: T[] | undefined, additional: T[] | undefined): T[] | undefined {
|
||||
if (additional) {
|
||||
if (!previous) {
|
||||
previous = [];
|
||||
}
|
||||
for (const x of additional) {
|
||||
previous.push(x);
|
||||
}
|
||||
}
|
||||
return previous;
|
||||
}
|
||||
|
||||
export function getJSDocComments(node: Node, checkParentVariableStatement: boolean): string[] {
|
||||
return getJSDocs(node, checkParentVariableStatement, docs => map(docs, doc => doc.comment), tags => map(tags, tag => tag.comment));
|
||||
}
|
||||
|
||||
function getJSDocTags(node: Node, checkParentVariableStatement: boolean): JSDocTag[] {
|
||||
return getJSDocs(node, checkParentVariableStatement, docs => {
|
||||
function getJSDocTags(node: Node, kind: SyntaxKind): JSDocTag[] {
|
||||
const docs = getJSDocs(node);
|
||||
if (docs) {
|
||||
const result: JSDocTag[] = [];
|
||||
for (const doc of docs) {
|
||||
if (doc.tags) {
|
||||
result.push(...doc.tags);
|
||||
if (doc.kind === SyntaxKind.JSDocParameterTag) {
|
||||
if (doc.kind === kind) {
|
||||
result.push(doc as JSDocTag);
|
||||
}
|
||||
}
|
||||
else {
|
||||
result.push(...filter((doc as JSDoc).tags, tag => tag.kind === kind));
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}, tags => tags);
|
||||
}
|
||||
}
|
||||
|
||||
function getJSDocs<T>(node: Node, checkParentVariableStatement: boolean, getDocs: (docs: JSDoc[]) => T[], getTags: (tags: JSDocTag[]) => T[]): T[] {
|
||||
// TODO: Get rid of getJsDocComments and friends (note the lowercase 's' in Js)
|
||||
// TODO: A lot of this work should be cached, maybe. I guess it's only used in services right now...
|
||||
let result: T[] = undefined;
|
||||
// prepend documentation from parent sources
|
||||
if (checkParentVariableStatement) {
|
||||
function getFirstJSDocTag(node: Node, kind: SyntaxKind): JSDocTag {
|
||||
return node && firstOrUndefined(getJSDocTags(node, kind));
|
||||
}
|
||||
|
||||
function getJSDocs(node: Node): (JSDoc | JSDocTag)[] {
|
||||
let cache: (JSDoc | JSDocTag)[] = node.jsDocCache;
|
||||
if (!cache) {
|
||||
getJSDocsWorker(node);
|
||||
node.jsDocCache = cache;
|
||||
}
|
||||
return cache;
|
||||
|
||||
function getJSDocsWorker(node: Node) {
|
||||
const parent = node.parent;
|
||||
// Try to recognize this pattern when node is initializer of variable declaration and JSDoc comments are on containing variable statement.
|
||||
// /**
|
||||
// * @param {number} name
|
||||
|
@ -1481,68 +1459,55 @@ namespace ts {
|
|||
// */
|
||||
// var x = function(name) { return name.length; }
|
||||
const isInitializerOfVariableDeclarationInStatement =
|
||||
isVariableLike(node.parent) &&
|
||||
(node.parent).initializer === node &&
|
||||
node.parent.parent.parent.kind === SyntaxKind.VariableStatement;
|
||||
isVariableLike(parent) &&
|
||||
parent.initializer === node &&
|
||||
parent.parent.parent.kind === SyntaxKind.VariableStatement;
|
||||
const isVariableOfVariableDeclarationStatement = isVariableLike(node) &&
|
||||
node.parent.parent.kind === SyntaxKind.VariableStatement;
|
||||
|
||||
parent.parent.kind === SyntaxKind.VariableStatement;
|
||||
const variableStatementNode =
|
||||
isInitializerOfVariableDeclarationInStatement ? node.parent.parent.parent :
|
||||
isVariableOfVariableDeclarationStatement ? node.parent.parent :
|
||||
undefined;
|
||||
isInitializerOfVariableDeclarationInStatement ? parent.parent.parent :
|
||||
isVariableOfVariableDeclarationStatement ? parent.parent :
|
||||
undefined;
|
||||
if (variableStatementNode) {
|
||||
result = append(result, getJSDocs(variableStatementNode, checkParentVariableStatement, getDocs, getTags));
|
||||
}
|
||||
if (node.kind === SyntaxKind.ModuleDeclaration &&
|
||||
node.parent && node.parent.kind === SyntaxKind.ModuleDeclaration) {
|
||||
result = append(result, getJSDocs(node.parent, checkParentVariableStatement, getDocs, getTags));
|
||||
getJSDocsWorker(variableStatementNode);
|
||||
}
|
||||
|
||||
// Also recognize when the node is the RHS of an assignment expression
|
||||
const parent = node.parent;
|
||||
const isSourceOfAssignmentExpressionStatement =
|
||||
parent && parent.parent &&
|
||||
parent.kind === SyntaxKind.BinaryExpression &&
|
||||
(parent as BinaryExpression).operatorToken.kind === SyntaxKind.EqualsToken &&
|
||||
parent.parent.kind === SyntaxKind.ExpressionStatement;
|
||||
if (isSourceOfAssignmentExpressionStatement) {
|
||||
result = append(result, getJSDocs(parent.parent, checkParentVariableStatement, getDocs, getTags));
|
||||
getJSDocsWorker(parent.parent);
|
||||
}
|
||||
|
||||
const isModuleDeclaration = node.kind === SyntaxKind.ModuleDeclaration &&
|
||||
parent && parent.kind === SyntaxKind.ModuleDeclaration;
|
||||
const isPropertyAssignmentExpression = parent && parent.kind === SyntaxKind.PropertyAssignment;
|
||||
if (isPropertyAssignmentExpression) {
|
||||
result = append(result, getJSDocs(parent, checkParentVariableStatement, getDocs, getTags));
|
||||
if (isModuleDeclaration || isPropertyAssignmentExpression) {
|
||||
getJSDocsWorker(parent);
|
||||
}
|
||||
|
||||
// Pull parameter comments from declaring function as well
|
||||
if (node.kind === SyntaxKind.Parameter) {
|
||||
const paramTags = getJSDocParameterTag(node as ParameterDeclaration, checkParentVariableStatement);
|
||||
if (paramTags) {
|
||||
result = append(result, getTags(paramTags));
|
||||
}
|
||||
cache = concatenate(cache, getJSDocParameterTags(node));
|
||||
}
|
||||
}
|
||||
|
||||
if (isVariableLike(node) && node.initializer) {
|
||||
result = append(result, getJSDocs(node.initializer, /*checkParentVariableStatement*/ false, getDocs, getTags));
|
||||
}
|
||||
|
||||
if (node.jsDocComments) {
|
||||
if (result) {
|
||||
result = append(result, getDocs(node.jsDocComments));
|
||||
if (isVariableLike(node) && node.initializer) {
|
||||
cache = concatenate(cache, node.initializer.jsDoc);
|
||||
}
|
||||
else {
|
||||
return getDocs(node.jsDocComments);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
cache = concatenate(cache, node.jsDoc);
|
||||
}
|
||||
}
|
||||
|
||||
function getJSDocParameterTag(param: ParameterDeclaration, checkParentVariableStatement: boolean): JSDocTag[] {
|
||||
export function getJSDocParameterTags(param: Node): JSDocParameterTag[] {
|
||||
if (!isParameter(param)) {
|
||||
return undefined;
|
||||
}
|
||||
const func = param.parent as FunctionLikeDeclaration;
|
||||
const tags = getJSDocTags(func, checkParentVariableStatement);
|
||||
const tags = getJSDocTags(func, SyntaxKind.JSDocParameterTag) as JSDocParameterTag[];
|
||||
if (!param.name) {
|
||||
// this is an anonymous jsdoc param from a `function(type1, type2): type3` specification
|
||||
const i = func.parameters.indexOf(param);
|
||||
|
@ -1553,10 +1518,7 @@ namespace ts {
|
|||
}
|
||||
else if (param.name.kind === SyntaxKind.Identifier) {
|
||||
const name = (param.name as Identifier).text;
|
||||
const paramTags = filter(tags, tag => tag.kind === SyntaxKind.JSDocParameterTag && (tag as JSDocParameterTag).parameterName.text === name);
|
||||
if (paramTags) {
|
||||
return paramTags;
|
||||
}
|
||||
return filter(tags, tag => tag.kind === SyntaxKind.JSDocParameterTag && tag.parameterName.text === name);
|
||||
}
|
||||
else {
|
||||
// TODO: it's a destructured parameter, so it should look up an "object type" series of multiple lines
|
||||
|
@ -1565,39 +1527,24 @@ namespace ts {
|
|||
}
|
||||
}
|
||||
|
||||
export function getJSDocTypeTag(node: Node): JSDocTypeTag {
|
||||
return <JSDocTypeTag>getJSDocTag(node, SyntaxKind.JSDocTypeTag, /*checkParentVariableStatement*/ false);
|
||||
}
|
||||
|
||||
export function getJSDocReturnTag(node: Node): JSDocReturnTag {
|
||||
return <JSDocReturnTag>getJSDocTag(node, SyntaxKind.JSDocReturnTag, /*checkParentVariableStatement*/ true);
|
||||
}
|
||||
|
||||
export function getJSDocTemplateTag(node: Node): JSDocTemplateTag {
|
||||
return <JSDocTemplateTag>getJSDocTag(node, SyntaxKind.JSDocTemplateTag, /*checkParentVariableStatement*/ false);
|
||||
}
|
||||
|
||||
export function getCorrespondingJSDocParameterTag(parameter: ParameterDeclaration): JSDocParameterTag {
|
||||
if (parameter.name && parameter.name.kind === SyntaxKind.Identifier) {
|
||||
// If it's a parameter, see if the parent has a jsdoc comment with an @param
|
||||
// annotation.
|
||||
const parameterName = (<Identifier>parameter.name).text;
|
||||
|
||||
const jsDocTags = getJSDocTags(parameter.parent, /*checkParentVariableStatement*/ true);
|
||||
if (!jsDocTags) {
|
||||
return undefined;
|
||||
}
|
||||
for (const tag of jsDocTags) {
|
||||
if (tag.kind === SyntaxKind.JSDocParameterTag) {
|
||||
const parameterTag = <JSDocParameterTag>tag;
|
||||
if (parameterTag.parameterName.text === parameterName) {
|
||||
return parameterTag;
|
||||
}
|
||||
}
|
||||
export function getJSDocType(node: Node): JSDocType {
|
||||
let tag: JSDocTypeTag | JSDocParameterTag = getFirstJSDocTag(node, SyntaxKind.JSDocTypeTag) as JSDocTypeTag;
|
||||
if (!tag && node.kind === SyntaxKind.Parameter) {
|
||||
const paramTags = getJSDocParameterTags(node);
|
||||
if (paramTags) {
|
||||
tag = find(paramTags, tag => !!tag.typeExpression);
|
||||
}
|
||||
}
|
||||
|
||||
return undefined;
|
||||
return tag && tag.typeExpression && tag.typeExpression.type;
|
||||
}
|
||||
|
||||
export function getJSDocReturnTag(node: Node): JSDocReturnTag {
|
||||
return getFirstJSDocTag(node, SyntaxKind.JSDocReturnTag) as JSDocReturnTag;
|
||||
}
|
||||
|
||||
export function getJSDocTemplateTag(node: Node): JSDocTemplateTag {
|
||||
return getFirstJSDocTag(node, SyntaxKind.JSDocTemplateTag) as JSDocTemplateTag;
|
||||
}
|
||||
|
||||
export function hasRestParameter(s: SignatureDeclaration): boolean {
|
||||
|
@ -1610,14 +1557,11 @@ namespace ts {
|
|||
|
||||
export function isRestParameter(node: ParameterDeclaration) {
|
||||
if (node && (node.flags & NodeFlags.JavaScriptFile)) {
|
||||
if (node.type && node.type.kind === SyntaxKind.JSDocVariadicType) {
|
||||
if (node.type && node.type.kind === SyntaxKind.JSDocVariadicType ||
|
||||
forEach(getJSDocParameterTags(node),
|
||||
t => t.typeExpression && t.typeExpression.type.kind === SyntaxKind.JSDocVariadicType)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
const paramTag = getCorrespondingJSDocParameterTag(node);
|
||||
if (paramTag && paramTag.typeExpression) {
|
||||
return paramTag.typeExpression.type.kind === SyntaxKind.JSDocVariadicType;
|
||||
}
|
||||
}
|
||||
return isDeclaredRestParam(node);
|
||||
}
|
||||
|
|
|
@ -2015,7 +2015,7 @@ namespace Harness {
|
|||
|
||||
export function isDefaultLibraryFile(filePath: string): boolean {
|
||||
// We need to make sure that the filePath is prefixed with "lib." not just containing "lib." and end with ".d.ts"
|
||||
const fileName = ts.getBaseFileName(filePath);
|
||||
const fileName = ts.getBaseFileName(ts.normalizeSlashes(filePath));
|
||||
return ts.startsWith(fileName, "lib.") && ts.endsWith(fileName, ".d.ts");
|
||||
}
|
||||
|
||||
|
|
|
@ -199,7 +199,7 @@ namespace RWC {
|
|||
}
|
||||
// Do not include the library in the baselines to avoid noise
|
||||
const baselineFiles = inputFiles.concat(otherFiles).filter(f => !Harness.isDefaultLibraryFile(f.unitName));
|
||||
const errors = compilerResult.errors.filter(e => !Harness.isDefaultLibraryFile(e.file.fileName));
|
||||
const errors = compilerResult.errors.filter(e => e.file && !Harness.isDefaultLibraryFile(e.file.fileName));
|
||||
return Harness.Compiler.getErrorBaseline(baselineFiles, errors);
|
||||
}, baselineOpts);
|
||||
});
|
||||
|
|
|
@ -89,8 +89,6 @@ namespace ts {
|
|||
"c:/dev/g.min.js/.g/g.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);
|
||||
|
@ -98,6 +96,23 @@ namespace ts {
|
|||
}
|
||||
|
||||
describe("matchFiles", () => {
|
||||
it("with defaults", () => {
|
||||
const json = {};
|
||||
const expected: ts.ParsedCommandLine = {
|
||||
options: {},
|
||||
errors: [],
|
||||
fileNames: [
|
||||
"c:/dev/a.ts",
|
||||
"c:/dev/b.ts"
|
||||
],
|
||||
wildcardDirectories: {
|
||||
"c:/dev": ts.WatchDirectoryFlags.Recursive
|
||||
},
|
||||
};
|
||||
const actual = ts.parseJsonConfigFileContent(json, caseInsensitiveCommonFoldersHost, caseInsensitiveBasePath);
|
||||
assertParsed(actual, expected);
|
||||
});
|
||||
|
||||
describe("with literal file list", () => {
|
||||
it("without exclusions", () => {
|
||||
const json = {
|
||||
|
@ -192,7 +207,7 @@ namespace ts {
|
|||
options: {},
|
||||
errors: [
|
||||
ts.createCompilerDiagnostic(ts.Diagnostics.No_inputs_were_found_in_config_file_0_Specified_include_paths_were_1_and_exclude_paths_were_2,
|
||||
caseInsensitiveTsconfigPath, JSON.stringify(json.include), JSON.stringify(defaultExcludes))
|
||||
caseInsensitiveTsconfigPath, JSON.stringify(json.include), "[]")
|
||||
],
|
||||
fileNames: [],
|
||||
wildcardDirectories: {},
|
||||
|
@ -211,7 +226,7 @@ namespace ts {
|
|||
options: {},
|
||||
errors: [
|
||||
ts.createCompilerDiagnostic(ts.Diagnostics.No_inputs_were_found_in_config_file_0_Specified_include_paths_were_1_and_exclude_paths_were_2,
|
||||
caseInsensitiveTsconfigPath, JSON.stringify(json.include), JSON.stringify(defaultExcludes))
|
||||
caseInsensitiveTsconfigPath, JSON.stringify(json.include), "[]")
|
||||
],
|
||||
fileNames: [],
|
||||
wildcardDirectories: {},
|
||||
|
@ -330,7 +345,10 @@ namespace ts {
|
|||
errors: [],
|
||||
fileNames: [
|
||||
"c:/dev/a.ts",
|
||||
"c:/dev/b.ts"
|
||||
"c:/dev/b.ts",
|
||||
"c:/dev/bower_components/a.ts",
|
||||
"c:/dev/jspm_packages/a.ts",
|
||||
"c:/dev/node_modules/a.ts"
|
||||
],
|
||||
wildcardDirectories: {},
|
||||
};
|
||||
|
@ -372,8 +390,7 @@ namespace ts {
|
|||
"node_modules/a.ts",
|
||||
"bower_components/a.ts",
|
||||
"jspm_packages/a.ts"
|
||||
],
|
||||
exclude: <string[]>[]
|
||||
]
|
||||
};
|
||||
const expected: ts.ParsedCommandLine = {
|
||||
options: {},
|
||||
|
@ -530,7 +547,7 @@ namespace ts {
|
|||
options: {},
|
||||
errors: [
|
||||
ts.createCompilerDiagnostic(ts.Diagnostics.No_inputs_were_found_in_config_file_0_Specified_include_paths_were_1_and_exclude_paths_were_2,
|
||||
caseInsensitiveTsconfigPath, JSON.stringify(json.include), JSON.stringify(defaultExcludes))
|
||||
caseInsensitiveTsconfigPath, JSON.stringify(json.include), "[]")
|
||||
],
|
||||
fileNames: [],
|
||||
wildcardDirectories: {
|
||||
|
@ -600,7 +617,10 @@ namespace ts {
|
|||
options: {},
|
||||
errors: [],
|
||||
fileNames: [
|
||||
"c:/dev/a.ts"
|
||||
"c:/dev/a.ts",
|
||||
"c:/dev/bower_components/a.ts",
|
||||
"c:/dev/jspm_packages/a.ts",
|
||||
"c:/dev/node_modules/a.ts"
|
||||
],
|
||||
wildcardDirectories: {
|
||||
"c:/dev": ts.WatchDirectoryFlags.Recursive
|
||||
|
@ -671,7 +691,7 @@ namespace ts {
|
|||
},
|
||||
errors: [
|
||||
ts.createCompilerDiagnostic(ts.Diagnostics.No_inputs_were_found_in_config_file_0_Specified_include_paths_were_1_and_exclude_paths_were_2,
|
||||
caseInsensitiveTsconfigPath, JSON.stringify(json.include), JSON.stringify(defaultExcludes))
|
||||
caseInsensitiveTsconfigPath, JSON.stringify(json.include), "[]")
|
||||
],
|
||||
fileNames: [],
|
||||
wildcardDirectories: {
|
||||
|
@ -980,7 +1000,7 @@ namespace ts {
|
|||
errors: [
|
||||
ts.createCompilerDiagnostic(ts.Diagnostics.File_specification_cannot_end_in_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0, "**"),
|
||||
ts.createCompilerDiagnostic(ts.Diagnostics.No_inputs_were_found_in_config_file_0_Specified_include_paths_were_1_and_exclude_paths_were_2,
|
||||
caseInsensitiveTsconfigPath, JSON.stringify(json.include), JSON.stringify(defaultExcludes))
|
||||
caseInsensitiveTsconfigPath, JSON.stringify(json.include), "[]")
|
||||
],
|
||||
fileNames: [],
|
||||
wildcardDirectories: {}
|
||||
|
@ -1022,7 +1042,7 @@ namespace ts {
|
|||
errors: [
|
||||
ts.createCompilerDiagnostic(ts.Diagnostics.File_specification_cannot_contain_multiple_recursive_directory_wildcards_Asterisk_Asterisk_Colon_0, "**/x/**/*"),
|
||||
ts.createCompilerDiagnostic(ts.Diagnostics.No_inputs_were_found_in_config_file_0_Specified_include_paths_were_1_and_exclude_paths_were_2,
|
||||
caseInsensitiveTsconfigPath, JSON.stringify(json.include), JSON.stringify(defaultExcludes))
|
||||
caseInsensitiveTsconfigPath, JSON.stringify(json.include), "[]")
|
||||
],
|
||||
fileNames: [],
|
||||
wildcardDirectories: {}
|
||||
|
@ -1071,7 +1091,7 @@ namespace ts {
|
|||
errors: [
|
||||
ts.createCompilerDiagnostic(ts.Diagnostics.File_specification_cannot_contain_a_parent_directory_that_appears_after_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0, "**/../*"),
|
||||
ts.createCompilerDiagnostic(ts.Diagnostics.No_inputs_were_found_in_config_file_0_Specified_include_paths_were_1_and_exclude_paths_were_2,
|
||||
caseInsensitiveTsconfigPath, JSON.stringify(json.include), JSON.stringify(defaultExcludes))
|
||||
caseInsensitiveTsconfigPath, JSON.stringify(json.include), "[]")
|
||||
],
|
||||
fileNames: [],
|
||||
wildcardDirectories: {}
|
||||
|
@ -1091,7 +1111,7 @@ namespace ts {
|
|||
errors: [
|
||||
ts.createCompilerDiagnostic(ts.Diagnostics.File_specification_cannot_contain_a_parent_directory_that_appears_after_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0, "**/y/../*"),
|
||||
ts.createCompilerDiagnostic(ts.Diagnostics.No_inputs_were_found_in_config_file_0_Specified_include_paths_were_1_and_exclude_paths_were_2,
|
||||
caseInsensitiveTsconfigPath, JSON.stringify(json.include), JSON.stringify(defaultExcludes))
|
||||
caseInsensitiveTsconfigPath, JSON.stringify(json.include), "[]")
|
||||
],
|
||||
fileNames: [],
|
||||
wildcardDirectories: {}
|
||||
|
|
2
src/lib/es5.d.ts
vendored
2
src/lib/es5.d.ts
vendored
|
@ -1367,7 +1367,7 @@ type Pick<T, K extends keyof T> = {
|
|||
/**
|
||||
* Construct a type with a set of properties K of type T
|
||||
*/
|
||||
type Record<K extends string | number, T> = {
|
||||
type Record<K extends string, T> = {
|
||||
[P in K]: T;
|
||||
}
|
||||
|
||||
|
|
|
@ -31,6 +31,7 @@ namespace ts.server {
|
|||
os.tmpdir();
|
||||
break;
|
||||
case "linux":
|
||||
case "android":
|
||||
basePath = (os.homedir && os.homedir()) ||
|
||||
process.env.HOME ||
|
||||
((process.env.LOGNAME || process.env.USER) && `/home/${process.env.LOGNAME || process.env.USER}`) ||
|
||||
|
@ -603,4 +604,4 @@ namespace ts.server {
|
|||
(process as any).noAsar = true;
|
||||
// Start listening
|
||||
ioSession.listen();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// /* @internal */
|
||||
// /* @internal */
|
||||
// namespace ts.codefix {
|
||||
|
||||
// type ImportCodeActionKind = "CodeChange" | "InsertingIntoExistingImport" | "NewImport";
|
||||
|
@ -145,7 +145,7 @@
|
|||
// if (localSymbol && localSymbol.name === name && checkSymbolHasMeaning(localSymbol, currentTokenMeaning)) {
|
||||
// // check if this symbol is already used
|
||||
// const symbolId = getUniqueSymbolId(localSymbol);
|
||||
// symbolIdActionMap.addActions(symbolId, getCodeActionForImport(moduleSymbol, /*isDefaultExport*/ true));
|
||||
// symbolIdActionMap.addActions(symbolId, getCodeActionForImport(moduleSymbol, /*isDefault*/ true));
|
||||
// }
|
||||
// }
|
||||
|
||||
|
@ -483,7 +483,7 @@
|
|||
// const normalizedTypeRoots = map(typeRoots, typeRoot => toPath(typeRoot, /*basePath*/ undefined, getCanonicalFileName));
|
||||
// for (const typeRoot of normalizedTypeRoots) {
|
||||
// if (startsWith(moduleFileName, typeRoot)) {
|
||||
// let relativeFileName = moduleFileName.substring(typeRoot.length + 1);
|
||||
// const relativeFileName = moduleFileName.substring(typeRoot.length + 1);
|
||||
// return removeExtensionAndIndexPostFix(relativeFileName);
|
||||
// }
|
||||
// }
|
||||
|
@ -588,4 +588,4 @@
|
|||
// }
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
// }
|
|
@ -52,7 +52,7 @@ namespace ts.JsDoc {
|
|||
// from Array<T> - Array<string> and Array<number>
|
||||
const documentationComment = <SymbolDisplayPart[]>[];
|
||||
forEachUnique(declarations, declaration => {
|
||||
const comments = getJSDocComments(declaration, /*checkParentVariableStatement*/ true);
|
||||
const comments = getCommentsFromJSDoc(declaration);
|
||||
if (!comments) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -225,8 +225,8 @@ namespace ts.NavigationBar {
|
|||
break;
|
||||
|
||||
default:
|
||||
forEach(node.jsDocComments, jsDocComment => {
|
||||
forEach(jsDocComment.tags, tag => {
|
||||
forEach(node.jsDoc, jsDoc => {
|
||||
forEach(jsDoc.tags, tag => {
|
||||
if (tag.kind === SyntaxKind.JSDocTypedefTag) {
|
||||
addLeafNode(tag);
|
||||
}
|
||||
|
|
|
@ -45,7 +45,7 @@ namespace ts {
|
|||
public end: number;
|
||||
public flags: NodeFlags;
|
||||
public parent: Node;
|
||||
public jsDocComments: JSDoc[];
|
||||
public jsDoc: JSDoc[];
|
||||
public original: Node;
|
||||
public transformFlags: TransformFlags;
|
||||
private _children: Node[];
|
||||
|
@ -154,8 +154,8 @@ namespace ts {
|
|||
pos = nodes.end;
|
||||
};
|
||||
// jsDocComments need to be the first children
|
||||
if (this.jsDocComments) {
|
||||
for (const jsDocComment of this.jsDocComments) {
|
||||
if (this.jsDoc) {
|
||||
for (const jsDocComment of this.jsDoc) {
|
||||
processNode(jsDocComment);
|
||||
}
|
||||
}
|
||||
|
@ -1975,9 +1975,9 @@ namespace ts {
|
|||
break;
|
||||
default:
|
||||
forEachChild(node, walk);
|
||||
if (node.jsDocComments) {
|
||||
for (const jsDocComment of node.jsDocComments) {
|
||||
forEachChild(jsDocComment, walk);
|
||||
if (node.jsDoc) {
|
||||
for (const jsDoc of node.jsDoc) {
|
||||
forEachChild(jsDoc, walk);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -951,10 +951,10 @@ namespace ts {
|
|||
}
|
||||
|
||||
if (node) {
|
||||
if (node.jsDocComments) {
|
||||
for (const jsDocComment of node.jsDocComments) {
|
||||
if (jsDocComment.tags) {
|
||||
for (const tag of jsDocComment.tags) {
|
||||
if (node.jsDoc) {
|
||||
for (const jsDoc of node.jsDoc) {
|
||||
if (jsDoc.tags) {
|
||||
for (const tag of jsDoc.tags) {
|
||||
if (tag.pos <= position && position <= tag.end) {
|
||||
return tag;
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@ var C = (function () {
|
|||
set: function () {
|
||||
var v = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
v[_i - 0] = arguments[_i];
|
||||
v[_i] = arguments[_i];
|
||||
}
|
||||
},
|
||||
enumerable: true,
|
||||
|
@ -23,7 +23,7 @@ var C = (function () {
|
|||
set: function () {
|
||||
var v2 = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
v2[_i - 0] = arguments[_i];
|
||||
v2[_i] = arguments[_i];
|
||||
}
|
||||
},
|
||||
enumerable: true,
|
||||
|
|
|
@ -52,14 +52,14 @@ a = function () { return 1; }; // ok, same number of required params
|
|||
a = function () {
|
||||
var args = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
args[_i - 0] = arguments[_i];
|
||||
args[_i] = arguments[_i];
|
||||
}
|
||||
return 1;
|
||||
}; // ok, same number of required params
|
||||
a = function () {
|
||||
var args = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
args[_i - 0] = arguments[_i];
|
||||
args[_i] = arguments[_i];
|
||||
}
|
||||
return 1;
|
||||
}; // error, type mismatch
|
||||
|
@ -72,7 +72,7 @@ a2 = function () { return 1; }; // ok, fewer required params
|
|||
a2 = function () {
|
||||
var args = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
args[_i - 0] = arguments[_i];
|
||||
args[_i] = arguments[_i];
|
||||
}
|
||||
return 1;
|
||||
}; // ok, fewer required params
|
||||
|
|
|
@ -23,7 +23,7 @@ var Derived2 = (function () {
|
|||
Derived2.prototype.method = function () {
|
||||
var args = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
args[_i - 0] = arguments[_i];
|
||||
args[_i] = arguments[_i];
|
||||
}
|
||||
};
|
||||
return Derived2;
|
||||
|
|
|
@ -17,7 +17,7 @@ var Based = (function () {
|
|||
function Based() {
|
||||
var arg = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
arg[_i - 0] = arguments[_i];
|
||||
arg[_i] = arguments[_i];
|
||||
}
|
||||
}
|
||||
return Based;
|
||||
|
|
|
@ -20,7 +20,7 @@ var Base = (function () {
|
|||
function Base() {
|
||||
var arg = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
arg[_i - 0] = arguments[_i];
|
||||
arg[_i] = arguments[_i];
|
||||
}
|
||||
}
|
||||
return Base;
|
||||
|
|
|
@ -20,7 +20,7 @@ var Base = (function () {
|
|||
function Base() {
|
||||
var arg = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
arg[_i - 0] = arguments[_i];
|
||||
arg[_i] = arguments[_i];
|
||||
}
|
||||
}
|
||||
return Base;
|
||||
|
|
|
@ -37,7 +37,7 @@ var f1NoError = function (arguments) {
|
|||
var f2 = function () {
|
||||
var restParameters = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
restParameters[_i - 0] = arguments[_i];
|
||||
restParameters[_i] = arguments[_i];
|
||||
}
|
||||
var arguments = 10; // No Error
|
||||
};
|
||||
|
|
|
@ -118,7 +118,7 @@ var c2 = (function () {
|
|||
function c2() {
|
||||
var restParameters = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
restParameters[_i - 0] = arguments[_i];
|
||||
restParameters[_i] = arguments[_i];
|
||||
}
|
||||
var arguments = 10; // no error
|
||||
}
|
||||
|
|
|
@ -94,7 +94,7 @@ var c3 = (function () {
|
|||
c3.prototype.foo = function () {
|
||||
var restParameters = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
restParameters[_i - 0] = arguments[_i];
|
||||
restParameters[_i] = arguments[_i];
|
||||
}
|
||||
var arguments = 10; // no error
|
||||
};
|
||||
|
|
|
@ -66,7 +66,7 @@ function f1NoError(arguments) {
|
|||
function f3() {
|
||||
var restParameters = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
restParameters[_i - 0] = arguments[_i];
|
||||
restParameters[_i] = arguments[_i];
|
||||
}
|
||||
var arguments = 10; // no error
|
||||
}
|
||||
|
|
|
@ -56,7 +56,7 @@ function foo() {
|
|||
function f3() {
|
||||
var restParameters = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
restParameters[_i - 0] = arguments[_i];
|
||||
restParameters[_i] = arguments[_i];
|
||||
}
|
||||
var arguments = 10; // no error
|
||||
}
|
||||
|
|
|
@ -27,7 +27,7 @@ var f1NoError = function (_i) {
|
|||
var f2 = function () {
|
||||
var restParameters = [];
|
||||
for (var _a = 0; _a < arguments.length; _a++) {
|
||||
restParameters[_a - 0] = arguments[_a];
|
||||
restParameters[_a] = arguments[_a];
|
||||
}
|
||||
var _i = 10; // No Error
|
||||
};
|
||||
|
|
|
@ -88,7 +88,7 @@ var c2 = (function () {
|
|||
function c2() {
|
||||
var restParameters = [];
|
||||
for (var _a = 0; _a < arguments.length; _a++) {
|
||||
restParameters[_a - 0] = arguments[_a];
|
||||
restParameters[_a] = arguments[_a];
|
||||
}
|
||||
var _i = 10; // no error
|
||||
}
|
||||
|
|
|
@ -70,7 +70,7 @@ var c3 = (function () {
|
|||
c3.prototype.foo = function () {
|
||||
var restParameters = [];
|
||||
for (var _a = 0; _a < arguments.length; _a++) {
|
||||
restParameters[_a - 0] = arguments[_a];
|
||||
restParameters[_a] = arguments[_a];
|
||||
}
|
||||
var _i = 10; // no error
|
||||
};
|
||||
|
|
|
@ -48,7 +48,7 @@ function f1NoError(_i) {
|
|||
function f3() {
|
||||
var restParameters = [];
|
||||
for (var _a = 0; _a < arguments.length; _a++) {
|
||||
restParameters[_a - 0] = arguments[_a];
|
||||
restParameters[_a] = arguments[_a];
|
||||
}
|
||||
var _i = 10; // no error
|
||||
}
|
||||
|
|
|
@ -39,7 +39,7 @@ function foo() {
|
|||
function f3() {
|
||||
var restParameters = [];
|
||||
for (var _a = 0; _a < arguments.length; _a++) {
|
||||
restParameters[_a - 0] = arguments[_a];
|
||||
restParameters[_a] = arguments[_a];
|
||||
}
|
||||
var _i = 10; // no error
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@ var Foo = (function () {
|
|||
function Foo() {
|
||||
var args = [];
|
||||
for (var _a = 0; _a < arguments.length; _a++) {
|
||||
args[_a - 0] = arguments[_a];
|
||||
args[_a] = arguments[_a];
|
||||
}
|
||||
console.log(_i); // This should result in error
|
||||
}
|
||||
|
|
|
@ -297,7 +297,7 @@ var TypeScriptAllInOne;
|
|||
Program.Main = function () {
|
||||
var args = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
args[_i - 0] = arguments[_i];
|
||||
args[_i] = arguments[_i];
|
||||
}
|
||||
try {
|
||||
var bfs = new BasicFeatures();
|
||||
|
|
|
@ -57,21 +57,21 @@ let eleven = (o => o.a(11))({ a: function(n) { return n; } });
|
|||
(function () {
|
||||
var numbers = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
numbers[_i - 0] = arguments[_i];
|
||||
numbers[_i] = arguments[_i];
|
||||
}
|
||||
return numbers.every(function (n) { return n > 0; });
|
||||
})(5, 6, 7);
|
||||
(function () {
|
||||
var mixed = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
mixed[_i - 0] = arguments[_i];
|
||||
mixed[_i] = arguments[_i];
|
||||
}
|
||||
return mixed.every(function (n) { return !!n; });
|
||||
})(5, 'oops', 'oh no');
|
||||
(function () {
|
||||
var noNumbers = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
noNumbers[_i - 0] = arguments[_i];
|
||||
noNumbers[_i] = arguments[_i];
|
||||
}
|
||||
return noNumbers.some(function (n) { return n > 0; });
|
||||
})();
|
||||
|
|
|
@ -11,7 +11,7 @@ var x: (...y: string[]) => void = function (.../*3*/y) {
|
|||
var x = function () {
|
||||
var y = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
y[_i - 0] = arguments[_i];
|
||||
y[_i] = arguments[_i];
|
||||
}
|
||||
var t = y;
|
||||
var x2 = t; // This should be error
|
||||
|
|
|
@ -14,7 +14,7 @@ var f6 = () => { return [<any>10]; }
|
|||
function f1() {
|
||||
var args = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
args[_i - 0] = arguments[_i];
|
||||
args[_i] = arguments[_i];
|
||||
}
|
||||
}
|
||||
function f2(x) { }
|
||||
|
|
|
@ -13,13 +13,13 @@ function foo2(...rest: any[]) {
|
|||
function foo() {
|
||||
var rest = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
rest[_i - 0] = arguments[_i];
|
||||
rest[_i] = arguments[_i];
|
||||
}
|
||||
}
|
||||
function foo2() {
|
||||
var rest = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
rest[_i - 0] = arguments[_i];
|
||||
rest[_i] = arguments[_i];
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ export default function f(...args: any[]) {
|
|||
function f() {
|
||||
var args = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
args[_i - 0] = arguments[_i];
|
||||
args[_i] = arguments[_i];
|
||||
}
|
||||
}
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
|
|
|
@ -43,31 +43,31 @@ foo1(1, 2, "string", E1.a, E.b); // Error
|
|||
function a0() {
|
||||
var x = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
x[_i - 0] = arguments[_i];
|
||||
x[_i] = arguments[_i];
|
||||
}
|
||||
} // Error, rest parameter must be array type
|
||||
function a1() {
|
||||
var x = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
x[_i - 0] = arguments[_i];
|
||||
x[_i] = arguments[_i];
|
||||
}
|
||||
}
|
||||
function a2() {
|
||||
var a = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
a[_i - 0] = arguments[_i];
|
||||
a[_i] = arguments[_i];
|
||||
}
|
||||
} // Error, rest parameter must be array type
|
||||
function a3() {
|
||||
var b = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
b[_i - 0] = arguments[_i];
|
||||
b[_i] = arguments[_i];
|
||||
}
|
||||
} // Error, can't be optional
|
||||
function a4() {
|
||||
var b = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
b[_i - 0] = arguments[_i];
|
||||
b[_i] = arguments[_i];
|
||||
}
|
||||
} // Error, can't have initializer
|
||||
function a5(_a) {
|
||||
|
@ -86,7 +86,7 @@ var C = (function () {
|
|||
function C() {
|
||||
var temp = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
temp[_i - 0] = arguments[_i];
|
||||
temp[_i] = arguments[_i];
|
||||
}
|
||||
this.temp = temp;
|
||||
} // Error, rest parameter can't have properties
|
||||
|
@ -96,7 +96,7 @@ var C = (function () {
|
|||
function foo1() {
|
||||
var a = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
a[_i - 0] = arguments[_i];
|
||||
a[_i] = arguments[_i];
|
||||
}
|
||||
}
|
||||
foo1(1, 2, "string", E1.a, E.b); // Error
|
||||
|
|
|
@ -40,20 +40,20 @@ while (, )
|
|||
function a5() {
|
||||
var = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
[_i - 0] = arguments[_i];
|
||||
[_i] = arguments[_i];
|
||||
}
|
||||
}
|
||||
while () { }
|
||||
function a6() {
|
||||
var public = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
public[_i - 0] = arguments[_i];
|
||||
public[_i] = arguments[_i];
|
||||
}
|
||||
}
|
||||
function a7() {
|
||||
var a = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
a[_i - 0] = arguments[_i];
|
||||
a[_i] = arguments[_i];
|
||||
}
|
||||
}
|
||||
a({ "while": 1 });
|
||||
|
|
|
@ -19,7 +19,7 @@ var TestFile = (function () {
|
|||
return function () {
|
||||
var x = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
x[_i - 0] = arguments[_i];
|
||||
x[_i] = arguments[_i];
|
||||
}
|
||||
/// <summary>Test summary</summary>
|
||||
/// <param name="message" type="String" />
|
||||
|
|
|
@ -23,7 +23,7 @@ var TestFile = (function () {
|
|||
/// <returns type="Function" />
|
||||
var x = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
x[_i - 0] = arguments[_i];
|
||||
x[_i] = arguments[_i];
|
||||
}
|
||||
return message + _this.name;
|
||||
};
|
||||
|
|
|
@ -92,13 +92,13 @@ var f4 = function (x, y) {
|
|||
var f5 = function () {
|
||||
var rest = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
rest[_i - 0] = arguments[_i];
|
||||
rest[_i] = arguments[_i];
|
||||
}
|
||||
};
|
||||
var f6 = function () {
|
||||
var rest = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
rest[_i - 0] = arguments[_i];
|
||||
rest[_i] = arguments[_i];
|
||||
}
|
||||
};
|
||||
var f7 = function (x, y, z) {
|
||||
|
|
|
@ -32,13 +32,13 @@ var A = (function () {
|
|||
function A() {
|
||||
var args = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
args[_i - 0] = arguments[_i];
|
||||
args[_i] = arguments[_i];
|
||||
}
|
||||
}
|
||||
A.prototype.method = function () {
|
||||
var args = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
args[_i - 0] = arguments[_i];
|
||||
args[_i] = arguments[_i];
|
||||
}
|
||||
};
|
||||
return A;
|
||||
|
@ -57,13 +57,13 @@ var B = (function () {
|
|||
function B() {
|
||||
var args = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
args[_i - 0] = arguments[_i];
|
||||
args[_i] = arguments[_i];
|
||||
}
|
||||
}
|
||||
B.prototype.method = function () {
|
||||
var args = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
args[_i - 0] = arguments[_i];
|
||||
args[_i] = arguments[_i];
|
||||
}
|
||||
};
|
||||
return B;
|
||||
|
|
|
@ -6,7 +6,7 @@ function foo(x: number, y: string, ...rest) { }
|
|||
function bar() {
|
||||
var rest = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
rest[_i - 0] = arguments[_i];
|
||||
rest[_i] = arguments[_i];
|
||||
}
|
||||
}
|
||||
function foo(x, y) {
|
||||
|
|
|
@ -9,7 +9,7 @@ var funcExp3 = (function (...rest) { })()
|
|||
var funcExp = function () {
|
||||
var rest = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
rest[_i - 0] = arguments[_i];
|
||||
rest[_i] = arguments[_i];
|
||||
}
|
||||
};
|
||||
var funcExp1 = function (X) {
|
||||
|
@ -21,12 +21,12 @@ var funcExp1 = function (X) {
|
|||
var funcExp2 = function () {
|
||||
var rest = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
rest[_i - 0] = arguments[_i];
|
||||
rest[_i] = arguments[_i];
|
||||
}
|
||||
};
|
||||
var funcExp3 = (function () {
|
||||
var rest = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
rest[_i - 0] = arguments[_i];
|
||||
rest[_i] = arguments[_i];
|
||||
}
|
||||
})();
|
||||
|
|
|
@ -13,7 +13,7 @@ var obj2 = {
|
|||
func: function () {
|
||||
var rest = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
rest[_i - 0] = arguments[_i];
|
||||
rest[_i] = arguments[_i];
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
@ -24,7 +24,7 @@ var C = (function () {
|
|||
C.prototype.bar = function () {
|
||||
var rest = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
rest[_i - 0] = arguments[_i];
|
||||
rest[_i] = arguments[_i];
|
||||
}
|
||||
};
|
||||
C.prototype.foo = function (x) {
|
||||
|
@ -39,13 +39,13 @@ var D = (function () {
|
|||
function D() {
|
||||
var rest = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
rest[_i - 0] = arguments[_i];
|
||||
rest[_i] = arguments[_i];
|
||||
}
|
||||
}
|
||||
D.prototype.bar = function () {
|
||||
var rest = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
rest[_i - 0] = arguments[_i];
|
||||
rest[_i] = arguments[_i];
|
||||
}
|
||||
};
|
||||
D.prototype.foo = function (x) {
|
||||
|
|
|
@ -11,7 +11,7 @@ function rebase(fn) {
|
|||
return function () {
|
||||
var args = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
args[_i - 0] = arguments[_i];
|
||||
args[_i] = arguments[_i];
|
||||
}
|
||||
return fn.apply(this, [this].concat(args));
|
||||
};
|
||||
|
|
|
@ -236,7 +236,7 @@ var SplatMonster = (function () {
|
|||
function SplatMonster() {
|
||||
var args = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
args[_i - 0] = arguments[_i];
|
||||
args[_i] = arguments[_i];
|
||||
}
|
||||
}
|
||||
SplatMonster.prototype.roar = function (name) {
|
||||
|
|
|
@ -17,7 +17,7 @@ export function f1(d) {
|
|||
export function f2() {
|
||||
var arg = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
arg[_i - 0] = arguments[_i];
|
||||
arg[_i] = arguments[_i];
|
||||
}
|
||||
}
|
||||
export default function f3(d) {
|
||||
|
|
|
@ -16,7 +16,7 @@ var x4= (...a: any[]) { };
|
|||
foo(function () {
|
||||
var Far = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
Far[_i - 0] = arguments[_i];
|
||||
Far[_i] = arguments[_i];
|
||||
}
|
||||
return 0;
|
||||
});
|
||||
|
@ -36,6 +36,6 @@ var x3 = function (a) { };
|
|||
var x4 = function () {
|
||||
var a = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
a[_i - 0] = arguments[_i];
|
||||
a[_i] = arguments[_i];
|
||||
}
|
||||
};
|
||||
|
|
|
@ -159,7 +159,7 @@ foo(
|
|||
(function () {
|
||||
var arg = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
arg[_i - 0] = arguments[_i];
|
||||
arg[_i] = arguments[_i];
|
||||
}
|
||||
return 8;
|
||||
});
|
||||
|
@ -203,7 +203,7 @@ foo(
|
|||
(function () {
|
||||
var arg = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
arg[_i - 0] = arguments[_i];
|
||||
arg[_i] = arguments[_i];
|
||||
}
|
||||
return 28;
|
||||
});
|
||||
|
@ -226,7 +226,7 @@ false ? function (arg) {
|
|||
false ? function () {
|
||||
var arg = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
arg[_i - 0] = arguments[_i];
|
||||
arg[_i] = arguments[_i];
|
||||
}
|
||||
return 48;
|
||||
} : null;
|
||||
|
@ -247,7 +247,7 @@ false ? (function (arg) {
|
|||
false ? (function () {
|
||||
var arg = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
arg[_i - 0] = arguments[_i];
|
||||
arg[_i] = arguments[_i];
|
||||
}
|
||||
return 58;
|
||||
}) : null;
|
||||
|
@ -268,7 +268,7 @@ false ? null : function (arg) {
|
|||
false ? null : function () {
|
||||
var arg = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
arg[_i - 0] = arguments[_i];
|
||||
arg[_i] = arguments[_i];
|
||||
}
|
||||
return 68;
|
||||
};
|
||||
|
@ -294,7 +294,7 @@ false ? null : function () {
|
|||
(function () {
|
||||
var arg = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
arg[_i - 0] = arguments[_i];
|
||||
arg[_i] = arguments[_i];
|
||||
}
|
||||
return 96;
|
||||
}) instanceof Function;
|
||||
|
@ -326,13 +326,13 @@ false ? null : function () {
|
|||
(function () {
|
||||
var arg = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
arg[_i - 0] = arguments[_i];
|
||||
arg[_i] = arguments[_i];
|
||||
}
|
||||
return 0;
|
||||
}) + '' + (function () {
|
||||
var arg = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
arg[_i - 0] = arguments[_i];
|
||||
arg[_i] = arguments[_i];
|
||||
}
|
||||
return 107;
|
||||
});
|
||||
|
@ -354,7 +354,7 @@ false ? null : function () {
|
|||
function foo() {
|
||||
var arg = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
arg[_i - 0] = arguments[_i];
|
||||
arg[_i] = arguments[_i];
|
||||
}
|
||||
}
|
||||
foo(function (a) { return 110; }, (function (a) { return 111; }), function (a) {
|
||||
|
@ -371,7 +371,7 @@ foo(function (a) { return 110; }, (function (a) { return 111; }), function (a) {
|
|||
}, function () {
|
||||
var a = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
a[_i - 0] = arguments[_i];
|
||||
a[_i] = arguments[_i];
|
||||
}
|
||||
return 119;
|
||||
}, function (a, b) {
|
||||
|
|
|
@ -12,21 +12,21 @@
|
|||
(function () {
|
||||
var arg = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
arg[_i - 0] = arguments[_i];
|
||||
arg[_i] = arguments[_i];
|
||||
}
|
||||
return 102;
|
||||
});
|
||||
(function () {
|
||||
var arg = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
arg[_i - 0] = arguments[_i];
|
||||
arg[_i] = arguments[_i];
|
||||
}
|
||||
return 103;
|
||||
});
|
||||
(function () {
|
||||
var arg = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
arg[_i - 0] = arguments[_i];
|
||||
arg[_i] = arguments[_i];
|
||||
}
|
||||
return 104;
|
||||
});
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
(function () {
|
||||
var = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
[_i - 0] = arguments[_i];
|
||||
[_i] = arguments[_i];
|
||||
}
|
||||
return 105;
|
||||
});
|
||||
|
|
|
@ -56,7 +56,7 @@ foo(function (a) { return 110; }, (function (a) { return 111; }), function (a) {
|
|||
}, function () {
|
||||
var a = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
a[_i - 0] = arguments[_i];
|
||||
a[_i] = arguments[_i];
|
||||
}
|
||||
return 119;
|
||||
}, function (a, b) {
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
tests/cases/conformance/statements/for-inStatements/for-inStatements.ts(33,18): error TS2403: Subsequent variable declarations must have the same type. Variable 'x' must be of type 'string', but here has type 'keyof this'.
|
||||
tests/cases/conformance/statements/for-inStatements/for-inStatements.ts(50,18): error TS2403: Subsequent variable declarations must have the same type. Variable 'x' must be of type 'string', but here has type 'keyof this'.
|
||||
tests/cases/conformance/statements/for-inStatements/for-inStatements.ts(79,15): error TS2407: The right-hand side of a 'for...in' statement must be of type 'any', an object type or a type parameter.
|
||||
|
||||
|
||||
==== tests/cases/conformance/statements/for-inStatements/for-inStatements.ts (1 errors) ====
|
||||
==== tests/cases/conformance/statements/for-inStatements/for-inStatements.ts (3 errors) ====
|
||||
var aString: string;
|
||||
for (aString in {}) { }
|
||||
|
||||
|
@ -35,6 +37,8 @@ tests/cases/conformance/statements/for-inStatements/for-inStatements.ts(79,15):
|
|||
for (var x in this.biz()) { }
|
||||
for (var x in this.biz) { }
|
||||
for (var x in this) { }
|
||||
~
|
||||
!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'x' must be of type 'string', but here has type 'keyof this'.
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -52,6 +56,8 @@ tests/cases/conformance/statements/for-inStatements/for-inStatements.ts(79,15):
|
|||
for (var x in this.biz()) { }
|
||||
for (var x in this.biz) { }
|
||||
for (var x in this) { }
|
||||
~
|
||||
!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'x' must be of type 'string', but here has type 'keyof this'.
|
||||
|
||||
for (var x in super.biz) { }
|
||||
for (var x in super.biz()) { }
|
||||
|
|
|
@ -9,13 +9,15 @@ tests/cases/conformance/statements/for-inStatements/for-inStatementsInvalid.ts(1
|
|||
tests/cases/conformance/statements/for-inStatements/for-inStatementsInvalid.ts(20,15): error TS2407: The right-hand side of a 'for...in' statement must be of type 'any', an object type or a type parameter.
|
||||
tests/cases/conformance/statements/for-inStatements/for-inStatementsInvalid.ts(22,15): error TS2407: The right-hand side of a 'for...in' statement must be of type 'any', an object type or a type parameter.
|
||||
tests/cases/conformance/statements/for-inStatements/for-inStatementsInvalid.ts(29,23): error TS2407: The right-hand side of a 'for...in' statement must be of type 'any', an object type or a type parameter.
|
||||
tests/cases/conformance/statements/for-inStatements/for-inStatementsInvalid.ts(31,18): error TS2403: Subsequent variable declarations must have the same type. Variable 'x' must be of type 'string', but here has type 'keyof this'.
|
||||
tests/cases/conformance/statements/for-inStatements/for-inStatementsInvalid.ts(38,23): error TS2407: The right-hand side of a 'for...in' statement must be of type 'any', an object type or a type parameter.
|
||||
tests/cases/conformance/statements/for-inStatements/for-inStatementsInvalid.ts(46,23): error TS2407: The right-hand side of a 'for...in' statement must be of type 'any', an object type or a type parameter.
|
||||
tests/cases/conformance/statements/for-inStatements/for-inStatementsInvalid.ts(48,18): error TS2403: Subsequent variable declarations must have the same type. Variable 'x' must be of type 'string', but here has type 'keyof this'.
|
||||
tests/cases/conformance/statements/for-inStatements/for-inStatementsInvalid.ts(51,23): error TS2407: The right-hand side of a 'for...in' statement must be of type 'any', an object type or a type parameter.
|
||||
tests/cases/conformance/statements/for-inStatements/for-inStatementsInvalid.ts(62,15): error TS2407: The right-hand side of a 'for...in' statement must be of type 'any', an object type or a type parameter.
|
||||
|
||||
|
||||
==== tests/cases/conformance/statements/for-inStatements/for-inStatementsInvalid.ts (15 errors) ====
|
||||
==== tests/cases/conformance/statements/for-inStatements/for-inStatementsInvalid.ts (17 errors) ====
|
||||
var aNumber: number;
|
||||
for (aNumber in {}) { }
|
||||
~~~~~~~
|
||||
|
@ -69,6 +71,8 @@ tests/cases/conformance/statements/for-inStatements/for-inStatementsInvalid.ts(6
|
|||
!!! error TS2407: The right-hand side of a 'for...in' statement must be of type 'any', an object type or a type parameter.
|
||||
for (var x in this.biz) { }
|
||||
for (var x in this) { }
|
||||
~
|
||||
!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'x' must be of type 'string', but here has type 'keyof this'.
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -90,6 +94,8 @@ tests/cases/conformance/statements/for-inStatements/for-inStatementsInvalid.ts(6
|
|||
!!! error TS2407: The right-hand side of a 'for...in' statement must be of type 'any', an object type or a type parameter.
|
||||
for (var x in this.biz) { }
|
||||
for (var x in this) { }
|
||||
~
|
||||
!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'x' must be of type 'string', but here has type 'keyof this'.
|
||||
|
||||
for (var x in super.biz) { }
|
||||
for (var x in super.biz()) { }
|
||||
|
|
|
@ -8,7 +8,7 @@ function F<T>() {
|
|||
>T : T
|
||||
|
||||
for (var a in expr) {
|
||||
>a : string
|
||||
>a : keyof T
|
||||
>expr : T
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@ foo(1, 'bar');
|
|||
function foo() {
|
||||
var a = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
a[_i - 0] = arguments[_i];
|
||||
a[_i] = arguments[_i];
|
||||
}
|
||||
}
|
||||
;
|
||||
|
|
|
@ -28,7 +28,7 @@ var A = (function () {
|
|||
function Choice() {
|
||||
var v_args = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
v_args[_i - 0] = arguments[_i];
|
||||
v_args[_i] = arguments[_i];
|
||||
}
|
||||
return new A();
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@ var a2Gc = makeArrayG<any[]>(1, ""); // error
|
|||
function makeArrayG() {
|
||||
var items = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
items[_i - 0] = arguments[_i];
|
||||
items[_i] = arguments[_i];
|
||||
}
|
||||
return items;
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@ function func2(a, b, c) { }
|
|||
function func3() {
|
||||
var args = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
args[_i - 0] = arguments[_i];
|
||||
args[_i] = arguments[_i];
|
||||
}
|
||||
}
|
||||
; // error at "args"
|
||||
|
|
|
@ -22,7 +22,7 @@ class C {
|
|||
>temp : () => void
|
||||
|
||||
for (var x in this) {
|
||||
>x : string
|
||||
>x : keyof this
|
||||
>this : this
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,7 +9,7 @@ class C<T> {
|
|||
>T : T
|
||||
|
||||
for (var p in x) {
|
||||
>p : string
|
||||
>p : keyof T
|
||||
>x : T
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@ var Base = (function () {
|
|||
function Base() {
|
||||
var a = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
a[_i - 0] = arguments[_i];
|
||||
a[_i] = arguments[_i];
|
||||
}
|
||||
}
|
||||
return Base;
|
||||
|
|
|
@ -95,22 +95,18 @@ function f10(shape: Shape) {
|
|||
|
||||
function f11(a: Shape[]) {
|
||||
let len = getProperty(a, "length"); // number
|
||||
let shape = getProperty(a, 1000); // Shape
|
||||
setProperty(a, 1000, getProperty(a, 1001));
|
||||
setProperty(a, "length", len);
|
||||
}
|
||||
|
||||
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 y = getProperty(foo, "100"); // any
|
||||
let z = getProperty(foo, bar); // any
|
||||
}
|
||||
|
||||
|
@ -181,6 +177,46 @@ function f40(c: C) {
|
|||
let z: Z = c["z"];
|
||||
}
|
||||
|
||||
function f50<T>(k: keyof T, s: string) {
|
||||
const x1 = s as keyof T;
|
||||
const x2 = k as string;
|
||||
}
|
||||
|
||||
function f51<T, K extends keyof T>(k: K, s: string) {
|
||||
const x1 = s as keyof T;
|
||||
const x2 = k as string;
|
||||
}
|
||||
|
||||
function f52<T>(obj: { [x: string]: boolean }, k: keyof T, s: string, n: number) {
|
||||
const x1 = obj[s];
|
||||
const x2 = obj[n];
|
||||
const x3 = obj[k];
|
||||
}
|
||||
|
||||
function f53<T, K extends keyof T>(obj: { [x: string]: boolean }, k: K, s: string, n: number) {
|
||||
const x1 = obj[s];
|
||||
const x2 = obj[n];
|
||||
const x3 = obj[k];
|
||||
}
|
||||
|
||||
function f54<T>(obj: T, key: keyof T) {
|
||||
for (let s in obj[key]) {
|
||||
}
|
||||
const b = "foo" in obj[key];
|
||||
}
|
||||
|
||||
function f55<T, K extends keyof T>(obj: T, key: K) {
|
||||
for (let s in obj[key]) {
|
||||
}
|
||||
const b = "foo" in obj[key];
|
||||
}
|
||||
|
||||
function f60<T>(source: T, target: T) {
|
||||
for (let k in source) {
|
||||
target[k] = source[k];
|
||||
}
|
||||
}
|
||||
|
||||
// Repros from #12011
|
||||
|
||||
class Base {
|
||||
|
@ -257,20 +293,16 @@ function f10(shape) {
|
|||
}
|
||||
function f11(a) {
|
||||
var len = getProperty(a, "length"); // number
|
||||
var shape = getProperty(a, 1000); // Shape
|
||||
setProperty(a, 1000, getProperty(a, 1001));
|
||||
setProperty(a, "length", len);
|
||||
}
|
||||
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 y = getProperty(foo, "100"); // any
|
||||
var z = getProperty(foo, bar); // any
|
||||
}
|
||||
var Component = (function () {
|
||||
|
@ -329,6 +361,39 @@ function f40(c) {
|
|||
var y = c["y"];
|
||||
var z = c["z"];
|
||||
}
|
||||
function f50(k, s) {
|
||||
var x1 = s;
|
||||
var x2 = k;
|
||||
}
|
||||
function f51(k, s) {
|
||||
var x1 = s;
|
||||
var x2 = k;
|
||||
}
|
||||
function f52(obj, k, s, n) {
|
||||
var x1 = obj[s];
|
||||
var x2 = obj[n];
|
||||
var x3 = obj[k];
|
||||
}
|
||||
function f53(obj, k, s, n) {
|
||||
var x1 = obj[s];
|
||||
var x2 = obj[n];
|
||||
var x3 = obj[k];
|
||||
}
|
||||
function f54(obj, key) {
|
||||
for (var s in obj[key]) {
|
||||
}
|
||||
var b = "foo" in obj[key];
|
||||
}
|
||||
function f55(obj, key) {
|
||||
for (var s in obj[key]) {
|
||||
}
|
||||
var b = "foo" in obj[key];
|
||||
}
|
||||
function f60(source, target) {
|
||||
for (var k in source) {
|
||||
target[k] = source[k];
|
||||
}
|
||||
}
|
||||
// Repros from #12011
|
||||
var Base = (function () {
|
||||
function Base() {
|
||||
|
@ -454,6 +519,17 @@ declare class C {
|
|||
private z;
|
||||
}
|
||||
declare function f40(c: C): void;
|
||||
declare function f50<T>(k: keyof T, s: string): void;
|
||||
declare function f51<T, K extends keyof T>(k: K, s: string): void;
|
||||
declare function f52<T>(obj: {
|
||||
[x: string]: boolean;
|
||||
}, k: keyof T, s: string, n: number): void;
|
||||
declare function f53<T, K extends keyof T>(obj: {
|
||||
[x: string]: boolean;
|
||||
}, k: K, s: string, n: number): void;
|
||||
declare function f54<T>(obj: T, key: keyof T): void;
|
||||
declare function f55<T, K extends keyof T>(obj: T, key: K): void;
|
||||
declare function f60<T>(source: T, target: T): void;
|
||||
declare class Base {
|
||||
get<K extends keyof this>(prop: K): this[K];
|
||||
set<K extends keyof this>(prop: K, value: this[K]): void;
|
||||
|
|
|
@ -299,411 +299,540 @@ function f11(a: Shape[]) {
|
|||
>getProperty : Symbol(getProperty, Decl(keyofAndIndexedAccess.ts, 75, 26))
|
||||
>a : Symbol(a, Decl(keyofAndIndexedAccess.ts, 94, 13))
|
||||
|
||||
let shape = getProperty(a, 1000); // Shape
|
||||
>shape : Symbol(shape, Decl(keyofAndIndexedAccess.ts, 96, 7))
|
||||
>getProperty : Symbol(getProperty, Decl(keyofAndIndexedAccess.ts, 75, 26))
|
||||
>a : Symbol(a, Decl(keyofAndIndexedAccess.ts, 94, 13))
|
||||
|
||||
setProperty(a, 1000, getProperty(a, 1001));
|
||||
setProperty(a, "length", len);
|
||||
>setProperty : Symbol(setProperty, Decl(keyofAndIndexedAccess.ts, 79, 1))
|
||||
>a : Symbol(a, Decl(keyofAndIndexedAccess.ts, 94, 13))
|
||||
>getProperty : Symbol(getProperty, Decl(keyofAndIndexedAccess.ts, 75, 26))
|
||||
>a : Symbol(a, Decl(keyofAndIndexedAccess.ts, 94, 13))
|
||||
>len : Symbol(len, Decl(keyofAndIndexedAccess.ts, 95, 7))
|
||||
}
|
||||
|
||||
function f12(t: [Shape, boolean]) {
|
||||
>f12 : Symbol(f12, Decl(keyofAndIndexedAccess.ts, 98, 1))
|
||||
>t : Symbol(t, Decl(keyofAndIndexedAccess.ts, 100, 13))
|
||||
>f12 : Symbol(f12, Decl(keyofAndIndexedAccess.ts, 97, 1))
|
||||
>t : Symbol(t, Decl(keyofAndIndexedAccess.ts, 99, 13))
|
||||
>Shape : Symbol(Shape, Decl(keyofAndIndexedAccess.ts, 0, 0))
|
||||
|
||||
let len = getProperty(t, "length");
|
||||
>len : Symbol(len, Decl(keyofAndIndexedAccess.ts, 101, 7))
|
||||
>len : Symbol(len, Decl(keyofAndIndexedAccess.ts, 100, 7))
|
||||
>getProperty : Symbol(getProperty, Decl(keyofAndIndexedAccess.ts, 75, 26))
|
||||
>t : Symbol(t, Decl(keyofAndIndexedAccess.ts, 100, 13))
|
||||
|
||||
let s1 = getProperty(t, 0); // Shape
|
||||
>s1 : Symbol(s1, Decl(keyofAndIndexedAccess.ts, 102, 7))
|
||||
>getProperty : Symbol(getProperty, Decl(keyofAndIndexedAccess.ts, 75, 26))
|
||||
>t : Symbol(t, Decl(keyofAndIndexedAccess.ts, 100, 13))
|
||||
>t : Symbol(t, Decl(keyofAndIndexedAccess.ts, 99, 13))
|
||||
|
||||
let s2 = getProperty(t, "0"); // Shape
|
||||
>s2 : Symbol(s2, Decl(keyofAndIndexedAccess.ts, 103, 7))
|
||||
>s2 : Symbol(s2, Decl(keyofAndIndexedAccess.ts, 101, 7))
|
||||
>getProperty : Symbol(getProperty, Decl(keyofAndIndexedAccess.ts, 75, 26))
|
||||
>t : Symbol(t, Decl(keyofAndIndexedAccess.ts, 100, 13))
|
||||
|
||||
let b1 = getProperty(t, 1); // boolean
|
||||
>b1 : Symbol(b1, Decl(keyofAndIndexedAccess.ts, 104, 7))
|
||||
>getProperty : Symbol(getProperty, Decl(keyofAndIndexedAccess.ts, 75, 26))
|
||||
>t : Symbol(t, Decl(keyofAndIndexedAccess.ts, 100, 13))
|
||||
>t : Symbol(t, Decl(keyofAndIndexedAccess.ts, 99, 13))
|
||||
|
||||
let b2 = getProperty(t, "1"); // boolean
|
||||
>b2 : Symbol(b2, Decl(keyofAndIndexedAccess.ts, 105, 7))
|
||||
>b2 : Symbol(b2, Decl(keyofAndIndexedAccess.ts, 102, 7))
|
||||
>getProperty : Symbol(getProperty, Decl(keyofAndIndexedAccess.ts, 75, 26))
|
||||
>t : Symbol(t, Decl(keyofAndIndexedAccess.ts, 100, 13))
|
||||
|
||||
let x1 = getProperty(t, 2); // Shape | boolean
|
||||
>x1 : Symbol(x1, Decl(keyofAndIndexedAccess.ts, 106, 7))
|
||||
>getProperty : Symbol(getProperty, Decl(keyofAndIndexedAccess.ts, 75, 26))
|
||||
>t : Symbol(t, Decl(keyofAndIndexedAccess.ts, 100, 13))
|
||||
>t : Symbol(t, Decl(keyofAndIndexedAccess.ts, 99, 13))
|
||||
}
|
||||
|
||||
function f13(foo: any, bar: any) {
|
||||
>f13 : Symbol(f13, Decl(keyofAndIndexedAccess.ts, 107, 1))
|
||||
>foo : Symbol(foo, Decl(keyofAndIndexedAccess.ts, 109, 13))
|
||||
>bar : Symbol(bar, Decl(keyofAndIndexedAccess.ts, 109, 22))
|
||||
>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, 110, 7))
|
||||
>x : Symbol(x, Decl(keyofAndIndexedAccess.ts, 106, 7))
|
||||
>getProperty : Symbol(getProperty, Decl(keyofAndIndexedAccess.ts, 75, 26))
|
||||
>foo : Symbol(foo, Decl(keyofAndIndexedAccess.ts, 109, 13))
|
||||
>foo : Symbol(foo, Decl(keyofAndIndexedAccess.ts, 105, 13))
|
||||
|
||||
let y = getProperty(foo, 100); // any
|
||||
>y : Symbol(y, Decl(keyofAndIndexedAccess.ts, 111, 7))
|
||||
let y = getProperty(foo, "100"); // any
|
||||
>y : Symbol(y, Decl(keyofAndIndexedAccess.ts, 107, 7))
|
||||
>getProperty : Symbol(getProperty, Decl(keyofAndIndexedAccess.ts, 75, 26))
|
||||
>foo : Symbol(foo, Decl(keyofAndIndexedAccess.ts, 109, 13))
|
||||
>foo : Symbol(foo, Decl(keyofAndIndexedAccess.ts, 105, 13))
|
||||
|
||||
let z = getProperty(foo, bar); // any
|
||||
>z : Symbol(z, Decl(keyofAndIndexedAccess.ts, 112, 7))
|
||||
>z : Symbol(z, Decl(keyofAndIndexedAccess.ts, 108, 7))
|
||||
>getProperty : Symbol(getProperty, Decl(keyofAndIndexedAccess.ts, 75, 26))
|
||||
>foo : Symbol(foo, Decl(keyofAndIndexedAccess.ts, 109, 13))
|
||||
>bar : Symbol(bar, Decl(keyofAndIndexedAccess.ts, 109, 22))
|
||||
>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, 113, 1))
|
||||
>PropType : Symbol(PropType, Decl(keyofAndIndexedAccess.ts, 115, 16))
|
||||
>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, 115, 27))
|
||||
>PropType : Symbol(PropType, Decl(keyofAndIndexedAccess.ts, 115, 16))
|
||||
>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, 116, 20))
|
||||
>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 117, 16))
|
||||
>PropType : Symbol(PropType, Decl(keyofAndIndexedAccess.ts, 115, 16))
|
||||
>key : Symbol(key, Decl(keyofAndIndexedAccess.ts, 117, 42))
|
||||
>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 117, 16))
|
||||
>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, 115, 27))
|
||||
>this : Symbol(Component, Decl(keyofAndIndexedAccess.ts, 113, 1))
|
||||
>props : Symbol(Component.props, Decl(keyofAndIndexedAccess.ts, 115, 27))
|
||||
>key : Symbol(key, Decl(keyofAndIndexedAccess.ts, 117, 42))
|
||||
>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, 119, 5))
|
||||
>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 120, 16))
|
||||
>PropType : Symbol(PropType, Decl(keyofAndIndexedAccess.ts, 115, 16))
|
||||
>key : Symbol(key, Decl(keyofAndIndexedAccess.ts, 120, 42))
|
||||
>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 120, 16))
|
||||
>value : Symbol(value, Decl(keyofAndIndexedAccess.ts, 120, 49))
|
||||
>PropType : Symbol(PropType, Decl(keyofAndIndexedAccess.ts, 115, 16))
|
||||
>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 120, 16))
|
||||
>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, 115, 27))
|
||||
>this : Symbol(Component, Decl(keyofAndIndexedAccess.ts, 113, 1))
|
||||
>props : Symbol(Component.props, Decl(keyofAndIndexedAccess.ts, 115, 27))
|
||||
>key : Symbol(key, Decl(keyofAndIndexedAccess.ts, 120, 42))
|
||||
>value : Symbol(value, Decl(keyofAndIndexedAccess.ts, 120, 49))
|
||||
>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, 123, 1))
|
||||
>component : Symbol(component, Decl(keyofAndIndexedAccess.ts, 125, 13))
|
||||
>Component : Symbol(Component, Decl(keyofAndIndexedAccess.ts, 113, 1))
|
||||
>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, 126, 7))
|
||||
>component.getProperty : Symbol(Component.getProperty, Decl(keyofAndIndexedAccess.ts, 116, 20))
|
||||
>component : Symbol(component, Decl(keyofAndIndexedAccess.ts, 125, 13))
|
||||
>getProperty : Symbol(Component.getProperty, Decl(keyofAndIndexedAccess.ts, 116, 20))
|
||||
>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, 127, 7))
|
||||
>component.getProperty : Symbol(Component.getProperty, Decl(keyofAndIndexedAccess.ts, 116, 20))
|
||||
>component : Symbol(component, Decl(keyofAndIndexedAccess.ts, 125, 13))
|
||||
>getProperty : Symbol(Component.getProperty, Decl(keyofAndIndexedAccess.ts, 116, 20))
|
||||
>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, 75, 11))
|
||||
|
||||
let nameOrVisible = component.getProperty(cond ? "name" : "visible"); // string | boolean
|
||||
>nameOrVisible : Symbol(nameOrVisible, Decl(keyofAndIndexedAccess.ts, 128, 7))
|
||||
>component.getProperty : Symbol(Component.getProperty, Decl(keyofAndIndexedAccess.ts, 116, 20))
|
||||
>component : Symbol(component, Decl(keyofAndIndexedAccess.ts, 125, 13))
|
||||
>getProperty : Symbol(Component.getProperty, Decl(keyofAndIndexedAccess.ts, 116, 20))
|
||||
>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, 75, 11))
|
||||
|
||||
component.setProperty("name", "rectangle");
|
||||
>component.setProperty : Symbol(Component.setProperty, Decl(keyofAndIndexedAccess.ts, 119, 5))
|
||||
>component : Symbol(component, Decl(keyofAndIndexedAccess.ts, 125, 13))
|
||||
>setProperty : Symbol(Component.setProperty, Decl(keyofAndIndexedAccess.ts, 119, 5))
|
||||
>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, 119, 5))
|
||||
>component : Symbol(component, Decl(keyofAndIndexedAccess.ts, 125, 13))
|
||||
>setProperty : Symbol(Component.setProperty, Decl(keyofAndIndexedAccess.ts, 119, 5))
|
||||
>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, 75, 11))
|
||||
|
||||
component.setProperty(cond ? "name" : "visible", true); // Technically not safe
|
||||
>component.setProperty : Symbol(Component.setProperty, Decl(keyofAndIndexedAccess.ts, 119, 5))
|
||||
>component : Symbol(component, Decl(keyofAndIndexedAccess.ts, 125, 13))
|
||||
>setProperty : Symbol(Component.setProperty, Decl(keyofAndIndexedAccess.ts, 119, 5))
|
||||
>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, 75, 11))
|
||||
}
|
||||
|
||||
function pluck<T, K extends keyof T>(array: T[], key: K) {
|
||||
>pluck : Symbol(pluck, Decl(keyofAndIndexedAccess.ts, 132, 1))
|
||||
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 134, 15))
|
||||
>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 134, 17))
|
||||
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 134, 15))
|
||||
>array : Symbol(array, Decl(keyofAndIndexedAccess.ts, 134, 37))
|
||||
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 134, 15))
|
||||
>key : Symbol(key, Decl(keyofAndIndexedAccess.ts, 134, 48))
|
||||
>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 134, 17))
|
||||
>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, 134, 37))
|
||||
>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, 135, 21))
|
||||
>x : Symbol(x, Decl(keyofAndIndexedAccess.ts, 135, 21))
|
||||
>key : Symbol(key, Decl(keyofAndIndexedAccess.ts, 134, 48))
|
||||
>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, 136, 1))
|
||||
>shapes : Symbol(shapes, Decl(keyofAndIndexedAccess.ts, 138, 13))
|
||||
>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, 139, 7))
|
||||
>pluck : Symbol(pluck, Decl(keyofAndIndexedAccess.ts, 132, 1))
|
||||
>shapes : Symbol(shapes, Decl(keyofAndIndexedAccess.ts, 138, 13))
|
||||
>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, 140, 7))
|
||||
>pluck : Symbol(pluck, Decl(keyofAndIndexedAccess.ts, 132, 1))
|
||||
>shapes : Symbol(shapes, Decl(keyofAndIndexedAccess.ts, 138, 13))
|
||||
>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, 141, 7))
|
||||
>pluck : Symbol(pluck, Decl(keyofAndIndexedAccess.ts, 132, 1))
|
||||
>shapes : Symbol(shapes, Decl(keyofAndIndexedAccess.ts, 138, 13))
|
||||
>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, 75, 11))
|
||||
}
|
||||
|
||||
function f31<K extends keyof Shape>(key: K) {
|
||||
>f31 : Symbol(f31, Decl(keyofAndIndexedAccess.ts, 142, 1))
|
||||
>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 144, 13))
|
||||
>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, 144, 36))
|
||||
>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 144, 13))
|
||||
>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, 145, 9))
|
||||
>shape : Symbol(shape, Decl(keyofAndIndexedAccess.ts, 141, 9))
|
||||
>Shape : Symbol(Shape, Decl(keyofAndIndexedAccess.ts, 0, 0))
|
||||
>name : Symbol(name, Decl(keyofAndIndexedAccess.ts, 145, 26))
|
||||
>width : Symbol(width, Decl(keyofAndIndexedAccess.ts, 145, 39))
|
||||
>height : Symbol(height, Decl(keyofAndIndexedAccess.ts, 145, 49))
|
||||
>visible : Symbol(visible, Decl(keyofAndIndexedAccess.ts, 145, 61))
|
||||
>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, 145, 9))
|
||||
>key : Symbol(key, Decl(keyofAndIndexedAccess.ts, 144, 36))
|
||||
>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, 147, 1))
|
||||
>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 149, 13))
|
||||
>key : Symbol(key, Decl(keyofAndIndexedAccess.ts, 149, 43))
|
||||
>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 149, 13))
|
||||
>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, 150, 9))
|
||||
>shape : Symbol(shape, Decl(keyofAndIndexedAccess.ts, 146, 9))
|
||||
>Shape : Symbol(Shape, Decl(keyofAndIndexedAccess.ts, 0, 0))
|
||||
>name : Symbol(name, Decl(keyofAndIndexedAccess.ts, 150, 26))
|
||||
>width : Symbol(width, Decl(keyofAndIndexedAccess.ts, 150, 39))
|
||||
>height : Symbol(height, Decl(keyofAndIndexedAccess.ts, 150, 49))
|
||||
>visible : Symbol(visible, Decl(keyofAndIndexedAccess.ts, 150, 61))
|
||||
>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, 150, 9))
|
||||
>key : Symbol(key, Decl(keyofAndIndexedAccess.ts, 149, 43))
|
||||
>shape : Symbol(shape, Decl(keyofAndIndexedAccess.ts, 146, 9))
|
||||
>key : Symbol(key, Decl(keyofAndIndexedAccess.ts, 145, 43))
|
||||
}
|
||||
|
||||
function f33<S extends Shape, K extends keyof S>(shape: S, key: K) {
|
||||
>f33 : Symbol(f33, Decl(keyofAndIndexedAccess.ts, 152, 1))
|
||||
>S : Symbol(S, Decl(keyofAndIndexedAccess.ts, 154, 13))
|
||||
>f33 : Symbol(f33, Decl(keyofAndIndexedAccess.ts, 148, 1))
|
||||
>S : Symbol(S, Decl(keyofAndIndexedAccess.ts, 150, 13))
|
||||
>Shape : Symbol(Shape, Decl(keyofAndIndexedAccess.ts, 0, 0))
|
||||
>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 154, 29))
|
||||
>S : Symbol(S, Decl(keyofAndIndexedAccess.ts, 154, 13))
|
||||
>shape : Symbol(shape, Decl(keyofAndIndexedAccess.ts, 154, 49))
|
||||
>S : Symbol(S, Decl(keyofAndIndexedAccess.ts, 154, 13))
|
||||
>key : Symbol(key, Decl(keyofAndIndexedAccess.ts, 154, 58))
|
||||
>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 154, 29))
|
||||
>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 150, 29))
|
||||
>S : Symbol(S, Decl(keyofAndIndexedAccess.ts, 150, 13))
|
||||
>shape : Symbol(shape, Decl(keyofAndIndexedAccess.ts, 150, 49))
|
||||
>S : Symbol(S, Decl(keyofAndIndexedAccess.ts, 150, 13))
|
||||
>key : Symbol(key, Decl(keyofAndIndexedAccess.ts, 150, 58))
|
||||
>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 150, 29))
|
||||
|
||||
let name = getProperty(shape, "name");
|
||||
>name : Symbol(name, Decl(keyofAndIndexedAccess.ts, 155, 7))
|
||||
>name : Symbol(name, Decl(keyofAndIndexedAccess.ts, 151, 7))
|
||||
>getProperty : Symbol(getProperty, Decl(keyofAndIndexedAccess.ts, 75, 26))
|
||||
>shape : Symbol(shape, Decl(keyofAndIndexedAccess.ts, 154, 49))
|
||||
>shape : Symbol(shape, Decl(keyofAndIndexedAccess.ts, 150, 49))
|
||||
|
||||
let prop = getProperty(shape, key);
|
||||
>prop : Symbol(prop, Decl(keyofAndIndexedAccess.ts, 156, 7))
|
||||
>prop : Symbol(prop, Decl(keyofAndIndexedAccess.ts, 152, 7))
|
||||
>getProperty : Symbol(getProperty, Decl(keyofAndIndexedAccess.ts, 75, 26))
|
||||
>shape : Symbol(shape, Decl(keyofAndIndexedAccess.ts, 154, 49))
|
||||
>key : Symbol(key, Decl(keyofAndIndexedAccess.ts, 154, 58))
|
||||
>shape : Symbol(shape, Decl(keyofAndIndexedAccess.ts, 150, 49))
|
||||
>key : Symbol(key, Decl(keyofAndIndexedAccess.ts, 150, 58))
|
||||
|
||||
return prop;
|
||||
>prop : Symbol(prop, Decl(keyofAndIndexedAccess.ts, 156, 7))
|
||||
>prop : Symbol(prop, Decl(keyofAndIndexedAccess.ts, 152, 7))
|
||||
}
|
||||
|
||||
function f34(ts: TaggedShape) {
|
||||
>f34 : Symbol(f34, Decl(keyofAndIndexedAccess.ts, 158, 1))
|
||||
>ts : Symbol(ts, Decl(keyofAndIndexedAccess.ts, 160, 13))
|
||||
>f34 : Symbol(f34, Decl(keyofAndIndexedAccess.ts, 154, 1))
|
||||
>ts : Symbol(ts, Decl(keyofAndIndexedAccess.ts, 156, 13))
|
||||
>TaggedShape : Symbol(TaggedShape, Decl(keyofAndIndexedAccess.ts, 6, 1))
|
||||
|
||||
let tag1 = f33(ts, "tag");
|
||||
>tag1 : Symbol(tag1, Decl(keyofAndIndexedAccess.ts, 161, 7))
|
||||
>f33 : Symbol(f33, Decl(keyofAndIndexedAccess.ts, 152, 1))
|
||||
>ts : Symbol(ts, Decl(keyofAndIndexedAccess.ts, 160, 13))
|
||||
>tag1 : Symbol(tag1, Decl(keyofAndIndexedAccess.ts, 157, 7))
|
||||
>f33 : Symbol(f33, Decl(keyofAndIndexedAccess.ts, 148, 1))
|
||||
>ts : Symbol(ts, Decl(keyofAndIndexedAccess.ts, 156, 13))
|
||||
|
||||
let tag2 = getProperty(ts, "tag");
|
||||
>tag2 : Symbol(tag2, Decl(keyofAndIndexedAccess.ts, 162, 7))
|
||||
>tag2 : Symbol(tag2, Decl(keyofAndIndexedAccess.ts, 158, 7))
|
||||
>getProperty : Symbol(getProperty, Decl(keyofAndIndexedAccess.ts, 75, 26))
|
||||
>ts : Symbol(ts, Decl(keyofAndIndexedAccess.ts, 160, 13))
|
||||
>ts : Symbol(ts, Decl(keyofAndIndexedAccess.ts, 156, 13))
|
||||
}
|
||||
|
||||
class C {
|
||||
>C : Symbol(C, Decl(keyofAndIndexedAccess.ts, 163, 1))
|
||||
>C : Symbol(C, Decl(keyofAndIndexedAccess.ts, 159, 1))
|
||||
|
||||
public x: string;
|
||||
>x : Symbol(C.x, Decl(keyofAndIndexedAccess.ts, 165, 9))
|
||||
>x : Symbol(C.x, Decl(keyofAndIndexedAccess.ts, 161, 9))
|
||||
|
||||
protected y: string;
|
||||
>y : Symbol(C.y, Decl(keyofAndIndexedAccess.ts, 166, 21))
|
||||
>y : Symbol(C.y, Decl(keyofAndIndexedAccess.ts, 162, 21))
|
||||
|
||||
private z: string;
|
||||
>z : Symbol(C.z, Decl(keyofAndIndexedAccess.ts, 167, 24))
|
||||
>z : Symbol(C.z, Decl(keyofAndIndexedAccess.ts, 163, 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, 169, 1))
|
||||
>c : Symbol(c, Decl(keyofAndIndexedAccess.ts, 173, 13))
|
||||
>C : Symbol(C, Decl(keyofAndIndexedAccess.ts, 163, 1))
|
||||
>f40 : Symbol(f40, Decl(keyofAndIndexedAccess.ts, 165, 1))
|
||||
>c : Symbol(c, Decl(keyofAndIndexedAccess.ts, 169, 13))
|
||||
>C : Symbol(C, Decl(keyofAndIndexedAccess.ts, 159, 1))
|
||||
|
||||
type X = C["x"];
|
||||
>X : Symbol(X, Decl(keyofAndIndexedAccess.ts, 173, 20))
|
||||
>C : Symbol(C, Decl(keyofAndIndexedAccess.ts, 163, 1))
|
||||
>X : Symbol(X, Decl(keyofAndIndexedAccess.ts, 169, 20))
|
||||
>C : Symbol(C, Decl(keyofAndIndexedAccess.ts, 159, 1))
|
||||
|
||||
type Y = C["y"];
|
||||
>Y : Symbol(Y, Decl(keyofAndIndexedAccess.ts, 174, 20))
|
||||
>C : Symbol(C, Decl(keyofAndIndexedAccess.ts, 163, 1))
|
||||
>Y : Symbol(Y, Decl(keyofAndIndexedAccess.ts, 170, 20))
|
||||
>C : Symbol(C, Decl(keyofAndIndexedAccess.ts, 159, 1))
|
||||
|
||||
type Z = C["z"];
|
||||
>Z : Symbol(Z, Decl(keyofAndIndexedAccess.ts, 175, 20))
|
||||
>C : Symbol(C, Decl(keyofAndIndexedAccess.ts, 163, 1))
|
||||
>Z : Symbol(Z, Decl(keyofAndIndexedAccess.ts, 171, 20))
|
||||
>C : Symbol(C, Decl(keyofAndIndexedAccess.ts, 159, 1))
|
||||
|
||||
let x: X = c["x"];
|
||||
>x : Symbol(x, Decl(keyofAndIndexedAccess.ts, 177, 7))
|
||||
>X : Symbol(X, Decl(keyofAndIndexedAccess.ts, 173, 20))
|
||||
>c : Symbol(c, Decl(keyofAndIndexedAccess.ts, 173, 13))
|
||||
>"x" : Symbol(C.x, Decl(keyofAndIndexedAccess.ts, 165, 9))
|
||||
>x : Symbol(x, Decl(keyofAndIndexedAccess.ts, 173, 7))
|
||||
>X : Symbol(X, Decl(keyofAndIndexedAccess.ts, 169, 20))
|
||||
>c : Symbol(c, Decl(keyofAndIndexedAccess.ts, 169, 13))
|
||||
>"x" : Symbol(C.x, Decl(keyofAndIndexedAccess.ts, 161, 9))
|
||||
|
||||
let y: Y = c["y"];
|
||||
>y : Symbol(y, Decl(keyofAndIndexedAccess.ts, 178, 7))
|
||||
>Y : Symbol(Y, Decl(keyofAndIndexedAccess.ts, 174, 20))
|
||||
>c : Symbol(c, Decl(keyofAndIndexedAccess.ts, 173, 13))
|
||||
>"y" : Symbol(C.y, Decl(keyofAndIndexedAccess.ts, 166, 21))
|
||||
>y : Symbol(y, Decl(keyofAndIndexedAccess.ts, 174, 7))
|
||||
>Y : Symbol(Y, Decl(keyofAndIndexedAccess.ts, 170, 20))
|
||||
>c : Symbol(c, Decl(keyofAndIndexedAccess.ts, 169, 13))
|
||||
>"y" : Symbol(C.y, Decl(keyofAndIndexedAccess.ts, 162, 21))
|
||||
|
||||
let z: Z = c["z"];
|
||||
>z : Symbol(z, Decl(keyofAndIndexedAccess.ts, 179, 7))
|
||||
>Z : Symbol(Z, Decl(keyofAndIndexedAccess.ts, 175, 20))
|
||||
>c : Symbol(c, Decl(keyofAndIndexedAccess.ts, 173, 13))
|
||||
>"z" : Symbol(C.z, Decl(keyofAndIndexedAccess.ts, 167, 24))
|
||||
>z : Symbol(z, Decl(keyofAndIndexedAccess.ts, 175, 7))
|
||||
>Z : Symbol(Z, Decl(keyofAndIndexedAccess.ts, 171, 20))
|
||||
>c : Symbol(c, Decl(keyofAndIndexedAccess.ts, 169, 13))
|
||||
>"z" : Symbol(C.z, Decl(keyofAndIndexedAccess.ts, 163, 24))
|
||||
}
|
||||
|
||||
function f50<T>(k: keyof T, s: string) {
|
||||
>f50 : Symbol(f50, Decl(keyofAndIndexedAccess.ts, 176, 1))
|
||||
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 178, 13))
|
||||
>k : Symbol(k, Decl(keyofAndIndexedAccess.ts, 178, 16))
|
||||
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 178, 13))
|
||||
>s : Symbol(s, Decl(keyofAndIndexedAccess.ts, 178, 27))
|
||||
|
||||
const x1 = s as keyof T;
|
||||
>x1 : Symbol(x1, Decl(keyofAndIndexedAccess.ts, 179, 9))
|
||||
>s : Symbol(s, Decl(keyofAndIndexedAccess.ts, 178, 27))
|
||||
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 178, 13))
|
||||
|
||||
const x2 = k as string;
|
||||
>x2 : Symbol(x2, Decl(keyofAndIndexedAccess.ts, 180, 9))
|
||||
>k : Symbol(k, Decl(keyofAndIndexedAccess.ts, 178, 16))
|
||||
}
|
||||
|
||||
function f51<T, K extends keyof T>(k: K, s: string) {
|
||||
>f51 : Symbol(f51, Decl(keyofAndIndexedAccess.ts, 181, 1))
|
||||
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 183, 13))
|
||||
>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 183, 15))
|
||||
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 183, 13))
|
||||
>k : Symbol(k, Decl(keyofAndIndexedAccess.ts, 183, 35))
|
||||
>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 183, 15))
|
||||
>s : Symbol(s, Decl(keyofAndIndexedAccess.ts, 183, 40))
|
||||
|
||||
const x1 = s as keyof T;
|
||||
>x1 : Symbol(x1, Decl(keyofAndIndexedAccess.ts, 184, 9))
|
||||
>s : Symbol(s, Decl(keyofAndIndexedAccess.ts, 183, 40))
|
||||
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 183, 13))
|
||||
|
||||
const x2 = k as string;
|
||||
>x2 : Symbol(x2, Decl(keyofAndIndexedAccess.ts, 185, 9))
|
||||
>k : Symbol(k, Decl(keyofAndIndexedAccess.ts, 183, 35))
|
||||
}
|
||||
|
||||
function f52<T>(obj: { [x: string]: boolean }, k: keyof T, s: string, n: number) {
|
||||
>f52 : Symbol(f52, Decl(keyofAndIndexedAccess.ts, 186, 1))
|
||||
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 188, 13))
|
||||
>obj : Symbol(obj, Decl(keyofAndIndexedAccess.ts, 188, 16))
|
||||
>x : Symbol(x, Decl(keyofAndIndexedAccess.ts, 188, 24))
|
||||
>k : Symbol(k, Decl(keyofAndIndexedAccess.ts, 188, 46))
|
||||
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 188, 13))
|
||||
>s : Symbol(s, Decl(keyofAndIndexedAccess.ts, 188, 58))
|
||||
>n : Symbol(n, Decl(keyofAndIndexedAccess.ts, 188, 69))
|
||||
|
||||
const x1 = obj[s];
|
||||
>x1 : Symbol(x1, Decl(keyofAndIndexedAccess.ts, 189, 9))
|
||||
>obj : Symbol(obj, Decl(keyofAndIndexedAccess.ts, 188, 16))
|
||||
>s : Symbol(s, Decl(keyofAndIndexedAccess.ts, 188, 58))
|
||||
|
||||
const x2 = obj[n];
|
||||
>x2 : Symbol(x2, Decl(keyofAndIndexedAccess.ts, 190, 9))
|
||||
>obj : Symbol(obj, Decl(keyofAndIndexedAccess.ts, 188, 16))
|
||||
>n : Symbol(n, Decl(keyofAndIndexedAccess.ts, 188, 69))
|
||||
|
||||
const x3 = obj[k];
|
||||
>x3 : Symbol(x3, Decl(keyofAndIndexedAccess.ts, 191, 9))
|
||||
>obj : Symbol(obj, Decl(keyofAndIndexedAccess.ts, 188, 16))
|
||||
>k : Symbol(k, Decl(keyofAndIndexedAccess.ts, 188, 46))
|
||||
}
|
||||
|
||||
function f53<T, K extends keyof T>(obj: { [x: string]: boolean }, k: K, s: string, n: number) {
|
||||
>f53 : Symbol(f53, Decl(keyofAndIndexedAccess.ts, 192, 1))
|
||||
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 194, 13))
|
||||
>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 194, 15))
|
||||
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 194, 13))
|
||||
>obj : Symbol(obj, Decl(keyofAndIndexedAccess.ts, 194, 35))
|
||||
>x : Symbol(x, Decl(keyofAndIndexedAccess.ts, 194, 43))
|
||||
>k : Symbol(k, Decl(keyofAndIndexedAccess.ts, 194, 65))
|
||||
>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 194, 15))
|
||||
>s : Symbol(s, Decl(keyofAndIndexedAccess.ts, 194, 71))
|
||||
>n : Symbol(n, Decl(keyofAndIndexedAccess.ts, 194, 82))
|
||||
|
||||
const x1 = obj[s];
|
||||
>x1 : Symbol(x1, Decl(keyofAndIndexedAccess.ts, 195, 9))
|
||||
>obj : Symbol(obj, Decl(keyofAndIndexedAccess.ts, 194, 35))
|
||||
>s : Symbol(s, Decl(keyofAndIndexedAccess.ts, 194, 71))
|
||||
|
||||
const x2 = obj[n];
|
||||
>x2 : Symbol(x2, Decl(keyofAndIndexedAccess.ts, 196, 9))
|
||||
>obj : Symbol(obj, Decl(keyofAndIndexedAccess.ts, 194, 35))
|
||||
>n : Symbol(n, Decl(keyofAndIndexedAccess.ts, 194, 82))
|
||||
|
||||
const x3 = obj[k];
|
||||
>x3 : Symbol(x3, Decl(keyofAndIndexedAccess.ts, 197, 9))
|
||||
>obj : Symbol(obj, Decl(keyofAndIndexedAccess.ts, 194, 35))
|
||||
>k : Symbol(k, Decl(keyofAndIndexedAccess.ts, 194, 65))
|
||||
}
|
||||
|
||||
function f54<T>(obj: T, key: keyof T) {
|
||||
>f54 : Symbol(f54, Decl(keyofAndIndexedAccess.ts, 198, 1))
|
||||
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 200, 13))
|
||||
>obj : Symbol(obj, Decl(keyofAndIndexedAccess.ts, 200, 16))
|
||||
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 200, 13))
|
||||
>key : Symbol(key, Decl(keyofAndIndexedAccess.ts, 200, 23))
|
||||
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 200, 13))
|
||||
|
||||
for (let s in obj[key]) {
|
||||
>s : Symbol(s, Decl(keyofAndIndexedAccess.ts, 201, 12))
|
||||
>obj : Symbol(obj, Decl(keyofAndIndexedAccess.ts, 200, 16))
|
||||
>key : Symbol(key, Decl(keyofAndIndexedAccess.ts, 200, 23))
|
||||
}
|
||||
const b = "foo" in obj[key];
|
||||
>b : Symbol(b, Decl(keyofAndIndexedAccess.ts, 203, 9))
|
||||
>obj : Symbol(obj, Decl(keyofAndIndexedAccess.ts, 200, 16))
|
||||
>key : Symbol(key, Decl(keyofAndIndexedAccess.ts, 200, 23))
|
||||
}
|
||||
|
||||
function f55<T, K extends keyof T>(obj: T, key: K) {
|
||||
>f55 : Symbol(f55, Decl(keyofAndIndexedAccess.ts, 204, 1))
|
||||
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 206, 13))
|
||||
>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 206, 15))
|
||||
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 206, 13))
|
||||
>obj : Symbol(obj, Decl(keyofAndIndexedAccess.ts, 206, 35))
|
||||
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 206, 13))
|
||||
>key : Symbol(key, Decl(keyofAndIndexedAccess.ts, 206, 42))
|
||||
>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 206, 15))
|
||||
|
||||
for (let s in obj[key]) {
|
||||
>s : Symbol(s, Decl(keyofAndIndexedAccess.ts, 207, 12))
|
||||
>obj : Symbol(obj, Decl(keyofAndIndexedAccess.ts, 206, 35))
|
||||
>key : Symbol(key, Decl(keyofAndIndexedAccess.ts, 206, 42))
|
||||
}
|
||||
const b = "foo" in obj[key];
|
||||
>b : Symbol(b, Decl(keyofAndIndexedAccess.ts, 209, 9))
|
||||
>obj : Symbol(obj, Decl(keyofAndIndexedAccess.ts, 206, 35))
|
||||
>key : Symbol(key, Decl(keyofAndIndexedAccess.ts, 206, 42))
|
||||
}
|
||||
|
||||
function f60<T>(source: T, target: T) {
|
||||
>f60 : Symbol(f60, Decl(keyofAndIndexedAccess.ts, 210, 1))
|
||||
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 212, 13))
|
||||
>source : Symbol(source, Decl(keyofAndIndexedAccess.ts, 212, 16))
|
||||
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 212, 13))
|
||||
>target : Symbol(target, Decl(keyofAndIndexedAccess.ts, 212, 26))
|
||||
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 212, 13))
|
||||
|
||||
for (let k in source) {
|
||||
>k : Symbol(k, Decl(keyofAndIndexedAccess.ts, 213, 12))
|
||||
>source : Symbol(source, Decl(keyofAndIndexedAccess.ts, 212, 16))
|
||||
|
||||
target[k] = source[k];
|
||||
>target : Symbol(target, Decl(keyofAndIndexedAccess.ts, 212, 26))
|
||||
>k : Symbol(k, Decl(keyofAndIndexedAccess.ts, 213, 12))
|
||||
>source : Symbol(source, Decl(keyofAndIndexedAccess.ts, 212, 16))
|
||||
>k : Symbol(k, Decl(keyofAndIndexedAccess.ts, 213, 12))
|
||||
}
|
||||
}
|
||||
|
||||
// Repros from #12011
|
||||
|
||||
class Base {
|
||||
>Base : Symbol(Base, Decl(keyofAndIndexedAccess.ts, 180, 1))
|
||||
>Base : Symbol(Base, Decl(keyofAndIndexedAccess.ts, 216, 1))
|
||||
|
||||
get<K extends keyof this>(prop: K) {
|
||||
>get : Symbol(Base.get, Decl(keyofAndIndexedAccess.ts, 184, 12))
|
||||
>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 185, 8))
|
||||
>prop : Symbol(prop, Decl(keyofAndIndexedAccess.ts, 185, 30))
|
||||
>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 185, 8))
|
||||
>get : Symbol(Base.get, Decl(keyofAndIndexedAccess.ts, 220, 12))
|
||||
>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 221, 8))
|
||||
>prop : Symbol(prop, Decl(keyofAndIndexedAccess.ts, 221, 30))
|
||||
>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 221, 8))
|
||||
|
||||
return this[prop];
|
||||
>this : Symbol(Base, Decl(keyofAndIndexedAccess.ts, 180, 1))
|
||||
>prop : Symbol(prop, Decl(keyofAndIndexedAccess.ts, 185, 30))
|
||||
>this : Symbol(Base, Decl(keyofAndIndexedAccess.ts, 216, 1))
|
||||
>prop : Symbol(prop, Decl(keyofAndIndexedAccess.ts, 221, 30))
|
||||
}
|
||||
set<K extends keyof this>(prop: K, value: this[K]) {
|
||||
>set : Symbol(Base.set, Decl(keyofAndIndexedAccess.ts, 187, 5))
|
||||
>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 188, 8))
|
||||
>prop : Symbol(prop, Decl(keyofAndIndexedAccess.ts, 188, 30))
|
||||
>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 188, 8))
|
||||
>value : Symbol(value, Decl(keyofAndIndexedAccess.ts, 188, 38))
|
||||
>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 188, 8))
|
||||
>set : Symbol(Base.set, Decl(keyofAndIndexedAccess.ts, 223, 5))
|
||||
>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 224, 8))
|
||||
>prop : Symbol(prop, Decl(keyofAndIndexedAccess.ts, 224, 30))
|
||||
>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 224, 8))
|
||||
>value : Symbol(value, Decl(keyofAndIndexedAccess.ts, 224, 38))
|
||||
>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 224, 8))
|
||||
|
||||
this[prop] = value;
|
||||
>this : Symbol(Base, Decl(keyofAndIndexedAccess.ts, 180, 1))
|
||||
>prop : Symbol(prop, Decl(keyofAndIndexedAccess.ts, 188, 30))
|
||||
>value : Symbol(value, Decl(keyofAndIndexedAccess.ts, 188, 38))
|
||||
>this : Symbol(Base, Decl(keyofAndIndexedAccess.ts, 216, 1))
|
||||
>prop : Symbol(prop, Decl(keyofAndIndexedAccess.ts, 224, 30))
|
||||
>value : Symbol(value, Decl(keyofAndIndexedAccess.ts, 224, 38))
|
||||
}
|
||||
}
|
||||
|
||||
class Person extends Base {
|
||||
>Person : Symbol(Person, Decl(keyofAndIndexedAccess.ts, 191, 1))
|
||||
>Base : Symbol(Base, Decl(keyofAndIndexedAccess.ts, 180, 1))
|
||||
>Person : Symbol(Person, Decl(keyofAndIndexedAccess.ts, 227, 1))
|
||||
>Base : Symbol(Base, Decl(keyofAndIndexedAccess.ts, 216, 1))
|
||||
|
||||
parts: number;
|
||||
>parts : Symbol(Person.parts, Decl(keyofAndIndexedAccess.ts, 193, 27))
|
||||
>parts : Symbol(Person.parts, Decl(keyofAndIndexedAccess.ts, 229, 27))
|
||||
|
||||
constructor(parts: number) {
|
||||
>parts : Symbol(parts, Decl(keyofAndIndexedAccess.ts, 195, 16))
|
||||
>parts : Symbol(parts, Decl(keyofAndIndexedAccess.ts, 231, 16))
|
||||
|
||||
super();
|
||||
>super : Symbol(Base, Decl(keyofAndIndexedAccess.ts, 180, 1))
|
||||
>super : Symbol(Base, Decl(keyofAndIndexedAccess.ts, 216, 1))
|
||||
|
||||
this.set("parts", parts);
|
||||
>this.set : Symbol(Base.set, Decl(keyofAndIndexedAccess.ts, 187, 5))
|
||||
>this : Symbol(Person, Decl(keyofAndIndexedAccess.ts, 191, 1))
|
||||
>set : Symbol(Base.set, Decl(keyofAndIndexedAccess.ts, 187, 5))
|
||||
>parts : Symbol(parts, Decl(keyofAndIndexedAccess.ts, 195, 16))
|
||||
>this.set : Symbol(Base.set, Decl(keyofAndIndexedAccess.ts, 223, 5))
|
||||
>this : Symbol(Person, Decl(keyofAndIndexedAccess.ts, 227, 1))
|
||||
>set : Symbol(Base.set, Decl(keyofAndIndexedAccess.ts, 223, 5))
|
||||
>parts : Symbol(parts, Decl(keyofAndIndexedAccess.ts, 231, 16))
|
||||
}
|
||||
getParts() {
|
||||
>getParts : Symbol(Person.getParts, Decl(keyofAndIndexedAccess.ts, 198, 5))
|
||||
>getParts : Symbol(Person.getParts, Decl(keyofAndIndexedAccess.ts, 234, 5))
|
||||
|
||||
return this.get("parts")
|
||||
>this.get : Symbol(Base.get, Decl(keyofAndIndexedAccess.ts, 184, 12))
|
||||
>this : Symbol(Person, Decl(keyofAndIndexedAccess.ts, 191, 1))
|
||||
>get : Symbol(Base.get, Decl(keyofAndIndexedAccess.ts, 184, 12))
|
||||
>this.get : Symbol(Base.get, Decl(keyofAndIndexedAccess.ts, 220, 12))
|
||||
>this : Symbol(Person, Decl(keyofAndIndexedAccess.ts, 227, 1))
|
||||
>get : Symbol(Base.get, Decl(keyofAndIndexedAccess.ts, 220, 12))
|
||||
}
|
||||
}
|
||||
|
||||
class OtherPerson {
|
||||
>OtherPerson : Symbol(OtherPerson, Decl(keyofAndIndexedAccess.ts, 202, 1))
|
||||
>OtherPerson : Symbol(OtherPerson, Decl(keyofAndIndexedAccess.ts, 238, 1))
|
||||
|
||||
parts: number;
|
||||
>parts : Symbol(OtherPerson.parts, Decl(keyofAndIndexedAccess.ts, 204, 19))
|
||||
>parts : Symbol(OtherPerson.parts, Decl(keyofAndIndexedAccess.ts, 240, 19))
|
||||
|
||||
constructor(parts: number) {
|
||||
>parts : Symbol(parts, Decl(keyofAndIndexedAccess.ts, 206, 16))
|
||||
>parts : Symbol(parts, Decl(keyofAndIndexedAccess.ts, 242, 16))
|
||||
|
||||
setProperty(this, "parts", parts);
|
||||
>setProperty : Symbol(setProperty, Decl(keyofAndIndexedAccess.ts, 79, 1))
|
||||
>this : Symbol(OtherPerson, Decl(keyofAndIndexedAccess.ts, 202, 1))
|
||||
>parts : Symbol(parts, Decl(keyofAndIndexedAccess.ts, 206, 16))
|
||||
>this : Symbol(OtherPerson, Decl(keyofAndIndexedAccess.ts, 238, 1))
|
||||
>parts : Symbol(parts, Decl(keyofAndIndexedAccess.ts, 242, 16))
|
||||
}
|
||||
getParts() {
|
||||
>getParts : Symbol(OtherPerson.getParts, Decl(keyofAndIndexedAccess.ts, 208, 5))
|
||||
>getParts : Symbol(OtherPerson.getParts, Decl(keyofAndIndexedAccess.ts, 244, 5))
|
||||
|
||||
return getProperty(this, "parts")
|
||||
>getProperty : Symbol(getProperty, Decl(keyofAndIndexedAccess.ts, 75, 26))
|
||||
>this : Symbol(OtherPerson, Decl(keyofAndIndexedAccess.ts, 202, 1))
|
||||
>this : Symbol(OtherPerson, Decl(keyofAndIndexedAccess.ts, 238, 1))
|
||||
}
|
||||
}
|
||||
|
|
|
@ -54,10 +54,10 @@ const enum E { A, B, C }
|
|||
>C : E.C
|
||||
|
||||
type K00 = keyof any; // string | number
|
||||
>K00 : string | number
|
||||
>K00 : string
|
||||
|
||||
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"
|
||||
>K01 : "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"
|
||||
|
@ -83,11 +83,11 @@ type K10 = keyof Shape; // "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"
|
||||
>K11 : "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
|
||||
>K12 : string
|
||||
>Dictionary : Dictionary<T>
|
||||
>Shape : Shape
|
||||
|
||||
|
@ -103,7 +103,7 @@ type K15 = keyof E; // "toString" | "toFixed" | "toExponential" | ...
|
|||
>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"
|
||||
>K16 : "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"
|
||||
|
@ -126,7 +126,7 @@ type K20 = KeyOf<Shape>; // "name" | "width" | "height" | "visible"
|
|||
>Shape : Shape
|
||||
|
||||
type K21 = KeyOf<Dictionary<Shape>>; // string | number
|
||||
>K21 : string | number
|
||||
>K21 : string
|
||||
>KeyOf : keyof T
|
||||
>Dictionary : Dictionary<T>
|
||||
>Shape : Shape
|
||||
|
@ -328,22 +328,12 @@ function f11(a: Shape[]) {
|
|||
>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(a, "length", len);
|
||||
>setProperty(a, "length", len) : 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
|
||||
>"length" : "length"
|
||||
>len : number
|
||||
}
|
||||
|
||||
function f12(t: [Shape, boolean]) {
|
||||
|
@ -358,13 +348,6 @@ function f12(t: [Shape, boolean]) {
|
|||
>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
|
||||
|
@ -372,26 +355,12 @@ function f12(t: [Shape, boolean]) {
|
|||
>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) {
|
||||
|
@ -406,12 +375,12 @@ function f13(foo: any, bar: any) {
|
|||
>foo : any
|
||||
>"x" : "x"
|
||||
|
||||
let y = getProperty(foo, 100); // any
|
||||
let y = getProperty(foo, "100"); // any
|
||||
>y : any
|
||||
>getProperty(foo, 100) : any
|
||||
>getProperty(foo, "100") : any
|
||||
>getProperty : <T, K extends keyof T>(obj: T, key: K) => T[K]
|
||||
>foo : any
|
||||
>100 : 100
|
||||
>"100" : "100"
|
||||
|
||||
let z = getProperty(foo, bar); // any
|
||||
>z : any
|
||||
|
@ -737,6 +706,177 @@ function f40(c: C) {
|
|||
>"z" : "z"
|
||||
}
|
||||
|
||||
function f50<T>(k: keyof T, s: string) {
|
||||
>f50 : <T>(k: keyof T, s: string) => void
|
||||
>T : T
|
||||
>k : keyof T
|
||||
>T : T
|
||||
>s : string
|
||||
|
||||
const x1 = s as keyof T;
|
||||
>x1 : keyof T
|
||||
>s as keyof T : keyof T
|
||||
>s : string
|
||||
>T : T
|
||||
|
||||
const x2 = k as string;
|
||||
>x2 : string
|
||||
>k as string : string
|
||||
>k : keyof T
|
||||
}
|
||||
|
||||
function f51<T, K extends keyof T>(k: K, s: string) {
|
||||
>f51 : <T, K extends keyof T>(k: K, s: string) => void
|
||||
>T : T
|
||||
>K : K
|
||||
>T : T
|
||||
>k : K
|
||||
>K : K
|
||||
>s : string
|
||||
|
||||
const x1 = s as keyof T;
|
||||
>x1 : keyof T
|
||||
>s as keyof T : keyof T
|
||||
>s : string
|
||||
>T : T
|
||||
|
||||
const x2 = k as string;
|
||||
>x2 : string
|
||||
>k as string : string
|
||||
>k : K
|
||||
}
|
||||
|
||||
function f52<T>(obj: { [x: string]: boolean }, k: keyof T, s: string, n: number) {
|
||||
>f52 : <T>(obj: { [x: string]: boolean; }, k: keyof T, s: string, n: number) => void
|
||||
>T : T
|
||||
>obj : { [x: string]: boolean; }
|
||||
>x : string
|
||||
>k : keyof T
|
||||
>T : T
|
||||
>s : string
|
||||
>n : number
|
||||
|
||||
const x1 = obj[s];
|
||||
>x1 : boolean
|
||||
>obj[s] : boolean
|
||||
>obj : { [x: string]: boolean; }
|
||||
>s : string
|
||||
|
||||
const x2 = obj[n];
|
||||
>x2 : boolean
|
||||
>obj[n] : boolean
|
||||
>obj : { [x: string]: boolean; }
|
||||
>n : number
|
||||
|
||||
const x3 = obj[k];
|
||||
>x3 : boolean
|
||||
>obj[k] : boolean
|
||||
>obj : { [x: string]: boolean; }
|
||||
>k : keyof T
|
||||
}
|
||||
|
||||
function f53<T, K extends keyof T>(obj: { [x: string]: boolean }, k: K, s: string, n: number) {
|
||||
>f53 : <T, K extends keyof T>(obj: { [x: string]: boolean; }, k: K, s: string, n: number) => void
|
||||
>T : T
|
||||
>K : K
|
||||
>T : T
|
||||
>obj : { [x: string]: boolean; }
|
||||
>x : string
|
||||
>k : K
|
||||
>K : K
|
||||
>s : string
|
||||
>n : number
|
||||
|
||||
const x1 = obj[s];
|
||||
>x1 : boolean
|
||||
>obj[s] : boolean
|
||||
>obj : { [x: string]: boolean; }
|
||||
>s : string
|
||||
|
||||
const x2 = obj[n];
|
||||
>x2 : boolean
|
||||
>obj[n] : boolean
|
||||
>obj : { [x: string]: boolean; }
|
||||
>n : number
|
||||
|
||||
const x3 = obj[k];
|
||||
>x3 : { [x: string]: boolean; }[K]
|
||||
>obj[k] : { [x: string]: boolean; }[K]
|
||||
>obj : { [x: string]: boolean; }
|
||||
>k : K
|
||||
}
|
||||
|
||||
function f54<T>(obj: T, key: keyof T) {
|
||||
>f54 : <T>(obj: T, key: keyof T) => void
|
||||
>T : T
|
||||
>obj : T
|
||||
>T : T
|
||||
>key : keyof T
|
||||
>T : T
|
||||
|
||||
for (let s in obj[key]) {
|
||||
>s : string
|
||||
>obj[key] : T[keyof T]
|
||||
>obj : T
|
||||
>key : keyof T
|
||||
}
|
||||
const b = "foo" in obj[key];
|
||||
>b : boolean
|
||||
>"foo" in obj[key] : boolean
|
||||
>"foo" : "foo"
|
||||
>obj[key] : T[keyof T]
|
||||
>obj : T
|
||||
>key : keyof T
|
||||
}
|
||||
|
||||
function f55<T, K extends keyof T>(obj: T, key: K) {
|
||||
>f55 : <T, K extends keyof T>(obj: T, key: K) => void
|
||||
>T : T
|
||||
>K : K
|
||||
>T : T
|
||||
>obj : T
|
||||
>T : T
|
||||
>key : K
|
||||
>K : K
|
||||
|
||||
for (let s in obj[key]) {
|
||||
>s : string
|
||||
>obj[key] : T[K]
|
||||
>obj : T
|
||||
>key : K
|
||||
}
|
||||
const b = "foo" in obj[key];
|
||||
>b : boolean
|
||||
>"foo" in obj[key] : boolean
|
||||
>"foo" : "foo"
|
||||
>obj[key] : T[K]
|
||||
>obj : T
|
||||
>key : K
|
||||
}
|
||||
|
||||
function f60<T>(source: T, target: T) {
|
||||
>f60 : <T>(source: T, target: T) => void
|
||||
>T : T
|
||||
>source : T
|
||||
>T : T
|
||||
>target : T
|
||||
>T : T
|
||||
|
||||
for (let k in source) {
|
||||
>k : keyof T
|
||||
>source : T
|
||||
|
||||
target[k] = source[k];
|
||||
>target[k] = source[k] : T[keyof T]
|
||||
>target[k] : T[keyof T]
|
||||
>target : T
|
||||
>k : keyof T
|
||||
>source[k] : T[keyof T]
|
||||
>source : T
|
||||
>k : keyof T
|
||||
}
|
||||
}
|
||||
|
||||
// Repros from #12011
|
||||
|
||||
class Base {
|
||||
|
|
|
@ -1,29 +1,28 @@
|
|||
tests/cases/conformance/types/mapped/mappedTypeErrors.ts(20,20): error TS2313: Type parameter 'P' has a circular constraint.
|
||||
tests/cases/conformance/types/mapped/mappedTypeErrors.ts(21,20): error TS2322: Type 'Date' is not assignable to type 'string | number'.
|
||||
Type 'Date' is not assignable to type 'number'.
|
||||
tests/cases/conformance/types/mapped/mappedTypeErrors.ts(22,19): error TS2344: Type 'Date' does not satisfy the constraint 'string | number'.
|
||||
Type 'Date' is not assignable to type 'number'.
|
||||
tests/cases/conformance/types/mapped/mappedTypeErrors.ts(25,24): error TS2344: Type '"foo"' does not satisfy the constraint '"name" | "width" | "height" | "visible"'.
|
||||
tests/cases/conformance/types/mapped/mappedTypeErrors.ts(26,24): error TS2344: Type '"name" | "foo"' does not satisfy the constraint '"name" | "width" | "height" | "visible"'.
|
||||
tests/cases/conformance/types/mapped/mappedTypeErrors.ts(21,20): error TS2322: Type 'number' is not assignable to type 'string'.
|
||||
tests/cases/conformance/types/mapped/mappedTypeErrors.ts(22,20): error TS2322: Type 'Date' is not assignable to type 'string'.
|
||||
tests/cases/conformance/types/mapped/mappedTypeErrors.ts(23,19): error TS2344: Type 'Date' does not satisfy the constraint 'string'.
|
||||
tests/cases/conformance/types/mapped/mappedTypeErrors.ts(26,24): error TS2344: Type '"foo"' does not satisfy the constraint '"name" | "width" | "height" | "visible"'.
|
||||
tests/cases/conformance/types/mapped/mappedTypeErrors.ts(27,24): error TS2344: Type '"name" | "foo"' does not satisfy the constraint '"name" | "width" | "height" | "visible"'.
|
||||
Type '"foo"' is not assignable to type '"name" | "width" | "height" | "visible"'.
|
||||
tests/cases/conformance/types/mapped/mappedTypeErrors.ts(28,24): error TS2344: Type '"x" | "y"' does not satisfy the constraint '"name" | "width" | "height" | "visible"'.
|
||||
tests/cases/conformance/types/mapped/mappedTypeErrors.ts(29,24): error TS2344: Type '"x" | "y"' does not satisfy the constraint '"name" | "width" | "height" | "visible"'.
|
||||
Type '"x"' is not assignable to type '"name" | "width" | "height" | "visible"'.
|
||||
tests/cases/conformance/types/mapped/mappedTypeErrors.ts(30,24): error TS2344: Type 'undefined' does not satisfy the constraint '"name" | "width" | "height" | "visible"'.
|
||||
tests/cases/conformance/types/mapped/mappedTypeErrors.ts(33,24): error TS2344: Type 'T' does not satisfy the constraint '"name" | "width" | "height" | "visible"'.
|
||||
tests/cases/conformance/types/mapped/mappedTypeErrors.ts(31,24): error TS2344: Type 'undefined' does not satisfy the constraint '"name" | "width" | "height" | "visible"'.
|
||||
tests/cases/conformance/types/mapped/mappedTypeErrors.ts(34,24): error TS2344: Type 'T' does not satisfy the constraint '"name" | "width" | "height" | "visible"'.
|
||||
Type 'T' is not assignable to type '"visible"'.
|
||||
tests/cases/conformance/types/mapped/mappedTypeErrors.ts(37,24): error TS2344: Type 'T' does not satisfy the constraint '"name" | "width" | "height" | "visible"'.
|
||||
tests/cases/conformance/types/mapped/mappedTypeErrors.ts(38,24): error TS2344: Type 'T' does not satisfy the constraint '"name" | "width" | "height" | "visible"'.
|
||||
Type 'string | number' is not assignable to type '"name" | "width" | "height" | "visible"'.
|
||||
Type 'string' is not assignable to type '"name" | "width" | "height" | "visible"'.
|
||||
Type 'T' is not assignable to type '"visible"'.
|
||||
Type 'string | number' is not assignable to type '"visible"'.
|
||||
Type 'string' is not assignable to type '"visible"'.
|
||||
tests/cases/conformance/types/mapped/mappedTypeErrors.ts(59,9): error TS2403: Subsequent variable declarations must have the same type. Variable 'x' must be of type '{ [P in keyof T]: T[P]; }', but here has type '{ [P in keyof T]?: T[P]; }'.
|
||||
tests/cases/conformance/types/mapped/mappedTypeErrors.ts(60,9): error TS2403: Subsequent variable declarations must have the same type. Variable 'x' must be of type '{ [P in keyof T]: T[P]; }', but here has type '{ readonly [P in keyof T]: T[P]; }'.
|
||||
tests/cases/conformance/types/mapped/mappedTypeErrors.ts(61,9): error TS2403: Subsequent variable declarations must have the same type. Variable 'x' must be of type '{ [P in keyof T]: T[P]; }', but here has type '{ readonly [P in keyof T]?: T[P]; }'.
|
||||
tests/cases/conformance/types/mapped/mappedTypeErrors.ts(66,9): error TS2403: Subsequent variable declarations must have the same type. Variable 'x' must be of type '{ [P in keyof T]: T[P]; }', but here has type '{ [P in keyof T]: T[P][]; }'.
|
||||
tests/cases/conformance/types/mapped/mappedTypeErrors.ts(60,9): error TS2403: Subsequent variable declarations must have the same type. Variable 'x' must be of type '{ [P in keyof T]: T[P]; }', but here has type '{ [P in keyof T]?: T[P]; }'.
|
||||
tests/cases/conformance/types/mapped/mappedTypeErrors.ts(61,9): error TS2403: Subsequent variable declarations must have the same type. Variable 'x' must be of type '{ [P in keyof T]: T[P]; }', but here has type '{ readonly [P in keyof T]: T[P]; }'.
|
||||
tests/cases/conformance/types/mapped/mappedTypeErrors.ts(62,9): error TS2403: Subsequent variable declarations must have the same type. Variable 'x' must be of type '{ [P in keyof T]: T[P]; }', but here has type '{ readonly [P in keyof T]?: T[P]; }'.
|
||||
tests/cases/conformance/types/mapped/mappedTypeErrors.ts(67,9): error TS2403: Subsequent variable declarations must have the same type. Variable 'x' must be of type '{ [P in keyof T]: T[P]; }', but here has type '{ [P in keyof T]: T[P][]; }'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/types/mapped/mappedTypeErrors.ts (13 errors) ====
|
||||
==== tests/cases/conformance/types/mapped/mappedTypeErrors.ts (14 errors) ====
|
||||
|
||||
interface Shape {
|
||||
name: string;
|
||||
|
@ -46,14 +45,15 @@ tests/cases/conformance/types/mapped/mappedTypeErrors.ts(66,9): error TS2403: Su
|
|||
type T00 = { [P in P]: string }; // Error
|
||||
~
|
||||
!!! error TS2313: Type parameter 'P' has a circular constraint.
|
||||
type T01 = { [P in Date]: number }; // Error
|
||||
type T01 = { [P in number]: string }; // Error
|
||||
~~~~~~
|
||||
!!! error TS2322: Type 'number' is not assignable to type 'string'.
|
||||
type T02 = { [P in Date]: number }; // Error
|
||||
~~~~
|
||||
!!! error TS2322: Type 'Date' is not assignable to type 'string | number'.
|
||||
!!! error TS2322: Type 'Date' is not assignable to type 'number'.
|
||||
type T02 = Record<Date, number>; // Error
|
||||
!!! error TS2322: Type 'Date' is not assignable to type 'string'.
|
||||
type T03 = Record<Date, number>; // Error
|
||||
~~~~
|
||||
!!! error TS2344: Type 'Date' does not satisfy the constraint 'string | number'.
|
||||
!!! error TS2344: Type 'Date' is not assignable to type 'number'.
|
||||
!!! error TS2344: Type 'Date' does not satisfy the constraint 'string'.
|
||||
|
||||
type T10 = Pick<Shape, "name">;
|
||||
type T11 = Pick<Shape, "foo">; // Error
|
||||
|
|
|
@ -19,8 +19,9 @@ interface Point {
|
|||
// Constraint checking
|
||||
|
||||
type T00 = { [P in P]: string }; // Error
|
||||
type T01 = { [P in Date]: number }; // Error
|
||||
type T02 = Record<Date, number>; // Error
|
||||
type T01 = { [P in number]: string }; // Error
|
||||
type T02 = { [P in Date]: number }; // Error
|
||||
type T03 = Record<Date, number>; // Error
|
||||
|
||||
type T10 = Pick<Shape, "name">;
|
||||
type T11 = Pick<Shape, "foo">; // Error
|
||||
|
@ -116,9 +117,12 @@ declare type T00 = {
|
|||
[P in P]: string;
|
||||
};
|
||||
declare type T01 = {
|
||||
[P in number]: string;
|
||||
};
|
||||
declare type T02 = {
|
||||
[P in Date]: number;
|
||||
};
|
||||
declare type T02 = Record<Date, number>;
|
||||
declare type T03 = Record<Date, number>;
|
||||
declare type T10 = Pick<Shape, "name">;
|
||||
declare type T11 = Pick<Shape, "foo">;
|
||||
declare type T12 = Pick<Shape, "name" | "foo">;
|
||||
|
|
|
@ -26,13 +26,9 @@ type T37 = { [P in keyof symbol]: void };
|
|||
type T38 = { [P in keyof never]: void };
|
||||
|
||||
type T40 = { [P in string]: void };
|
||||
type T41 = { [P in number]: void };
|
||||
type T42 = { [P in string | number]: void };
|
||||
type T43 = { [P in "a" | "b" | 0 | 1]: void };
|
||||
type T43 = { [P in "a" | "b"]: void };
|
||||
type T44 = { [P in "a" | "b" | "0" | "1"]: void };
|
||||
type T45 = { [P in "a" | "b" | "0" | "1" | 0 | 1]: void };
|
||||
type T46 = { [P in number | "a" | "b" | 0 | 1]: void };
|
||||
type T47 = { [P in string | number | "a" | "b" | 0 | 1]: void };
|
||||
type T47 = { [P in string | "a" | "b" | "0" | "1"]: void };
|
||||
|
||||
declare function f1<T1>(): { [P in keyof T1]: void };
|
||||
declare function f2<T1 extends string>(): { [P in keyof T1]: void };
|
||||
|
@ -114,26 +110,14 @@ declare type T38 = {
|
|||
declare type T40 = {
|
||||
[P in string]: void;
|
||||
};
|
||||
declare type T41 = {
|
||||
[P in number]: void;
|
||||
};
|
||||
declare type T42 = {
|
||||
[P in string | number]: void;
|
||||
};
|
||||
declare type T43 = {
|
||||
[P in "a" | "b" | 0 | 1]: void;
|
||||
[P in "a" | "b"]: void;
|
||||
};
|
||||
declare type T44 = {
|
||||
[P in "a" | "b" | "0" | "1"]: void;
|
||||
};
|
||||
declare type T45 = {
|
||||
[P in "a" | "b" | "0" | "1" | 0 | 1]: void;
|
||||
};
|
||||
declare type T46 = {
|
||||
[P in number | "a" | "b" | 0 | 1]: void;
|
||||
};
|
||||
declare type T47 = {
|
||||
[P in string | number | "a" | "b" | 0 | 1]: void;
|
||||
[P in string | "a" | "b" | "0" | "1"]: void;
|
||||
};
|
||||
declare function f1<T1>(): {
|
||||
[P in keyof T1]: void;
|
||||
|
@ -146,7 +130,6 @@ declare function f3<T1 extends number>(): {
|
|||
};
|
||||
declare let x1: {};
|
||||
declare let x2: {
|
||||
[x: number]: void;
|
||||
toString: void;
|
||||
charAt: void;
|
||||
charCodeAt: void;
|
||||
|
|
|
@ -110,61 +110,45 @@ type T40 = { [P in string]: void };
|
|||
>T40 : Symbol(T40, Decl(mappedTypes1.ts, 24, 40))
|
||||
>P : Symbol(P, Decl(mappedTypes1.ts, 26, 14))
|
||||
|
||||
type T41 = { [P in number]: void };
|
||||
>T41 : Symbol(T41, Decl(mappedTypes1.ts, 26, 35))
|
||||
type T43 = { [P in "a" | "b"]: void };
|
||||
>T43 : Symbol(T43, Decl(mappedTypes1.ts, 26, 35))
|
||||
>P : Symbol(P, Decl(mappedTypes1.ts, 27, 14))
|
||||
|
||||
type T42 = { [P in string | number]: void };
|
||||
>T42 : Symbol(T42, Decl(mappedTypes1.ts, 27, 35))
|
||||
type T44 = { [P in "a" | "b" | "0" | "1"]: void };
|
||||
>T44 : Symbol(T44, Decl(mappedTypes1.ts, 27, 38))
|
||||
>P : Symbol(P, Decl(mappedTypes1.ts, 28, 14))
|
||||
|
||||
type T43 = { [P in "a" | "b" | 0 | 1]: void };
|
||||
>T43 : Symbol(T43, Decl(mappedTypes1.ts, 28, 44))
|
||||
type T47 = { [P in string | "a" | "b" | "0" | "1"]: void };
|
||||
>T47 : Symbol(T47, Decl(mappedTypes1.ts, 28, 50))
|
||||
>P : Symbol(P, Decl(mappedTypes1.ts, 29, 14))
|
||||
|
||||
type T44 = { [P in "a" | "b" | "0" | "1"]: void };
|
||||
>T44 : Symbol(T44, Decl(mappedTypes1.ts, 29, 46))
|
||||
>P : Symbol(P, Decl(mappedTypes1.ts, 30, 14))
|
||||
|
||||
type T45 = { [P in "a" | "b" | "0" | "1" | 0 | 1]: void };
|
||||
>T45 : Symbol(T45, Decl(mappedTypes1.ts, 30, 50))
|
||||
>P : Symbol(P, Decl(mappedTypes1.ts, 31, 14))
|
||||
|
||||
type T46 = { [P in number | "a" | "b" | 0 | 1]: void };
|
||||
>T46 : Symbol(T46, Decl(mappedTypes1.ts, 31, 58))
|
||||
>P : Symbol(P, Decl(mappedTypes1.ts, 32, 14))
|
||||
|
||||
type T47 = { [P in string | number | "a" | "b" | 0 | 1]: void };
|
||||
>T47 : Symbol(T47, Decl(mappedTypes1.ts, 32, 55))
|
||||
>P : Symbol(P, Decl(mappedTypes1.ts, 33, 14))
|
||||
|
||||
declare function f1<T1>(): { [P in keyof T1]: void };
|
||||
>f1 : Symbol(f1, Decl(mappedTypes1.ts, 33, 64))
|
||||
>T1 : Symbol(T1, Decl(mappedTypes1.ts, 35, 20))
|
||||
>P : Symbol(P, Decl(mappedTypes1.ts, 35, 30))
|
||||
>T1 : Symbol(T1, Decl(mappedTypes1.ts, 35, 20))
|
||||
>f1 : Symbol(f1, Decl(mappedTypes1.ts, 29, 59))
|
||||
>T1 : Symbol(T1, Decl(mappedTypes1.ts, 31, 20))
|
||||
>P : Symbol(P, Decl(mappedTypes1.ts, 31, 30))
|
||||
>T1 : Symbol(T1, Decl(mappedTypes1.ts, 31, 20))
|
||||
|
||||
declare function f2<T1 extends string>(): { [P in keyof T1]: void };
|
||||
>f2 : Symbol(f2, Decl(mappedTypes1.ts, 35, 53))
|
||||
>T1 : Symbol(T1, Decl(mappedTypes1.ts, 36, 20))
|
||||
>P : Symbol(P, Decl(mappedTypes1.ts, 36, 45))
|
||||
>T1 : Symbol(T1, Decl(mappedTypes1.ts, 36, 20))
|
||||
>f2 : Symbol(f2, Decl(mappedTypes1.ts, 31, 53))
|
||||
>T1 : Symbol(T1, Decl(mappedTypes1.ts, 32, 20))
|
||||
>P : Symbol(P, Decl(mappedTypes1.ts, 32, 45))
|
||||
>T1 : Symbol(T1, Decl(mappedTypes1.ts, 32, 20))
|
||||
|
||||
declare function f3<T1 extends number>(): { [P in keyof T1]: void };
|
||||
>f3 : Symbol(f3, Decl(mappedTypes1.ts, 36, 68))
|
||||
>T1 : Symbol(T1, Decl(mappedTypes1.ts, 37, 20))
|
||||
>P : Symbol(P, Decl(mappedTypes1.ts, 37, 45))
|
||||
>T1 : Symbol(T1, Decl(mappedTypes1.ts, 37, 20))
|
||||
>f3 : Symbol(f3, Decl(mappedTypes1.ts, 32, 68))
|
||||
>T1 : Symbol(T1, Decl(mappedTypes1.ts, 33, 20))
|
||||
>P : Symbol(P, Decl(mappedTypes1.ts, 33, 45))
|
||||
>T1 : Symbol(T1, Decl(mappedTypes1.ts, 33, 20))
|
||||
|
||||
let x1 = f1();
|
||||
>x1 : Symbol(x1, Decl(mappedTypes1.ts, 39, 3))
|
||||
>f1 : Symbol(f1, Decl(mappedTypes1.ts, 33, 64))
|
||||
>x1 : Symbol(x1, Decl(mappedTypes1.ts, 35, 3))
|
||||
>f1 : Symbol(f1, Decl(mappedTypes1.ts, 29, 59))
|
||||
|
||||
let x2 = f2();
|
||||
>x2 : Symbol(x2, Decl(mappedTypes1.ts, 40, 3))
|
||||
>f2 : Symbol(f2, Decl(mappedTypes1.ts, 35, 53))
|
||||
>x2 : Symbol(x2, Decl(mappedTypes1.ts, 36, 3))
|
||||
>f2 : Symbol(f2, Decl(mappedTypes1.ts, 31, 53))
|
||||
|
||||
let x3 = f3();
|
||||
>x3 : Symbol(x3, Decl(mappedTypes1.ts, 41, 3))
|
||||
>f3 : Symbol(f3, Decl(mappedTypes1.ts, 36, 68))
|
||||
>x3 : Symbol(x3, Decl(mappedTypes1.ts, 37, 3))
|
||||
>f3 : Symbol(f3, Decl(mappedTypes1.ts, 32, 68))
|
||||
|
||||
|
|
|
@ -112,15 +112,7 @@ type T40 = { [P in string]: void };
|
|||
>T40 : T40
|
||||
>P : P
|
||||
|
||||
type T41 = { [P in number]: void };
|
||||
>T41 : T41
|
||||
>P : P
|
||||
|
||||
type T42 = { [P in string | number]: void };
|
||||
>T42 : T42
|
||||
>P : P
|
||||
|
||||
type T43 = { [P in "a" | "b" | 0 | 1]: void };
|
||||
type T43 = { [P in "a" | "b"]: void };
|
||||
>T43 : T43
|
||||
>P : P
|
||||
|
||||
|
@ -128,15 +120,7 @@ type T44 = { [P in "a" | "b" | "0" | "1"]: void };
|
|||
>T44 : T44
|
||||
>P : P
|
||||
|
||||
type T45 = { [P in "a" | "b" | "0" | "1" | 0 | 1]: void };
|
||||
>T45 : T45
|
||||
>P : P
|
||||
|
||||
type T46 = { [P in number | "a" | "b" | 0 | 1]: void };
|
||||
>T46 : T46
|
||||
>P : P
|
||||
|
||||
type T47 = { [P in string | number | "a" | "b" | 0 | 1]: void };
|
||||
type T47 = { [P in string | "a" | "b" | "0" | "1"]: void };
|
||||
>T47 : T47
|
||||
>P : P
|
||||
|
||||
|
@ -164,8 +148,8 @@ let x1 = f1();
|
|||
>f1 : <T1>() => { [P in keyof T1]: void; }
|
||||
|
||||
let x2 = f2();
|
||||
>x2 : { [x: number]: void; toString: void; charAt: void; charCodeAt: void; concat: void; indexOf: void; lastIndexOf: void; localeCompare: void; match: void; replace: void; search: void; slice: void; split: void; substring: void; toLowerCase: void; toLocaleLowerCase: void; toUpperCase: void; toLocaleUpperCase: void; trim: void; length: void; substr: void; valueOf: void; }
|
||||
>f2() : { [x: number]: void; toString: void; charAt: void; charCodeAt: void; concat: void; indexOf: void; lastIndexOf: void; localeCompare: void; match: void; replace: void; search: void; slice: void; split: void; substring: void; toLowerCase: void; toLocaleLowerCase: void; toUpperCase: void; toLocaleUpperCase: void; trim: void; length: void; substr: void; valueOf: void; }
|
||||
>x2 : { toString: void; charAt: void; charCodeAt: void; concat: void; indexOf: void; lastIndexOf: void; localeCompare: void; match: void; replace: void; search: void; slice: void; split: void; substring: void; toLowerCase: void; toLocaleLowerCase: void; toUpperCase: void; toLocaleUpperCase: void; trim: void; length: void; substr: void; valueOf: void; }
|
||||
>f2() : { toString: void; charAt: void; charCodeAt: void; concat: void; indexOf: void; lastIndexOf: void; localeCompare: void; match: void; replace: void; search: void; slice: void; split: void; substring: void; toLowerCase: void; toLocaleLowerCase: void; toUpperCase: void; toLocaleUpperCase: void; trim: void; length: void; substr: void; valueOf: void; }
|
||||
>f2 : <T1 extends string>() => { [P in keyof T1]: void; }
|
||||
|
||||
let x3 = f3();
|
||||
|
|
|
@ -27,7 +27,7 @@ type DeepReadonly<T> = {
|
|||
declare function assign<T>(obj: T, props: Partial<T>): void;
|
||||
declare function freeze<T>(obj: T): Readonly<T>;
|
||||
declare function pick<T, K extends keyof T>(obj: T, ...keys: K[]): Pick<T, K>;
|
||||
declare function mapObject<K extends string | number, T, U>(obj: Record<K, T>, f: (x: T) => U): Record<K, U>;
|
||||
declare function mapObject<K extends string, T, U>(obj: Record<K, T>, f: (x: T) => U): Record<K, U>;
|
||||
declare function proxify<T>(obj: T): Proxify<T>;
|
||||
|
||||
interface Shape {
|
||||
|
@ -148,7 +148,7 @@ declare type DeepReadonly<T> = {
|
|||
declare function assign<T>(obj: T, props: Partial<T>): void;
|
||||
declare function freeze<T>(obj: T): Readonly<T>;
|
||||
declare function pick<T, K extends keyof T>(obj: T, ...keys: K[]): Pick<T, K>;
|
||||
declare function mapObject<K extends string | number, T, U>(obj: Record<K, T>, f: (x: T) => U): Record<K, U>;
|
||||
declare function mapObject<K extends string, T, U>(obj: Record<K, T>, f: (x: T) => U): Record<K, U>;
|
||||
declare function proxify<T>(obj: T): Proxify<T>;
|
||||
interface Shape {
|
||||
name: string;
|
||||
|
|
|
@ -126,25 +126,25 @@ declare function pick<T, K extends keyof T>(obj: T, ...keys: K[]): Pick<T, K>;
|
|||
>T : Symbol(T, Decl(mappedTypes2.ts, 27, 22))
|
||||
>K : Symbol(K, Decl(mappedTypes2.ts, 27, 24))
|
||||
|
||||
declare function mapObject<K extends string | number, T, U>(obj: Record<K, T>, f: (x: T) => U): Record<K, U>;
|
||||
declare function mapObject<K extends string, T, U>(obj: Record<K, T>, f: (x: T) => U): Record<K, U>;
|
||||
>mapObject : Symbol(mapObject, Decl(mappedTypes2.ts, 27, 78))
|
||||
>K : Symbol(K, Decl(mappedTypes2.ts, 28, 27))
|
||||
>T : Symbol(T, Decl(mappedTypes2.ts, 28, 53))
|
||||
>U : Symbol(U, Decl(mappedTypes2.ts, 28, 56))
|
||||
>obj : Symbol(obj, Decl(mappedTypes2.ts, 28, 60))
|
||||
>T : Symbol(T, Decl(mappedTypes2.ts, 28, 44))
|
||||
>U : Symbol(U, Decl(mappedTypes2.ts, 28, 47))
|
||||
>obj : Symbol(obj, Decl(mappedTypes2.ts, 28, 51))
|
||||
>Record : Symbol(Record, Decl(lib.d.ts, --, --))
|
||||
>K : Symbol(K, Decl(mappedTypes2.ts, 28, 27))
|
||||
>T : Symbol(T, Decl(mappedTypes2.ts, 28, 53))
|
||||
>f : Symbol(f, Decl(mappedTypes2.ts, 28, 78))
|
||||
>x : Symbol(x, Decl(mappedTypes2.ts, 28, 83))
|
||||
>T : Symbol(T, Decl(mappedTypes2.ts, 28, 53))
|
||||
>U : Symbol(U, Decl(mappedTypes2.ts, 28, 56))
|
||||
>T : Symbol(T, Decl(mappedTypes2.ts, 28, 44))
|
||||
>f : Symbol(f, Decl(mappedTypes2.ts, 28, 69))
|
||||
>x : Symbol(x, Decl(mappedTypes2.ts, 28, 74))
|
||||
>T : Symbol(T, Decl(mappedTypes2.ts, 28, 44))
|
||||
>U : Symbol(U, Decl(mappedTypes2.ts, 28, 47))
|
||||
>Record : Symbol(Record, Decl(lib.d.ts, --, --))
|
||||
>K : Symbol(K, Decl(mappedTypes2.ts, 28, 27))
|
||||
>U : Symbol(U, Decl(mappedTypes2.ts, 28, 56))
|
||||
>U : Symbol(U, Decl(mappedTypes2.ts, 28, 47))
|
||||
|
||||
declare function proxify<T>(obj: T): Proxify<T>;
|
||||
>proxify : Symbol(proxify, Decl(mappedTypes2.ts, 28, 109))
|
||||
>proxify : Symbol(proxify, Decl(mappedTypes2.ts, 28, 100))
|
||||
>T : Symbol(T, Decl(mappedTypes2.ts, 29, 25))
|
||||
>obj : Symbol(obj, Decl(mappedTypes2.ts, 29, 28))
|
||||
>T : Symbol(T, Decl(mappedTypes2.ts, 29, 25))
|
||||
|
@ -295,7 +295,7 @@ function f5(shape: Shape) {
|
|||
|
||||
const p = proxify(shape);
|
||||
>p : Symbol(p, Decl(mappedTypes2.ts, 79, 9))
|
||||
>proxify : Symbol(proxify, Decl(mappedTypes2.ts, 28, 109))
|
||||
>proxify : Symbol(proxify, Decl(mappedTypes2.ts, 28, 100))
|
||||
>shape : Symbol(shape, Decl(mappedTypes2.ts, 78, 12))
|
||||
|
||||
let name = p.name.get();
|
||||
|
|
|
@ -126,8 +126,8 @@ declare function pick<T, K extends keyof T>(obj: T, ...keys: K[]): Pick<T, K>;
|
|||
>T : T
|
||||
>K : K
|
||||
|
||||
declare function mapObject<K extends string | number, T, U>(obj: Record<K, T>, f: (x: T) => U): Record<K, U>;
|
||||
>mapObject : <K extends string | number, T, U>(obj: Record<K, T>, f: (x: T) => U) => Record<K, U>
|
||||
declare function mapObject<K extends string, T, U>(obj: Record<K, T>, f: (x: T) => U): Record<K, U>;
|
||||
>mapObject : <K extends string, T, U>(obj: Record<K, T>, f: (x: T) => U) => Record<K, U>
|
||||
>K : K
|
||||
>T : T
|
||||
>U : U
|
||||
|
@ -297,7 +297,7 @@ function f4() {
|
|||
const lengths = mapObject(rec, s => s.length); // { foo: number, bar: number, baz: number }
|
||||
>lengths : Record<"foo" | "bar" | "baz", number>
|
||||
>mapObject(rec, s => s.length) : Record<"foo" | "bar" | "baz", number>
|
||||
>mapObject : <K extends string | number, T, U>(obj: Record<K, T>, f: (x: T) => U) => Record<K, U>
|
||||
>mapObject : <K extends string, T, U>(obj: Record<K, T>, f: (x: T) => U) => Record<K, U>
|
||||
>rec : { foo: string; bar: string; baz: string; }
|
||||
>s => s.length : (s: string) => number
|
||||
>s : string
|
||||
|
|
|
@ -107,7 +107,7 @@ function f(x, y) {
|
|||
function f2() {
|
||||
var x = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
x[_i - 0] = arguments[_i];
|
||||
x[_i] = arguments[_i];
|
||||
}
|
||||
}
|
||||
var B = (function () {
|
||||
|
|
|
@ -106,7 +106,7 @@ function f(x, y) {
|
|||
function f2() {
|
||||
var x = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
x[_i - 0] = arguments[_i];
|
||||
x[_i] = arguments[_i];
|
||||
}
|
||||
}
|
||||
var B = (function () {
|
||||
|
|
|
@ -59,7 +59,7 @@ function f5(x, y, z) { }
|
|||
function f6() {
|
||||
var r = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
r[_i - 0] = arguments[_i];
|
||||
r[_i] = arguments[_i];
|
||||
}
|
||||
}
|
||||
// Implicit-'any'/'any[]' errors for x, r.
|
||||
|
@ -82,7 +82,7 @@ var f12 = function (x, y, z) { return ""; };
|
|||
var f13 = function () {
|
||||
var r = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
r[_i - 0] = arguments[_i];
|
||||
r[_i] = arguments[_i];
|
||||
}
|
||||
return "";
|
||||
};
|
||||
|
|
|
@ -107,7 +107,7 @@ var C = (function () {
|
|||
this.pub_f13 = function () {
|
||||
var r = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
r[_i - 0] = arguments[_i];
|
||||
r[_i] = arguments[_i];
|
||||
}
|
||||
return "";
|
||||
};
|
||||
|
@ -131,7 +131,7 @@ var C = (function () {
|
|||
this.priv_f13 = function () {
|
||||
var r = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
r[_i - 0] = arguments[_i];
|
||||
r[_i] = arguments[_i];
|
||||
}
|
||||
return "";
|
||||
};
|
||||
|
@ -158,7 +158,7 @@ var C = (function () {
|
|||
C.prototype.pub_f6 = function () {
|
||||
var r = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
r[_i - 0] = arguments[_i];
|
||||
r[_i] = arguments[_i];
|
||||
}
|
||||
};
|
||||
// Implicit-'any'/'any[]' errors for x, r.
|
||||
|
@ -184,7 +184,7 @@ var C = (function () {
|
|||
C.prototype.priv_f6 = function () {
|
||||
var r = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
r[_i - 0] = arguments[_i];
|
||||
r[_i] = arguments[_i];
|
||||
}
|
||||
};
|
||||
// Implicit-'any'/'any[]' errors for x, r.
|
||||
|
|
|
@ -63,7 +63,7 @@ var M;
|
|||
function m_f6() {
|
||||
var r = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
r[_i - 0] = arguments[_i];
|
||||
r[_i] = arguments[_i];
|
||||
}
|
||||
}
|
||||
// Implicit-'any'/'any[]' errors for x and r.
|
||||
|
@ -86,7 +86,7 @@ var M;
|
|||
var m_f13 = function () {
|
||||
var r = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
r[_i - 0] = arguments[_i];
|
||||
r[_i] = arguments[_i];
|
||||
}
|
||||
return "";
|
||||
};
|
||||
|
|
|
@ -8,7 +8,7 @@ function foo(...rest: number) { // error
|
|||
function foo() {
|
||||
var rest = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
rest[_i - 0] = arguments[_i];
|
||||
rest[_i] = arguments[_i];
|
||||
}
|
||||
var x = rest[0];
|
||||
return x;
|
||||
|
|
|
@ -13,7 +13,7 @@ foo([false, 0, ""]);
|
|||
function foo() {
|
||||
var rest = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
rest[_i - 0] = arguments[_i];
|
||||
rest[_i] = arguments[_i];
|
||||
}
|
||||
}
|
||||
foo(["", 0, false]);
|
||||
|
|
|
@ -13,7 +13,7 @@ foo({ x: false, y: 0, z: "" });
|
|||
function foo() {
|
||||
var rest = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
rest[_i - 0] = arguments[_i];
|
||||
rest[_i] = arguments[_i];
|
||||
}
|
||||
}
|
||||
foo({ x: "", y: 0, z: false });
|
||||
|
|
|
@ -24,7 +24,7 @@ var A = (function () {
|
|||
function Choice() {
|
||||
var v_args = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
v_args[_i - 0] = arguments[_i];
|
||||
v_args[_i] = arguments[_i];
|
||||
}
|
||||
return new A();
|
||||
}
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue