mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Merge remote-tracking branch 'tsupstream/master'
This commit is contained in:
+6
-8
@@ -256,7 +256,7 @@ var harnessSources = harnessCoreSources.concat([
|
||||
"commandLineParsing.ts",
|
||||
"configurationExtension.ts",
|
||||
"convertCompilerOptionsFromJson.ts",
|
||||
"convertTypingOptionsFromJson.ts",
|
||||
"convertTypeAcquisitionFromJson.ts",
|
||||
"tsserverProjectSystem.ts",
|
||||
"compileOnSave.ts",
|
||||
"typingsInstaller.ts",
|
||||
@@ -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);
|
||||
});
|
||||
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
+81
-88
@@ -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,
|
||||
@@ -3824,6 +3797,16 @@ namespace ts {
|
||||
}
|
||||
baseType = getReturnTypeOfSignature(constructors[0]);
|
||||
}
|
||||
|
||||
// In a JS file, you can use the @augments jsdoc tag to specify a base type with type parameters
|
||||
const valueDecl = type.symbol.valueDeclaration;
|
||||
if (valueDecl && isInJavaScriptFile(valueDecl)) {
|
||||
const augTag = getJSDocAugmentsTag(type.symbol.valueDeclaration);
|
||||
if (augTag) {
|
||||
baseType = getTypeFromTypeNode(augTag.typeExpression.type);
|
||||
}
|
||||
}
|
||||
|
||||
if (baseType === unknownType) {
|
||||
return;
|
||||
}
|
||||
@@ -3832,7 +3815,7 @@ namespace ts {
|
||||
return;
|
||||
}
|
||||
if (type === baseType || hasBaseType(<InterfaceType>baseType, type)) {
|
||||
error(type.symbol.valueDeclaration, Diagnostics.Type_0_recursively_references_itself_as_a_base_type,
|
||||
error(valueDecl, Diagnostics.Type_0_recursively_references_itself_as_a_base_type,
|
||||
typeToString(type, /*enclosingDeclaration*/ undefined, TypeFormatFlags.WriteArrayAsGenericType));
|
||||
return;
|
||||
}
|
||||
@@ -4688,7 +4671,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 +4883,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 +5903,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 +6021,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 +6033,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 +7105,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) {
|
||||
@@ -9002,7 +8977,7 @@ namespace ts {
|
||||
|
||||
function getTypeWithDefault(type: Type, defaultExpression: Expression) {
|
||||
if (defaultExpression) {
|
||||
const defaultType = checkExpression(defaultExpression);
|
||||
const defaultType = getTypeOfExpression(defaultExpression);
|
||||
return getUnionType([getTypeWithFacts(type, TypeFacts.NEUndefined), defaultType]);
|
||||
}
|
||||
return type;
|
||||
@@ -9029,7 +9004,7 @@ namespace ts {
|
||||
function getAssignedTypeOfBinaryExpression(node: BinaryExpression): Type {
|
||||
return node.parent.kind === SyntaxKind.ArrayLiteralExpression || node.parent.kind === SyntaxKind.PropertyAssignment ?
|
||||
getTypeWithDefault(getAssignedType(node), node.right) :
|
||||
checkExpression(node.right);
|
||||
getTypeOfExpression(node.right);
|
||||
}
|
||||
|
||||
function getAssignedTypeOfArrayLiteralElement(node: ArrayLiteralExpression, element: Expression): Type {
|
||||
@@ -9087,7 +9062,7 @@ namespace ts {
|
||||
// from its initializer, we'll already have cached the type. Otherwise we compute it now
|
||||
// without caching such that transient types are reflected.
|
||||
const links = getNodeLinks(node);
|
||||
return links.resolvedType || checkExpression(node);
|
||||
return links.resolvedType || getTypeOfExpression(node);
|
||||
}
|
||||
|
||||
function getInitialTypeOfVariableDeclaration(node: VariableDeclaration) {
|
||||
@@ -9147,7 +9122,7 @@ namespace ts {
|
||||
|
||||
function getTypeOfSwitchClause(clause: CaseClause | DefaultClause) {
|
||||
if (clause.kind === SyntaxKind.CaseClause) {
|
||||
const caseType = getRegularTypeOfLiteralType(checkExpression((<CaseClause>clause).expression));
|
||||
const caseType = getRegularTypeOfLiteralType(getTypeOfExpression((<CaseClause>clause).expression));
|
||||
return isUnitType(caseType) ? caseType : undefined;
|
||||
}
|
||||
return neverType;
|
||||
@@ -9252,7 +9227,7 @@ namespace ts {
|
||||
// we defer subtype reduction until the evolving array type is finalized into a manifest
|
||||
// array type.
|
||||
function addEvolvingArrayElementType(evolvingArrayType: EvolvingArrayType, node: Expression): EvolvingArrayType {
|
||||
const elementType = getBaseTypeOfLiteralType(checkExpression(node));
|
||||
const elementType = getBaseTypeOfLiteralType(getTypeOfExpression(node));
|
||||
return isTypeSubsetOf(elementType, evolvingArrayType.elementType) ? evolvingArrayType : getEvolvingArrayType(getUnionType([evolvingArrayType.elementType, elementType]));
|
||||
}
|
||||
|
||||
@@ -9313,7 +9288,7 @@ namespace ts {
|
||||
(<BinaryExpression>parent.parent).operatorToken.kind === SyntaxKind.EqualsToken &&
|
||||
(<BinaryExpression>parent.parent).left === parent &&
|
||||
!isAssignmentTarget(parent.parent) &&
|
||||
isTypeAnyOrAllConstituentTypesHaveKind(checkExpression((<ElementAccessExpression>parent).argumentExpression), TypeFlags.NumberLike | TypeFlags.Undefined);
|
||||
isTypeAnyOrAllConstituentTypesHaveKind(getTypeOfExpression((<ElementAccessExpression>parent).argumentExpression), TypeFlags.NumberLike | TypeFlags.Undefined);
|
||||
return isLengthPushOrUnshift || isElementAssignment;
|
||||
}
|
||||
|
||||
@@ -9475,7 +9450,7 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
else {
|
||||
const indexType = checkExpression((<ElementAccessExpression>(<BinaryExpression>node).left).argumentExpression);
|
||||
const indexType = getTypeOfExpression((<ElementAccessExpression>(<BinaryExpression>node).left).argumentExpression);
|
||||
if (isTypeAnyOrAllConstituentTypesHaveKind(indexType, TypeFlags.NumberLike | TypeFlags.Undefined)) {
|
||||
evolvedType = addEvolvingArrayElementType(evolvedType, (<BinaryExpression>node).right);
|
||||
}
|
||||
@@ -9700,7 +9675,7 @@ namespace ts {
|
||||
if (operator === SyntaxKind.ExclamationEqualsToken || operator === SyntaxKind.ExclamationEqualsEqualsToken) {
|
||||
assumeTrue = !assumeTrue;
|
||||
}
|
||||
const valueType = checkExpression(value);
|
||||
const valueType = getTypeOfExpression(value);
|
||||
if (valueType.flags & TypeFlags.Nullable) {
|
||||
if (!strictNullChecks) {
|
||||
return type;
|
||||
@@ -9787,7 +9762,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
// Check that right operand is a function type with a prototype property
|
||||
const rightType = checkExpression(expr.right);
|
||||
const rightType = getTypeOfExpression(expr.right);
|
||||
if (!isTypeSubtypeOf(rightType, globalFunctionType)) {
|
||||
return type;
|
||||
}
|
||||
@@ -9928,7 +9903,7 @@ namespace ts {
|
||||
location = location.parent;
|
||||
}
|
||||
if (isPartOfExpression(location) && !isAssignmentTarget(location)) {
|
||||
const type = checkExpression(<Expression>location);
|
||||
const type = getTypeOfExpression(<Expression>location);
|
||||
if (getExportSymbolOfValueSymbolIfExported(getNodeLinks(location).resolvedSymbol) === symbol) {
|
||||
return type;
|
||||
}
|
||||
@@ -10394,9 +10369,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);
|
||||
}
|
||||
@@ -10796,7 +10771,7 @@ namespace ts {
|
||||
|
||||
// In an assignment expression, the right operand is contextually typed by the type of the left operand.
|
||||
if (node === binaryExpression.right) {
|
||||
return checkExpression(binaryExpression.left);
|
||||
return getTypeOfExpression(binaryExpression.left);
|
||||
}
|
||||
}
|
||||
else if (operator === SyntaxKind.BarBarToken) {
|
||||
@@ -10804,7 +10779,7 @@ namespace ts {
|
||||
// expression has no contextual type, the right operand is contextually typed by the type of the left operand.
|
||||
let type = getContextualType(binaryExpression);
|
||||
if (!type && node === binaryExpression.right) {
|
||||
type = checkExpression(binaryExpression.left);
|
||||
type = getTypeOfExpression(binaryExpression.left);
|
||||
}
|
||||
return type;
|
||||
}
|
||||
@@ -12175,7 +12150,7 @@ namespace ts {
|
||||
if (node.kind === SyntaxKind.ForInStatement &&
|
||||
child === (<ForInStatement>node).statement &&
|
||||
getForInVariableSymbol(<ForInStatement>node) === symbol &&
|
||||
hasNumericPropertyNames(checkExpression((<ForInStatement>node).expression))) {
|
||||
hasNumericPropertyNames(getTypeOfExpression((<ForInStatement>node).expression))) {
|
||||
return true;
|
||||
}
|
||||
child = node;
|
||||
@@ -13630,7 +13605,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);
|
||||
@@ -13811,7 +13786,7 @@ namespace ts {
|
||||
if (!node.possiblyExhaustive) {
|
||||
return false;
|
||||
}
|
||||
const type = checkExpression(node.expression);
|
||||
const type = getTypeOfExpression(node.expression);
|
||||
if (!isLiteralType(type)) {
|
||||
return false;
|
||||
}
|
||||
@@ -14258,7 +14233,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;
|
||||
@@ -14903,6 +14878,24 @@ namespace ts {
|
||||
return type;
|
||||
}
|
||||
|
||||
// Returns the type of an expression. Unlike checkExpression, this function is simply concerned
|
||||
// with computing the type and may not fully check all contained sub-expressions for errors.
|
||||
function getTypeOfExpression(node: Expression) {
|
||||
// Optimize for the common case of a call to a function with a single non-generic call
|
||||
// signature where we can just fetch the return type without checking the arguments.
|
||||
if (node.kind === SyntaxKind.CallExpression && (<CallExpression>node).expression.kind !== SyntaxKind.SuperKeyword) {
|
||||
const funcType = checkNonNullExpression((<CallExpression>node).expression);
|
||||
const signature = getSingleCallSignature(funcType);
|
||||
if (signature && !signature.typeParameters) {
|
||||
return getReturnTypeOfSignature(signature);
|
||||
}
|
||||
}
|
||||
// Otherwise simply call checkExpression. Ideally, the entire family of checkXXX functions
|
||||
// should have a parameter that indicates whether full error checking is required such that
|
||||
// we can perform the optimizations locally.
|
||||
return checkExpression(node);
|
||||
}
|
||||
|
||||
// Checks an expression and returns its type. The contextualMapper parameter serves two purposes: When
|
||||
// contextualMapper is not undefined and not equal to the identityMapper function object it indicates that the
|
||||
// expression is being inferentially typed (section 4.15.2 in spec) and provides the type mapper to use in
|
||||
@@ -15652,7 +15645,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 {
|
||||
@@ -17163,7 +17156,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);
|
||||
}
|
||||
|
||||
@@ -18285,7 +18278,7 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
enumType = checkExpression(expression);
|
||||
enumType = getTypeOfExpression(expression);
|
||||
// allow references to constant members of other enums
|
||||
if (!(enumType.symbol && (enumType.symbol.flags & SymbolFlags.Enum))) {
|
||||
return undefined;
|
||||
@@ -19455,7 +19448,7 @@ namespace ts {
|
||||
// fallthrough
|
||||
|
||||
case SyntaxKind.SuperKeyword:
|
||||
const type = isPartOfExpression(node) ? checkExpression(<Expression>node) : getTypeFromTypeNode(<TypeNode>node);
|
||||
const type = isPartOfExpression(node) ? getTypeOfExpression(<Expression>node) : getTypeFromTypeNode(<TypeNode>node);
|
||||
return type.symbol;
|
||||
|
||||
case SyntaxKind.ThisType:
|
||||
@@ -19485,7 +19478,7 @@ namespace ts {
|
||||
case SyntaxKind.NumericLiteral:
|
||||
// index access
|
||||
if (node.parent.kind === SyntaxKind.ElementAccessExpression && (<ElementAccessExpression>node.parent).argumentExpression === node) {
|
||||
const objectType = checkExpression((<ElementAccessExpression>node.parent).expression);
|
||||
const objectType = getTypeOfExpression((<ElementAccessExpression>node.parent).expression);
|
||||
if (objectType === unknownType) return undefined;
|
||||
const apparentType = getApparentType(objectType);
|
||||
if (apparentType === unknownType) return undefined;
|
||||
@@ -19524,7 +19517,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
if (isPartOfExpression(node)) {
|
||||
return getTypeOfExpression(<Expression>node);
|
||||
return getRegularTypeOfExpression(<Expression>node);
|
||||
}
|
||||
|
||||
if (isExpressionWithTypeArgumentsInClassExtendsClause(node)) {
|
||||
@@ -19586,7 +19579,7 @@ namespace ts {
|
||||
// If this is from "for" initializer
|
||||
// for ({a } = elems[0];.....) { }
|
||||
if (expr.parent.kind === SyntaxKind.BinaryExpression) {
|
||||
const iteratedType = checkExpression((<BinaryExpression>expr.parent).right);
|
||||
const iteratedType = getTypeOfExpression((<BinaryExpression>expr.parent).right);
|
||||
return checkDestructuringAssignment(expr, iteratedType || unknownType);
|
||||
}
|
||||
// If this is from nested object binding pattern
|
||||
@@ -19616,11 +19609,11 @@ namespace ts {
|
||||
return typeOfObjectLiteral && getPropertyOfType(typeOfObjectLiteral, location.text);
|
||||
}
|
||||
|
||||
function getTypeOfExpression(expr: Expression): Type {
|
||||
function getRegularTypeOfExpression(expr: Expression): Type {
|
||||
if (isRightSideOfQualifiedNameOrPropertyAccess(expr)) {
|
||||
expr = <Expression>expr.parent;
|
||||
}
|
||||
return getRegularTypeOfLiteralType(checkExpression(expr));
|
||||
return getRegularTypeOfLiteralType(getTypeOfExpression(expr));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -20047,7 +20040,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
function writeTypeOfExpression(expr: Expression, enclosingDeclaration: Node, flags: TypeFormatFlags, writer: SymbolWriter) {
|
||||
const type = getWidenedType(getTypeOfExpression(expr));
|
||||
const type = getWidenedType(getRegularTypeOfExpression(expr));
|
||||
getSymbolDisplayBuilder().buildTypeDisplay(type, writer, enclosingDeclaration, flags);
|
||||
}
|
||||
|
||||
|
||||
@@ -462,11 +462,18 @@ namespace ts {
|
||||
];
|
||||
|
||||
/* @internal */
|
||||
export let typingOptionDeclarations: CommandLineOption[] = [
|
||||
export let typeAcquisitionDeclarations: CommandLineOption[] = [
|
||||
{
|
||||
/* @deprecated typingOptions.enableAutoDiscovery
|
||||
* Use typeAcquisition.enable instead.
|
||||
*/
|
||||
name: "enableAutoDiscovery",
|
||||
type: "boolean",
|
||||
},
|
||||
{
|
||||
name: "enable",
|
||||
type: "boolean",
|
||||
},
|
||||
{
|
||||
name: "include",
|
||||
type: "list",
|
||||
@@ -501,6 +508,20 @@ namespace ts {
|
||||
|
||||
let optionNameMapCache: OptionNameMap;
|
||||
|
||||
/* @internal */
|
||||
export function convertEnableAutoDiscoveryToEnable(typeAcquisition: TypeAcquisition): TypeAcquisition {
|
||||
// Convert deprecated typingOptions.enableAutoDiscovery to typeAcquisition.enable
|
||||
if (typeAcquisition && typeAcquisition.enableAutoDiscovery !== undefined && typeAcquisition.enable === undefined) {
|
||||
const result: TypeAcquisition = {
|
||||
enable: typeAcquisition.enableAutoDiscovery,
|
||||
include: typeAcquisition.include || [],
|
||||
exclude: typeAcquisition.exclude || []
|
||||
};
|
||||
return result;
|
||||
}
|
||||
return typeAcquisition;
|
||||
}
|
||||
|
||||
/* @internal */
|
||||
export function getOptionNameMap(): OptionNameMap {
|
||||
if (optionNameMapCache) {
|
||||
@@ -835,7 +856,7 @@ namespace ts {
|
||||
return {
|
||||
options: {},
|
||||
fileNames: [],
|
||||
typingOptions: {},
|
||||
typeAcquisition: {},
|
||||
raw: json,
|
||||
errors: [createCompilerDiagnostic(Diagnostics.Circularity_detected_while_resolving_configuration_Colon_0, [...resolutionStack, resolvedPath].join(" -> "))],
|
||||
wildcardDirectories: {}
|
||||
@@ -843,7 +864,10 @@ namespace ts {
|
||||
}
|
||||
|
||||
let options: CompilerOptions = convertCompilerOptionsFromJsonWorker(json["compilerOptions"], basePath, errors, configFileName);
|
||||
const typingOptions: TypingOptions = convertTypingOptionsFromJsonWorker(json["typingOptions"], basePath, errors, configFileName);
|
||||
// typingOptions has been deprecated and is only supported for backward compatibility purposes.
|
||||
// It should be removed in future releases - use typeAcquisition instead.
|
||||
const jsonOptions = json["typeAcquisition"] || json["typingOptions"];
|
||||
const typeAcquisition: TypeAcquisition = convertTypeAcquisitionFromJsonWorker(jsonOptions, basePath, errors, configFileName);
|
||||
|
||||
if (json["extends"]) {
|
||||
let [include, exclude, files, baseOptions]: [string[], string[], string[], CompilerOptions] = [undefined, undefined, undefined, {}];
|
||||
@@ -874,7 +898,7 @@ namespace ts {
|
||||
return {
|
||||
options,
|
||||
fileNames,
|
||||
typingOptions,
|
||||
typeAcquisition,
|
||||
raw: json,
|
||||
errors,
|
||||
wildcardDirectories,
|
||||
@@ -951,8 +975,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) {
|
||||
@@ -996,9 +1020,9 @@ namespace ts {
|
||||
return { options, errors };
|
||||
}
|
||||
|
||||
export function convertTypingOptionsFromJson(jsonOptions: any, basePath: string, configFileName?: string): { options: TypingOptions, errors: Diagnostic[] } {
|
||||
export function convertTypeAcquisitionFromJson(jsonOptions: any, basePath: string, configFileName?: string): { options: TypeAcquisition, errors: Diagnostic[] } {
|
||||
const errors: Diagnostic[] = [];
|
||||
const options = convertTypingOptionsFromJsonWorker(jsonOptions, basePath, errors, configFileName);
|
||||
const options = convertTypeAcquisitionFromJsonWorker(jsonOptions, basePath, errors, configFileName);
|
||||
return { options, errors };
|
||||
}
|
||||
|
||||
@@ -1012,16 +1036,18 @@ namespace ts {
|
||||
return options;
|
||||
}
|
||||
|
||||
function convertTypingOptionsFromJsonWorker(jsonOptions: any,
|
||||
basePath: string, errors: Diagnostic[], configFileName?: string): TypingOptions {
|
||||
function convertTypeAcquisitionFromJsonWorker(jsonOptions: any,
|
||||
basePath: string, errors: Diagnostic[], configFileName?: string): TypeAcquisition {
|
||||
|
||||
const options: TypeAcquisition = { enable: getBaseFileName(configFileName) === "jsconfig.json", include: [], exclude: [] };
|
||||
const typeAcquisition = convertEnableAutoDiscoveryToEnable(jsonOptions);
|
||||
convertOptionsFromJson(typeAcquisitionDeclarations, typeAcquisition, basePath, options, Diagnostics.Unknown_type_acquisition_option_0, errors);
|
||||
|
||||
const options: TypingOptions = { enableAutoDiscovery: getBaseFileName(configFileName) === "jsconfig.json", include: [], exclude: [] };
|
||||
convertOptionsFromJson(typingOptionDeclarations, jsonOptions, basePath, options, Diagnostics.Unknown_typing_option_0, errors);
|
||||
return options;
|
||||
}
|
||||
|
||||
function convertOptionsFromJson(optionDeclarations: CommandLineOption[], jsonOptions: any, basePath: string,
|
||||
defaultOptions: CompilerOptions | TypingOptions, diagnosticMessage: DiagnosticMessage, errors: Diagnostic[]) {
|
||||
defaultOptions: CompilerOptions | TypeAcquisition, diagnosticMessage: DiagnosticMessage, errors: Diagnostic[]) {
|
||||
|
||||
if (!jsonOptions) {
|
||||
return;
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -3137,7 +3137,7 @@
|
||||
"category": "Error",
|
||||
"code": 17009
|
||||
},
|
||||
"Unknown typing option '{0}'.": {
|
||||
"Unknown type acquisition option '{0}'.": {
|
||||
"category": "Error",
|
||||
"code": 17010
|
||||
},
|
||||
|
||||
@@ -143,7 +143,7 @@ namespace ts {
|
||||
|
||||
// Write the source map
|
||||
if (compilerOptions.sourceMap && !compilerOptions.inlineSourceMap) {
|
||||
writeFile(host, emitterDiagnostics, sourceMapFilePath, sourceMap.getText(), /*writeByteOrderMark*/ false);
|
||||
writeFile(host, emitterDiagnostics, sourceMapFilePath, sourceMap.getText(), /*writeByteOrderMark*/ false, sourceFiles);
|
||||
}
|
||||
|
||||
// Record source map data for the test harness.
|
||||
@@ -152,7 +152,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
// Write the output file
|
||||
writeFile(host, emitterDiagnostics, jsFilePath, writer.getText(), compilerOptions.emitBOM);
|
||||
writeFile(host, emitterDiagnostics, jsFilePath, writer.getText(), compilerOptions.emitBOM, sourceFiles);
|
||||
|
||||
// Reset state
|
||||
sourceMap.reset();
|
||||
|
||||
+13
-4
@@ -654,16 +654,16 @@ namespace ts {
|
||||
if (whenFalse) {
|
||||
// second overload
|
||||
node.questionToken = <QuestionToken>questionTokenOrWhenTrue;
|
||||
node.whenTrue = whenTrueOrWhenFalse;
|
||||
node.whenTrue = parenthesizeSubexpressionOfConditionalExpression(whenTrueOrWhenFalse);
|
||||
node.colonToken = <ColonToken>colonTokenOrLocation;
|
||||
node.whenFalse = whenFalse;
|
||||
node.whenFalse = parenthesizeSubexpressionOfConditionalExpression(whenFalse);
|
||||
}
|
||||
else {
|
||||
// first overload
|
||||
node.questionToken = createToken(SyntaxKind.QuestionToken);
|
||||
node.whenTrue = <Expression>questionTokenOrWhenTrue;
|
||||
node.whenTrue = parenthesizeSubexpressionOfConditionalExpression(<Expression>questionTokenOrWhenTrue);
|
||||
node.colonToken = createToken(SyntaxKind.ColonToken);
|
||||
node.whenFalse = whenTrueOrWhenFalse;
|
||||
node.whenFalse = parenthesizeSubexpressionOfConditionalExpression(whenTrueOrWhenFalse);
|
||||
}
|
||||
return node;
|
||||
}
|
||||
@@ -2381,6 +2381,15 @@ namespace ts {
|
||||
return condition;
|
||||
}
|
||||
|
||||
function parenthesizeSubexpressionOfConditionalExpression(e: Expression): Expression {
|
||||
// per ES grammar both 'whenTrue' and 'whenFalse' parts of conditional expression are assignment expressions
|
||||
// so in case when comma expression is introduced as a part of previous transformations
|
||||
// if should be wrapped in parens since comma operator has the lowest precedence
|
||||
return e.kind === SyntaxKind.BinaryExpression && (<BinaryExpression>e).operatorToken.kind === SyntaxKind.CommaToken
|
||||
? createParen(e)
|
||||
: e;
|
||||
}
|
||||
|
||||
/**
|
||||
* Wraps an expression in parentheses if it is needed in order to use the expression
|
||||
* as the expression of a NewExpression node.
|
||||
|
||||
+26
-11
@@ -418,6 +418,8 @@ namespace ts {
|
||||
return visitNode(cbNode, (<JSDocReturnTag>node).typeExpression);
|
||||
case SyntaxKind.JSDocTypeTag:
|
||||
return visitNode(cbNode, (<JSDocTypeTag>node).typeExpression);
|
||||
case SyntaxKind.JSDocAugmentsTag:
|
||||
return visitNode(cbNode, (<JSDocAugmentsTag>node).typeExpression);
|
||||
case SyntaxKind.JSDocTemplateTag:
|
||||
return visitNodes(cbNodes, (<JSDocTemplateTag>node).typeParameters);
|
||||
case SyntaxKind.JSDocTypedefTag:
|
||||
@@ -681,7 +683,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 +691,10 @@ namespace ts {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!node.jsDocComments) {
|
||||
node.jsDocComments = [];
|
||||
if (!node.jsDoc) {
|
||||
node.jsDoc = [];
|
||||
}
|
||||
node.jsDocComments.push(jsDoc);
|
||||
node.jsDoc.push(jsDoc);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -719,11 +721,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;
|
||||
@@ -6426,6 +6428,9 @@ namespace ts {
|
||||
let tag: JSDocTag;
|
||||
if (tagName) {
|
||||
switch (tagName.text) {
|
||||
case "augments":
|
||||
tag = parseAugmentsTag(atToken, tagName);
|
||||
break;
|
||||
case "param":
|
||||
tag = parseParamTag(atToken, tagName);
|
||||
break;
|
||||
@@ -6642,6 +6647,16 @@ namespace ts {
|
||||
return finishNode(result);
|
||||
}
|
||||
|
||||
function parseAugmentsTag(atToken: AtToken, tagName: Identifier): JSDocAugmentsTag {
|
||||
const typeExpression = tryParseTypeExpression();
|
||||
|
||||
const result = <JSDocAugmentsTag>createNode(SyntaxKind.JSDocAugmentsTag, atToken.pos);
|
||||
result.atToken = atToken;
|
||||
result.tagName = tagName;
|
||||
result.typeExpression = typeExpression;
|
||||
return finishNode(result);
|
||||
}
|
||||
|
||||
function parseTypedefTag(atToken: AtToken, tagName: Identifier): JSDocTypedefTag {
|
||||
const typeExpression = tryParseTypeExpression();
|
||||
skipWhitespace();
|
||||
@@ -6954,8 +6969,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);
|
||||
}
|
||||
}
|
||||
|
||||
+1
-61
@@ -43,66 +43,6 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks to see if the locale is in the appropriate format,
|
||||
* and if it is, attempts to set the appropriate language.
|
||||
*/
|
||||
function validateLocaleAndSetLanguage(locale: string, errors: Diagnostic[]): boolean {
|
||||
const matchResult = /^([a-z]+)([_\-]([a-z]+))?$/.exec(locale.toLowerCase());
|
||||
|
||||
if (!matchResult) {
|
||||
errors.push(createCompilerDiagnostic(Diagnostics.Locale_must_be_of_the_form_language_or_language_territory_For_example_0_or_1, "en", "ja-jp"));
|
||||
return false;
|
||||
}
|
||||
|
||||
const language = matchResult[1];
|
||||
const territory = matchResult[3];
|
||||
|
||||
// First try the entire locale, then fall back to just language if that's all we have.
|
||||
// Either ways do not fail, and fallback to the English diagnostic strings.
|
||||
if (!trySetLanguageAndTerritory(language, territory, errors)) {
|
||||
trySetLanguageAndTerritory(language, undefined, errors);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function trySetLanguageAndTerritory(language: string, territory: string, errors: Diagnostic[]): boolean {
|
||||
const compilerFilePath = normalizePath(sys.getExecutingFilePath());
|
||||
const containingDirectoryPath = getDirectoryPath(compilerFilePath);
|
||||
|
||||
let filePath = combinePaths(containingDirectoryPath, language);
|
||||
|
||||
if (territory) {
|
||||
filePath = filePath + "-" + territory;
|
||||
}
|
||||
|
||||
filePath = sys.resolvePath(combinePaths(filePath, "diagnosticMessages.generated.json"));
|
||||
|
||||
if (!sys.fileExists(filePath)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// TODO: Add codePage support for readFile?
|
||||
let fileContents = "";
|
||||
try {
|
||||
fileContents = sys.readFile(filePath);
|
||||
}
|
||||
catch (e) {
|
||||
errors.push(createCompilerDiagnostic(Diagnostics.Unable_to_open_file_0, filePath));
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
ts.localizedDiagnosticMessages = JSON.parse(fileContents);
|
||||
}
|
||||
catch (e) {
|
||||
errors.push(createCompilerDiagnostic(Diagnostics.Corrupted_locale_file_0, filePath));
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function countLines(program: Program): number {
|
||||
let count = 0;
|
||||
forEach(program.getSourceFiles(), file => {
|
||||
@@ -263,7 +203,7 @@ namespace ts {
|
||||
reportDiagnostic(createCompilerDiagnostic(Diagnostics.The_current_host_does_not_support_the_0_option, "--locale"), /* host */ undefined);
|
||||
return sys.exit(ExitStatus.DiagnosticsPresent_OutputsSkipped);
|
||||
}
|
||||
validateLocaleAndSetLanguage(commandLine.options.locale, commandLine.errors);
|
||||
validateLocaleAndSetLanguage(commandLine.options.locale, sys, commandLine.errors);
|
||||
}
|
||||
|
||||
// If there are any errors due to command line parsing and/or
|
||||
|
||||
+16
-5
@@ -349,6 +349,7 @@ namespace ts {
|
||||
JSDocThisType,
|
||||
JSDocComment,
|
||||
JSDocTag,
|
||||
JSDocAugmentsTag,
|
||||
JSDocParameterTag,
|
||||
JSDocReturnTag,
|
||||
JSDocTypeTag,
|
||||
@@ -497,7 +498,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)
|
||||
@@ -1988,6 +1990,11 @@ namespace ts {
|
||||
kind: SyntaxKind.JSDocTag;
|
||||
}
|
||||
|
||||
export interface JSDocAugmentsTag extends JSDocTag {
|
||||
kind: SyntaxKind.JSDocAugmentsTag;
|
||||
typeExpression: JSDocTypeExpression;
|
||||
}
|
||||
|
||||
export interface JSDocTemplateTag extends JSDocTag {
|
||||
kind: SyntaxKind.JSDocTemplateTag;
|
||||
typeParameters: NodeArray<TypeParameterDeclaration>;
|
||||
@@ -2789,7 +2796,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,
|
||||
@@ -3198,8 +3205,12 @@ namespace ts {
|
||||
[option: string]: CompilerOptionsValue | undefined;
|
||||
}
|
||||
|
||||
export interface TypingOptions {
|
||||
export interface TypeAcquisition {
|
||||
/* @deprecated typingOptions.enableAutoDiscovery
|
||||
* Use typeAcquisition.enable instead.
|
||||
*/
|
||||
enableAutoDiscovery?: boolean;
|
||||
enable?: boolean;
|
||||
include?: string[];
|
||||
exclude?: string[];
|
||||
[option: string]: string[] | boolean | undefined;
|
||||
@@ -3210,7 +3221,7 @@ namespace ts {
|
||||
projectRootPath: string; // The path to the project root directory
|
||||
safeListPath: string; // The path used to retrieve the safe list
|
||||
packageNameToTypingLocation: Map<string>; // The map of package names to their cached typing locations
|
||||
typingOptions: TypingOptions; // Used to customize the typing inference process
|
||||
typeAcquisition: TypeAcquisition; // Used to customize the type acquisition process
|
||||
compilerOptions: CompilerOptions; // Used as a source for typing inference
|
||||
unresolvedImports: ReadonlyArray<string>; // List of unresolved module ids from imports
|
||||
}
|
||||
@@ -3275,7 +3286,7 @@ namespace ts {
|
||||
/** Either a parsed command line or a parsed tsconfig.json */
|
||||
export interface ParsedCommandLine {
|
||||
options: CompilerOptions;
|
||||
typingOptions?: TypingOptions;
|
||||
typeAcquisition?: TypeAcquisition;
|
||||
fileNames: string[];
|
||||
raw?: any;
|
||||
errors: Diagnostic[];
|
||||
|
||||
+159
-144
@@ -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);
|
||||
@@ -472,15 +472,15 @@ namespace ts {
|
||||
|
||||
export function getTextOfPropertyName(name: PropertyName): string {
|
||||
switch (name.kind) {
|
||||
case SyntaxKind.Identifier:
|
||||
return (<Identifier>name).text;
|
||||
case SyntaxKind.StringLiteral:
|
||||
case SyntaxKind.NumericLiteral:
|
||||
return (<LiteralExpression>name).text;
|
||||
case SyntaxKind.ComputedPropertyName:
|
||||
if (isStringOrNumericLiteral((<ComputedPropertyName>name).expression)) {
|
||||
return (<LiteralExpression>(<ComputedPropertyName>name).expression).text;
|
||||
}
|
||||
case SyntaxKind.Identifier:
|
||||
return (<Identifier>name).text;
|
||||
case SyntaxKind.StringLiteral:
|
||||
case SyntaxKind.NumericLiteral:
|
||||
return (<LiteralExpression>name).text;
|
||||
case SyntaxKind.ComputedPropertyName:
|
||||
if (isStringOrNumericLiteral((<ComputedPropertyName>name).expression)) {
|
||||
return (<LiteralExpression>(<ComputedPropertyName>name).expression).text;
|
||||
}
|
||||
}
|
||||
|
||||
return undefined;
|
||||
@@ -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,28 @@ 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 getJSDocAugmentsTag(node: Node): JSDocAugmentsTag {
|
||||
return getFirstJSDocTag(node, SyntaxKind.JSDocAugmentsTag) as JSDocAugmentsTag;
|
||||
}
|
||||
|
||||
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 +1561,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);
|
||||
}
|
||||
@@ -4554,4 +4502,71 @@ namespace ts {
|
||||
|
||||
return flags;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks to see if the locale is in the appropriate format,
|
||||
* and if it is, attempts to set the appropriate language.
|
||||
*/
|
||||
export function validateLocaleAndSetLanguage(
|
||||
locale: string,
|
||||
sys: { getExecutingFilePath(): string, resolvePath(path: string): string, fileExists(fileName: string): boolean, readFile(fileName: string): string },
|
||||
errors?: Diagnostic[]) {
|
||||
const matchResult = /^([a-z]+)([_\-]([a-z]+))?$/.exec(locale.toLowerCase());
|
||||
|
||||
if (!matchResult) {
|
||||
if (errors) {
|
||||
errors.push(createCompilerDiagnostic(Diagnostics.Locale_must_be_of_the_form_language_or_language_territory_For_example_0_or_1, "en", "ja-jp"));
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
const language = matchResult[1];
|
||||
const territory = matchResult[3];
|
||||
|
||||
// First try the entire locale, then fall back to just language if that's all we have.
|
||||
// Either ways do not fail, and fallback to the English diagnostic strings.
|
||||
if (!trySetLanguageAndTerritory(language, territory, errors)) {
|
||||
trySetLanguageAndTerritory(language, /*territory*/ undefined, errors);
|
||||
}
|
||||
|
||||
function trySetLanguageAndTerritory(language: string, territory: string, errors?: Diagnostic[]): boolean {
|
||||
const compilerFilePath = normalizePath(sys.getExecutingFilePath());
|
||||
const containingDirectoryPath = getDirectoryPath(compilerFilePath);
|
||||
|
||||
let filePath = combinePaths(containingDirectoryPath, language);
|
||||
|
||||
if (territory) {
|
||||
filePath = filePath + "-" + territory;
|
||||
}
|
||||
|
||||
filePath = sys.resolvePath(combinePaths(filePath, "diagnosticMessages.generated.json"));
|
||||
|
||||
if (!sys.fileExists(filePath)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// TODO: Add codePage support for readFile?
|
||||
let fileContents = "";
|
||||
try {
|
||||
fileContents = sys.readFile(filePath);
|
||||
}
|
||||
catch (e) {
|
||||
if (errors) {
|
||||
errors.push(createCompilerDiagnostic(Diagnostics.Unable_to_open_file_0, filePath));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
ts.localizedDiagnosticMessages = JSON.parse(fileContents);
|
||||
}
|
||||
catch (e) {
|
||||
if (errors) {
|
||||
errors.push(createCompilerDiagnostic(Diagnostics.Corrupted_locale_file_0, filePath));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
});
|
||||
|
||||
@@ -108,7 +108,7 @@
|
||||
"./unittests/commandLineParsing.ts",
|
||||
"./unittests/configurationExtension.ts",
|
||||
"./unittests/convertCompilerOptionsFromJson.ts",
|
||||
"./unittests/convertTypingOptionsFromJson.ts",
|
||||
"./unittests/convertTypeAcquisitionFromJson.ts",
|
||||
"./unittests/tsserverProjectSystem.ts",
|
||||
"./unittests/matchFiles.ts",
|
||||
"./unittests/initializeTSConfig.ts",
|
||||
|
||||
+72
-49
@@ -2,12 +2,13 @@
|
||||
/// <reference path="..\..\compiler\commandLineParser.ts" />
|
||||
|
||||
namespace ts {
|
||||
describe("convertTypingOptionsFromJson", () => {
|
||||
function assertTypingOptions(json: any, configFileName: string, expectedResult: { typingOptions: TypingOptions, errors: Diagnostic[] }) {
|
||||
const { options: actualTypingOptions, errors: actualErrors } = convertTypingOptionsFromJson(json["typingOptions"], "/apath/", configFileName);
|
||||
const parsedTypingOptions = JSON.stringify(actualTypingOptions);
|
||||
const expectedTypingOptions = JSON.stringify(expectedResult.typingOptions);
|
||||
assert.equal(parsedTypingOptions, expectedTypingOptions);
|
||||
describe("convertTypeAcquisitionFromJson", () => {
|
||||
function assertTypeAcquisition(json: any, configFileName: string, expectedResult: { typeAcquisition: TypeAcquisition, errors: Diagnostic[] }) {
|
||||
const jsonOptions = json["typeAcquisition"] || json["typingOptions"];
|
||||
const { options: actualTypeAcquisition, errors: actualErrors } = convertTypeAcquisitionFromJson(jsonOptions, "/apath/", configFileName);
|
||||
const parsedTypeAcquisition = JSON.stringify(actualTypeAcquisition);
|
||||
const expectedTypeAcquisition = JSON.stringify(expectedResult.typeAcquisition);
|
||||
assert.equal(parsedTypeAcquisition, expectedTypeAcquisition);
|
||||
|
||||
const expectedErrors = expectedResult.errors;
|
||||
assert.isTrue(expectedResult.errors.length === actualErrors.length, `Expected error: ${JSON.stringify(expectedResult.errors)}. Actual error: ${JSON.stringify(actualErrors)}.`);
|
||||
@@ -20,8 +21,8 @@ namespace ts {
|
||||
}
|
||||
|
||||
// tsconfig.json
|
||||
it("Convert correctly format tsconfig.json to typing-options ", () => {
|
||||
assertTypingOptions(
|
||||
it("Convert deprecated typingOptions.enableAutoDiscovery format tsconfig.json to typeAcquisition ", () => {
|
||||
assertTypeAcquisition(
|
||||
{
|
||||
"typingOptions":
|
||||
{
|
||||
@@ -32,9 +33,9 @@ namespace ts {
|
||||
},
|
||||
"tsconfig.json",
|
||||
{
|
||||
typingOptions:
|
||||
typeAcquisition:
|
||||
{
|
||||
enableAutoDiscovery: true,
|
||||
enable: true,
|
||||
include: ["0.d.ts", "1.d.ts"],
|
||||
exclude: ["0.js", "1.js"]
|
||||
},
|
||||
@@ -42,25 +43,47 @@ namespace ts {
|
||||
});
|
||||
});
|
||||
|
||||
it("Convert incorrect format tsconfig.json to typing-options ", () => {
|
||||
assertTypingOptions(
|
||||
it("Convert correctly format tsconfig.json to typeAcquisition ", () => {
|
||||
assertTypeAcquisition(
|
||||
{
|
||||
"typingOptions":
|
||||
"typeAcquisition":
|
||||
{
|
||||
"enable": true,
|
||||
"include": ["0.d.ts", "1.d.ts"],
|
||||
"exclude": ["0.js", "1.js"]
|
||||
}
|
||||
},
|
||||
"tsconfig.json",
|
||||
{
|
||||
typeAcquisition:
|
||||
{
|
||||
enable: true,
|
||||
include: ["0.d.ts", "1.d.ts"],
|
||||
exclude: ["0.js", "1.js"]
|
||||
},
|
||||
errors: <Diagnostic[]>[]
|
||||
});
|
||||
});
|
||||
|
||||
it("Convert incorrect format tsconfig.json to typeAcquisition ", () => {
|
||||
assertTypeAcquisition(
|
||||
{
|
||||
"typeAcquisition":
|
||||
{
|
||||
"enableAutoDiscovy": true,
|
||||
}
|
||||
}, "tsconfig.json",
|
||||
{
|
||||
typingOptions:
|
||||
typeAcquisition:
|
||||
{
|
||||
enableAutoDiscovery: false,
|
||||
enable: false,
|
||||
include: [],
|
||||
exclude: []
|
||||
},
|
||||
errors: [
|
||||
{
|
||||
category: Diagnostics.Unknown_typing_option_0.category,
|
||||
code: Diagnostics.Unknown_typing_option_0.code,
|
||||
category: Diagnostics.Unknown_type_acquisition_option_0.category,
|
||||
code: Diagnostics.Unknown_type_acquisition_option_0.code,
|
||||
file: undefined,
|
||||
start: 0,
|
||||
length: 0,
|
||||
@@ -70,12 +93,12 @@ namespace ts {
|
||||
});
|
||||
});
|
||||
|
||||
it("Convert default tsconfig.json to typing-options ", () => {
|
||||
assertTypingOptions({}, "tsconfig.json",
|
||||
it("Convert default tsconfig.json to typeAcquisition ", () => {
|
||||
assertTypeAcquisition({}, "tsconfig.json",
|
||||
{
|
||||
typingOptions:
|
||||
typeAcquisition:
|
||||
{
|
||||
enableAutoDiscovery: false,
|
||||
enable: false,
|
||||
include: [],
|
||||
exclude: []
|
||||
},
|
||||
@@ -83,18 +106,18 @@ namespace ts {
|
||||
});
|
||||
});
|
||||
|
||||
it("Convert tsconfig.json with only enableAutoDiscovery property to typing-options ", () => {
|
||||
assertTypingOptions(
|
||||
it("Convert tsconfig.json with only enable property to typeAcquisition ", () => {
|
||||
assertTypeAcquisition(
|
||||
{
|
||||
"typingOptions":
|
||||
"typeAcquisition":
|
||||
{
|
||||
"enableAutoDiscovery": true
|
||||
"enable": true
|
||||
}
|
||||
}, "tsconfig.json",
|
||||
{
|
||||
typingOptions:
|
||||
typeAcquisition:
|
||||
{
|
||||
enableAutoDiscovery: true,
|
||||
enable: true,
|
||||
include: [],
|
||||
exclude: []
|
||||
},
|
||||
@@ -103,20 +126,20 @@ namespace ts {
|
||||
});
|
||||
|
||||
// jsconfig.json
|
||||
it("Convert jsconfig.json to typing-options ", () => {
|
||||
assertTypingOptions(
|
||||
it("Convert jsconfig.json to typeAcquisition ", () => {
|
||||
assertTypeAcquisition(
|
||||
{
|
||||
"typingOptions":
|
||||
"typeAcquisition":
|
||||
{
|
||||
"enableAutoDiscovery": false,
|
||||
"enable": false,
|
||||
"include": ["0.d.ts"],
|
||||
"exclude": ["0.js"]
|
||||
}
|
||||
}, "jsconfig.json",
|
||||
{
|
||||
typingOptions:
|
||||
typeAcquisition:
|
||||
{
|
||||
enableAutoDiscovery: false,
|
||||
enable: false,
|
||||
include: ["0.d.ts"],
|
||||
exclude: ["0.js"]
|
||||
},
|
||||
@@ -124,12 +147,12 @@ namespace ts {
|
||||
});
|
||||
});
|
||||
|
||||
it("Convert default jsconfig.json to typing-options ", () => {
|
||||
assertTypingOptions({ }, "jsconfig.json",
|
||||
it("Convert default jsconfig.json to typeAcquisition ", () => {
|
||||
assertTypeAcquisition({ }, "jsconfig.json",
|
||||
{
|
||||
typingOptions:
|
||||
typeAcquisition:
|
||||
{
|
||||
enableAutoDiscovery: true,
|
||||
enable: true,
|
||||
include: [],
|
||||
exclude: []
|
||||
},
|
||||
@@ -137,25 +160,25 @@ namespace ts {
|
||||
});
|
||||
});
|
||||
|
||||
it("Convert incorrect format jsconfig.json to typing-options ", () => {
|
||||
assertTypingOptions(
|
||||
it("Convert incorrect format jsconfig.json to typeAcquisition ", () => {
|
||||
assertTypeAcquisition(
|
||||
{
|
||||
"typingOptions":
|
||||
"typeAcquisition":
|
||||
{
|
||||
"enableAutoDiscovy": true,
|
||||
}
|
||||
}, "jsconfig.json",
|
||||
{
|
||||
typingOptions:
|
||||
typeAcquisition:
|
||||
{
|
||||
enableAutoDiscovery: true,
|
||||
enable: true,
|
||||
include: [],
|
||||
exclude: []
|
||||
},
|
||||
errors: [
|
||||
{
|
||||
category: Diagnostics.Unknown_compiler_option_0.category,
|
||||
code: Diagnostics.Unknown_typing_option_0.code,
|
||||
code: Diagnostics.Unknown_type_acquisition_option_0.code,
|
||||
file: undefined,
|
||||
start: 0,
|
||||
length: 0,
|
||||
@@ -165,18 +188,18 @@ namespace ts {
|
||||
});
|
||||
});
|
||||
|
||||
it("Convert jsconfig.json with only enableAutoDiscovery property to typing-options ", () => {
|
||||
assertTypingOptions(
|
||||
it("Convert jsconfig.json with only enable property to typeAcquisition ", () => {
|
||||
assertTypeAcquisition(
|
||||
{
|
||||
"typingOptions":
|
||||
"typeAcquisition":
|
||||
{
|
||||
"enableAutoDiscovery": false
|
||||
"enable": false
|
||||
}
|
||||
}, "jsconfig.json",
|
||||
{
|
||||
typingOptions:
|
||||
typeAcquisition:
|
||||
{
|
||||
enableAutoDiscovery: false,
|
||||
enable: false,
|
||||
include: [],
|
||||
exclude: []
|
||||
},
|
||||
@@ -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: {}
|
||||
|
||||
@@ -90,8 +90,8 @@ namespace ts.projectSystem {
|
||||
this.projectService.updateTypingsForProject(response);
|
||||
}
|
||||
|
||||
enqueueInstallTypingsRequest(project: server.Project, typingOptions: TypingOptions, unresolvedImports: server.SortedReadonlyArray<string>) {
|
||||
const request = server.createInstallTypingsRequest(project, typingOptions, unresolvedImports, this.globalTypingsCacheLocation);
|
||||
enqueueInstallTypingsRequest(project: server.Project, typeAcquisition: TypeAcquisition, unresolvedImports: server.SortedReadonlyArray<string>) {
|
||||
const request = server.createInstallTypingsRequest(project, typeAcquisition, unresolvedImports, this.globalTypingsCacheLocation);
|
||||
this.install(request);
|
||||
}
|
||||
|
||||
@@ -1726,8 +1726,8 @@ namespace ts.projectSystem {
|
||||
options: {}
|
||||
});
|
||||
projectService.checkNumberOfProjects({ externalProjects: 1 });
|
||||
const typingOptions = projectService.externalProjects[0].getTypingOptions();
|
||||
assert.isTrue(typingOptions.enableAutoDiscovery, "Typing autodiscovery should be enabled");
|
||||
const typeAcquisition = projectService.externalProjects[0].getTypeAcquisition();
|
||||
assert.isTrue(typeAcquisition.enable, "Typine acquisition should be enabled");
|
||||
});
|
||||
});
|
||||
|
||||
@@ -2452,6 +2452,43 @@ namespace ts.projectSystem {
|
||||
openFilesForSession([file], session);
|
||||
serverEventManager.checkEventCountOfType("configFileDiag", 1);
|
||||
});
|
||||
|
||||
it("are generated when the config file changes", () => {
|
||||
const serverEventManager = new TestServerEventManager();
|
||||
const file = {
|
||||
path: "/a/b/app.ts",
|
||||
content: "let x = 10"
|
||||
};
|
||||
const configFile = {
|
||||
path: "/a/b/tsconfig.json",
|
||||
content: `{
|
||||
"compilerOptions": {}
|
||||
}`
|
||||
};
|
||||
|
||||
const host = createServerHost([file, configFile]);
|
||||
const session = createSession(host, /*typingsInstaller*/ undefined, serverEventManager.handler);
|
||||
openFilesForSession([file], session);
|
||||
serverEventManager.checkEventCountOfType("configFileDiag", 1);
|
||||
|
||||
configFile.content = `{
|
||||
"compilerOptions": {
|
||||
"haha": 123
|
||||
}
|
||||
}`;
|
||||
host.reloadFS([file, configFile]);
|
||||
host.triggerFileWatcherCallback(configFile.path);
|
||||
host.runQueuedTimeoutCallbacks();
|
||||
serverEventManager.checkEventCountOfType("configFileDiag", 2);
|
||||
|
||||
configFile.content = `{
|
||||
"compilerOptions": {}
|
||||
}`;
|
||||
host.reloadFS([file, configFile]);
|
||||
host.triggerFileWatcherCallback(configFile.path);
|
||||
host.runQueuedTimeoutCallbacks();
|
||||
serverEventManager.checkEventCountOfType("configFileDiag", 3);
|
||||
});
|
||||
});
|
||||
|
||||
describe("skipLibCheck", () => {
|
||||
|
||||
@@ -57,8 +57,8 @@ namespace ts.projectSystem {
|
||||
compilerOptions: {
|
||||
allowJs: true
|
||||
},
|
||||
typingOptions: {
|
||||
enableAutoDiscovery: true
|
||||
typeAcquisition: {
|
||||
enable: true
|
||||
}
|
||||
})
|
||||
};
|
||||
@@ -145,7 +145,7 @@ namespace ts.projectSystem {
|
||||
checkProjectActualFiles(p, [file1.path, jquery.path]);
|
||||
});
|
||||
|
||||
it("external project - no typing options, no .d.ts/js files", () => {
|
||||
it("external project - no type acquisition, no .d.ts/js files", () => {
|
||||
const file1 = {
|
||||
path: "/a/b/app.ts",
|
||||
content: ""
|
||||
@@ -173,7 +173,7 @@ namespace ts.projectSystem {
|
||||
projectService.checkNumberOfProjects({ externalProjects: 1 });
|
||||
});
|
||||
|
||||
it("external project - no autoDiscovery in typing options, no .d.ts/js files", () => {
|
||||
it("external project - no auto in typing acquisition, no .d.ts/js files", () => {
|
||||
const file1 = {
|
||||
path: "/a/b/app.ts",
|
||||
content: ""
|
||||
@@ -194,11 +194,11 @@ namespace ts.projectSystem {
|
||||
projectFileName,
|
||||
options: {},
|
||||
rootFiles: [toExternalFile(file1.path)],
|
||||
typingOptions: { include: ["jquery"] }
|
||||
typeAcquisition: { include: ["jquery"] }
|
||||
});
|
||||
installer.checkPendingCommands(/*expectedCount*/ 0);
|
||||
// by default auto discovery will kick in if project contain only .js/.d.ts files
|
||||
// in this case project contain only ts files - no auto discovery even if typing options is set
|
||||
// in this case project contain only ts files - no auto discovery even if type acquisition is set
|
||||
projectService.checkNumberOfProjects({ externalProjects: 1 });
|
||||
});
|
||||
|
||||
@@ -217,9 +217,9 @@ namespace ts.projectSystem {
|
||||
constructor() {
|
||||
super(host, { typesRegistry: createTypesRegistry("jquery") });
|
||||
}
|
||||
enqueueInstallTypingsRequest(project: server.Project, typingOptions: TypingOptions, unresolvedImports: server.SortedReadonlyArray<string>) {
|
||||
enqueueInstallTypingsRequest(project: server.Project, typeAcquisition: TypeAcquisition, unresolvedImports: server.SortedReadonlyArray<string>) {
|
||||
enqueueIsCalled = true;
|
||||
super.enqueueInstallTypingsRequest(project, typingOptions, unresolvedImports);
|
||||
super.enqueueInstallTypingsRequest(project, typeAcquisition, unresolvedImports);
|
||||
}
|
||||
installWorker(_requestId: number, _args: string[], _cwd: string, cb: TI.RequestCompletedAction): void {
|
||||
const installedTypings = ["@types/node"];
|
||||
@@ -234,17 +234,17 @@ namespace ts.projectSystem {
|
||||
projectFileName,
|
||||
options: {},
|
||||
rootFiles: [toExternalFile(file1.path)],
|
||||
typingOptions: { enableAutoDiscovery: true, include: ["jquery"] }
|
||||
typeAcquisition: { enable: true, include: ["jquery"] }
|
||||
});
|
||||
|
||||
assert.isTrue(enqueueIsCalled, "expected enqueueIsCalled to be true");
|
||||
installer.installAll(/*expectedCount*/ 1);
|
||||
|
||||
// autoDiscovery is set in typing options - use it even if project contains only .ts files
|
||||
// auto is set in type acquisition - use it even if project contains only .ts files
|
||||
projectService.checkNumberOfProjects({ externalProjects: 1 });
|
||||
});
|
||||
|
||||
it("external project - no typing options, with only js, jsx, d.ts files", () => {
|
||||
it("external project - no type acquisition, with only js, jsx, d.ts files", () => {
|
||||
// Tests:
|
||||
// 1. react typings are installed for .jsx
|
||||
// 2. loose files names are matched against safe list for typings if
|
||||
@@ -288,7 +288,7 @@ namespace ts.projectSystem {
|
||||
projectFileName,
|
||||
options: { allowJS: true, moduleResolution: ModuleResolutionKind.NodeJs },
|
||||
rootFiles: [toExternalFile(file1.path), toExternalFile(file2.path), toExternalFile(file3.path)],
|
||||
typingOptions: {}
|
||||
typeAcquisition: {}
|
||||
});
|
||||
|
||||
const p = projectService.externalProjects[0];
|
||||
@@ -301,7 +301,7 @@ namespace ts.projectSystem {
|
||||
checkProjectActualFiles(p, [file1.path, file2.path, file3.path, lodash.path, react.path]);
|
||||
});
|
||||
|
||||
it("external project - no typing options, with js & ts files", () => {
|
||||
it("external project - no type acquisition, with js & ts files", () => {
|
||||
// Tests:
|
||||
// 1. No typings are included for JS projects when the project contains ts files
|
||||
const file1 = {
|
||||
@@ -319,9 +319,9 @@ namespace ts.projectSystem {
|
||||
constructor() {
|
||||
super(host, { typesRegistry: createTypesRegistry("jquery") });
|
||||
}
|
||||
enqueueInstallTypingsRequest(project: server.Project, typingOptions: TypingOptions, unresolvedImports: server.SortedReadonlyArray<string>) {
|
||||
enqueueInstallTypingsRequest(project: server.Project, typeAcquisition: TypeAcquisition, unresolvedImports: server.SortedReadonlyArray<string>) {
|
||||
enqueueIsCalled = true;
|
||||
super.enqueueInstallTypingsRequest(project, typingOptions, unresolvedImports);
|
||||
super.enqueueInstallTypingsRequest(project, typeAcquisition, unresolvedImports);
|
||||
}
|
||||
installWorker(_requestId: number, _args: string[], _cwd: string, cb: TI.RequestCompletedAction): void {
|
||||
const installedTypings: string[] = [];
|
||||
@@ -336,7 +336,7 @@ namespace ts.projectSystem {
|
||||
projectFileName,
|
||||
options: { allowJS: true, moduleResolution: ModuleResolutionKind.NodeJs },
|
||||
rootFiles: [toExternalFile(file1.path), toExternalFile(file2.path)],
|
||||
typingOptions: {}
|
||||
typeAcquisition: {}
|
||||
});
|
||||
|
||||
const p = projectService.externalProjects[0];
|
||||
@@ -349,11 +349,11 @@ namespace ts.projectSystem {
|
||||
checkProjectActualFiles(p, [file1.path, file2.path]);
|
||||
});
|
||||
|
||||
it("external project - with typing options, with only js, d.ts files", () => {
|
||||
it("external project - with type acquisition, with only js, d.ts files", () => {
|
||||
// Tests:
|
||||
// 1. Safelist matching, typing options includes/excludes and package.json typings are all acquired
|
||||
// 2. Types for safelist matches are not included when they also appear in the typing option exclude list
|
||||
// 3. Multiple includes and excludes are respected in typing options
|
||||
// 1. Safelist matching, type acquisition includes/excludes and package.json typings are all acquired
|
||||
// 2. Types for safelist matches are not included when they also appear in the type acquisition exclude list
|
||||
// 3. Multiple includes and excludes are respected in type acquisition
|
||||
const file1 = {
|
||||
path: "/a/b/lodash.js",
|
||||
content: ""
|
||||
@@ -411,7 +411,7 @@ namespace ts.projectSystem {
|
||||
projectFileName,
|
||||
options: { allowJS: true, moduleResolution: ModuleResolutionKind.NodeJs },
|
||||
rootFiles: [toExternalFile(file1.path), toExternalFile(file2.path), toExternalFile(file3.path)],
|
||||
typingOptions: { include: ["jquery", "moment"], exclude: ["lodash"] }
|
||||
typeAcquisition: { include: ["jquery", "moment"], exclude: ["lodash"] }
|
||||
});
|
||||
|
||||
const p = projectService.externalProjects[0];
|
||||
@@ -486,7 +486,7 @@ namespace ts.projectSystem {
|
||||
projectFileName,
|
||||
options: { allowJS: true, moduleResolution: ModuleResolutionKind.NodeJs },
|
||||
rootFiles: [toExternalFile(lodashJs.path), toExternalFile(commanderJs.path), toExternalFile(file3.path)],
|
||||
typingOptions: { include: ["jquery", "moment"] }
|
||||
typeAcquisition: { include: ["jquery", "moment"] }
|
||||
});
|
||||
|
||||
const p = projectService.externalProjects[0];
|
||||
@@ -572,7 +572,7 @@ namespace ts.projectSystem {
|
||||
projectFileName: projectFileName1,
|
||||
options: { allowJS: true, moduleResolution: ModuleResolutionKind.NodeJs },
|
||||
rootFiles: [toExternalFile(lodashJs.path), toExternalFile(commanderJs.path), toExternalFile(file3.path)],
|
||||
typingOptions: { include: ["jquery", "cordova"] }
|
||||
typeAcquisition: { include: ["jquery", "cordova"] }
|
||||
});
|
||||
|
||||
installer.checkPendingCommands(/*expectedCount*/ 1);
|
||||
@@ -584,7 +584,7 @@ namespace ts.projectSystem {
|
||||
projectFileName: projectFileName2,
|
||||
options: { allowJS: true, moduleResolution: ModuleResolutionKind.NodeJs },
|
||||
rootFiles: [toExternalFile(file3.path)],
|
||||
typingOptions: { include: ["grunt", "gulp"] }
|
||||
typeAcquisition: { include: ["grunt", "gulp"] }
|
||||
});
|
||||
assert.equal(installer.pendingRunRequests.length, 1, "expect one throttled request");
|
||||
|
||||
@@ -930,7 +930,7 @@ namespace ts.projectSystem {
|
||||
const host = createServerHost([f]);
|
||||
const cache = createMap<string>();
|
||||
for (const name of JsTyping.nodeCoreModuleList) {
|
||||
const result = JsTyping.discoverTypings(host, [f.path], getDirectoryPath(<Path>f.path), /*safeListPath*/ undefined, cache, { enableAutoDiscovery: true }, [name, "somename"]);
|
||||
const result = JsTyping.discoverTypings(host, [f.path], getDirectoryPath(<Path>f.path), /*safeListPath*/ undefined, cache, { enable: true }, [name, "somename"]);
|
||||
assert.deepEqual(result.newTypingNames.sort(), ["node", "somename"]);
|
||||
}
|
||||
});
|
||||
@@ -946,7 +946,7 @@ namespace ts.projectSystem {
|
||||
};
|
||||
const host = createServerHost([f, node]);
|
||||
const cache = createMap<string>({ "node": node.path });
|
||||
const result = JsTyping.discoverTypings(host, [f.path], getDirectoryPath(<Path>f.path), /*safeListPath*/ undefined, cache, { enableAutoDiscovery: true }, ["fs", "bar"]);
|
||||
const result = JsTyping.discoverTypings(host, [f.path], getDirectoryPath(<Path>f.path), /*safeListPath*/ undefined, cache, { enable: true }, ["fs", "bar"]);
|
||||
assert.deepEqual(result.cachedTypingPaths, [node.path]);
|
||||
assert.deepEqual(result.newTypingNames, ["bar"]);
|
||||
});
|
||||
|
||||
Vendored
+1687
-2599
File diff suppressed because it is too large
Load Diff
Vendored
+1
-1
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Vendored
+131
-83
@@ -8,6 +8,7 @@ interface Algorithm {
|
||||
}
|
||||
|
||||
interface EventInit {
|
||||
scoped?: boolean;
|
||||
bubbles?: boolean;
|
||||
cancelable?: boolean;
|
||||
}
|
||||
@@ -242,10 +243,12 @@ interface Event {
|
||||
readonly target: EventTarget;
|
||||
readonly timeStamp: number;
|
||||
readonly type: string;
|
||||
readonly scoped: boolean;
|
||||
initEvent(eventTypeArg: string, canBubbleArg: boolean, cancelableArg: boolean): void;
|
||||
preventDefault(): void;
|
||||
stopImmediatePropagation(): void;
|
||||
stopPropagation(): void;
|
||||
deepPath(): EventTarget[];
|
||||
readonly AT_TARGET: number;
|
||||
readonly BUBBLING_PHASE: number;
|
||||
readonly CAPTURING_PHASE: number;
|
||||
@@ -298,6 +301,7 @@ interface FileReader extends EventTarget, MSBaseReader {
|
||||
readAsBinaryString(blob: Blob): void;
|
||||
readAsDataURL(blob: Blob): void;
|
||||
readAsText(blob: Blob, encoding?: string): void;
|
||||
addEventListener<K extends keyof MSBaseReaderEventMap>(type: K, listener: (this: MSBaseReader, ev: MSBaseReaderEventMap[K]) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void;
|
||||
}
|
||||
|
||||
@@ -339,11 +343,16 @@ declare var IDBCursorWithValue: {
|
||||
new(): IDBCursorWithValue;
|
||||
}
|
||||
|
||||
interface IDBDatabaseEventMap {
|
||||
"abort": Event;
|
||||
"error": ErrorEvent;
|
||||
}
|
||||
|
||||
interface IDBDatabase extends EventTarget {
|
||||
readonly name: string;
|
||||
readonly objectStoreNames: DOMStringList;
|
||||
onabort: (this: this, ev: Event) => any;
|
||||
onerror: (this: this, ev: ErrorEvent) => any;
|
||||
onabort: (this: IDBDatabase, ev: Event) => any;
|
||||
onerror: (this: IDBDatabase, ev: ErrorEvent) => any;
|
||||
version: number;
|
||||
onversionchange: (ev: IDBVersionChangeEvent) => any;
|
||||
close(): void;
|
||||
@@ -351,8 +360,7 @@ interface IDBDatabase extends EventTarget {
|
||||
deleteObjectStore(name: string): void;
|
||||
transaction(storeNames: string | string[], mode?: string): IDBTransaction;
|
||||
addEventListener(type: "versionchange", listener: (ev: IDBVersionChangeEvent) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: "abort", listener: (this: this, ev: Event) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: "error", listener: (this: this, ev: ErrorEvent) => any, useCapture?: boolean): void;
|
||||
addEventListener<K extends keyof IDBDatabaseEventMap>(type: K, listener: (this: IDBDatabase, ev: IDBDatabaseEventMap[K]) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void;
|
||||
}
|
||||
|
||||
@@ -429,13 +437,15 @@ declare var IDBObjectStore: {
|
||||
new(): IDBObjectStore;
|
||||
}
|
||||
|
||||
interface IDBOpenDBRequestEventMap extends IDBRequestEventMap {
|
||||
"blocked": Event;
|
||||
"upgradeneeded": IDBVersionChangeEvent;
|
||||
}
|
||||
|
||||
interface IDBOpenDBRequest extends IDBRequest {
|
||||
onblocked: (this: this, ev: Event) => any;
|
||||
onupgradeneeded: (this: this, ev: IDBVersionChangeEvent) => any;
|
||||
addEventListener(type: "blocked", listener: (this: this, ev: Event) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: "error", listener: (this: this, ev: ErrorEvent) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: "success", listener: (this: this, ev: Event) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: "upgradeneeded", listener: (this: this, ev: IDBVersionChangeEvent) => any, useCapture?: boolean): void;
|
||||
onblocked: (this: IDBOpenDBRequest, ev: Event) => any;
|
||||
onupgradeneeded: (this: IDBOpenDBRequest, ev: IDBVersionChangeEvent) => any;
|
||||
addEventListener<K extends keyof IDBOpenDBRequestEventMap>(type: K, listener: (this: IDBOpenDBRequest, ev: IDBOpenDBRequestEventMap[K]) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void;
|
||||
}
|
||||
|
||||
@@ -444,16 +454,20 @@ declare var IDBOpenDBRequest: {
|
||||
new(): IDBOpenDBRequest;
|
||||
}
|
||||
|
||||
interface IDBRequestEventMap {
|
||||
"error": ErrorEvent;
|
||||
"success": Event;
|
||||
}
|
||||
|
||||
interface IDBRequest extends EventTarget {
|
||||
readonly error: DOMError;
|
||||
onerror: (this: this, ev: ErrorEvent) => any;
|
||||
onsuccess: (this: this, ev: Event) => any;
|
||||
onerror: (this: IDBRequest, ev: ErrorEvent) => any;
|
||||
onsuccess: (this: IDBRequest, ev: Event) => any;
|
||||
readonly readyState: string;
|
||||
readonly result: any;
|
||||
source: IDBObjectStore | IDBIndex | IDBCursor;
|
||||
readonly transaction: IDBTransaction;
|
||||
addEventListener(type: "error", listener: (this: this, ev: ErrorEvent) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: "success", listener: (this: this, ev: Event) => any, useCapture?: boolean): void;
|
||||
addEventListener<K extends keyof IDBRequestEventMap>(type: K, listener: (this: IDBRequest, ev: IDBRequestEventMap[K]) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void;
|
||||
}
|
||||
|
||||
@@ -462,21 +476,25 @@ declare var IDBRequest: {
|
||||
new(): IDBRequest;
|
||||
}
|
||||
|
||||
interface IDBTransactionEventMap {
|
||||
"abort": Event;
|
||||
"complete": Event;
|
||||
"error": ErrorEvent;
|
||||
}
|
||||
|
||||
interface IDBTransaction extends EventTarget {
|
||||
readonly db: IDBDatabase;
|
||||
readonly error: DOMError;
|
||||
readonly mode: string;
|
||||
onabort: (this: this, ev: Event) => any;
|
||||
oncomplete: (this: this, ev: Event) => any;
|
||||
onerror: (this: this, ev: ErrorEvent) => any;
|
||||
onabort: (this: IDBTransaction, ev: Event) => any;
|
||||
oncomplete: (this: IDBTransaction, ev: Event) => any;
|
||||
onerror: (this: IDBTransaction, ev: ErrorEvent) => any;
|
||||
abort(): void;
|
||||
objectStore(name: string): IDBObjectStore;
|
||||
readonly READ_ONLY: string;
|
||||
readonly READ_WRITE: string;
|
||||
readonly VERSION_CHANGE: string;
|
||||
addEventListener(type: "abort", listener: (this: this, ev: Event) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: "complete", listener: (this: this, ev: Event) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: "error", listener: (this: this, ev: ErrorEvent) => any, useCapture?: boolean): void;
|
||||
addEventListener<K extends keyof IDBTransactionEventMap>(type: K, listener: (this: IDBTransaction, ev: IDBTransactionEventMap[K]) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void;
|
||||
}
|
||||
|
||||
@@ -533,18 +551,22 @@ interface MSApp {
|
||||
}
|
||||
declare var MSApp: MSApp;
|
||||
|
||||
interface MSAppAsyncOperationEventMap {
|
||||
"complete": Event;
|
||||
"error": ErrorEvent;
|
||||
}
|
||||
|
||||
interface MSAppAsyncOperation extends EventTarget {
|
||||
readonly error: DOMError;
|
||||
oncomplete: (this: this, ev: Event) => any;
|
||||
onerror: (this: this, ev: ErrorEvent) => any;
|
||||
oncomplete: (this: MSAppAsyncOperation, ev: Event) => any;
|
||||
onerror: (this: MSAppAsyncOperation, ev: ErrorEvent) => any;
|
||||
readonly readyState: number;
|
||||
readonly result: any;
|
||||
start(): void;
|
||||
readonly COMPLETED: number;
|
||||
readonly ERROR: number;
|
||||
readonly STARTED: number;
|
||||
addEventListener(type: "complete", listener: (this: this, ev: Event) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: "error", listener: (this: this, ev: ErrorEvent) => any, useCapture?: boolean): void;
|
||||
addEventListener<K extends keyof MSAppAsyncOperationEventMap>(type: K, listener: (this: MSAppAsyncOperation, ev: MSAppAsyncOperationEventMap[K]) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void;
|
||||
}
|
||||
|
||||
@@ -584,6 +606,7 @@ interface MSStreamReader extends EventTarget, MSBaseReader {
|
||||
readAsBlob(stream: MSStream, size?: number): void;
|
||||
readAsDataURL(stream: MSStream, size?: number): void;
|
||||
readAsText(stream: MSStream, encoding?: string, size?: number): void;
|
||||
addEventListener<K extends keyof MSBaseReaderEventMap>(type: K, listener: (this: MSBaseReader, ev: MSBaseReaderEventMap[K]) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void;
|
||||
}
|
||||
|
||||
@@ -627,12 +650,16 @@ declare var MessageEvent: {
|
||||
new(type: string, eventInitDict?: MessageEventInit): MessageEvent;
|
||||
}
|
||||
|
||||
interface MessagePortEventMap {
|
||||
"message": MessageEvent;
|
||||
}
|
||||
|
||||
interface MessagePort extends EventTarget {
|
||||
onmessage: (this: this, ev: MessageEvent) => any;
|
||||
onmessage: (this: MessagePort, ev: MessageEvent) => any;
|
||||
close(): void;
|
||||
postMessage(message?: any, ports?: any): void;
|
||||
start(): void;
|
||||
addEventListener(type: "message", listener: (this: this, ev: MessageEvent) => any, useCapture?: boolean): void;
|
||||
addEventListener<K extends keyof MessagePortEventMap>(type: K, listener: (this: MessagePort, ev: MessagePortEventMap[K]) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void;
|
||||
}
|
||||
|
||||
@@ -680,14 +707,21 @@ declare var ProgressEvent: {
|
||||
new(type: string, eventInitDict?: ProgressEventInit): ProgressEvent;
|
||||
}
|
||||
|
||||
interface WebSocketEventMap {
|
||||
"close": CloseEvent;
|
||||
"error": ErrorEvent;
|
||||
"message": MessageEvent;
|
||||
"open": Event;
|
||||
}
|
||||
|
||||
interface WebSocket extends EventTarget {
|
||||
binaryType: string;
|
||||
readonly bufferedAmount: number;
|
||||
readonly extensions: string;
|
||||
onclose: (this: this, ev: CloseEvent) => any;
|
||||
onerror: (this: this, ev: ErrorEvent) => any;
|
||||
onmessage: (this: this, ev: MessageEvent) => any;
|
||||
onopen: (this: this, ev: Event) => any;
|
||||
onclose: (this: WebSocket, ev: CloseEvent) => any;
|
||||
onerror: (this: WebSocket, ev: ErrorEvent) => any;
|
||||
onmessage: (this: WebSocket, ev: MessageEvent) => any;
|
||||
onopen: (this: WebSocket, ev: Event) => any;
|
||||
readonly protocol: string;
|
||||
readonly readyState: number;
|
||||
readonly url: string;
|
||||
@@ -697,10 +731,7 @@ interface WebSocket extends EventTarget {
|
||||
readonly CLOSING: number;
|
||||
readonly CONNECTING: number;
|
||||
readonly OPEN: number;
|
||||
addEventListener(type: "close", listener: (this: this, ev: CloseEvent) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: "error", listener: (this: this, ev: ErrorEvent) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: "message", listener: (this: this, ev: MessageEvent) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: "open", listener: (this: this, ev: Event) => any, useCapture?: boolean): void;
|
||||
addEventListener<K extends keyof WebSocketEventMap>(type: K, listener: (this: WebSocket, ev: WebSocketEventMap[K]) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void;
|
||||
}
|
||||
|
||||
@@ -713,12 +744,15 @@ declare var WebSocket: {
|
||||
readonly OPEN: number;
|
||||
}
|
||||
|
||||
interface WorkerEventMap extends AbstractWorkerEventMap {
|
||||
"message": MessageEvent;
|
||||
}
|
||||
|
||||
interface Worker extends EventTarget, AbstractWorker {
|
||||
onmessage: (this: this, ev: MessageEvent) => any;
|
||||
onmessage: (this: Worker, ev: MessageEvent) => any;
|
||||
postMessage(message: any, ports?: any): void;
|
||||
terminate(): void;
|
||||
addEventListener(type: "error", listener: (this: this, ev: ErrorEvent) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: "message", listener: (this: this, ev: MessageEvent) => any, useCapture?: boolean): void;
|
||||
addEventListener<K extends keyof WorkerEventMap>(type: K, listener: (this: Worker, ev: WorkerEventMap[K]) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void;
|
||||
}
|
||||
|
||||
@@ -727,8 +761,12 @@ declare var Worker: {
|
||||
new(stringUrl: string): Worker;
|
||||
}
|
||||
|
||||
interface XMLHttpRequestEventMap extends XMLHttpRequestEventTargetEventMap {
|
||||
"readystatechange": Event;
|
||||
}
|
||||
|
||||
interface XMLHttpRequest extends EventTarget, XMLHttpRequestEventTarget {
|
||||
onreadystatechange: (this: this, ev: Event) => any;
|
||||
onreadystatechange: (this: XMLHttpRequest, ev: Event) => any;
|
||||
readonly readyState: number;
|
||||
readonly response: any;
|
||||
readonly responseText: string;
|
||||
@@ -755,14 +793,7 @@ interface XMLHttpRequest extends EventTarget, XMLHttpRequestEventTarget {
|
||||
readonly LOADING: number;
|
||||
readonly OPENED: number;
|
||||
readonly UNSENT: number;
|
||||
addEventListener(type: "abort", listener: (this: this, ev: ProgressEvent) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: "error", listener: (this: this, ev: ProgressEvent) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: "load", listener: (this: this, ev: ProgressEvent) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: "loadend", listener: (this: this, ev: ProgressEvent) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: "loadstart", listener: (this: this, ev: ProgressEvent) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: "progress", listener: (this: this, ev: ProgressEvent) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: "readystatechange", listener: (this: this, ev: Event) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: "timeout", listener: (this: this, ev: ProgressEvent) => any, useCapture?: boolean): void;
|
||||
addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void;
|
||||
}
|
||||
|
||||
@@ -778,6 +809,7 @@ declare var XMLHttpRequest: {
|
||||
}
|
||||
|
||||
interface XMLHttpRequestUpload extends EventTarget, XMLHttpRequestEventTarget {
|
||||
addEventListener<K extends keyof XMLHttpRequestEventTargetEventMap>(type: K, listener: (this: XMLHttpRequestEventTarget, ev: XMLHttpRequestEventTargetEventMap[K]) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void;
|
||||
}
|
||||
|
||||
@@ -786,31 +818,39 @@ declare var XMLHttpRequestUpload: {
|
||||
new(): XMLHttpRequestUpload;
|
||||
}
|
||||
|
||||
interface AbstractWorkerEventMap {
|
||||
"error": ErrorEvent;
|
||||
}
|
||||
|
||||
interface AbstractWorker {
|
||||
onerror: (this: this, ev: ErrorEvent) => any;
|
||||
addEventListener(type: "error", listener: (this: this, ev: ErrorEvent) => any, useCapture?: boolean): void;
|
||||
onerror: (this: AbstractWorker, ev: ErrorEvent) => any;
|
||||
addEventListener<K extends keyof AbstractWorkerEventMap>(type: K, listener: (this: AbstractWorker, ev: AbstractWorkerEventMap[K]) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void;
|
||||
}
|
||||
|
||||
interface MSBaseReaderEventMap {
|
||||
"abort": Event;
|
||||
"error": ErrorEvent;
|
||||
"load": Event;
|
||||
"loadend": ProgressEvent;
|
||||
"loadstart": Event;
|
||||
"progress": ProgressEvent;
|
||||
}
|
||||
|
||||
interface MSBaseReader {
|
||||
onabort: (this: this, ev: Event) => any;
|
||||
onerror: (this: this, ev: ErrorEvent) => any;
|
||||
onload: (this: this, ev: Event) => any;
|
||||
onloadend: (this: this, ev: ProgressEvent) => any;
|
||||
onloadstart: (this: this, ev: Event) => any;
|
||||
onprogress: (this: this, ev: ProgressEvent) => any;
|
||||
onabort: (this: MSBaseReader, ev: Event) => any;
|
||||
onerror: (this: MSBaseReader, ev: ErrorEvent) => any;
|
||||
onload: (this: MSBaseReader, ev: Event) => any;
|
||||
onloadend: (this: MSBaseReader, ev: ProgressEvent) => any;
|
||||
onloadstart: (this: MSBaseReader, ev: Event) => any;
|
||||
onprogress: (this: MSBaseReader, ev: ProgressEvent) => any;
|
||||
readonly readyState: number;
|
||||
readonly result: any;
|
||||
abort(): void;
|
||||
readonly DONE: number;
|
||||
readonly EMPTY: number;
|
||||
readonly LOADING: number;
|
||||
addEventListener(type: "abort", listener: (this: this, ev: Event) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: "error", listener: (this: this, ev: ErrorEvent) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: "load", listener: (this: this, ev: Event) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: "loadend", listener: (this: this, ev: ProgressEvent) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: "loadstart", listener: (this: this, ev: Event) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: "progress", listener: (this: this, ev: ProgressEvent) => any, useCapture?: boolean): void;
|
||||
addEventListener<K extends keyof MSBaseReaderEventMap>(type: K, listener: (this: MSBaseReader, ev: MSBaseReaderEventMap[K]) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void;
|
||||
}
|
||||
|
||||
@@ -838,21 +878,25 @@ interface WindowConsole {
|
||||
readonly console: Console;
|
||||
}
|
||||
|
||||
interface XMLHttpRequestEventTargetEventMap {
|
||||
"abort": Event;
|
||||
"error": ErrorEvent;
|
||||
"load": Event;
|
||||
"loadend": ProgressEvent;
|
||||
"loadstart": Event;
|
||||
"progress": ProgressEvent;
|
||||
"timeout": ProgressEvent;
|
||||
}
|
||||
|
||||
interface XMLHttpRequestEventTarget {
|
||||
onabort: (this: this, ev: Event) => any;
|
||||
onerror: (this: this, ev: ErrorEvent) => any;
|
||||
onload: (this: this, ev: Event) => any;
|
||||
onloadend: (this: this, ev: ProgressEvent) => any;
|
||||
onloadstart: (this: this, ev: Event) => any;
|
||||
onprogress: (this: this, ev: ProgressEvent) => any;
|
||||
ontimeout: (this: this, ev: ProgressEvent) => any;
|
||||
addEventListener(type: "abort", listener: (this: this, ev: Event) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: "error", listener: (this: this, ev: ErrorEvent) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: "load", listener: (this: this, ev: Event) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: "loadend", listener: (this: this, ev: ProgressEvent) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: "loadstart", listener: (this: this, ev: Event) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: "progress", listener: (this: this, ev: ProgressEvent) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: "timeout", listener: (this: this, ev: ProgressEvent) => any, useCapture?: boolean): void;
|
||||
onabort: (this: XMLHttpRequestEventTarget, ev: Event) => any;
|
||||
onerror: (this: XMLHttpRequestEventTarget, ev: ErrorEvent) => any;
|
||||
onload: (this: XMLHttpRequestEventTarget, ev: Event) => any;
|
||||
onloadend: (this: XMLHttpRequestEventTarget, ev: ProgressEvent) => any;
|
||||
onloadstart: (this: XMLHttpRequestEventTarget, ev: Event) => any;
|
||||
onprogress: (this: XMLHttpRequestEventTarget, ev: ProgressEvent) => any;
|
||||
ontimeout: (this: XMLHttpRequestEventTarget, ev: ProgressEvent) => any;
|
||||
addEventListener<K extends keyof XMLHttpRequestEventTargetEventMap>(type: K, listener: (this: XMLHttpRequestEventTarget, ev: XMLHttpRequestEventTargetEventMap[K]) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void;
|
||||
}
|
||||
|
||||
@@ -868,15 +912,18 @@ declare var FileReaderSync: {
|
||||
new(): FileReaderSync;
|
||||
}
|
||||
|
||||
interface WorkerGlobalScopeEventMap extends DedicatedWorkerGlobalScopeEventMap {
|
||||
"error": ErrorEvent;
|
||||
}
|
||||
|
||||
interface WorkerGlobalScope extends EventTarget, WorkerUtils, DedicatedWorkerGlobalScope, WindowConsole {
|
||||
readonly location: WorkerLocation;
|
||||
onerror: (this: this, ev: ErrorEvent) => any;
|
||||
onerror: (this: WorkerGlobalScope, ev: ErrorEvent) => any;
|
||||
readonly self: WorkerGlobalScope;
|
||||
close(): void;
|
||||
msWriteProfilerMark(profilerMarkName: string): void;
|
||||
toString(): string;
|
||||
addEventListener(type: "error", listener: (this: this, ev: ErrorEvent) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: "message", listener: (this: this, ev: MessageEvent) => any, useCapture?: boolean): void;
|
||||
addEventListener<K extends keyof WorkerGlobalScopeEventMap>(type: K, listener: (this: WorkerGlobalScope, ev: WorkerGlobalScopeEventMap[K]) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void;
|
||||
}
|
||||
|
||||
@@ -904,7 +951,6 @@ declare var WorkerLocation: {
|
||||
|
||||
interface WorkerNavigator extends Object, NavigatorID, NavigatorOnLine {
|
||||
readonly hardwareConcurrency: number;
|
||||
addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void;
|
||||
}
|
||||
|
||||
declare var WorkerNavigator: {
|
||||
@@ -912,10 +958,14 @@ declare var WorkerNavigator: {
|
||||
new(): WorkerNavigator;
|
||||
}
|
||||
|
||||
interface DedicatedWorkerGlobalScopeEventMap {
|
||||
"message": MessageEvent;
|
||||
}
|
||||
|
||||
interface DedicatedWorkerGlobalScope {
|
||||
onmessage: (this: this, ev: MessageEvent) => any;
|
||||
onmessage: (this: DedicatedWorkerGlobalScope, ev: MessageEvent) => any;
|
||||
postMessage(data: any): void;
|
||||
addEventListener(type: "message", listener: (this: this, ev: MessageEvent) => any, useCapture?: boolean): void;
|
||||
addEventListener<K extends keyof DedicatedWorkerGlobalScopeEventMap>(type: K, listener: (this: DedicatedWorkerGlobalScope, ev: DedicatedWorkerGlobalScopeEventMap[K]) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void;
|
||||
}
|
||||
|
||||
@@ -1176,7 +1226,6 @@ declare var self: WorkerGlobalScope;
|
||||
declare function close(): void;
|
||||
declare function msWriteProfilerMark(profilerMarkName: string): void;
|
||||
declare function toString(): string;
|
||||
declare function addEventListener(type: string, listener?: EventListenerOrEventListenerObject, useCapture?: boolean): void;
|
||||
declare function dispatchEvent(evt: Event): boolean;
|
||||
declare function removeEventListener(type: string, listener?: EventListenerOrEventListenerObject, useCapture?: boolean): void;
|
||||
declare var indexedDB: IDBFactory;
|
||||
@@ -1197,8 +1246,7 @@ declare function btoa(rawString: string): string;
|
||||
declare var onmessage: (this: WorkerGlobalScope, ev: MessageEvent) => any;
|
||||
declare function postMessage(data: any): void;
|
||||
declare var console: Console;
|
||||
declare function addEventListener(type: "error", listener: (this: WorkerGlobalScope, ev: ErrorEvent) => any, useCapture?: boolean): void;
|
||||
declare function addEventListener(type: "message", listener: (this: WorkerGlobalScope, ev: MessageEvent) => any, useCapture?: boolean): void;
|
||||
declare function addEventListener<K extends keyof WorkerGlobalScopeEventMap>(type: K, listener: (this: WorkerGlobalScope, ev: WorkerGlobalScopeEventMap[K]) => any, useCapture?: boolean): void;
|
||||
declare function addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void;
|
||||
type AlgorithmIdentifier = string | Algorithm;
|
||||
type IDBKeyPath = string;
|
||||
|
||||
@@ -317,7 +317,7 @@ namespace ts.server {
|
||||
}
|
||||
switch (response.kind) {
|
||||
case ActionSet:
|
||||
this.typingsCache.updateTypingsForProject(response.projectName, response.compilerOptions, response.typingOptions, response.unresolvedImports, response.typings);
|
||||
this.typingsCache.updateTypingsForProject(response.projectName, response.compilerOptions, response.typeAcquisition, response.unresolvedImports, response.typings);
|
||||
break;
|
||||
case ActionInvalidate:
|
||||
this.typingsCache.deleteTypingsForProject(response.projectName);
|
||||
@@ -520,8 +520,10 @@ namespace ts.server {
|
||||
}
|
||||
|
||||
private onConfigChangedForConfiguredProject(project: ConfiguredProject) {
|
||||
this.logger.info(`Config file changed: ${project.getConfigFilePath()}`);
|
||||
this.updateConfiguredProject(project);
|
||||
const configFileName = project.getConfigFilePath();
|
||||
this.logger.info(`Config file changed: ${configFileName}`);
|
||||
const configFileErrors = this.updateConfiguredProject(project);
|
||||
this.reportConfigFileDiagnostics(configFileName, configFileErrors, /*triggerFile*/ configFileName);
|
||||
this.refreshInferredProjects();
|
||||
}
|
||||
|
||||
@@ -821,7 +823,7 @@ namespace ts.server {
|
||||
compilerOptions: parsedCommandLine.options,
|
||||
configHasFilesProperty: config["files"] !== undefined,
|
||||
wildcardDirectories: createMap(parsedCommandLine.wildcardDirectories),
|
||||
typingOptions: parsedCommandLine.typingOptions,
|
||||
typeAcquisition: parsedCommandLine.typeAcquisition,
|
||||
compileOnSave: parsedCommandLine.compileOnSave
|
||||
};
|
||||
return { success: true, projectOptions, configFileErrors: errors };
|
||||
@@ -845,7 +847,7 @@ namespace ts.server {
|
||||
return false;
|
||||
}
|
||||
|
||||
private createAndAddExternalProject(projectFileName: string, files: protocol.ExternalFile[], options: protocol.ExternalProjectCompilerOptions, typingOptions: TypingOptions) {
|
||||
private createAndAddExternalProject(projectFileName: string, files: protocol.ExternalFile[], options: protocol.ExternalProjectCompilerOptions, typeAcquisition: TypeAcquisition) {
|
||||
const compilerOptions = convertCompilerOptions(options);
|
||||
const project = new ExternalProject(
|
||||
projectFileName,
|
||||
@@ -855,7 +857,7 @@ namespace ts.server {
|
||||
/*languageServiceEnabled*/ !this.exceededTotalSizeLimitForNonTsFiles(compilerOptions, files, externalFilePropertyReader),
|
||||
options.compileOnSave === undefined ? true : options.compileOnSave);
|
||||
|
||||
this.addFilesToProjectAndUpdateGraph(project, files, externalFilePropertyReader, /*clientFileName*/ undefined, typingOptions, /*configFileErrors*/ undefined);
|
||||
this.addFilesToProjectAndUpdateGraph(project, files, externalFilePropertyReader, /*clientFileName*/ undefined, typeAcquisition, /*configFileErrors*/ undefined);
|
||||
this.externalProjects.push(project);
|
||||
return project;
|
||||
}
|
||||
@@ -883,7 +885,7 @@ namespace ts.server {
|
||||
/*languageServiceEnabled*/ !sizeLimitExceeded,
|
||||
projectOptions.compileOnSave === undefined ? false : projectOptions.compileOnSave);
|
||||
|
||||
this.addFilesToProjectAndUpdateGraph(project, projectOptions.files, fileNamePropertyReader, clientFileName, projectOptions.typingOptions, configFileErrors);
|
||||
this.addFilesToProjectAndUpdateGraph(project, projectOptions.files, fileNamePropertyReader, clientFileName, projectOptions.typeAcquisition, configFileErrors);
|
||||
|
||||
project.watchConfigFile(project => this.onConfigChangedForConfiguredProject(project));
|
||||
if (!sizeLimitExceeded) {
|
||||
@@ -902,7 +904,7 @@ namespace ts.server {
|
||||
}
|
||||
}
|
||||
|
||||
private addFilesToProjectAndUpdateGraph<T>(project: ConfiguredProject | ExternalProject, files: T[], propertyReader: FilePropertyReader<T>, clientFileName: string, typingOptions: TypingOptions, configFileErrors: Diagnostic[]): void {
|
||||
private addFilesToProjectAndUpdateGraph<T>(project: ConfiguredProject | ExternalProject, files: T[], propertyReader: FilePropertyReader<T>, clientFileName: string, typeAcquisition: TypeAcquisition, configFileErrors: Diagnostic[]): void {
|
||||
let errors: Diagnostic[];
|
||||
for (const f of files) {
|
||||
const rootFilename = propertyReader.getFileName(f);
|
||||
@@ -917,7 +919,7 @@ namespace ts.server {
|
||||
}
|
||||
}
|
||||
project.setProjectErrors(concatenate(configFileErrors, errors));
|
||||
project.setTypingOptions(typingOptions);
|
||||
project.setTypeAcquisition(typeAcquisition);
|
||||
project.updateGraph();
|
||||
}
|
||||
|
||||
@@ -934,7 +936,7 @@ namespace ts.server {
|
||||
};
|
||||
}
|
||||
|
||||
private updateNonInferredProject<T>(project: ExternalProject | ConfiguredProject, newUncheckedFiles: T[], propertyReader: FilePropertyReader<T>, newOptions: CompilerOptions, newTypingOptions: TypingOptions, compileOnSave: boolean, configFileErrors: Diagnostic[]) {
|
||||
private updateNonInferredProject<T>(project: ExternalProject | ConfiguredProject, newUncheckedFiles: T[], propertyReader: FilePropertyReader<T>, newOptions: CompilerOptions, newTypeAcquisition: TypeAcquisition, compileOnSave: boolean, configFileErrors: Diagnostic[]) {
|
||||
const oldRootScriptInfos = project.getRootScriptInfos();
|
||||
const newRootScriptInfos: ScriptInfo[] = [];
|
||||
const newRootScriptInfoMap: NormalizedPathMap<ScriptInfo> = createNormalizedPathMap<ScriptInfo>();
|
||||
@@ -996,7 +998,7 @@ namespace ts.server {
|
||||
}
|
||||
|
||||
project.setCompilerOptions(newOptions);
|
||||
(<ExternalProject | ConfiguredProject>project).setTypingOptions(newTypingOptions);
|
||||
(<ExternalProject | ConfiguredProject>project).setTypeAcquisition(newTypeAcquisition);
|
||||
|
||||
// VS only set the CompileOnSaveEnabled option in the request if the option was changed recently
|
||||
// therefore if it is undefined, it should not be updated.
|
||||
@@ -1015,6 +1017,9 @@ namespace ts.server {
|
||||
return;
|
||||
}
|
||||
|
||||
// note: the returned "success" is true does not mean the "configFileErrors" is empty.
|
||||
// because we might have tolerated the errors and kept going. So always return the configFileErrors
|
||||
// regardless the "success" here is true or not.
|
||||
const { success, projectOptions, configFileErrors } = this.convertConfigFileContentToProjectOptions(project.getConfigFilePath());
|
||||
if (!success) {
|
||||
// reset project settings to default
|
||||
@@ -1026,7 +1031,7 @@ namespace ts.server {
|
||||
project.setCompilerOptions(projectOptions.compilerOptions);
|
||||
if (!project.languageServiceEnabled) {
|
||||
// language service is already disabled
|
||||
return;
|
||||
return configFileErrors;
|
||||
}
|
||||
project.disableLanguageService();
|
||||
project.stopWatchingDirectory();
|
||||
@@ -1036,8 +1041,9 @@ namespace ts.server {
|
||||
project.enableLanguageService();
|
||||
}
|
||||
this.watchConfigDirectoryForProject(project, projectOptions);
|
||||
this.updateNonInferredProject(project, projectOptions.files, fileNamePropertyReader, projectOptions.compilerOptions, projectOptions.typingOptions, projectOptions.compileOnSave, configFileErrors);
|
||||
this.updateNonInferredProject(project, projectOptions.files, fileNamePropertyReader, projectOptions.compilerOptions, projectOptions.typeAcquisition, projectOptions.compileOnSave, configFileErrors);
|
||||
}
|
||||
return configFileErrors;
|
||||
}
|
||||
|
||||
createInferredProjectWithRootFileIfNecessary(root: ScriptInfo) {
|
||||
@@ -1316,6 +1322,12 @@ namespace ts.server {
|
||||
}
|
||||
|
||||
openExternalProject(proj: protocol.ExternalProject): void {
|
||||
// typingOptions has been deprecated and is only supported for backward compatibility
|
||||
// purposes. It should be removed in future releases - use typeAcquisition instead.
|
||||
if (proj.typingOptions && !proj.typeAcquisition) {
|
||||
const typeAcquisition = convertEnableAutoDiscoveryToEnable(proj.typingOptions);
|
||||
proj.typeAcquisition = typeAcquisition;
|
||||
}
|
||||
let tsConfigFiles: NormalizedPath[];
|
||||
const rootFiles: protocol.ExternalFile[] = [];
|
||||
for (const file of proj.rootFiles) {
|
||||
@@ -1340,7 +1352,7 @@ namespace ts.server {
|
||||
if (externalProject) {
|
||||
if (!tsConfigFiles) {
|
||||
// external project already exists and not config files were added - update the project and return;
|
||||
this.updateNonInferredProject(externalProject, proj.rootFiles, externalFilePropertyReader, convertCompilerOptions(proj.options), proj.typingOptions, proj.options.compileOnSave, /*configFileErrors*/ undefined);
|
||||
this.updateNonInferredProject(externalProject, proj.rootFiles, externalFilePropertyReader, convertCompilerOptions(proj.options), proj.typeAcquisition, proj.options.compileOnSave, /*configFileErrors*/ undefined);
|
||||
return;
|
||||
}
|
||||
// some config files were added to external project (that previously were not there)
|
||||
@@ -1400,7 +1412,7 @@ namespace ts.server {
|
||||
else {
|
||||
// no config files - remove the item from the collection
|
||||
delete this.externalProjectToConfiguredProjectMap[proj.projectFileName];
|
||||
this.createAndAddExternalProject(proj.projectFileName, rootFiles, proj.options, proj.typingOptions);
|
||||
this.createAndAddExternalProject(proj.projectFileName, rootFiles, proj.options, proj.typeAcquisition);
|
||||
}
|
||||
this.refreshInferredProjects();
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ namespace ts.server {
|
||||
}
|
||||
|
||||
this.resolveModuleName = (moduleName, containingFile, compilerOptions, host) => {
|
||||
const globalCache = this.project.getTypingOptions().enableAutoDiscovery
|
||||
const globalCache = this.project.getTypeAcquisition().enable
|
||||
? this.project.projectService.typingsInstaller.globalTypingsCacheLocation
|
||||
: undefined;
|
||||
const primaryResult = resolveModuleName(moduleName, containingFile, compilerOptions, host);
|
||||
|
||||
+22
-22
@@ -312,7 +312,7 @@ namespace ts.server {
|
||||
return this.projectName;
|
||||
}
|
||||
abstract getProjectRootPath(): string | undefined;
|
||||
abstract getTypingOptions(): TypingOptions;
|
||||
abstract getTypeAcquisition(): TypeAcquisition;
|
||||
|
||||
getSourceFile(path: Path) {
|
||||
if (!this.program) {
|
||||
@@ -802,9 +802,9 @@ namespace ts.server {
|
||||
}
|
||||
}
|
||||
|
||||
getTypingOptions(): TypingOptions {
|
||||
getTypeAcquisition(): TypeAcquisition {
|
||||
return {
|
||||
enableAutoDiscovery: allRootFilesAreJsOrDts(this),
|
||||
enable: allRootFilesAreJsOrDts(this),
|
||||
include: [],
|
||||
exclude: []
|
||||
};
|
||||
@@ -812,7 +812,7 @@ namespace ts.server {
|
||||
}
|
||||
|
||||
export class ConfiguredProject extends Project {
|
||||
private typingOptions: TypingOptions;
|
||||
private typeAcquisition: TypeAcquisition;
|
||||
private projectFileWatcher: FileWatcher;
|
||||
private directoryWatcher: FileWatcher;
|
||||
private directoriesWatchedForWildcards: Map<FileWatcher>;
|
||||
@@ -844,12 +844,12 @@ namespace ts.server {
|
||||
this.projectErrors = projectErrors;
|
||||
}
|
||||
|
||||
setTypingOptions(newTypingOptions: TypingOptions): void {
|
||||
this.typingOptions = newTypingOptions;
|
||||
setTypeAcquisition(newTypeAcquisition: TypeAcquisition): void {
|
||||
this.typeAcquisition = newTypeAcquisition;
|
||||
}
|
||||
|
||||
getTypingOptions() {
|
||||
return this.typingOptions;
|
||||
getTypeAcquisition() {
|
||||
return this.typeAcquisition;
|
||||
}
|
||||
|
||||
watchConfigFile(callback: (project: ConfiguredProject) => void) {
|
||||
@@ -939,7 +939,7 @@ namespace ts.server {
|
||||
}
|
||||
|
||||
export class ExternalProject extends Project {
|
||||
private typingOptions: TypingOptions;
|
||||
private typeAcquisition: TypeAcquisition;
|
||||
constructor(externalProjectName: string,
|
||||
projectService: ProjectService,
|
||||
documentRegistry: ts.DocumentRegistry,
|
||||
@@ -960,36 +960,36 @@ namespace ts.server {
|
||||
return getDirectoryPath(normalizeSlashes(this.getProjectName()));
|
||||
}
|
||||
|
||||
getTypingOptions() {
|
||||
return this.typingOptions;
|
||||
getTypeAcquisition() {
|
||||
return this.typeAcquisition;
|
||||
}
|
||||
|
||||
setProjectErrors(projectErrors: Diagnostic[]) {
|
||||
this.projectErrors = projectErrors;
|
||||
}
|
||||
|
||||
setTypingOptions(newTypingOptions: TypingOptions): void {
|
||||
if (!newTypingOptions) {
|
||||
setTypeAcquisition(newTypeAcquisition: TypeAcquisition): void {
|
||||
if (!newTypeAcquisition) {
|
||||
// set default typings options
|
||||
newTypingOptions = {
|
||||
enableAutoDiscovery: allRootFilesAreJsOrDts(this),
|
||||
newTypeAcquisition = {
|
||||
enable: allRootFilesAreJsOrDts(this),
|
||||
include: [],
|
||||
exclude: []
|
||||
};
|
||||
}
|
||||
else {
|
||||
if (newTypingOptions.enableAutoDiscovery === undefined) {
|
||||
if (newTypeAcquisition.enable === undefined) {
|
||||
// if autoDiscovery was not specified by the caller - set it based on the content of the project
|
||||
newTypingOptions.enableAutoDiscovery = allRootFilesAreJsOrDts(this);
|
||||
newTypeAcquisition.enable = allRootFilesAreJsOrDts(this);
|
||||
}
|
||||
if (!newTypingOptions.include) {
|
||||
newTypingOptions.include = [];
|
||||
if (!newTypeAcquisition.include) {
|
||||
newTypeAcquisition.include = [];
|
||||
}
|
||||
if (!newTypingOptions.exclude) {
|
||||
newTypingOptions.exclude = [];
|
||||
if (!newTypeAcquisition.exclude) {
|
||||
newTypeAcquisition.exclude = [];
|
||||
}
|
||||
}
|
||||
this.typingOptions = newTypingOptions;
|
||||
this.typeAcquisition = newTypeAcquisition;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -861,9 +861,13 @@ namespace ts.server.protocol {
|
||||
*/
|
||||
options: ExternalProjectCompilerOptions;
|
||||
/**
|
||||
* Explicitly specified typing options for the project
|
||||
* @deprecated typingOptions. Use typeAcquisition instead
|
||||
*/
|
||||
typingOptions?: TypingOptions;
|
||||
typingOptions?: TypeAcquisition;
|
||||
/**
|
||||
* Explicitly specified type acquisition for the project
|
||||
*/
|
||||
typeAcquisition?: TypeAcquisition;
|
||||
}
|
||||
|
||||
export interface CompileOnSaveMixin {
|
||||
|
||||
@@ -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}`) ||
|
||||
@@ -275,8 +276,8 @@ namespace ts.server {
|
||||
this.installer.send({ projectName: p.getProjectName(), kind: "closeProject" });
|
||||
}
|
||||
|
||||
enqueueInstallTypingsRequest(project: Project, typingOptions: TypingOptions, unresolvedImports: SortedReadonlyArray<string>): void {
|
||||
const request = createInstallTypingsRequest(project, typingOptions, unresolvedImports);
|
||||
enqueueInstallTypingsRequest(project: Project, typeAcquisition: TypeAcquisition, unresolvedImports: SortedReadonlyArray<string>): void {
|
||||
const request = createInstallTypingsRequest(project, typeAcquisition, unresolvedImports);
|
||||
if (this.logger.hasLevel(LogLevel.verbose)) {
|
||||
if (this.logger.hasLevel(LogLevel.verbose)) {
|
||||
this.logger.info(`Scheduling throttled operation: ${JSON.stringify(request)}`);
|
||||
@@ -577,6 +578,11 @@ namespace ts.server {
|
||||
}
|
||||
}
|
||||
|
||||
const localeStr = findArgument("--locale");
|
||||
if (localeStr) {
|
||||
validateLocaleAndSetLanguage(localeStr, sys);
|
||||
}
|
||||
|
||||
const useSingleInferredProject = hasArgument("--useSingleInferredProject");
|
||||
const disableAutomaticTypingAcquisition = hasArgument("--disableAutomaticTypingAcquisition");
|
||||
const telemetryEnabled = hasArgument(Arguments.EnableTelemetry);
|
||||
@@ -598,4 +604,4 @@ namespace ts.server {
|
||||
(process as any).noAsar = true;
|
||||
// Start listening
|
||||
ioSession.listen();
|
||||
}
|
||||
}
|
||||
|
||||
Vendored
+2
-2
@@ -31,7 +31,7 @@ declare namespace ts.server {
|
||||
readonly fileNames: string[];
|
||||
readonly projectRootPath: ts.Path;
|
||||
readonly compilerOptions: ts.CompilerOptions;
|
||||
readonly typingOptions: ts.TypingOptions;
|
||||
readonly typeAcquisition: ts.TypeAcquisition;
|
||||
readonly unresolvedImports: SortedReadonlyArray<string>;
|
||||
readonly cachePath?: string;
|
||||
readonly kind: "discover";
|
||||
@@ -54,7 +54,7 @@ declare namespace ts.server {
|
||||
}
|
||||
|
||||
export interface SetTypings extends ProjectResponse {
|
||||
readonly typingOptions: ts.TypingOptions;
|
||||
readonly typeAcquisition: ts.TypeAcquisition;
|
||||
readonly compilerOptions: ts.CompilerOptions;
|
||||
readonly typings: string[];
|
||||
readonly unresolvedImports: SortedReadonlyArray<string>;
|
||||
|
||||
+11
-11
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace ts.server {
|
||||
export interface ITypingsInstaller {
|
||||
enqueueInstallTypingsRequest(p: Project, typingOptions: TypingOptions, unresolvedImports: SortedReadonlyArray<string>): void;
|
||||
enqueueInstallTypingsRequest(p: Project, typeAcquisition: TypeAcquisition, unresolvedImports: SortedReadonlyArray<string>): void;
|
||||
attach(projectService: ProjectService): void;
|
||||
onProjectClosed(p: Project): void;
|
||||
readonly globalTypingsCacheLocation: string;
|
||||
@@ -16,7 +16,7 @@ namespace ts.server {
|
||||
};
|
||||
|
||||
class TypingsCacheEntry {
|
||||
readonly typingOptions: TypingOptions;
|
||||
readonly typeAcquisition: TypeAcquisition;
|
||||
readonly compilerOptions: CompilerOptions;
|
||||
readonly typings: SortedReadonlyArray<string>;
|
||||
readonly unresolvedImports: SortedReadonlyArray<string>;
|
||||
@@ -52,8 +52,8 @@ namespace ts.server {
|
||||
return unique === 0;
|
||||
}
|
||||
|
||||
function typingOptionsChanged(opt1: TypingOptions, opt2: TypingOptions): boolean {
|
||||
return opt1.enableAutoDiscovery !== opt2.enableAutoDiscovery ||
|
||||
function typeAcquisitionChanged(opt1: TypeAcquisition, opt2: TypeAcquisition): boolean {
|
||||
return opt1.enable !== opt2.enable ||
|
||||
!setIsEqualTo(opt1.include, opt2.include) ||
|
||||
!setIsEqualTo(opt1.exclude, opt2.exclude);
|
||||
}
|
||||
@@ -77,9 +77,9 @@ namespace ts.server {
|
||||
}
|
||||
|
||||
getTypingsForProject(project: Project, unresolvedImports: SortedReadonlyArray<string>, forceRefresh: boolean): SortedReadonlyArray<string> {
|
||||
const typingOptions = project.getTypingOptions();
|
||||
const typeAcquisition = project.getTypeAcquisition();
|
||||
|
||||
if (!typingOptions || !typingOptions.enableAutoDiscovery) {
|
||||
if (!typeAcquisition || !typeAcquisition.enable) {
|
||||
return <any>emptyArray;
|
||||
}
|
||||
|
||||
@@ -87,28 +87,28 @@ namespace ts.server {
|
||||
const result: SortedReadonlyArray<string> = entry ? entry.typings : <any>emptyArray;
|
||||
if (forceRefresh ||
|
||||
!entry ||
|
||||
typingOptionsChanged(typingOptions, entry.typingOptions) ||
|
||||
typeAcquisitionChanged(typeAcquisition, entry.typeAcquisition) ||
|
||||
compilerOptionsChanged(project.getCompilerOptions(), entry.compilerOptions) ||
|
||||
unresolvedImportsChanged(unresolvedImports, entry.unresolvedImports)) {
|
||||
// Note: entry is now poisoned since it does not really contain typings for a given combination of compiler options\typings options.
|
||||
// instead it acts as a placeholder to prevent issuing multiple requests
|
||||
this.perProjectCache[project.getProjectName()] = {
|
||||
compilerOptions: project.getCompilerOptions(),
|
||||
typingOptions,
|
||||
typeAcquisition,
|
||||
typings: result,
|
||||
unresolvedImports,
|
||||
poisoned: true
|
||||
};
|
||||
// something has been changed, issue a request to update typings
|
||||
this.installer.enqueueInstallTypingsRequest(project, typingOptions, unresolvedImports);
|
||||
this.installer.enqueueInstallTypingsRequest(project, typeAcquisition, unresolvedImports);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
updateTypingsForProject(projectName: string, compilerOptions: CompilerOptions, typingOptions: TypingOptions, unresolvedImports: SortedReadonlyArray<string>, newTypings: string[]) {
|
||||
updateTypingsForProject(projectName: string, compilerOptions: CompilerOptions, typeAcquisition: TypeAcquisition, unresolvedImports: SortedReadonlyArray<string>, newTypings: string[]) {
|
||||
this.perProjectCache[projectName] = {
|
||||
compilerOptions,
|
||||
typingOptions,
|
||||
typeAcquisition,
|
||||
typings: toSortedReadonlyArray(newTypings),
|
||||
unresolvedImports,
|
||||
poisoned: false
|
||||
|
||||
@@ -127,7 +127,7 @@ namespace ts.server.typingsInstaller {
|
||||
if (this.log.isEnabled()) {
|
||||
this.log.writeLine(`#${requestId} with arguments'${JSON.stringify(args)}'.`);
|
||||
}
|
||||
const command = `${this.npmPath} install ${args.join(" ")} --save-dev`;
|
||||
const command = `${this.npmPath} install ${args.join(" ")} --save-dev --user-agent="typesInstaller/${version}"`;
|
||||
const start = Date.now();
|
||||
let stdout: Buffer;
|
||||
let stderr: Buffer;
|
||||
|
||||
@@ -150,7 +150,7 @@ namespace ts.server.typingsInstaller {
|
||||
req.projectRootPath,
|
||||
this.safeListPath,
|
||||
this.packageNameToTypingLocation,
|
||||
req.typingOptions,
|
||||
req.typeAcquisition,
|
||||
req.unresolvedImports);
|
||||
|
||||
if (this.log.isEnabled()) {
|
||||
@@ -391,7 +391,7 @@ namespace ts.server.typingsInstaller {
|
||||
private createSetTypings(request: DiscoverTypings, typings: string[]): SetTypings {
|
||||
return {
|
||||
projectName: request.projectName,
|
||||
typingOptions: request.typingOptions,
|
||||
typeAcquisition: request.typeAcquisition,
|
||||
compilerOptions: request.compilerOptions,
|
||||
typings,
|
||||
unresolvedImports: request.unresolvedImports,
|
||||
|
||||
@@ -46,12 +46,12 @@ namespace ts.server {
|
||||
}
|
||||
}
|
||||
|
||||
export function createInstallTypingsRequest(project: Project, typingOptions: TypingOptions, unresolvedImports: SortedReadonlyArray<string>, cachePath?: string): DiscoverTypings {
|
||||
export function createInstallTypingsRequest(project: Project, typeAcquisition: TypeAcquisition, unresolvedImports: SortedReadonlyArray<string>, cachePath?: string): DiscoverTypings {
|
||||
return {
|
||||
projectName: project.getProjectName(),
|
||||
fileNames: project.getFileNames(/*excludeFilesFromExternalLibraries*/ true),
|
||||
compilerOptions: project.getCompilerOptions(),
|
||||
typingOptions,
|
||||
typeAcquisition,
|
||||
unresolvedImports,
|
||||
projectRootPath: getProjectRootPath(project),
|
||||
cachePath,
|
||||
@@ -171,7 +171,7 @@ namespace ts.server {
|
||||
files?: string[];
|
||||
wildcardDirectories?: Map<WatchDirectoryFlags>;
|
||||
compilerOptions?: CompilerOptions;
|
||||
typingOptions?: TypingOptions;
|
||||
typeAcquisition?: TypeAcquisition;
|
||||
compileOnSave?: boolean;
|
||||
}
|
||||
|
||||
|
||||
@@ -52,7 +52,7 @@ namespace ts.codefix {
|
||||
// than another existing one. For example, you may have new imports from "./foo/bar"
|
||||
// and "bar", when the new one is "bar/bar2" and the current one is "./foo/bar". The new
|
||||
// one and the current one are not comparable (one relative path and one absolute path),
|
||||
// but the new one is worse than the other one, so should not add to the list.
|
||||
// but the new one is worse than the other one, so should not add to the list.
|
||||
updatedNewImports.push(existingAction);
|
||||
break;
|
||||
case ModuleSpecifierComparison.Worse:
|
||||
@@ -145,7 +145,7 @@ namespace ts.codefix {
|
||||
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 @@ namespace ts.codefix {
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -886,12 +886,25 @@ namespace ts.formatting {
|
||||
else {
|
||||
const tokenStart = sourceFile.getLineAndCharacterOfPosition(pos);
|
||||
const startLinePosition = getStartPositionOfLine(tokenStart.line, sourceFile);
|
||||
if (indentation !== tokenStart.character || indentationIsDifferent(indentationString, startLinePosition)) {
|
||||
if (indentation !== characterToColumn(startLinePosition, tokenStart.character) || indentationIsDifferent(indentationString, startLinePosition)) {
|
||||
recordReplace(startLinePosition, tokenStart.character, indentationString);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function characterToColumn(startLinePosition: number, characterInLine: number): number {
|
||||
let column = 0;
|
||||
for (let i = 0; i < characterInLine; i++) {
|
||||
if (sourceFile.text.charCodeAt(startLinePosition + i) === CharacterCodes.tab) {
|
||||
column += options.tabSize - column % options.tabSize;
|
||||
}
|
||||
else {
|
||||
column++;
|
||||
}
|
||||
}
|
||||
return column;
|
||||
}
|
||||
|
||||
function indentationIsDifferent(indentationString: string, startLinePosition: number): boolean {
|
||||
return indentationString !== sourceFile.text.substr(startLinePosition, indentationString.length);
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ namespace ts.JsTyping {
|
||||
* @param projectRootPath is the path to the project root directory
|
||||
* @param safeListPath is the path used to retrieve the safe list
|
||||
* @param packageNameToTypingLocation is the map of package names to their cached typing locations
|
||||
* @param typingOptions are used to customize the typing inference process
|
||||
* @param typeAcquisition is used to customize the typing acquisition process
|
||||
* @param compilerOptions are used as a source for typing inference
|
||||
*/
|
||||
export function discoverTypings(
|
||||
@@ -57,14 +57,14 @@ namespace ts.JsTyping {
|
||||
projectRootPath: Path,
|
||||
safeListPath: Path,
|
||||
packageNameToTypingLocation: Map<string>,
|
||||
typingOptions: TypingOptions,
|
||||
typeAcquisition: TypeAcquisition,
|
||||
unresolvedImports: ReadonlyArray<string>):
|
||||
{ cachedTypingPaths: string[], newTypingNames: string[], filesToWatch: string[] } {
|
||||
|
||||
// A typing name to typing file path mapping
|
||||
const inferredTypings = createMap<string>();
|
||||
|
||||
if (!typingOptions || !typingOptions.enableAutoDiscovery) {
|
||||
if (!typeAcquisition || !typeAcquisition.enable) {
|
||||
return { cachedTypingPaths: [], newTypingNames: [], filesToWatch: [] };
|
||||
}
|
||||
|
||||
@@ -84,8 +84,8 @@ namespace ts.JsTyping {
|
||||
let searchDirs: string[] = [];
|
||||
let exclude: string[] = [];
|
||||
|
||||
mergeTypings(typingOptions.include);
|
||||
exclude = typingOptions.exclude || [];
|
||||
mergeTypings(typeAcquisition.include);
|
||||
exclude = typeAcquisition.exclude || [];
|
||||
|
||||
const possibleSearchDirs = map(fileNames, getDirectoryPath);
|
||||
if (projectRootPath) {
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1138,7 +1138,7 @@ namespace ts {
|
||||
if (result.error) {
|
||||
return {
|
||||
options: {},
|
||||
typingOptions: {},
|
||||
typeAcquisition: {},
|
||||
files: [],
|
||||
raw: {},
|
||||
errors: [realizeDiagnostic(result.error, "\r\n")]
|
||||
@@ -1150,7 +1150,7 @@ namespace ts {
|
||||
|
||||
return {
|
||||
options: configFile.options,
|
||||
typingOptions: configFile.typingOptions,
|
||||
typeAcquisition: configFile.typeAcquisition,
|
||||
files: configFile.fileNames,
|
||||
raw: configFile.raw,
|
||||
errors: realizeDiagnostics(configFile.errors, "\r\n")
|
||||
@@ -1175,7 +1175,7 @@ namespace ts {
|
||||
toPath(info.projectRootPath, info.projectRootPath, getCanonicalFileName),
|
||||
toPath(info.safeListPath, info.safeListPath, getCanonicalFileName),
|
||||
info.packageNameToTypingLocation,
|
||||
info.typingOptions,
|
||||
info.typeAcquisition,
|
||||
info.unresolvedImports);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
const fs = require("fs");
|
||||
>fs : typeof "fs"
|
||||
>require("fs") : typeof "fs"
|
||||
>require("fs") : any
|
||||
>require : (moduleName: string) => any
|
||||
>"fs" : "fs"
|
||||
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
//// [commaOperatorInConditionalExpression.ts]
|
||||
function f (m: string) {
|
||||
[1, 2, 3].map(i => {
|
||||
return true? { [m]: i } : { [m]: i + 1 }
|
||||
})
|
||||
}
|
||||
|
||||
//// [commaOperatorInConditionalExpression.js]
|
||||
function f(m) {
|
||||
[1, 2, 3].map(function (i) {
|
||||
return true ? (_a = {}, _a[m] = i, _a) : (_b = {}, _b[m] = i + 1, _b);
|
||||
var _a, _b;
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
=== tests/cases/compiler/commaOperatorInConditionalExpression.ts ===
|
||||
function f (m: string) {
|
||||
>f : Symbol(f, Decl(commaOperatorInConditionalExpression.ts, 0, 0))
|
||||
>m : Symbol(m, Decl(commaOperatorInConditionalExpression.ts, 0, 12))
|
||||
|
||||
[1, 2, 3].map(i => {
|
||||
>[1, 2, 3].map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
|
||||
>map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
|
||||
>i : Symbol(i, Decl(commaOperatorInConditionalExpression.ts, 1, 18))
|
||||
|
||||
return true? { [m]: i } : { [m]: i + 1 }
|
||||
>m : Symbol(m, Decl(commaOperatorInConditionalExpression.ts, 0, 12))
|
||||
>i : Symbol(i, Decl(commaOperatorInConditionalExpression.ts, 1, 18))
|
||||
>m : Symbol(m, Decl(commaOperatorInConditionalExpression.ts, 0, 12))
|
||||
>i : Symbol(i, Decl(commaOperatorInConditionalExpression.ts, 1, 18))
|
||||
|
||||
})
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
=== tests/cases/compiler/commaOperatorInConditionalExpression.ts ===
|
||||
function f (m: string) {
|
||||
>f : (m: string) => void
|
||||
>m : string
|
||||
|
||||
[1, 2, 3].map(i => {
|
||||
>[1, 2, 3].map(i => { return true? { [m]: i } : { [m]: i + 1 } }) : { [x: string]: number; }[]
|
||||
>[1, 2, 3].map : { <U>(this: [number, number, number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U, U, U]; <U>(this: [number, number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U, U]; <U>(this: [number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U]; <U>(this: [number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U]; <U>(callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): U[]; }
|
||||
>[1, 2, 3] : number[]
|
||||
>1 : 1
|
||||
>2 : 2
|
||||
>3 : 3
|
||||
>map : { <U>(this: [number, number, number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U, U, U]; <U>(this: [number, number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U, U]; <U>(this: [number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U]; <U>(this: [number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U]; <U>(callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): U[]; }
|
||||
>i => { return true? { [m]: i } : { [m]: i + 1 } } : (i: number) => { [x: string]: number; }
|
||||
>i : number
|
||||
|
||||
return true? { [m]: i } : { [m]: i + 1 }
|
||||
>true? { [m]: i } : { [m]: i + 1 } : { [x: string]: number; }
|
||||
>true : true
|
||||
>{ [m]: i } : { [x: string]: number; }
|
||||
>m : string
|
||||
>i : number
|
||||
>{ [m]: i + 1 } : { [x: string]: number; }
|
||||
>m : string
|
||||
>i + 1 : number
|
||||
>i : number
|
||||
>1 : 1
|
||||
|
||||
})
|
||||
}
|
||||
@@ -0,0 +1,188 @@
|
||||
tests/cases/compiler/controlFlowSelfReferentialLoop.ts(6,17): error TS7006: Parameter 'a' implicitly has an 'any' type.
|
||||
tests/cases/compiler/controlFlowSelfReferentialLoop.ts(6,19): error TS7006: Parameter 'b' implicitly has an 'any' type.
|
||||
tests/cases/compiler/controlFlowSelfReferentialLoop.ts(6,21): error TS7006: Parameter 'c' implicitly has an 'any' type.
|
||||
tests/cases/compiler/controlFlowSelfReferentialLoop.ts(6,23): error TS7006: Parameter 'd' implicitly has an 'any' type.
|
||||
tests/cases/compiler/controlFlowSelfReferentialLoop.ts(6,25): error TS7006: Parameter 'x' implicitly has an 'any' type.
|
||||
tests/cases/compiler/controlFlowSelfReferentialLoop.ts(6,27): error TS7006: Parameter 's' implicitly has an 'any' type.
|
||||
tests/cases/compiler/controlFlowSelfReferentialLoop.ts(6,29): error TS7006: Parameter 'ac' implicitly has an 'any' type.
|
||||
tests/cases/compiler/controlFlowSelfReferentialLoop.ts(10,17): error TS7006: Parameter 'a' implicitly has an 'any' type.
|
||||
tests/cases/compiler/controlFlowSelfReferentialLoop.ts(10,19): error TS7006: Parameter 'b' implicitly has an 'any' type.
|
||||
tests/cases/compiler/controlFlowSelfReferentialLoop.ts(10,21): error TS7006: Parameter 'c' implicitly has an 'any' type.
|
||||
tests/cases/compiler/controlFlowSelfReferentialLoop.ts(10,23): error TS7006: Parameter 'd' implicitly has an 'any' type.
|
||||
tests/cases/compiler/controlFlowSelfReferentialLoop.ts(10,25): error TS7006: Parameter 'x' implicitly has an 'any' type.
|
||||
tests/cases/compiler/controlFlowSelfReferentialLoop.ts(10,27): error TS7006: Parameter 's' implicitly has an 'any' type.
|
||||
tests/cases/compiler/controlFlowSelfReferentialLoop.ts(10,29): error TS7006: Parameter 'ac' implicitly has an 'any' type.
|
||||
tests/cases/compiler/controlFlowSelfReferentialLoop.ts(14,17): error TS7006: Parameter 'a' implicitly has an 'any' type.
|
||||
tests/cases/compiler/controlFlowSelfReferentialLoop.ts(14,19): error TS7006: Parameter 'b' implicitly has an 'any' type.
|
||||
tests/cases/compiler/controlFlowSelfReferentialLoop.ts(14,21): error TS7006: Parameter 'c' implicitly has an 'any' type.
|
||||
tests/cases/compiler/controlFlowSelfReferentialLoop.ts(14,23): error TS7006: Parameter 'd' implicitly has an 'any' type.
|
||||
tests/cases/compiler/controlFlowSelfReferentialLoop.ts(14,25): error TS7006: Parameter 'x' implicitly has an 'any' type.
|
||||
tests/cases/compiler/controlFlowSelfReferentialLoop.ts(14,27): error TS7006: Parameter 's' implicitly has an 'any' type.
|
||||
tests/cases/compiler/controlFlowSelfReferentialLoop.ts(14,29): error TS7006: Parameter 'ac' implicitly has an 'any' type.
|
||||
tests/cases/compiler/controlFlowSelfReferentialLoop.ts(18,17): error TS7006: Parameter 'a' implicitly has an 'any' type.
|
||||
tests/cases/compiler/controlFlowSelfReferentialLoop.ts(18,19): error TS7006: Parameter 'b' implicitly has an 'any' type.
|
||||
tests/cases/compiler/controlFlowSelfReferentialLoop.ts(18,21): error TS7006: Parameter 'c' implicitly has an 'any' type.
|
||||
tests/cases/compiler/controlFlowSelfReferentialLoop.ts(18,23): error TS7006: Parameter 'd' implicitly has an 'any' type.
|
||||
tests/cases/compiler/controlFlowSelfReferentialLoop.ts(18,25): error TS7006: Parameter 'x' implicitly has an 'any' type.
|
||||
tests/cases/compiler/controlFlowSelfReferentialLoop.ts(18,27): error TS7006: Parameter 's' implicitly has an 'any' type.
|
||||
tests/cases/compiler/controlFlowSelfReferentialLoop.ts(18,29): error TS7006: Parameter 'ac' implicitly has an 'any' type.
|
||||
|
||||
|
||||
==== tests/cases/compiler/controlFlowSelfReferentialLoop.ts (28 errors) ====
|
||||
|
||||
// Repro from #12319
|
||||
|
||||
function md5(string:string): void {
|
||||
|
||||
function FF(a,b,c,d,x,s,ac) {
|
||||
~
|
||||
!!! error TS7006: Parameter 'a' implicitly has an 'any' type.
|
||||
~
|
||||
!!! error TS7006: Parameter 'b' implicitly has an 'any' type.
|
||||
~
|
||||
!!! error TS7006: Parameter 'c' implicitly has an 'any' type.
|
||||
~
|
||||
!!! error TS7006: Parameter 'd' implicitly has an 'any' type.
|
||||
~
|
||||
!!! error TS7006: Parameter 'x' implicitly has an 'any' type.
|
||||
~
|
||||
!!! error TS7006: Parameter 's' implicitly has an 'any' type.
|
||||
~~
|
||||
!!! error TS7006: Parameter 'ac' implicitly has an 'any' type.
|
||||
return 0;
|
||||
};
|
||||
|
||||
function GG(a,b,c,d,x,s,ac) {
|
||||
~
|
||||
!!! error TS7006: Parameter 'a' implicitly has an 'any' type.
|
||||
~
|
||||
!!! error TS7006: Parameter 'b' implicitly has an 'any' type.
|
||||
~
|
||||
!!! error TS7006: Parameter 'c' implicitly has an 'any' type.
|
||||
~
|
||||
!!! error TS7006: Parameter 'd' implicitly has an 'any' type.
|
||||
~
|
||||
!!! error TS7006: Parameter 'x' implicitly has an 'any' type.
|
||||
~
|
||||
!!! error TS7006: Parameter 's' implicitly has an 'any' type.
|
||||
~~
|
||||
!!! error TS7006: Parameter 'ac' implicitly has an 'any' type.
|
||||
return 0;
|
||||
};
|
||||
|
||||
function HH(a,b,c,d,x,s,ac) {
|
||||
~
|
||||
!!! error TS7006: Parameter 'a' implicitly has an 'any' type.
|
||||
~
|
||||
!!! error TS7006: Parameter 'b' implicitly has an 'any' type.
|
||||
~
|
||||
!!! error TS7006: Parameter 'c' implicitly has an 'any' type.
|
||||
~
|
||||
!!! error TS7006: Parameter 'd' implicitly has an 'any' type.
|
||||
~
|
||||
!!! error TS7006: Parameter 'x' implicitly has an 'any' type.
|
||||
~
|
||||
!!! error TS7006: Parameter 's' implicitly has an 'any' type.
|
||||
~~
|
||||
!!! error TS7006: Parameter 'ac' implicitly has an 'any' type.
|
||||
return 0;
|
||||
};
|
||||
|
||||
function II(a,b,c,d,x,s,ac) {
|
||||
~
|
||||
!!! error TS7006: Parameter 'a' implicitly has an 'any' type.
|
||||
~
|
||||
!!! error TS7006: Parameter 'b' implicitly has an 'any' type.
|
||||
~
|
||||
!!! error TS7006: Parameter 'c' implicitly has an 'any' type.
|
||||
~
|
||||
!!! error TS7006: Parameter 'd' implicitly has an 'any' type.
|
||||
~
|
||||
!!! error TS7006: Parameter 'x' implicitly has an 'any' type.
|
||||
~
|
||||
!!! error TS7006: Parameter 's' implicitly has an 'any' type.
|
||||
~~
|
||||
!!! error TS7006: Parameter 'ac' implicitly has an 'any' type.
|
||||
return 0;
|
||||
};
|
||||
|
||||
var x=Array();
|
||||
var k,AA,BB,CC,DD,a,b,c,d;
|
||||
var S11=7, S12=12, S13=17, S14=22;
|
||||
var S21=5, S22=9 , S23=14, S24=20;
|
||||
var S31=4, S32=11, S33=16, S34=23;
|
||||
var S41=6, S42=10, S43=15, S44=21;
|
||||
|
||||
x = [1];
|
||||
|
||||
a = 0x67452301; b = 0xEFCDAB89; c = 0x98BADCFE; d = 0x10325476;
|
||||
|
||||
for (k=0;k<x.length;k+=16) {
|
||||
AA=a; BB=b; CC=c; DD=d;
|
||||
a=FF(a,b,c,d,x[k+0], S11,0xD76AA478);
|
||||
d=FF(d,a,b,c,x[k+1], S12,0xE8C7B756);
|
||||
c=FF(c,d,a,b,x[k+2], S13,0x242070DB);
|
||||
b=FF(b,c,d,a,x[k+3], S14,0xC1BDCEEE);
|
||||
a=FF(a,b,c,d,x[k+4], S11,0xF57C0FAF);
|
||||
d=FF(d,a,b,c,x[k+5], S12,0x4787C62A);
|
||||
c=FF(c,d,a,b,x[k+6], S13,0xA8304613);
|
||||
b=FF(b,c,d,a,x[k+7], S14,0xFD469501);
|
||||
a=FF(a,b,c,d,x[k+8], S11,0x698098D8);
|
||||
d=FF(d,a,b,c,x[k+9], S12,0x8B44F7AF);
|
||||
c=FF(c,d,a,b,x[k+10],S13,0xFFFF5BB1);
|
||||
b=FF(b,c,d,a,x[k+11],S14,0x895CD7BE);
|
||||
a=FF(a,b,c,d,x[k+12],S11,0x6B901122);
|
||||
d=FF(d,a,b,c,x[k+13],S12,0xFD987193);
|
||||
c=FF(c,d,a,b,x[k+14],S13,0xA679438E);
|
||||
b=FF(b,c,d,a,x[k+15],S14,0x49B40821);
|
||||
a=GG(a,b,c,d,x[k+1], S21,0xF61E2562);
|
||||
d=GG(d,a,b,c,x[k+6], S22,0xC040B340);
|
||||
c=GG(c,d,a,b,x[k+11],S23,0x265E5A51);
|
||||
b=GG(b,c,d,a,x[k+0], S24,0xE9B6C7AA);
|
||||
a=GG(a,b,c,d,x[k+5], S21,0xD62F105D);
|
||||
d=GG(d,a,b,c,x[k+10],S22,0x2441453);
|
||||
c=GG(c,d,a,b,x[k+15],S23,0xD8A1E681);
|
||||
b=GG(b,c,d,a,x[k+4], S24,0xE7D3FBC8);
|
||||
a=GG(a,b,c,d,x[k+9], S21,0x21E1CDE6);
|
||||
d=GG(d,a,b,c,x[k+14],S22,0xC33707D6);
|
||||
c=GG(c,d,a,b,x[k+3], S23,0xF4D50D87);
|
||||
b=GG(b,c,d,a,x[k+8], S24,0x455A14ED);
|
||||
a=GG(a,b,c,d,x[k+13],S21,0xA9E3E905);
|
||||
d=GG(d,a,b,c,x[k+2], S22,0xFCEFA3F8);
|
||||
c=GG(c,d,a,b,x[k+7], S23,0x676F02D9);
|
||||
b=GG(b,c,d,a,x[k+12],S24,0x8D2A4C8A);
|
||||
a=HH(a,b,c,d,x[k+5], S31,0xFFFA3942);
|
||||
d=HH(d,a,b,c,x[k+8], S32,0x8771F681);
|
||||
c=HH(c,d,a,b,x[k+11],S33,0x6D9D6122);
|
||||
b=HH(b,c,d,a,x[k+14],S34,0xFDE5380C);
|
||||
a=HH(a,b,c,d,x[k+1], S31,0xA4BEEA44);
|
||||
d=HH(d,a,b,c,x[k+4], S32,0x4BDECFA9);
|
||||
c=HH(c,d,a,b,x[k+7], S33,0xF6BB4B60);
|
||||
b=HH(b,c,d,a,x[k+10],S34,0xBEBFBC70);
|
||||
a=HH(a,b,c,d,x[k+13],S31,0x289B7EC6);
|
||||
d=HH(d,a,b,c,x[k+0], S32,0xEAA127FA);
|
||||
c=HH(c,d,a,b,x[k+3], S33,0xD4EF3085);
|
||||
b=HH(b,c,d,a,x[k+6], S34,0x4881D05);
|
||||
a=HH(a,b,c,d,x[k+9], S31,0xD9D4D039);
|
||||
d=HH(d,a,b,c,x[k+12],S32,0xE6DB99E5);
|
||||
c=HH(c,d,a,b,x[k+15],S33,0x1FA27CF8);
|
||||
b=HH(b,c,d,a,x[k+2], S34,0xC4AC5665);
|
||||
a=II(a,b,c,d,x[k+0], S41,0xF4292244);
|
||||
d=II(d,a,b,c,x[k+7], S42,0x432AFF97);
|
||||
c=II(c,d,a,b,x[k+14],S43,0xAB9423A7);
|
||||
b=II(b,c,d,a,x[k+5], S44,0xFC93A039);
|
||||
a=II(a,b,c,d,x[k+12],S41,0x655B59C3);
|
||||
d=II(d,a,b,c,x[k+3], S42,0x8F0CCC92);
|
||||
c=II(c,d,a,b,x[k+10],S43,0xFFEFF47D);
|
||||
b=II(b,c,d,a,x[k+1], S44,0x85845DD1);
|
||||
a=II(a,b,c,d,x[k+8], S41,0x6FA87E4F);
|
||||
d=II(d,a,b,c,x[k+15],S42,0xFE2CE6E0);
|
||||
c=II(c,d,a,b,x[k+6], S43,0xA3014314);
|
||||
b=II(b,c,d,a,x[k+13],S44,0x4E0811A1);
|
||||
a=II(a,b,c,d,x[k+4], S41,0xF7537E82);
|
||||
d=II(d,a,b,c,x[k+11],S42,0xBD3AF235);
|
||||
c=II(c,d,a,b,x[k+2], S43,0x2AD7D2BB);
|
||||
b=II(b,c,d,a,x[k+9], S44,0xEB86D391);
|
||||
}
|
||||
}
|
||||
export default md5;
|
||||
@@ -0,0 +1,207 @@
|
||||
//// [controlFlowSelfReferentialLoop.ts]
|
||||
|
||||
// Repro from #12319
|
||||
|
||||
function md5(string:string): void {
|
||||
|
||||
function FF(a,b,c,d,x,s,ac) {
|
||||
return 0;
|
||||
};
|
||||
|
||||
function GG(a,b,c,d,x,s,ac) {
|
||||
return 0;
|
||||
};
|
||||
|
||||
function HH(a,b,c,d,x,s,ac) {
|
||||
return 0;
|
||||
};
|
||||
|
||||
function II(a,b,c,d,x,s,ac) {
|
||||
return 0;
|
||||
};
|
||||
|
||||
var x=Array();
|
||||
var k,AA,BB,CC,DD,a,b,c,d;
|
||||
var S11=7, S12=12, S13=17, S14=22;
|
||||
var S21=5, S22=9 , S23=14, S24=20;
|
||||
var S31=4, S32=11, S33=16, S34=23;
|
||||
var S41=6, S42=10, S43=15, S44=21;
|
||||
|
||||
x = [1];
|
||||
|
||||
a = 0x67452301; b = 0xEFCDAB89; c = 0x98BADCFE; d = 0x10325476;
|
||||
|
||||
for (k=0;k<x.length;k+=16) {
|
||||
AA=a; BB=b; CC=c; DD=d;
|
||||
a=FF(a,b,c,d,x[k+0], S11,0xD76AA478);
|
||||
d=FF(d,a,b,c,x[k+1], S12,0xE8C7B756);
|
||||
c=FF(c,d,a,b,x[k+2], S13,0x242070DB);
|
||||
b=FF(b,c,d,a,x[k+3], S14,0xC1BDCEEE);
|
||||
a=FF(a,b,c,d,x[k+4], S11,0xF57C0FAF);
|
||||
d=FF(d,a,b,c,x[k+5], S12,0x4787C62A);
|
||||
c=FF(c,d,a,b,x[k+6], S13,0xA8304613);
|
||||
b=FF(b,c,d,a,x[k+7], S14,0xFD469501);
|
||||
a=FF(a,b,c,d,x[k+8], S11,0x698098D8);
|
||||
d=FF(d,a,b,c,x[k+9], S12,0x8B44F7AF);
|
||||
c=FF(c,d,a,b,x[k+10],S13,0xFFFF5BB1);
|
||||
b=FF(b,c,d,a,x[k+11],S14,0x895CD7BE);
|
||||
a=FF(a,b,c,d,x[k+12],S11,0x6B901122);
|
||||
d=FF(d,a,b,c,x[k+13],S12,0xFD987193);
|
||||
c=FF(c,d,a,b,x[k+14],S13,0xA679438E);
|
||||
b=FF(b,c,d,a,x[k+15],S14,0x49B40821);
|
||||
a=GG(a,b,c,d,x[k+1], S21,0xF61E2562);
|
||||
d=GG(d,a,b,c,x[k+6], S22,0xC040B340);
|
||||
c=GG(c,d,a,b,x[k+11],S23,0x265E5A51);
|
||||
b=GG(b,c,d,a,x[k+0], S24,0xE9B6C7AA);
|
||||
a=GG(a,b,c,d,x[k+5], S21,0xD62F105D);
|
||||
d=GG(d,a,b,c,x[k+10],S22,0x2441453);
|
||||
c=GG(c,d,a,b,x[k+15],S23,0xD8A1E681);
|
||||
b=GG(b,c,d,a,x[k+4], S24,0xE7D3FBC8);
|
||||
a=GG(a,b,c,d,x[k+9], S21,0x21E1CDE6);
|
||||
d=GG(d,a,b,c,x[k+14],S22,0xC33707D6);
|
||||
c=GG(c,d,a,b,x[k+3], S23,0xF4D50D87);
|
||||
b=GG(b,c,d,a,x[k+8], S24,0x455A14ED);
|
||||
a=GG(a,b,c,d,x[k+13],S21,0xA9E3E905);
|
||||
d=GG(d,a,b,c,x[k+2], S22,0xFCEFA3F8);
|
||||
c=GG(c,d,a,b,x[k+7], S23,0x676F02D9);
|
||||
b=GG(b,c,d,a,x[k+12],S24,0x8D2A4C8A);
|
||||
a=HH(a,b,c,d,x[k+5], S31,0xFFFA3942);
|
||||
d=HH(d,a,b,c,x[k+8], S32,0x8771F681);
|
||||
c=HH(c,d,a,b,x[k+11],S33,0x6D9D6122);
|
||||
b=HH(b,c,d,a,x[k+14],S34,0xFDE5380C);
|
||||
a=HH(a,b,c,d,x[k+1], S31,0xA4BEEA44);
|
||||
d=HH(d,a,b,c,x[k+4], S32,0x4BDECFA9);
|
||||
c=HH(c,d,a,b,x[k+7], S33,0xF6BB4B60);
|
||||
b=HH(b,c,d,a,x[k+10],S34,0xBEBFBC70);
|
||||
a=HH(a,b,c,d,x[k+13],S31,0x289B7EC6);
|
||||
d=HH(d,a,b,c,x[k+0], S32,0xEAA127FA);
|
||||
c=HH(c,d,a,b,x[k+3], S33,0xD4EF3085);
|
||||
b=HH(b,c,d,a,x[k+6], S34,0x4881D05);
|
||||
a=HH(a,b,c,d,x[k+9], S31,0xD9D4D039);
|
||||
d=HH(d,a,b,c,x[k+12],S32,0xE6DB99E5);
|
||||
c=HH(c,d,a,b,x[k+15],S33,0x1FA27CF8);
|
||||
b=HH(b,c,d,a,x[k+2], S34,0xC4AC5665);
|
||||
a=II(a,b,c,d,x[k+0], S41,0xF4292244);
|
||||
d=II(d,a,b,c,x[k+7], S42,0x432AFF97);
|
||||
c=II(c,d,a,b,x[k+14],S43,0xAB9423A7);
|
||||
b=II(b,c,d,a,x[k+5], S44,0xFC93A039);
|
||||
a=II(a,b,c,d,x[k+12],S41,0x655B59C3);
|
||||
d=II(d,a,b,c,x[k+3], S42,0x8F0CCC92);
|
||||
c=II(c,d,a,b,x[k+10],S43,0xFFEFF47D);
|
||||
b=II(b,c,d,a,x[k+1], S44,0x85845DD1);
|
||||
a=II(a,b,c,d,x[k+8], S41,0x6FA87E4F);
|
||||
d=II(d,a,b,c,x[k+15],S42,0xFE2CE6E0);
|
||||
c=II(c,d,a,b,x[k+6], S43,0xA3014314);
|
||||
b=II(b,c,d,a,x[k+13],S44,0x4E0811A1);
|
||||
a=II(a,b,c,d,x[k+4], S41,0xF7537E82);
|
||||
d=II(d,a,b,c,x[k+11],S42,0xBD3AF235);
|
||||
c=II(c,d,a,b,x[k+2], S43,0x2AD7D2BB);
|
||||
b=II(b,c,d,a,x[k+9], S44,0xEB86D391);
|
||||
}
|
||||
}
|
||||
export default md5;
|
||||
|
||||
//// [controlFlowSelfReferentialLoop.js]
|
||||
// Repro from #12319
|
||||
"use strict";
|
||||
function md5(string) {
|
||||
function FF(a, b, c, d, x, s, ac) {
|
||||
return 0;
|
||||
}
|
||||
;
|
||||
function GG(a, b, c, d, x, s, ac) {
|
||||
return 0;
|
||||
}
|
||||
;
|
||||
function HH(a, b, c, d, x, s, ac) {
|
||||
return 0;
|
||||
}
|
||||
;
|
||||
function II(a, b, c, d, x, s, ac) {
|
||||
return 0;
|
||||
}
|
||||
;
|
||||
var x = Array();
|
||||
var k, AA, BB, CC, DD, a, b, c, d;
|
||||
var S11 = 7, S12 = 12, S13 = 17, S14 = 22;
|
||||
var S21 = 5, S22 = 9, S23 = 14, S24 = 20;
|
||||
var S31 = 4, S32 = 11, S33 = 16, S34 = 23;
|
||||
var S41 = 6, S42 = 10, S43 = 15, S44 = 21;
|
||||
x = [1];
|
||||
a = 0x67452301;
|
||||
b = 0xEFCDAB89;
|
||||
c = 0x98BADCFE;
|
||||
d = 0x10325476;
|
||||
for (k = 0; k < x.length; k += 16) {
|
||||
AA = a;
|
||||
BB = b;
|
||||
CC = c;
|
||||
DD = d;
|
||||
a = FF(a, b, c, d, x[k + 0], S11, 0xD76AA478);
|
||||
d = FF(d, a, b, c, x[k + 1], S12, 0xE8C7B756);
|
||||
c = FF(c, d, a, b, x[k + 2], S13, 0x242070DB);
|
||||
b = FF(b, c, d, a, x[k + 3], S14, 0xC1BDCEEE);
|
||||
a = FF(a, b, c, d, x[k + 4], S11, 0xF57C0FAF);
|
||||
d = FF(d, a, b, c, x[k + 5], S12, 0x4787C62A);
|
||||
c = FF(c, d, a, b, x[k + 6], S13, 0xA8304613);
|
||||
b = FF(b, c, d, a, x[k + 7], S14, 0xFD469501);
|
||||
a = FF(a, b, c, d, x[k + 8], S11, 0x698098D8);
|
||||
d = FF(d, a, b, c, x[k + 9], S12, 0x8B44F7AF);
|
||||
c = FF(c, d, a, b, x[k + 10], S13, 0xFFFF5BB1);
|
||||
b = FF(b, c, d, a, x[k + 11], S14, 0x895CD7BE);
|
||||
a = FF(a, b, c, d, x[k + 12], S11, 0x6B901122);
|
||||
d = FF(d, a, b, c, x[k + 13], S12, 0xFD987193);
|
||||
c = FF(c, d, a, b, x[k + 14], S13, 0xA679438E);
|
||||
b = FF(b, c, d, a, x[k + 15], S14, 0x49B40821);
|
||||
a = GG(a, b, c, d, x[k + 1], S21, 0xF61E2562);
|
||||
d = GG(d, a, b, c, x[k + 6], S22, 0xC040B340);
|
||||
c = GG(c, d, a, b, x[k + 11], S23, 0x265E5A51);
|
||||
b = GG(b, c, d, a, x[k + 0], S24, 0xE9B6C7AA);
|
||||
a = GG(a, b, c, d, x[k + 5], S21, 0xD62F105D);
|
||||
d = GG(d, a, b, c, x[k + 10], S22, 0x2441453);
|
||||
c = GG(c, d, a, b, x[k + 15], S23, 0xD8A1E681);
|
||||
b = GG(b, c, d, a, x[k + 4], S24, 0xE7D3FBC8);
|
||||
a = GG(a, b, c, d, x[k + 9], S21, 0x21E1CDE6);
|
||||
d = GG(d, a, b, c, x[k + 14], S22, 0xC33707D6);
|
||||
c = GG(c, d, a, b, x[k + 3], S23, 0xF4D50D87);
|
||||
b = GG(b, c, d, a, x[k + 8], S24, 0x455A14ED);
|
||||
a = GG(a, b, c, d, x[k + 13], S21, 0xA9E3E905);
|
||||
d = GG(d, a, b, c, x[k + 2], S22, 0xFCEFA3F8);
|
||||
c = GG(c, d, a, b, x[k + 7], S23, 0x676F02D9);
|
||||
b = GG(b, c, d, a, x[k + 12], S24, 0x8D2A4C8A);
|
||||
a = HH(a, b, c, d, x[k + 5], S31, 0xFFFA3942);
|
||||
d = HH(d, a, b, c, x[k + 8], S32, 0x8771F681);
|
||||
c = HH(c, d, a, b, x[k + 11], S33, 0x6D9D6122);
|
||||
b = HH(b, c, d, a, x[k + 14], S34, 0xFDE5380C);
|
||||
a = HH(a, b, c, d, x[k + 1], S31, 0xA4BEEA44);
|
||||
d = HH(d, a, b, c, x[k + 4], S32, 0x4BDECFA9);
|
||||
c = HH(c, d, a, b, x[k + 7], S33, 0xF6BB4B60);
|
||||
b = HH(b, c, d, a, x[k + 10], S34, 0xBEBFBC70);
|
||||
a = HH(a, b, c, d, x[k + 13], S31, 0x289B7EC6);
|
||||
d = HH(d, a, b, c, x[k + 0], S32, 0xEAA127FA);
|
||||
c = HH(c, d, a, b, x[k + 3], S33, 0xD4EF3085);
|
||||
b = HH(b, c, d, a, x[k + 6], S34, 0x4881D05);
|
||||
a = HH(a, b, c, d, x[k + 9], S31, 0xD9D4D039);
|
||||
d = HH(d, a, b, c, x[k + 12], S32, 0xE6DB99E5);
|
||||
c = HH(c, d, a, b, x[k + 15], S33, 0x1FA27CF8);
|
||||
b = HH(b, c, d, a, x[k + 2], S34, 0xC4AC5665);
|
||||
a = II(a, b, c, d, x[k + 0], S41, 0xF4292244);
|
||||
d = II(d, a, b, c, x[k + 7], S42, 0x432AFF97);
|
||||
c = II(c, d, a, b, x[k + 14], S43, 0xAB9423A7);
|
||||
b = II(b, c, d, a, x[k + 5], S44, 0xFC93A039);
|
||||
a = II(a, b, c, d, x[k + 12], S41, 0x655B59C3);
|
||||
d = II(d, a, b, c, x[k + 3], S42, 0x8F0CCC92);
|
||||
c = II(c, d, a, b, x[k + 10], S43, 0xFFEFF47D);
|
||||
b = II(b, c, d, a, x[k + 1], S44, 0x85845DD1);
|
||||
a = II(a, b, c, d, x[k + 8], S41, 0x6FA87E4F);
|
||||
d = II(d, a, b, c, x[k + 15], S42, 0xFE2CE6E0);
|
||||
c = II(c, d, a, b, x[k + 6], S43, 0xA3014314);
|
||||
b = II(b, c, d, a, x[k + 13], S44, 0x4E0811A1);
|
||||
a = II(a, b, c, d, x[k + 4], S41, 0xF7537E82);
|
||||
d = II(d, a, b, c, x[k + 11], S42, 0xBD3AF235);
|
||||
c = II(c, d, a, b, x[k + 2], S43, 0x2AD7D2BB);
|
||||
b = II(b, c, d, a, x[k + 9], S44, 0xEB86D391);
|
||||
}
|
||||
}
|
||||
exports.__esModule = true;
|
||||
exports["default"] = md5;
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -1,7 +0,0 @@
|
||||
tests/cases/conformance/parser/ecmascript5/Statements/parserES5ForOfStatement19.ts(1,16): 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/parser/ecmascript5/Statements/parserES5ForOfStatement19.ts (1 errors) ====
|
||||
for (var of in of) { }
|
||||
~~
|
||||
!!! error TS2407: The right-hand side of a 'for...in' statement must be of type 'any', an object type or a type parameter.
|
||||
@@ -0,0 +1,5 @@
|
||||
=== tests/cases/conformance/parser/ecmascript5/Statements/parserES5ForOfStatement19.ts ===
|
||||
for (var of in of) { }
|
||||
>of : Symbol(of, Decl(parserES5ForOfStatement19.ts, 0, 8))
|
||||
>of : Symbol(of, Decl(parserES5ForOfStatement19.ts, 0, 8))
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
=== tests/cases/conformance/parser/ecmascript5/Statements/parserES5ForOfStatement19.ts ===
|
||||
for (var of in of) { }
|
||||
>of : any
|
||||
>of : any
|
||||
|
||||
@@ -1,10 +1,7 @@
|
||||
tests/cases/conformance/parser/ecmascript5/Statements/parserES5ForOfStatement20.ts(1,10): error TS1189: The variable declaration of a 'for...in' statement cannot have an initializer.
|
||||
tests/cases/conformance/parser/ecmascript5/Statements/parserES5ForOfStatement20.ts(1,20): 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/parser/ecmascript5/Statements/parserES5ForOfStatement20.ts (2 errors) ====
|
||||
==== tests/cases/conformance/parser/ecmascript5/Statements/parserES5ForOfStatement20.ts (1 errors) ====
|
||||
for (var of = 0 in of) { }
|
||||
~~
|
||||
!!! error TS1189: The variable declaration of a 'for...in' statement cannot have an initializer.
|
||||
~~
|
||||
!!! error TS2407: The right-hand side of a 'for...in' statement must be of type 'any', an object type or a type parameter.
|
||||
!!! error TS1189: The variable declaration of a 'for...in' statement cannot have an initializer.
|
||||
@@ -1,7 +0,0 @@
|
||||
tests/cases/conformance/parser/ecmascript6/Iterators/parserForOfStatement19.ts(1,16): 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/parser/ecmascript6/Iterators/parserForOfStatement19.ts (1 errors) ====
|
||||
for (var of in of) { }
|
||||
~~
|
||||
!!! error TS2407: The right-hand side of a 'for...in' statement must be of type 'any', an object type or a type parameter.
|
||||
@@ -0,0 +1,5 @@
|
||||
=== tests/cases/conformance/parser/ecmascript6/Iterators/parserForOfStatement19.ts ===
|
||||
for (var of in of) { }
|
||||
>of : Symbol(of, Decl(parserForOfStatement19.ts, 0, 8))
|
||||
>of : Symbol(of, Decl(parserForOfStatement19.ts, 0, 8))
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
=== tests/cases/conformance/parser/ecmascript6/Iterators/parserForOfStatement19.ts ===
|
||||
for (var of in of) { }
|
||||
>of : any
|
||||
>of : any
|
||||
|
||||
@@ -1,10 +1,7 @@
|
||||
tests/cases/conformance/parser/ecmascript6/Iterators/parserForOfStatement20.ts(1,10): error TS1189: The variable declaration of a 'for...in' statement cannot have an initializer.
|
||||
tests/cases/conformance/parser/ecmascript6/Iterators/parserForOfStatement20.ts(1,20): 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/parser/ecmascript6/Iterators/parserForOfStatement20.ts (2 errors) ====
|
||||
==== tests/cases/conformance/parser/ecmascript6/Iterators/parserForOfStatement20.ts (1 errors) ====
|
||||
for (var of = 0 in of) { }
|
||||
~~
|
||||
!!! error TS1189: The variable declaration of a 'for...in' statement cannot have an initializer.
|
||||
~~
|
||||
!!! error TS2407: The right-hand side of a 'for...in' statement must be of type 'any', an object type or a type parameter.
|
||||
!!! error TS1189: The variable declaration of a 'for...in' statement cannot have an initializer.
|
||||
@@ -5,14 +5,13 @@ tests/cases/compiler/recursiveLetConst.ts(5,14): error TS2448: Block-scoped vari
|
||||
tests/cases/compiler/recursiveLetConst.ts(6,14): error TS2448: Block-scoped variable 'v' used before its declaration.
|
||||
tests/cases/compiler/recursiveLetConst.ts(7,1): error TS7027: Unreachable code detected.
|
||||
tests/cases/compiler/recursiveLetConst.ts(7,16): error TS2448: Block-scoped variable 'v' used before its declaration.
|
||||
tests/cases/compiler/recursiveLetConst.ts(8,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/compiler/recursiveLetConst.ts(8,15): error TS2448: Block-scoped variable 'v' used before its declaration.
|
||||
tests/cases/compiler/recursiveLetConst.ts(9,15): error TS2448: Block-scoped variable 'v' used before its declaration.
|
||||
tests/cases/compiler/recursiveLetConst.ts(10,17): error TS2448: Block-scoped variable 'v' used before its declaration.
|
||||
tests/cases/compiler/recursiveLetConst.ts(11,11): error TS2448: Block-scoped variable 'x2' used before its declaration.
|
||||
|
||||
|
||||
==== tests/cases/compiler/recursiveLetConst.ts (12 errors) ====
|
||||
==== tests/cases/compiler/recursiveLetConst.ts (11 errors) ====
|
||||
'use strict'
|
||||
let x = x + 1;
|
||||
~
|
||||
@@ -36,8 +35,6 @@ tests/cases/compiler/recursiveLetConst.ts(11,11): error TS2448: Block-scoped var
|
||||
!!! error TS2448: Block-scoped variable 'v' used before its declaration.
|
||||
for (let v in v) { }
|
||||
~
|
||||
!!! error TS2407: The right-hand side of a 'for...in' statement must be of type 'any', an object type or a type parameter.
|
||||
~
|
||||
!!! error TS2448: Block-scoped variable 'v' used before its declaration.
|
||||
for (let v of v) { }
|
||||
~
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
function f (m: string) {
|
||||
[1, 2, 3].map(i => {
|
||||
return true? { [m]: i } : { [m]: i + 1 }
|
||||
})
|
||||
}
|
||||
@@ -0,0 +1,102 @@
|
||||
// @noimplicitany: true
|
||||
|
||||
// Repro from #12319
|
||||
|
||||
function md5(string:string): void {
|
||||
|
||||
function FF(a,b,c,d,x,s,ac) {
|
||||
return 0;
|
||||
};
|
||||
|
||||
function GG(a,b,c,d,x,s,ac) {
|
||||
return 0;
|
||||
};
|
||||
|
||||
function HH(a,b,c,d,x,s,ac) {
|
||||
return 0;
|
||||
};
|
||||
|
||||
function II(a,b,c,d,x,s,ac) {
|
||||
return 0;
|
||||
};
|
||||
|
||||
var x=Array();
|
||||
var k,AA,BB,CC,DD,a,b,c,d;
|
||||
var S11=7, S12=12, S13=17, S14=22;
|
||||
var S21=5, S22=9 , S23=14, S24=20;
|
||||
var S31=4, S32=11, S33=16, S34=23;
|
||||
var S41=6, S42=10, S43=15, S44=21;
|
||||
|
||||
x = [1];
|
||||
|
||||
a = 0x67452301; b = 0xEFCDAB89; c = 0x98BADCFE; d = 0x10325476;
|
||||
|
||||
for (k=0;k<x.length;k+=16) {
|
||||
AA=a; BB=b; CC=c; DD=d;
|
||||
a=FF(a,b,c,d,x[k+0], S11,0xD76AA478);
|
||||
d=FF(d,a,b,c,x[k+1], S12,0xE8C7B756);
|
||||
c=FF(c,d,a,b,x[k+2], S13,0x242070DB);
|
||||
b=FF(b,c,d,a,x[k+3], S14,0xC1BDCEEE);
|
||||
a=FF(a,b,c,d,x[k+4], S11,0xF57C0FAF);
|
||||
d=FF(d,a,b,c,x[k+5], S12,0x4787C62A);
|
||||
c=FF(c,d,a,b,x[k+6], S13,0xA8304613);
|
||||
b=FF(b,c,d,a,x[k+7], S14,0xFD469501);
|
||||
a=FF(a,b,c,d,x[k+8], S11,0x698098D8);
|
||||
d=FF(d,a,b,c,x[k+9], S12,0x8B44F7AF);
|
||||
c=FF(c,d,a,b,x[k+10],S13,0xFFFF5BB1);
|
||||
b=FF(b,c,d,a,x[k+11],S14,0x895CD7BE);
|
||||
a=FF(a,b,c,d,x[k+12],S11,0x6B901122);
|
||||
d=FF(d,a,b,c,x[k+13],S12,0xFD987193);
|
||||
c=FF(c,d,a,b,x[k+14],S13,0xA679438E);
|
||||
b=FF(b,c,d,a,x[k+15],S14,0x49B40821);
|
||||
a=GG(a,b,c,d,x[k+1], S21,0xF61E2562);
|
||||
d=GG(d,a,b,c,x[k+6], S22,0xC040B340);
|
||||
c=GG(c,d,a,b,x[k+11],S23,0x265E5A51);
|
||||
b=GG(b,c,d,a,x[k+0], S24,0xE9B6C7AA);
|
||||
a=GG(a,b,c,d,x[k+5], S21,0xD62F105D);
|
||||
d=GG(d,a,b,c,x[k+10],S22,0x2441453);
|
||||
c=GG(c,d,a,b,x[k+15],S23,0xD8A1E681);
|
||||
b=GG(b,c,d,a,x[k+4], S24,0xE7D3FBC8);
|
||||
a=GG(a,b,c,d,x[k+9], S21,0x21E1CDE6);
|
||||
d=GG(d,a,b,c,x[k+14],S22,0xC33707D6);
|
||||
c=GG(c,d,a,b,x[k+3], S23,0xF4D50D87);
|
||||
b=GG(b,c,d,a,x[k+8], S24,0x455A14ED);
|
||||
a=GG(a,b,c,d,x[k+13],S21,0xA9E3E905);
|
||||
d=GG(d,a,b,c,x[k+2], S22,0xFCEFA3F8);
|
||||
c=GG(c,d,a,b,x[k+7], S23,0x676F02D9);
|
||||
b=GG(b,c,d,a,x[k+12],S24,0x8D2A4C8A);
|
||||
a=HH(a,b,c,d,x[k+5], S31,0xFFFA3942);
|
||||
d=HH(d,a,b,c,x[k+8], S32,0x8771F681);
|
||||
c=HH(c,d,a,b,x[k+11],S33,0x6D9D6122);
|
||||
b=HH(b,c,d,a,x[k+14],S34,0xFDE5380C);
|
||||
a=HH(a,b,c,d,x[k+1], S31,0xA4BEEA44);
|
||||
d=HH(d,a,b,c,x[k+4], S32,0x4BDECFA9);
|
||||
c=HH(c,d,a,b,x[k+7], S33,0xF6BB4B60);
|
||||
b=HH(b,c,d,a,x[k+10],S34,0xBEBFBC70);
|
||||
a=HH(a,b,c,d,x[k+13],S31,0x289B7EC6);
|
||||
d=HH(d,a,b,c,x[k+0], S32,0xEAA127FA);
|
||||
c=HH(c,d,a,b,x[k+3], S33,0xD4EF3085);
|
||||
b=HH(b,c,d,a,x[k+6], S34,0x4881D05);
|
||||
a=HH(a,b,c,d,x[k+9], S31,0xD9D4D039);
|
||||
d=HH(d,a,b,c,x[k+12],S32,0xE6DB99E5);
|
||||
c=HH(c,d,a,b,x[k+15],S33,0x1FA27CF8);
|
||||
b=HH(b,c,d,a,x[k+2], S34,0xC4AC5665);
|
||||
a=II(a,b,c,d,x[k+0], S41,0xF4292244);
|
||||
d=II(d,a,b,c,x[k+7], S42,0x432AFF97);
|
||||
c=II(c,d,a,b,x[k+14],S43,0xAB9423A7);
|
||||
b=II(b,c,d,a,x[k+5], S44,0xFC93A039);
|
||||
a=II(a,b,c,d,x[k+12],S41,0x655B59C3);
|
||||
d=II(d,a,b,c,x[k+3], S42,0x8F0CCC92);
|
||||
c=II(c,d,a,b,x[k+10],S43,0xFFEFF47D);
|
||||
b=II(b,c,d,a,x[k+1], S44,0x85845DD1);
|
||||
a=II(a,b,c,d,x[k+8], S41,0x6FA87E4F);
|
||||
d=II(d,a,b,c,x[k+15],S42,0xFE2CE6E0);
|
||||
c=II(c,d,a,b,x[k+6], S43,0xA3014314);
|
||||
b=II(b,c,d,a,x[k+13],S44,0x4E0811A1);
|
||||
a=II(a,b,c,d,x[k+4], S41,0xF7537E82);
|
||||
d=II(d,a,b,c,x[k+11],S42,0xBD3AF235);
|
||||
c=II(c,d,a,b,x[k+2], S43,0x2AD7D2BB);
|
||||
b=II(b,c,d,a,x[k+9], S44,0xEB86D391);
|
||||
}
|
||||
}
|
||||
export default md5;
|
||||
@@ -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 {
|
||||
|
||||
@@ -20,8 +20,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
|
||||
|
||||
@@ -27,13 +27,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 };
|
||||
|
||||
@@ -28,7 +28,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 {
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
/// <reference path="fourslash.ts"/>
|
||||
|
||||
////const foo = [
|
||||
//// 1
|
||||
////];
|
||||
|
||||
const options = format.copyFormatOptions();
|
||||
options.IndentSize = 2;
|
||||
options.TabSize = 2;
|
||||
options.ConvertTabsToSpaces = false;
|
||||
format.setFormatOptions(options);
|
||||
format.document();
|
||||
verify.currentFileContentIs(
|
||||
`const foo = [
|
||||
1
|
||||
];`);
|
||||
@@ -0,0 +1,16 @@
|
||||
/// <reference path="fourslash.ts"/>
|
||||
|
||||
////const foo = [
|
||||
//// 1
|
||||
////];
|
||||
|
||||
const options = format.copyFormatOptions();
|
||||
options.IndentSize = 2;
|
||||
options.TabSize = 2;
|
||||
options.ConvertTabsToSpaces = false;
|
||||
format.setFormatOptions(options);
|
||||
format.document();
|
||||
verify.currentFileContentIs(
|
||||
`const foo = [
|
||||
1
|
||||
];`);
|
||||
@@ -0,0 +1,23 @@
|
||||
///<reference path="fourslash.ts" />
|
||||
|
||||
// @allowJs: true
|
||||
// @Filename: dummy.js
|
||||
|
||||
//// /**
|
||||
//// * @augments {Thing<string>}
|
||||
//// */
|
||||
//// class MyStringThing extends Thing {
|
||||
//// constructor() {
|
||||
//// var x = this.mine;
|
||||
//// x/**/;
|
||||
//// }
|
||||
//// }
|
||||
|
||||
// @Filename: declarations.d.ts
|
||||
//// declare class Thing<T> {
|
||||
//// mine: T;
|
||||
//// }
|
||||
|
||||
goTo.marker();
|
||||
verify.quickInfoIs("(local var) x: string");
|
||||
|
||||
Reference in New Issue
Block a user