Merge branch 'master' into ownJsonParsing

This commit is contained in:
Sheetal Nandi
2016-11-23 13:17:56 -08:00
258 changed files with 5515 additions and 4864 deletions
+6 -8
View File
@@ -258,7 +258,7 @@ var harnessSources = harnessCoreSources.concat([
"commandLineParsing.ts",
"configurationExtension.ts",
"convertCompilerOptionsFromJson.ts",
"convertTypingOptionsFromJson.ts",
"convertTypeAcquisitionFromJson.ts",
"tsserverProjectSystem.ts",
"compileOnSave.ts",
"typingsInstaller.ts",
@@ -932,7 +932,7 @@ function runConsoleTests(defaultReporter, runInParallel) {
}
if (tests && tests.toLocaleLowerCase() === "rwc") {
testTimeout = 400000;
testTimeout = 800000;
}
colors = process.env.colors || process.env.color;
@@ -1088,12 +1088,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';
@@ -1117,12 +1115,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);
});
+13 -9
View File
@@ -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 -1
View File
@@ -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 -1
View File
@@ -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 -1
View File
@@ -1,4 +1,4 @@
import * as Lint from "tslint/lib/lint";
import * as Lint from "tslint/lib";
import * as ts from "typescript";
+1 -1
View File
@@ -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 -1
View File
@@ -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 -1
View File
@@ -1,4 +1,4 @@
import * as Lint from "tslint/lib/lint";
import * as Lint from "tslint/lib";
import * as ts from "typescript";
+2 -2
View File
@@ -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);
+212 -125
View File
@@ -126,6 +126,7 @@ namespace ts {
const intersectionTypes = createMap<IntersectionType>();
const stringLiteralTypes = createMap<LiteralType>();
const numericLiteralTypes = createMap<LiteralType>();
const indexedAccessTypes = createMap<IndexedAccessType>();
const evolvingArrayTypes: EvolvingArrayType[] = [];
const unknownSymbol = createSymbol(SymbolFlags.Property | SymbolFlags.Transient, "unknown");
@@ -147,7 +148,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);
@@ -928,6 +928,7 @@ namespace ts {
if (!errorLocation ||
!checkAndReportErrorForMissingPrefix(errorLocation, name, nameArg) &&
!checkAndReportErrorForExtendingInterface(errorLocation) &&
!checkAndReportErrorForUsingTypeAsNamespace(errorLocation, name, meaning) &&
!checkAndReportErrorForUsingTypeAsValue(errorLocation, name, meaning)) {
error(errorLocation, nameNotFoundMessage, typeof nameArg === "string" ? nameArg : declarationNameToString(nameArg));
}
@@ -1038,6 +1039,18 @@ namespace ts {
}
}
function checkAndReportErrorForUsingTypeAsNamespace(errorLocation: Node, name: string, meaning: SymbolFlags): boolean {
if (meaning === SymbolFlags.Namespace) {
const symbol = resolveSymbol(resolveName(errorLocation, name, SymbolFlags.Type & ~SymbolFlags.Value, /*nameNotFoundMessage*/undefined, /*nameArg*/ undefined));
if (symbol) {
error(errorLocation, Diagnostics._0_only_refers_to_a_type_but_is_being_used_as_a_namespace_here, name);
return true;
}
}
return false;
}
function checkAndReportErrorForUsingTypeAsValue(errorLocation: Node, name: string, meaning: SymbolFlags): boolean {
if (meaning & (SymbolFlags.Value & ~SymbolFlags.NamespaceModule)) {
const symbol = resolveSymbol(resolveName(errorLocation, name, SymbolFlags.Type & ~SymbolFlags.Value, /*nameNotFoundMessage*/undefined, /*nameArg*/ undefined));
@@ -3161,38 +3174,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;
}
@@ -3222,9 +3207,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) {
@@ -3244,9 +3231,11 @@ namespace ts {
return addOptionality(getTypeFromTypeNode(declaration.type), /*optional*/ declaration.questionToken && includeOptionality);
}
if (declaration.kind === SyntaxKind.VariableDeclaration && !isBindingPattern(declaration.name) &&
if ((compilerOptions.noImplicitAny || declaration.flags & NodeFlags.JavaScriptFile) &&
declaration.kind === SyntaxKind.VariableDeclaration && !isBindingPattern(declaration.name) &&
!(getCombinedModifierFlags(declaration) & ModifierFlags.Export) && !isInAmbientContext(declaration)) {
// Use control flow tracked 'any' type for non-ambient, non-exported var or let variables with no
// If --noImplicitAny is on or the declaration is in a Javascript file,
// use control flow tracked 'any' type for non-ambient, non-exported var or let variables with no
// initializer or a 'null' or 'undefined' initializer.
if (!(getCombinedNodeFlags(declaration) & NodeFlags.Const) && (!declaration.initializer || isNullOrUndefined(declaration.initializer))) {
return autoType;
@@ -3458,9 +3447,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,
@@ -3827,6 +3816,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;
}
@@ -3835,7 +3834,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;
}
@@ -4671,18 +4670,26 @@ namespace ts {
return type.resolvedApparentType;
}
/**
* The apparent type of an indexed access T[K] is the type of T's string index signature, if any.
*/
function getApparentTypeOfIndexedAccess(type: IndexedAccessType) {
return getIndexTypeOfType(getApparentType(type.objectType), IndexKind.String) || type;
}
/**
* For a type parameter, return the base constraint of the type parameter. For the string, number,
* boolean, and symbol primitive types, return the corresponding object types. Otherwise return the
* type itself. Note that the apparent type of a union type is the union type itself.
*/
function getApparentType(type: Type): Type {
const t = type.flags & TypeFlags.TypeParameter ? getApparentTypeOfTypeParameter(<TypeParameter>type) : type;
const t = type.flags & TypeFlags.TypeParameter ? getApparentTypeOfTypeParameter(<TypeParameter>type) :
type.flags & TypeFlags.IndexedAccess ? getApparentTypeOfIndexedAccess(<IndexedAccessType>type) :
type;
return t.flags & TypeFlags.StringLike ? globalStringType :
t.flags & TypeFlags.NumberLike ? globalNumberType :
t.flags & TypeFlags.BooleanLike ? globalBooleanType :
t.flags & TypeFlags.ESSymbol ? getGlobalESSymbolType() :
t.flags & TypeFlags.Index ? stringOrNumberType :
t;
}
@@ -4895,15 +4902,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;
}
}
}
}
@@ -5913,8 +5921,8 @@ namespace ts {
function getIndexType(type: Type): Type {
return type.flags & TypeFlags.TypeParameter ? getIndexTypeForTypeParameter(<TypeParameter>type) :
type.flags & TypeFlags.Any || getIndexInfoOfType(type, IndexKind.String) ? stringOrNumberType :
getIndexInfoOfType(type, IndexKind.Number) ? getUnionType([numberType, getLiteralTypeFromPropertyNames(type)]) :
getObjectFlags(type) & ObjectFlags.Mapped ? getConstraintTypeFromMappedType(<MappedType>type) :
type.flags & TypeFlags.Any || getIndexInfoOfType(type, IndexKind.String) ? stringType :
getLiteralTypeFromPropertyNames(type);
}
@@ -5926,18 +5934,13 @@ namespace ts {
return links.resolvedType;
}
function createIndexedAccessType(objectType: Type, indexType: TypeParameter) {
function createIndexedAccessType(objectType: Type, indexType: Type) {
const type = <IndexedAccessType>createType(TypeFlags.IndexedAccess);
type.objectType = objectType;
type.indexType = indexType;
return type;
}
function getIndexedAccessTypeForTypeParameter(objectType: Type, indexType: TypeParameter) {
const indexedAccessTypes = indexType.resolvedIndexedAccessTypes || (indexType.resolvedIndexedAccessTypes = []);
return indexedAccessTypes[objectType.id] || (indexedAccessTypes[objectType.id] = createIndexedAccessType(objectType, indexType));
}
function getPropertyTypeForIndexType(objectType: Type, indexType: Type, accessNode: ElementAccessExpression | IndexedAccessTypeNode, cacheSymbol: boolean) {
const accessExpression = accessNode && accessNode.kind === SyntaxKind.ElementAccessExpression ? <ElementAccessExpression>accessNode : undefined;
const propName = indexType.flags & (TypeFlags.StringLiteral | TypeFlags.NumberLiteral | TypeFlags.EnumLiteral) ?
@@ -6001,19 +6004,47 @@ namespace ts {
return unknownType;
}
function getIndexedAccessType(objectType: Type, indexType: Type, accessNode?: ElementAccessExpression | IndexedAccessTypeNode) {
if (indexType.flags & TypeFlags.TypeParameter) {
if (accessNode && !isTypeAssignableTo(getConstraintOfTypeParameter(<TypeParameter>indexType) || emptyObjectType, getIndexType(objectType))) {
error(accessNode, Diagnostics.Type_0_is_not_constrained_to_keyof_1, typeToString(indexType), typeToString(objectType));
return unknownType;
}
return getIndexedAccessTypeForTypeParameter(objectType, <TypeParameter>indexType);
function getIndexedAccessForMappedType(type: MappedType, indexType: Type, accessNode?: ElementAccessExpression | IndexedAccessTypeNode) {
const accessExpression = accessNode && accessNode.kind === SyntaxKind.ElementAccessExpression ? <ElementAccessExpression>accessNode : undefined;
if (accessExpression && isAssignmentTarget(accessExpression) && type.declaration.readonlyToken) {
error(accessExpression, Diagnostics.Index_signature_in_type_0_only_permits_reading, typeToString(type));
return unknownType;
}
const apparentType = getApparentType(objectType);
const mapper = createUnaryTypeMapper(getTypeParameterFromMappedType(type), indexType);
const templateMapper = type.mapper ? combineTypeMappers(type.mapper, mapper) : mapper;
return addOptionality(instantiateType(getTemplateTypeFromMappedType(type), templateMapper), !!type.declaration.questionToken);
}
function getIndexedAccessType(objectType: Type, indexType: Type, accessNode?: ElementAccessExpression | IndexedAccessTypeNode) {
if (indexType.flags & TypeFlags.TypeParameter ||
objectType.flags & TypeFlags.TypeParameter && indexType.flags & TypeFlags.Index ||
isGenericMappedType(objectType)) {
// If either the object type or the index type are type parameters, or if the object type is a mapped
// type with a generic constraint, we are performing a higher-order index access where we cannot
// meaningfully access the properties of the object type. In those cases, we first check that the
// index type is assignable to 'keyof T' for the object type.
if (accessNode) {
const keyType = indexType.flags & TypeFlags.TypeParameter ? getConstraintOfTypeParameter(<TypeParameter>indexType) || emptyObjectType : indexType;
if (!isTypeAssignableTo(keyType, getIndexType(objectType))) {
error(accessNode, Diagnostics.Type_0_cannot_be_used_to_index_type_1, typeToString(indexType), typeToString(objectType));
return unknownType;
}
}
// If the object type is a mapped type { [P in K]: E }, we instantiate E using a mapper that substitutes
// the index type for P. For example, for an index access { [P in K]: Box<T[P]> }[X], we construct the
// type Box<T[X]>.
if (isGenericMappedType(objectType)) {
return getIndexedAccessForMappedType(<MappedType>objectType, indexType, accessNode);
}
// Otherwise we defer the operation by creating an indexed access type.
const id = objectType.id + "," + indexType.id;
return indexedAccessTypes[id] || (indexedAccessTypes[id] = createIndexedAccessType(objectType, indexType));
}
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;
}
@@ -6021,7 +6052,7 @@ namespace ts {
}
return getUnionType(propTypes);
}
return getPropertyTypeForIndexType(apparentType, indexType, accessNode, /*cacheSymbol*/ true);
return getPropertyTypeForIndexType(apparentObjectType, indexType, accessNode, /*cacheSymbol*/ true);
}
function getTypeFromIndexedAccessTypeNode(node: IndexedAccessTypeNode) {
@@ -6040,6 +6071,9 @@ namespace ts {
type.aliasSymbol = getAliasSymbolForTypeNode(node);
type.aliasTypeArguments = getAliasTypeArgumentsForTypeNode(node);
links.resolvedType = type;
// Eagerly resolve the constraint type which forces an error if the constraint type circularly
// references itself through one or more type aliases.
getConstraintTypeFromMappedType(type);
}
return links.resolvedType;
}
@@ -7090,13 +7124,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) {
@@ -7159,12 +7186,24 @@ namespace ts {
}
if (target.flags & TypeFlags.TypeParameter) {
// Given a type parameter K with a constraint keyof T, a type S is
// assignable to K if S is assignable to keyof T.
const constraint = getConstraintOfTypeParameter(<TypeParameter>target);
if (constraint && constraint.flags & TypeFlags.Index) {
if (result = isRelatedTo(source, constraint, reportErrors)) {
return result;
// A source type { [P in keyof T]: X } is related to a target type T if X is related to T[P].
if (getObjectFlags(source) & ObjectFlags.Mapped && getConstraintTypeFromMappedType(<MappedType>source) === getIndexType(target)) {
if (!(<MappedType>source).declaration.questionToken) {
const templateType = getTemplateTypeFromMappedType(<MappedType>source);
const indexedAccessType = getIndexedAccessType(target, getTypeParameterFromMappedType(<MappedType>source));
if (result = isRelatedTo(templateType, indexedAccessType, reportErrors)) {
return result;
}
}
}
else {
// Given a type parameter K with a constraint keyof T, a type S is
// assignable to K if S is assignable to keyof T.
const constraint = getConstraintOfTypeParameter(<TypeParameter>target);
if (constraint && constraint.flags & TypeFlags.Index) {
if (result = isRelatedTo(source, constraint, reportErrors)) {
return result;
}
}
}
}
@@ -7184,22 +7223,41 @@ namespace ts {
}
}
}
else if (target.flags & TypeFlags.IndexedAccess) {
// if we have indexed access types with identical index types, see if relationship holds for
// the two object types.
if (source.flags & TypeFlags.IndexedAccess && (<IndexedAccessType>source).indexType === (<IndexedAccessType>target).indexType) {
if (result = isRelatedTo((<IndexedAccessType>source).objectType, (<IndexedAccessType>target).objectType, reportErrors)) {
return result;
}
}
}
if (source.flags & TypeFlags.TypeParameter) {
let constraint = getConstraintOfTypeParameter(<TypeParameter>source);
if (!constraint || constraint.flags & TypeFlags.Any) {
constraint = emptyObjectType;
// A source type T is related to a target type { [P in keyof T]: X } if T[P] is related to X.
if (getObjectFlags(target) & ObjectFlags.Mapped && getConstraintTypeFromMappedType(<MappedType>target) === getIndexType(source)) {
const indexedAccessType = getIndexedAccessType(source, getTypeParameterFromMappedType(<MappedType>target));
const templateType = getTemplateTypeFromMappedType(<MappedType>target);
if (result = isRelatedTo(indexedAccessType, templateType, reportErrors)) {
return result;
}
}
else {
let constraint = getConstraintOfTypeParameter(<TypeParameter>source);
// The constraint may need to be further instantiated with its 'this' type.
constraint = getTypeWithThisArgument(constraint, source);
if (!constraint || constraint.flags & TypeFlags.Any) {
constraint = emptyObjectType;
}
// Report constraint errors only if the constraint is not the empty object type
const reportConstraintErrors = reportErrors && constraint !== emptyObjectType;
if (result = isRelatedTo(constraint, target, reportConstraintErrors)) {
errorInfo = saveErrorInfo;
return result;
// The constraint may need to be further instantiated with its 'this' type.
constraint = getTypeWithThisArgument(constraint, source);
// Report constraint errors only if the constraint is not the empty object type
const reportConstraintErrors = reportErrors && constraint !== emptyObjectType;
if (result = isRelatedTo(constraint, target, reportConstraintErrors)) {
errorInfo = saveErrorInfo;
return result;
}
}
}
else {
@@ -8936,7 +8994,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;
@@ -8963,7 +9021,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 {
@@ -9021,7 +9079,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) {
@@ -9081,7 +9139,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;
@@ -9186,7 +9244,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]));
}
@@ -9247,7 +9305,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;
}
@@ -9409,7 +9467,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);
}
@@ -9634,7 +9692,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;
@@ -9721,7 +9779,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;
}
@@ -9862,7 +9920,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;
}
@@ -10328,9 +10386,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);
}
@@ -10730,7 +10788,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) {
@@ -10738,7 +10796,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;
}
@@ -12109,7 +12167,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;
@@ -13564,7 +13622,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);
@@ -13745,7 +13803,7 @@ namespace ts {
if (!node.possiblyExhaustive) {
return false;
}
const type = checkExpression(node.expression);
const type = getTypeOfExpression(node.expression);
if (!isLiteralType(type)) {
return false;
}
@@ -14192,7 +14250,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;
@@ -14201,12 +14259,13 @@ namespace ts {
function checkObjectLiteralAssignment(node: ObjectLiteralExpression, sourceType: Type): Type {
const properties = node.properties;
for (const p of properties) {
checkObjectLiteralDestructuringPropertyAssignment(sourceType, p);
checkObjectLiteralDestructuringPropertyAssignment(sourceType, p, properties);
}
return sourceType;
}
function checkObjectLiteralDestructuringPropertyAssignment(objectLiteralType: Type, property: ObjectLiteralElementLike) {
/** Note: If property cannot be a SpreadAssignment, then allProperties does not need to be provided */
function checkObjectLiteralDestructuringPropertyAssignment(objectLiteralType: Type, property: ObjectLiteralElementLike, allProperties?: ObjectLiteralElementLike[]) {
if (property.kind === SyntaxKind.PropertyAssignment || property.kind === SyntaxKind.ShorthandPropertyAssignment) {
const name = <PropertyName>(<PropertyAssignment>property).name;
if (name.kind === SyntaxKind.ComputedPropertyName) {
@@ -14236,7 +14295,14 @@ namespace ts {
}
}
else if (property.kind === SyntaxKind.SpreadAssignment) {
checkReferenceExpression(property.expression, Diagnostics.The_target_of_an_object_rest_assignment_must_be_a_variable_or_a_property_access);
const nonRestNames: PropertyName[] = [];
if (allProperties) {
for (let i = 0; i < allProperties.length - 1; i++) {
nonRestNames.push(allProperties[i].name);
}
}
const type = getRestType(objectLiteralType, nonRestNames, objectLiteralType.symbol);
return checkDestructuringAssignment(property.expression, type);
}
else {
error(property, Diagnostics.Property_assignment_expected);
@@ -14334,7 +14400,10 @@ namespace ts {
function checkReferenceAssignment(target: Expression, sourceType: Type, contextualMapper?: TypeMapper): Type {
const targetType = checkExpression(target, contextualMapper);
if (checkReferenceExpression(target, Diagnostics.The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access)) {
const error = target.parent.kind === SyntaxKind.SpreadAssignment ?
Diagnostics.The_target_of_an_object_rest_assignment_must_be_a_variable_or_a_property_access :
Diagnostics.The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access;
if (checkReferenceExpression(target, error)) {
checkTypeAssignableTo(sourceType, targetType, target, /*headMessage*/ undefined);
}
return sourceType;
@@ -14826,6 +14895,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
@@ -15575,7 +15662,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 {
@@ -17086,7 +17173,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);
}
@@ -18208,7 +18295,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;
@@ -19378,7 +19465,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:
@@ -19408,7 +19495,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;
@@ -19447,7 +19534,7 @@ namespace ts {
}
if (isPartOfExpression(node)) {
return getTypeOfExpression(<Expression>node);
return getRegularTypeOfExpression(<Expression>node);
}
if (isExpressionWithTypeArgumentsInClassExtendsClause(node)) {
@@ -19509,7 +19596,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
@@ -19539,11 +19626,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));
}
/**
@@ -19970,7 +20057,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);
}
+45 -19
View File
@@ -462,11 +462,18 @@ namespace ts {
];
/* @internal */
export const 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) {
@@ -734,8 +755,8 @@ namespace ts {
{
name: "typingOptions",
type: "object",
optionDeclarations: typingOptionDeclarations,
extraKeyDiagnosticMessage: Diagnostics.Unknown_typing_option_0
optionDeclarations: typeAcquisitionDeclarations,
extraKeyDiagnosticMessage: Diagnostics.Unknown_type_acquisition_option_0
},
{
name: "extends",
@@ -1079,7 +1100,7 @@ namespace ts {
return {
options: {},
fileNames: [],
typingOptions: {},
typeAcquisition: {},
raw: json || convertToJson(jsonNode, errors),
errors: errors.concat(createCompilerDiagnostic(Diagnostics.Circularity_detected_while_resolving_configuration_Colon_0, [...resolutionStack, resolvedPath].join(" -> "))),
wildcardDirectories: {}
@@ -1087,17 +1108,20 @@ namespace ts {
}
let options: CompilerOptions;
let typingOptions: TypingOptions;
let typeAcquisition: TypeAcquisition;
let compileOnSave: boolean;
let hasExtendsError: boolean, extendedConfigPath: Path;
if (json) {
options = convertCompilerOptionsFromJsonWorker(json["compilerOptions"], basePath, errors, configFileName);
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"];
typeAcquisition = convertTypeAcquisitionFromJsonWorker(jsonOptions, basePath, errors, configFileName);
compileOnSave = convertCompileOnSaveOptionFromJson(json, basePath, errors);
}
else {
options = getDefaultCompilerOptions(configFileName);
typingOptions = getDefaultTypingOptions(configFileName);
typeAcquisition = getDefaultTypeAcquisition(configFileName);
const optionsIterator: JsonConversionNotifier = {
onSetOptionKeyValue(optionsObject: string, option: CommandLineOption, value: CompilerOptionsValue) {
Debug.assert(optionsObject === "compilerOptions" || optionsObject === "typingOptions");
@@ -1162,7 +1186,7 @@ namespace ts {
return {
options,
fileNames,
typingOptions,
typeAcquisition,
raw: json,
errors,
wildcardDirectories,
@@ -1253,8 +1277,8 @@ namespace ts {
createCompilerDiagnosticForJson(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) {
@@ -1304,9 +1328,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 };
}
@@ -1325,21 +1349,23 @@ namespace ts {
return options;
}
function getDefaultTypingOptions(configFileName?: string) {
const options: TypingOptions = { enableAutoDiscovery: getBaseFileName(configFileName) === "jsconfig.json", include: [], exclude: [] };
function getDefaultTypeAcquisition(configFileName?: string) {
const options: TypeAcquisition = { enable: getBaseFileName(configFileName) === "jsconfig.json", include: [], exclude: [] };
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 = getDefaultTypeAcquisition(configFileName);
const typeAcquisition = convertEnableAutoDiscoveryToEnable(jsonOptions);
convertOptionsFromJson(typeAcquisitionDeclarations, typeAcquisition, basePath, options, Diagnostics.Unknown_type_acquisition_option_0, errors);
const options = getDefaultTypingOptions(configFileName);
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;
+9 -2
View File
@@ -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);
@@ -1037,6 +1037,10 @@ namespace ts {
diagnosticMessage = Diagnostics.Type_parameter_0_of_exported_function_has_or_is_using_private_name_1;
break;
case SyntaxKind.TypeAliasDeclaration:
diagnosticMessage = Diagnostics.Type_parameter_0_of_exported_type_alias_has_or_is_using_private_name_1;
break;
default:
Debug.fail("This is unknown parent for type parameter: " + node.parent.kind);
}
@@ -1143,7 +1147,10 @@ namespace ts {
const prevEnclosingDeclaration = enclosingDeclaration;
enclosingDeclaration = node;
emitTypeParameters(node.typeParameters);
emitHeritageClause(getInterfaceBaseTypeNodes(node), /*isImplementsList*/ false);
const interfaceExtendsTypes = filter(getInterfaceBaseTypeNodes(node), base => isEntityNameExpression(base.expression));
if (interfaceExtendsTypes && interfaceExtendsTypes.length) {
emitHeritageClause(interfaceExtendsTypes, /*isImplementsList*/ false);
}
write(" {");
writeLine();
increaseIndent();
+10 -2
View File
@@ -1739,7 +1739,7 @@
"category": "Error",
"code": 2535
},
"Type '{0}' is not constrained to 'keyof {1}'.": {
"Type '{0}' cannot be used to index type '{1}'.": {
"category": "Error",
"code": 2536
},
@@ -2003,6 +2003,10 @@
"category": "Error",
"code": 2701
},
"'{0}' only refers to a type, but is being used as a namespace here.": {
"category": "Error",
"code": 2702
},
"Import declaration '{0}' is using private name '{1}'.": {
"category": "Error",
@@ -2284,6 +2288,10 @@
"category": "Error",
"code": 4082
},
"Type parameter '{0}' of exported type alias has or is using private name '{1}'.": {
"category": "Error",
"code": 4083
},
"Conflicting definitions for '{0}' found at '{1}' and '{2}'. Consider installing a specific version of this library to resolve the conflict.": {
"category": "Message",
"code": 4090
@@ -3141,7 +3149,7 @@
"category": "Error",
"code": 17009
},
"Unknown typing option '{0}'.": {
"Unknown type acquisition option '{0}'.": {
"category": "Error",
"code": 17010
},
+2 -2
View File
@@ -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
View File
@@ -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
View File
@@ -417,6 +417,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:
@@ -718,7 +720,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);
@@ -726,10 +728,10 @@ namespace ts {
continue;
}
if (!node.jsDocComments) {
node.jsDocComments = [];
if (!node.jsDoc) {
node.jsDoc = [];
}
node.jsDocComments.push(jsDoc);
node.jsDoc.push(jsDoc);
}
}
@@ -756,11 +758,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;
@@ -6463,6 +6465,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;
@@ -6679,6 +6684,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();
@@ -6991,8 +7006,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);
}
}
+2 -1
View File
@@ -364,7 +364,8 @@ namespace ts {
if (typeReferences.length) {
// This containingFilename needs to match with the one used in managed-side
const containingFilename = combinePaths(host.getCurrentDirectory(), "__inferred type names__.ts");
const containingDirectory = options.configFilePath ? getDirectoryPath(options.configFilePath) : host.getCurrentDirectory();
const containingFilename = combinePaths(containingDirectory, "__inferred type names__.ts");
const resolutions = resolveTypeReferenceDirectiveNamesWorker(typeReferences, containingFilename);
for (let i = 0; i < typeReferences.length; i++) {
processTypeReferenceDirective(typeReferences[i], resolutions[i]);
+3 -1
View File
@@ -1306,7 +1306,9 @@ namespace ts {
createAssignment(
createElementAccess(
expressionName,
createSubtract(temp, createLiteral(restIndex))
restIndex === 0
? temp
: createSubtract(temp, createLiteral(restIndex))
),
createElementAccess(createIdentifier("arguments"), temp)
),
+1 -61
View File
@@ -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
+17 -8
View File
@@ -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)
@@ -1990,6 +1992,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>;
@@ -2791,7 +2798,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,
@@ -2976,8 +2983,6 @@ namespace ts {
/* @internal */
resolvedIndexType: IndexType;
/* @internal */
resolvedIndexedAccessTypes: IndexedAccessType[];
/* @internal */
isThisType?: boolean;
}
@@ -2987,7 +2992,7 @@ namespace ts {
export interface IndexedAccessType extends Type {
objectType: Type;
indexType: TypeParameter;
indexType: Type;
}
export const enum SignatureKind {
@@ -3202,8 +3207,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;
@@ -3214,7 +3223,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
}
@@ -3279,7 +3288,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
View File
@@ -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.*?\/>/;
@@ -1417,57 +1410,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
@@ -1475,68 +1453,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);
@@ -1547,10 +1512,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
@@ -1559,39 +1521,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 {
@@ -1604,14 +1555,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);
}
@@ -4553,4 +4501,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;
}
}
}
+1 -1
View File
@@ -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");
}
+1 -1
View File
@@ -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);
});
+1 -1
View File
@@ -109,7 +109,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",
@@ -2,17 +2,18 @@
/// <reference path="..\..\compiler\commandLineParser.ts" />
namespace ts {
describe("convertTypingOptionsFromJson", () => {
function assertTypingOptions(json: any, configFileName: string, expectedResult: { typingOptions: TypingOptions, errors: Diagnostic[] }) {
assertTypingOptionsWithJson(json, configFileName, expectedResult);
assertTypingOptionsWithJsonNode(json, configFileName, expectedResult);
describe("convertTypeAcquisitionFromJson", () => {
function assertTypeAcquisition(json: any, configFileName: string, expectedResult: { typingOptions: TypingOptions, errors: Diagnostic[] }) {
assertTypeAcquisitionWithJson(json, configFileName, expectedResult);
assertTypeAcquisitionWithJsonNode(json, configFileName, expectedResult);
}
function assertTypingOptionsWithJson(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);
function assertTypeAcquisitionWithJson(json: any, configFileName: string, expectedResult: { typingOptions: TypingOptions, 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)}.`);
@@ -24,16 +25,16 @@ namespace ts {
}
}
function assertTypingOptionsWithJsonNode(json: any, configFileName: string, expectedResult: { typingOptions: TypingOptions, errors: Diagnostic[] }) {
function assertTypeAcquisitionWithJsonNode(json: any, configFileName: string, expectedResult: { typingOptions: TypingOptions, errors: Diagnostic[] }) {
const fileText = JSON.stringify(json);
const { node, errors } = parseJsonText(configFileName, fileText);
assert(!errors.length);
assert(!!node);
const host: ParseConfigHost = new Utils.MockParseConfigHost("/apath/", true, []);
const { typingOptions: actualTypingOptions, errors: actualParseErrors } = parseJsonNodeConfigFileContent(node, host, "/apath/", /*existingOptions*/ undefined, configFileName);
const parsedTypingOptions = JSON.stringify(actualTypingOptions);
const expectedTypingOptions = JSON.stringify(expectedResult.typingOptions);
assert.equal(parsedTypingOptions, expectedTypingOptions);
const { typeAcquisition: actualTypeAcquisition, errors: actualParseErrors } = parseJsonNodeConfigFileContent(node, host, "/apath/", /*existingOptions*/ undefined, configFileName);
const parsedTypeAcquisition = JSON.stringify(actualTypeAcquisition);
const expectedTypeAcquisition = JSON.stringify(expectedResult.actualTypeAcquisition);
assert.equal(parsedTypeAcquisition, expectedTypeAcquisition);
const actualErrors = filter(actualParseErrors, error => error.code !== Diagnostics.No_inputs_were_found_in_config_file_0_Specified_include_paths_were_1_and_exclude_paths_were_2.code);
const expectedErrors = expectedResult.errors;
@@ -50,8 +51,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":
{
@@ -62,9 +63,9 @@ namespace ts {
},
"tsconfig.json",
{
typingOptions:
typeAcquisition:
{
enableAutoDiscovery: true,
enable: true,
include: ["0.d.ts", "1.d.ts"],
exclude: ["0.js", "1.js"]
},
@@ -72,25 +73,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,
@@ -100,12 +123,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: []
},
@@ -113,18 +136,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: []
},
@@ -133,20 +156,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"]
},
@@ -154,12 +177,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: []
},
@@ -167,25 +190,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_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,
@@ -195,18 +218,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: []
},
+34 -14
View File
@@ -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);
@@ -131,6 +129,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 = {
@@ -221,7 +236,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: {},
@@ -239,7 +254,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: {},
@@ -353,7 +368,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: {},
};
@@ -393,8 +411,7 @@ namespace ts {
"node_modules/a.ts",
"bower_components/a.ts",
"jspm_packages/a.ts"
],
exclude: <string[]>[]
]
};
const expected: ts.ParsedCommandLine = {
options: {},
@@ -544,7 +561,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: {
@@ -611,7 +628,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
@@ -679,7 +699,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: {
@@ -975,7 +995,7 @@ namespace ts {
errors: [
createDiagnosticForConfigFile(json, 12, 4, 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: {}
@@ -1015,7 +1035,7 @@ namespace ts {
errors: [
createDiagnosticForConfigFile(json, 12, 11, 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: {}
@@ -1062,7 +1082,7 @@ namespace ts {
errors: [
createDiagnosticForConfigFile(json, 12, 9, 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: {}
@@ -1081,7 +1101,7 @@ namespace ts {
errors: [
createDiagnosticForConfigFile(json, 12, 11, 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: {}
+67 -4
View File
@@ -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);
}
@@ -1614,6 +1614,7 @@ namespace ts.projectSystem {
return;
}
assert.equal(e.eventName, server.ProjectLanguageServiceStateEvent);
assert.equal(e.data.project.getProjectName(), config.path, "project name");
lastEvent = <server.ProjectLanguageServiceStateEvent>e;
});
session.executeCommand(<protocol.OpenRequest>{
@@ -1628,6 +1629,7 @@ namespace ts.projectSystem {
assert.isFalse(project.languageServiceEnabled, "Language service enabled");
assert.isTrue(!!lastEvent, "should receive event");
assert.equal(lastEvent.data.project, project, "project name");
assert.equal(lastEvent.data.project.getProjectName(), config.path, "config path");
assert.isFalse(lastEvent.data.languageServiceEnabled, "Language service state");
host.reloadFS([f1, f2, configWithExclude]);
@@ -1724,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");
});
});
@@ -2337,6 +2339,30 @@ namespace ts.projectSystem {
projectService.openExternalProject({ rootFiles: toExternalFiles([f1.path, config.path]), options: {}, projectFileName: projectName });
projectService.checkNumberOfProjects({ configuredProjects: 1 });
});
it("types should load from config file path if config exists", () => {
const f1 = {
path: "/a/b/app.ts",
content: "let x = 1"
};
const config = {
path: "/a/b/tsconfig.json",
content: JSON.stringify({ compilerOptions: { types: ["node"], typeRoots: [] } })
};
const node = {
path: "/a/b/node_modules/@types/node/index.d.ts",
content: "declare var process: any"
};
const cwd = {
path: "/a/c"
};
debugger;
const host = createServerHost([f1, config, node, cwd], { currentDirectory: cwd.path });
const projectService = createProjectService(host);
projectService.openClientFile(f1.path);
projectService.checkNumberOfProjects({ configuredProjects: 1 });
checkProjectActualFiles(projectService.configuredProjects[0], [f1.path, node.path]);
});
});
describe("add the missing module file for inferred project", () => {
@@ -2426,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", () => {
+26 -26
View File
@@ -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"]);
});
+1687 -2599
View File
File diff suppressed because it is too large Load Diff
+1 -1
View File
@@ -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;
}
+131 -83
View File
@@ -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;
+32 -20
View File
@@ -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);
@@ -470,7 +470,7 @@ namespace ts.server {
private onTypeRootFileChanged(project: ConfiguredProject, fileName: string) {
this.logger.info(`Type root file ${fileName} changed`);
this.throttledOperations.schedule(project.configFileName + " * type root", /*delay*/ 250, () => {
this.throttledOperations.schedule(project.getConfigFilePath() + " * type root", /*delay*/ 250, () => {
project.updateTypes();
this.updateConfiguredProject(project); // TODO: Figure out why this is needed (should be redundant?)
this.refreshInferredProjects();
@@ -492,13 +492,13 @@ namespace ts.server {
this.logger.info(`Detected source file changes: ${fileName}`);
this.throttledOperations.schedule(
project.configFileName,
project.getConfigFilePath(),
/*delay*/250,
() => this.handleChangeInSourceFileForConfiguredProject(project, fileName));
}
private handleChangeInSourceFileForConfiguredProject(project: ConfiguredProject, triggerFile: string) {
const { projectOptions, configFileErrors } = this.convertConfigFileContentToProjectOptions(project.configFileName);
const { projectOptions, configFileErrors } = this.convertConfigFileContentToProjectOptions(project.getConfigFilePath());
this.reportConfigFileDiagnostics(project.getProjectName(), configFileErrors, triggerFile);
const newRootFiles = projectOptions.files.map((f => this.getCanonicalFileName(f)));
@@ -520,8 +520,10 @@ namespace ts.server {
}
private onConfigChangedForConfiguredProject(project: ConfiguredProject) {
this.logger.info(`Config file changed: ${project.configFileName}`);
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();
}
@@ -815,7 +817,7 @@ namespace ts.server {
compilerOptions: parsedCommandLine.options,
configHasFilesProperty: parsedCommandLine.raw["files"] !== undefined,
wildcardDirectories: createMap(parsedCommandLine.wildcardDirectories),
typingOptions: parsedCommandLine.typingOptions,
typeAcquisition: parsedCommandLine.typeAcquisition,
compileOnSave: parsedCommandLine.compileOnSave
};
return { success: true, projectOptions, configFileErrors: errors };
@@ -839,7 +841,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,
@@ -849,7 +851,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;
}
@@ -877,7 +879,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) {
@@ -896,7 +898,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);
@@ -911,7 +913,7 @@ namespace ts.server {
}
}
project.setProjectErrors(concatenate(configFileErrors, errors));
project.setTypingOptions(typingOptions);
project.setTypeAcquisition(typeAcquisition);
project.updateGraph();
}
@@ -928,7 +930,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>();
@@ -990,7 +992,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.
@@ -1003,13 +1005,16 @@ namespace ts.server {
}
private updateConfiguredProject(project: ConfiguredProject) {
if (!this.host.fileExists(project.configFileName)) {
if (!this.host.fileExists(project.getConfigFilePath())) {
this.logger.info("Config file deleted");
this.removeProject(project);
return;
}
const { success, projectOptions, configFileErrors } = this.convertConfigFileContentToProjectOptions(project.configFileName);
// 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
this.updateNonInferredProject(project, [], fileNamePropertyReader, {}, {}, /*compileOnSave*/false, configFileErrors);
@@ -1020,7 +1025,7 @@ namespace ts.server {
project.setCompilerOptions(projectOptions.compilerOptions);
if (!project.languageServiceEnabled) {
// language service is already disabled
return;
return configFileErrors;
}
project.disableLanguageService();
project.stopWatchingDirectory();
@@ -1030,8 +1035,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) {
@@ -1310,6 +1316,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) {
@@ -1334,7 +1346,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)
@@ -1394,7 +1406,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();
}
+1 -1
View File
@@ -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);
+49 -54
View File
@@ -229,6 +229,7 @@ namespace ts.server {
}
constructor(
private readonly projectName: string,
readonly projectKind: ProjectKind,
readonly projectService: ProjectService,
private documentRegistry: ts.DocumentRegistry,
@@ -307,9 +308,11 @@ namespace ts.server {
this.projectService.onUpdateLanguageServiceStateForProject(this, /*languageServiceEnabled*/ false);
}
abstract getProjectName(): string;
getProjectName() {
return this.projectName;
}
abstract getProjectRootPath(): string | undefined;
abstract getTypingOptions(): TypingOptions;
abstract getTypeAcquisition(): TypeAcquisition;
getSourceFile(path: Path) {
if (!this.program) {
@@ -759,31 +762,27 @@ namespace ts.server {
export class InferredProject extends Project {
private static NextId = 1;
/**
* Unique name that identifies this particular inferred project
*/
private readonly inferredProjectName: string;
private static newName = (() => {
let nextId = 1;
return () => {
const id = nextId;
nextId++;
return makeInferredProjectName(id);
}
})();
// Used to keep track of what directories are watched for this project
directoriesWatchedForTsconfig: string[] = [];
constructor(projectService: ProjectService, documentRegistry: ts.DocumentRegistry, compilerOptions: CompilerOptions) {
super(ProjectKind.Inferred,
super(InferredProject.newName(),
ProjectKind.Inferred,
projectService,
documentRegistry,
/*files*/ undefined,
/*languageServiceEnabled*/ true,
compilerOptions,
/*compileOnSaveEnabled*/ false);
this.inferredProjectName = makeInferredProjectName(InferredProject.NextId);
InferredProject.NextId++;
}
getProjectName() {
return this.inferredProjectName;
}
getProjectRootPath() {
@@ -803,9 +802,9 @@ namespace ts.server {
}
}
getTypingOptions(): TypingOptions {
getTypeAcquisition(): TypeAcquisition {
return {
enableAutoDiscovery: allRootFilesAreJsOrDts(this),
enable: allRootFilesAreJsOrDts(this),
include: [],
exclude: []
};
@@ -813,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>;
@@ -822,7 +821,7 @@ namespace ts.server {
/** Used for configured projects which may have multiple open roots */
openRefCount = 0;
constructor(readonly configFileName: NormalizedPath,
constructor(configFileName: NormalizedPath,
projectService: ProjectService,
documentRegistry: ts.DocumentRegistry,
hasExplicitListOfFiles: boolean,
@@ -830,31 +829,31 @@ namespace ts.server {
private wildcardDirectories: Map<WatchDirectoryFlags>,
languageServiceEnabled: boolean,
public compileOnSaveEnabled: boolean) {
super(ProjectKind.Configured, projectService, documentRegistry, hasExplicitListOfFiles, languageServiceEnabled, compilerOptions, compileOnSaveEnabled);
super(configFileName, ProjectKind.Configured, projectService, documentRegistry, hasExplicitListOfFiles, languageServiceEnabled, compilerOptions, compileOnSaveEnabled);
}
getConfigFilePath() {
return this.getProjectName();
}
getProjectRootPath() {
return getDirectoryPath(this.configFileName);
return getDirectoryPath(this.getConfigFilePath());
}
setProjectErrors(projectErrors: Diagnostic[]) {
this.projectErrors = projectErrors;
}
setTypingOptions(newTypingOptions: TypingOptions): void {
this.typingOptions = newTypingOptions;
setTypeAcquisition(newTypeAcquisition: TypeAcquisition): void {
this.typeAcquisition = newTypeAcquisition;
}
getTypingOptions() {
return this.typingOptions;
}
getProjectName() {
return this.configFileName;
getTypeAcquisition() {
return this.typeAcquisition;
}
watchConfigFile(callback: (project: ConfiguredProject) => void) {
this.projectFileWatcher = this.projectService.host.watchFile(this.configFileName, _ => callback(this));
this.projectFileWatcher = this.projectService.host.watchFile(this.getConfigFilePath(), _ => callback(this));
}
watchTypeRoots(callback: (project: ConfiguredProject, path: string) => void) {
@@ -872,7 +871,7 @@ namespace ts.server {
return;
}
const directoryToWatch = getDirectoryPath(this.configFileName);
const directoryToWatch = getDirectoryPath(this.getConfigFilePath());
this.projectService.logger.info(`Add recursive watcher for: ${directoryToWatch}`);
this.directoryWatcher = this.projectService.host.watchDirectory(directoryToWatch, path => callback(this, path), /*recursive*/ true);
}
@@ -881,7 +880,7 @@ namespace ts.server {
if (!this.wildcardDirectories) {
return;
}
const configDirectoryPath = getDirectoryPath(this.configFileName);
const configDirectoryPath = getDirectoryPath(this.getConfigFilePath());
this.directoriesWatchedForWildcards = reduceProperties(this.wildcardDirectories, (watchers, flag, directory) => {
if (comparePaths(configDirectoryPath, directory, ".", !this.projectService.host.useCaseSensitiveFileNames) !== Comparison.EqualTo) {
const recursive = (flag & WatchDirectoryFlags.Recursive) !== 0;
@@ -940,15 +939,15 @@ namespace ts.server {
}
export class ExternalProject extends Project {
private typingOptions: TypingOptions;
constructor(readonly externalProjectName: string,
private typeAcquisition: TypeAcquisition;
constructor(externalProjectName: string,
projectService: ProjectService,
documentRegistry: ts.DocumentRegistry,
compilerOptions: CompilerOptions,
languageServiceEnabled: boolean,
public compileOnSaveEnabled: boolean,
private readonly projectFilePath?: string) {
super(ProjectKind.External, projectService, documentRegistry, /*hasExplicitListOfFiles*/ true, languageServiceEnabled, compilerOptions, compileOnSaveEnabled);
super(externalProjectName, ProjectKind.External, projectService, documentRegistry, /*hasExplicitListOfFiles*/ true, languageServiceEnabled, compilerOptions, compileOnSaveEnabled);
}
getProjectRootPath() {
@@ -958,43 +957,39 @@ namespace ts.server {
// if the projectFilePath is not given, we make the assumption that the project name
// is the path of the project file. AS the project name is provided by VS, we need to
// normalize slashes before using it as a file name.
return getDirectoryPath(normalizeSlashes(this.externalProjectName));
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;
}
getProjectName() {
return this.externalProjectName;
this.typeAcquisition = newTypeAcquisition;
}
}
}
+6 -2
View File
@@ -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 {
+9 -3
View File
@@ -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();
}
}
+2 -2
View File
@@ -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
View File
@@ -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,
+3 -3
View File
@@ -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;
}
+3 -3
View File
@@ -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);
}
}
+14 -1
View File
@@ -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);
}
+1 -1
View File
@@ -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;
}
+5 -5
View File
@@ -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) {
+2 -2
View File
@@ -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);
}
+6 -6
View File
@@ -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);
}
}
}
+3 -3
View File
@@ -1138,7 +1138,7 @@ namespace ts {
if (!result.node) {
return {
options: {},
typingOptions: {},
typeAcquisition: {},
files: [],
raw: {},
errors: realizeDiagnostics(result.errors, "\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(result.errors.concat(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);
});
}
+4 -4
View File
@@ -951,10 +951,10 @@ namespace ts {
}
if (node) {
if (node.jsDocComments) {
for (const jsDocComment of node.jsDocComments) {
if (jsDocComment.tags) {
for (const tag of jsDocComment.tags) {
if (node.jsDoc) {
for (const jsDoc of node.jsDoc) {
if (jsDoc.tags) {
for (const tag of jsDoc.tags) {
if (tag.pos <= position && position <= tag.end) {
return tag;
}
@@ -13,7 +13,7 @@ var C = (function () {
set: function () {
var v = [];
for (var _i = 0; _i < arguments.length; _i++) {
v[_i - 0] = arguments[_i];
v[_i] = arguments[_i];
}
},
enumerable: true,
@@ -23,7 +23,7 @@ var C = (function () {
set: function () {
var v2 = [];
for (var _i = 0; _i < arguments.length; _i++) {
v2[_i - 0] = arguments[_i];
v2[_i] = arguments[_i];
}
},
enumerable: true,
@@ -3,7 +3,7 @@
const fs = require("fs");
>fs : typeof "fs"
>require("fs") : typeof "fs"
>require("fs") : any
>require : (moduleName: string) => any
>"fs" : "fs"
@@ -10,10 +10,10 @@ var Foo;
>Foo : any
type
>type : undefined
>type : any
Foo = string;
>Foo = string : undefined
>Foo = string : any
>Foo : any
>string : undefined
>string : any
@@ -59,9 +59,9 @@ var e = undefined;
>undefined : undefined
x = e;
>x = e : undefined
>x = e : any
>x : any
>e : undefined
>e : any
var e2: typeof undefined;
>e2 : any
@@ -52,14 +52,14 @@ a = function () { return 1; }; // ok, same number of required params
a = function () {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i - 0] = arguments[_i];
args[_i] = arguments[_i];
}
return 1;
}; // ok, same number of required params
a = function () {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i - 0] = arguments[_i];
args[_i] = arguments[_i];
}
return 1;
}; // error, type mismatch
@@ -72,7 +72,7 @@ a2 = function () { return 1; }; // ok, fewer required params
a2 = function () {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i - 0] = arguments[_i];
args[_i] = arguments[_i];
}
return 1;
}; // ok, fewer required params
@@ -23,7 +23,7 @@ var Derived2 = (function () {
Derived2.prototype.method = function () {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i - 0] = arguments[_i];
args[_i] = arguments[_i];
}
};
return Derived2;
@@ -179,7 +179,7 @@ function foo3(x) {
use(v);
>use(v) : any
>use : (a: any) => any
>v : undefined
>v : any
}
function foo4(x) {
@@ -283,8 +283,8 @@ function foo6(x) {
>y : any
var v = x;
>v : undefined
>x : undefined
>v : any
>x : any
(function() { return x + y + v });
>(function() { return x + y + v }) : () => any
@@ -293,7 +293,7 @@ function foo6(x) {
>x + y : any
>x : any
>y : any
>v : undefined
>v : any
(() => x + y + v);
>(() => x + y + v) : () => any
@@ -302,13 +302,13 @@ function foo6(x) {
>x + y : any
>x : any
>y : any
>v : undefined
>v : any
}
use(v)
>use(v) : any
>use : (a: any) => any
>v : undefined
>v : any
}
function foo7(x) {
@@ -321,8 +321,8 @@ function foo7(x) {
>y : any
var v = x;
>v : undefined
>x : undefined
>v : any
>x : any
(function() { return x + y + v });
>(function() { return x + y + v }) : () => any
@@ -331,7 +331,7 @@ function foo7(x) {
>x + y : any
>x : any
>y : any
>v : undefined
>v : any
(() => x + y + v);
>(() => x + y + v) : () => any
@@ -340,7 +340,7 @@ function foo7(x) {
>x + y : any
>x : any
>y : any
>v : undefined
>v : any
} while (1 === 1);
>1 === 1 : boolean
@@ -350,7 +350,7 @@ function foo7(x) {
use(v);
>use(v) : any
>use : (a: any) => any
>v : undefined
>v : any
}
@@ -574,7 +574,7 @@ function foo3_c(x) {
use(v);
>use(v) : any
>use : (a: any) => any
>v : undefined
>v : any
}
function foo4_c(x) {
@@ -180,7 +180,7 @@ function foo3(x) {
use(v);
>use(v) : any
>use : (a: any) => any
>v : undefined
>v : any
}
function foo4(x) {
@@ -284,8 +284,8 @@ function foo6(x) {
>y : any
var v = x;
>v : undefined
>x : undefined
>v : any
>x : any
(function() { return x + y + v });
>(function() { return x + y + v }) : () => any
@@ -294,7 +294,7 @@ function foo6(x) {
>x + y : any
>x : any
>y : any
>v : undefined
>v : any
(() => x + y + v);
>(() => x + y + v) : () => any
@@ -303,13 +303,13 @@ function foo6(x) {
>x + y : any
>x : any
>y : any
>v : undefined
>v : any
}
use(v)
>use(v) : any
>use : (a: any) => any
>v : undefined
>v : any
}
function foo7(x) {
@@ -322,8 +322,8 @@ function foo7(x) {
>y : any
var v = x;
>v : undefined
>x : undefined
>v : any
>x : any
(function() { return x + y + v });
>(function() { return x + y + v }) : () => any
@@ -332,7 +332,7 @@ function foo7(x) {
>x + y : any
>x : any
>y : any
>v : undefined
>v : any
(() => x + y + v);
>(() => x + y + v) : () => any
@@ -341,7 +341,7 @@ function foo7(x) {
>x + y : any
>x : any
>y : any
>v : undefined
>v : any
} while (1 === 1);
>1 === 1 : boolean
@@ -351,7 +351,7 @@ function foo7(x) {
use(v);
>use(v) : any
>use : (a: any) => any
>v : undefined
>v : any
}
@@ -575,7 +575,7 @@ function foo3_c(x) {
use(v);
>use(v) : any
>use : (a: any) => any
>v : undefined
>v : any
}
function foo4_c(x) {
@@ -17,12 +17,12 @@ export function exportedFoo() {
>v0 : any
>v00 : string
>v1 : number
>v2 : undefined
>v3 : undefined
>v2 : any
>v3 : any
>v4 : number
>v5 : number
>v6 : undefined
>v7 : undefined
>v6 : any
>v7 : any
>v8 : number
}
@@ -103,15 +103,15 @@ while (1 === 1) {
>x : any
var v2 = x;
>v2 : undefined
>x : undefined
>v2 : any
>x : any
(function() { return x + v2});
>(function() { return x + v2}) : () => any
>function() { return x + v2} : () => any
>x + v2 : any
>x : any
>v2 : undefined
>v2 : any
(() => x);
>(() => x) : () => any
@@ -124,15 +124,15 @@ do {
>x : any
var v3 = x;
>v3 : undefined
>x : undefined
>v3 : any
>x : any
(function() { return x + v3});
>(function() { return x + v3}) : () => any
>function() { return x + v3} : () => any
>x + v3 : any
>x : any
>v3 : undefined
>v3 : any
(() => x);
>(() => x) : () => any
@@ -216,8 +216,8 @@ while (1 === 1) {
>y : any
var v6 = x;
>v6 : undefined
>x : undefined
>v6 : any
>x : any
(function() { return x + y + v6});
>(function() { return x + y + v6}) : () => any
@@ -226,7 +226,7 @@ while (1 === 1) {
>x + y : any
>x : any
>y : any
>v6 : undefined
>v6 : any
(() => x + y);
>(() => x + y) : () => any
@@ -242,8 +242,8 @@ do {
>y : any
var v7 = x;
>v7 : undefined
>x : undefined
>v7 : any
>x : any
(function() { return x + y + v7});
>(function() { return x + y + v7}) : () => any
@@ -252,7 +252,7 @@ do {
>x + y : any
>x : any
>y : any
>v7 : undefined
>v7 : any
(() => x + y);
>(() => x + y) : () => any
@@ -17,12 +17,12 @@ export function exportedFoo() {
>v0 : any
>v00 : string
>v1 : number
>v2 : undefined
>v3 : undefined
>v2 : any
>v3 : any
>v4 : number
>v5 : number
>v6 : undefined
>v7 : undefined
>v6 : any
>v7 : any
>v8 : number
}
@@ -103,15 +103,15 @@ while (1 === 1) {
>x : any
var v2 = x;
>v2 : undefined
>x : undefined
>v2 : any
>x : any
(function() { return x + v2});
>(function() { return x + v2}) : () => any
>function() { return x + v2} : () => any
>x + v2 : any
>x : any
>v2 : undefined
>v2 : any
(() => x);
>(() => x) : () => any
@@ -124,15 +124,15 @@ do {
>x : any
var v3 = x;
>v3 : undefined
>x : undefined
>v3 : any
>x : any
(function() { return x + v3});
>(function() { return x + v3}) : () => any
>function() { return x + v3} : () => any
>x + v3 : any
>x : any
>v3 : undefined
>v3 : any
(() => x);
>(() => x) : () => any
@@ -216,8 +216,8 @@ while (1 === 1) {
>y : any
var v6 = x;
>v6 : undefined
>x : undefined
>v6 : any
>x : any
(function() { return x + y + v6});
>(function() { return x + y + v6}) : () => any
@@ -226,7 +226,7 @@ while (1 === 1) {
>x + y : any
>x : any
>y : any
>v6 : undefined
>v6 : any
(() => x + y);
>(() => x + y) : () => any
@@ -242,8 +242,8 @@ do {
>y : any
var v7 = x;
>v7 : undefined
>x : undefined
>v7 : any
>x : any
(function() { return x + y + v7});
>(function() { return x + y + v7}) : () => any
@@ -252,7 +252,7 @@ do {
>x + y : any
>x : any
>y : any
>v7 : undefined
>v7 : any
(() => x + y);
>(() => x + y) : () => any
@@ -39,7 +39,7 @@ for (let x = 0; x < 1; ++x) {
}
switch (x) {
>x : undefined
>x : any
case 1:
>1 : 1
@@ -40,7 +40,7 @@ for (let x = 0; x < 1; ++x) {
}
switch (x) {
>x : undefined
>x : any
case 1:
>1 : 1
@@ -17,7 +17,7 @@ var Based = (function () {
function Based() {
var arg = [];
for (var _i = 0; _i < arguments.length; _i++) {
arg[_i - 0] = arguments[_i];
arg[_i] = arguments[_i];
}
}
return Based;
@@ -20,7 +20,7 @@ var Base = (function () {
function Base() {
var arg = [];
for (var _i = 0; _i < arguments.length; _i++) {
arg[_i - 0] = arguments[_i];
arg[_i] = arguments[_i];
}
}
return Base;
@@ -20,7 +20,7 @@ var Base = (function () {
function Base() {
var arg = [];
for (var _i = 0; _i < arguments.length; _i++) {
arg[_i - 0] = arguments[_i];
arg[_i] = arguments[_i];
}
}
return Base;
@@ -37,7 +37,7 @@ var f1NoError = function (arguments) {
var f2 = function () {
var restParameters = [];
for (var _i = 0; _i < arguments.length; _i++) {
restParameters[_i - 0] = arguments[_i];
restParameters[_i] = arguments[_i];
}
var arguments = 10; // No Error
};
@@ -118,7 +118,7 @@ var c2 = (function () {
function c2() {
var restParameters = [];
for (var _i = 0; _i < arguments.length; _i++) {
restParameters[_i - 0] = arguments[_i];
restParameters[_i] = arguments[_i];
}
var arguments = 10; // no error
}
@@ -94,7 +94,7 @@ var c3 = (function () {
c3.prototype.foo = function () {
var restParameters = [];
for (var _i = 0; _i < arguments.length; _i++) {
restParameters[_i - 0] = arguments[_i];
restParameters[_i] = arguments[_i];
}
var arguments = 10; // no error
};
@@ -66,7 +66,7 @@ function f1NoError(arguments) {
function f3() {
var restParameters = [];
for (var _i = 0; _i < arguments.length; _i++) {
restParameters[_i - 0] = arguments[_i];
restParameters[_i] = arguments[_i];
}
var arguments = 10; // no error
}
@@ -56,7 +56,7 @@ function foo() {
function f3() {
var restParameters = [];
for (var _i = 0; _i < arguments.length; _i++) {
restParameters[_i - 0] = arguments[_i];
restParameters[_i] = arguments[_i];
}
var arguments = 10; // no error
}
@@ -27,7 +27,7 @@ var f1NoError = function (_i) {
var f2 = function () {
var restParameters = [];
for (var _a = 0; _a < arguments.length; _a++) {
restParameters[_a - 0] = arguments[_a];
restParameters[_a] = arguments[_a];
}
var _i = 10; // No Error
};
@@ -88,7 +88,7 @@ var c2 = (function () {
function c2() {
var restParameters = [];
for (var _a = 0; _a < arguments.length; _a++) {
restParameters[_a - 0] = arguments[_a];
restParameters[_a] = arguments[_a];
}
var _i = 10; // no error
}
@@ -70,7 +70,7 @@ var c3 = (function () {
c3.prototype.foo = function () {
var restParameters = [];
for (var _a = 0; _a < arguments.length; _a++) {
restParameters[_a - 0] = arguments[_a];
restParameters[_a] = arguments[_a];
}
var _i = 10; // no error
};
@@ -48,7 +48,7 @@ function f1NoError(_i) {
function f3() {
var restParameters = [];
for (var _a = 0; _a < arguments.length; _a++) {
restParameters[_a - 0] = arguments[_a];
restParameters[_a] = arguments[_a];
}
var _i = 10; // no error
}
@@ -39,7 +39,7 @@ function foo() {
function f3() {
var restParameters = [];
for (var _a = 0; _a < arguments.length; _a++) {
restParameters[_a - 0] = arguments[_a];
restParameters[_a] = arguments[_a];
}
var _i = 10; // no error
}
@@ -14,7 +14,7 @@ var Foo = (function () {
function Foo() {
var args = [];
for (var _a = 0; _a < arguments.length; _a++) {
args[_a - 0] = arguments[_a];
args[_a] = arguments[_a];
}
console.log(_i); // This should result in error
}
@@ -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
})
}
@@ -17,7 +17,7 @@ foo(/*c2*/ 1, /*d2*/ 1 + 2, /*e1*/ a + b);
>1 : 1
>2 : 2
>a + b : any
>a : undefined
>a : any
>b : any
foo(/*c3*/ function () { }, /*d2*/() => { }, /*e2*/ a + /*e3*/ b);
@@ -26,7 +26,7 @@ foo(/*c3*/ function () { }, /*d2*/() => { }, /*e2*/ a + /*e3*/ b);
>function () { } : () => void
>() => { } : () => void
>a + /*e3*/ b : any
>a : undefined
>a : any
>b : any
foo(/*c3*/ function () { }, /*d3*/() => { }, /*e3*/(a + b));
@@ -36,7 +36,7 @@ foo(/*c3*/ function () { }, /*d3*/() => { }, /*e3*/(a + b));
>() => { } : () => void
>(a + b) : any
>a + b : any
>a : undefined
>a : any
>b : any
foo(
@@ -9,12 +9,12 @@ var x1: number;
x1 *= value;
>x1 *= value : number
>x1 : number
>value : undefined
>value : any
x1 += value;
>x1 += value : number
>x1 += value : any
>x1 : number
>value : undefined
>value : any
function fn1(x2: number) {
>fn1 : (x2: number) => void
@@ -41,41 +41,41 @@ x3.a *= value;
>x3.a : number
>x3 : { a: number; }
>a : number
>value : undefined
>value : any
x3.a += value;
>x3.a += value : number
>x3.a += value : any
>x3.a : number
>x3 : { a: number; }
>a : number
>value : undefined
>value : any
x3['a'] *= value;
>x3['a'] *= value : number
>x3['a'] : number
>x3 : { a: number; }
>'a' : "a"
>value : undefined
>value : any
x3['a'] += value;
>x3['a'] += value : number
>x3['a'] += value : any
>x3['a'] : number
>x3 : { a: number; }
>'a' : "a"
>value : undefined
>value : any
// parentheses, the contained expression is reference
(x1) *= value;
>(x1) *= value : number
>(x1) : number
>x1 : number
>value : undefined
>value : any
(x1) += value;
>(x1) += value : number
>(x1) += value : any
>(x1) : number
>x1 : number
>value : undefined
>value : any
function fn2(x4: number) {
>fn2 : (x4: number) => void
@@ -100,15 +100,15 @@ function fn2(x4: number) {
>x3.a : number
>x3 : { a: number; }
>a : number
>value : undefined
>value : any
(x3.a) += value;
>(x3.a) += value : number
>(x3.a) += value : any
>(x3.a) : number
>x3.a : number
>x3 : { a: number; }
>a : number
>value : undefined
>value : any
(x3['a']) *= value;
>(x3['a']) *= value : number
@@ -116,13 +116,13 @@ function fn2(x4: number) {
>x3['a'] : number
>x3 : { a: number; }
>'a' : "a"
>value : undefined
>value : any
(x3['a']) += value;
>(x3['a']) += value : number
>(x3['a']) += value : any
>(x3['a']) : number
>x3['a'] : number
>x3 : { a: number; }
>'a' : "a"
>value : undefined
>value : any
@@ -35,20 +35,20 @@ var a;
>a : any
foo(a);
>foo(a) : undefined
>foo(a) : any
>foo : <T extends String>(x: T) => T
>a : undefined
>a : any
foo2(a);
>foo2(a) : undefined
>foo2(a) : any
>foo2 : <T extends { x: number; }>(x: T) => T
>a : undefined
>a : any
//foo3(a);
foo4(a);
>foo4(a) : undefined
>foo4(a) : any
>foo4 : <T extends <T>(x: T) => void>(x: T) => T
>a : undefined
>a : any
var b: number;
>b : number
@@ -84,10 +84,10 @@ class C<T extends String> {
}
var c1 = new C(a);
>c1 : C<undefined>
>new C(a) : C<undefined>
>c1 : C<any>
>new C(a) : C<any>
>C : typeof C
>a : undefined
>a : any
var c2 = new C<any>(b);
>c2 : C<any>
@@ -106,10 +106,10 @@ class C2<T extends { x: number }> {
}
var c3 = new C2(a);
>c3 : C2<undefined>
>new C2(a) : C2<undefined>
>c3 : C2<any>
>new C2(a) : C2<any>
>C2 : typeof C2
>a : undefined
>a : any
var c4 = new C2<any>(b);
>c4 : C2<any>
@@ -138,10 +138,10 @@ class C4<T extends <T>(x:T) => T> {
}
var c7 = new C4(a);
>c7 : C4<undefined>
>new C4(a) : C4<undefined>
>c7 : C4<any>
>new C4(a) : C4<any>
>C4 : typeof C4
>a : undefined
>a : any
var c8 = new C4<any>(b);
>c8 : C4<any>
@@ -297,7 +297,7 @@ var TypeScriptAllInOne;
Program.Main = function () {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i - 0] = arguments[_i];
args[_i] = arguments[_i];
}
try {
var bfs = new BasicFeatures();
@@ -57,21 +57,21 @@ let eleven = (o => o.a(11))({ a: function(n) { return n; } });
(function () {
var numbers = [];
for (var _i = 0; _i < arguments.length; _i++) {
numbers[_i - 0] = arguments[_i];
numbers[_i] = arguments[_i];
}
return numbers.every(function (n) { return n > 0; });
})(5, 6, 7);
(function () {
var mixed = [];
for (var _i = 0; _i < arguments.length; _i++) {
mixed[_i - 0] = arguments[_i];
mixed[_i] = arguments[_i];
}
return mixed.every(function (n) { return !!n; });
})(5, 'oops', 'oh no');
(function () {
var noNumbers = [];
for (var _i = 0; _i < arguments.length; _i++) {
noNumbers[_i - 0] = arguments[_i];
noNumbers[_i] = arguments[_i];
}
return noNumbers.some(function (n) { return n > 0; });
})();
@@ -11,7 +11,7 @@ var x: (...y: string[]) => void = function (.../*3*/y) {
var x = function () {
var y = [];
for (var _i = 0; _i < arguments.length; _i++) {
y[_i - 0] = arguments[_i];
y[_i] = arguments[_i];
}
var t = y;
var x2 = t; // This should be error
@@ -1,128 +0,0 @@
tests/cases/compiler/controlFlowCaching.ts(38,17): error TS2532: Object is possibly 'undefined'.
tests/cases/compiler/controlFlowCaching.ts(38,29): error TS2339: Property 'y' does not exist on type 'never'.
tests/cases/compiler/controlFlowCaching.ts(40,17): error TS2532: Object is possibly 'undefined'.
tests/cases/compiler/controlFlowCaching.ts(40,29): error TS2339: Property 'x' does not exist on type 'never'.
tests/cases/compiler/controlFlowCaching.ts(42,17): error TS2532: Object is possibly 'undefined'.
tests/cases/compiler/controlFlowCaching.ts(42,29): error TS2339: Property 'y' does not exist on type 'never'.
tests/cases/compiler/controlFlowCaching.ts(44,17): error TS2532: Object is possibly 'undefined'.
tests/cases/compiler/controlFlowCaching.ts(44,29): error TS2339: Property 'y' does not exist on type 'never'.
tests/cases/compiler/controlFlowCaching.ts(46,17): error TS2532: Object is possibly 'undefined'.
tests/cases/compiler/controlFlowCaching.ts(46,29): error TS2339: Property 'y' does not exist on type 'never'.
tests/cases/compiler/controlFlowCaching.ts(48,17): error TS2532: Object is possibly 'undefined'.
tests/cases/compiler/controlFlowCaching.ts(48,29): error TS2339: Property 'y' does not exist on type 'never'.
tests/cases/compiler/controlFlowCaching.ts(53,5): error TS2532: Object is possibly 'undefined'.
tests/cases/compiler/controlFlowCaching.ts(53,14): error TS2339: Property 'y' does not exist on type 'never'.
tests/cases/compiler/controlFlowCaching.ts(55,14): error TS2678: Type '"start"' is not comparable to type 'undefined'.
tests/cases/compiler/controlFlowCaching.ts(58,14): error TS2678: Type '"end"' is not comparable to type 'undefined'.
tests/cases/compiler/controlFlowCaching.ts(61,14): error TS2678: Type '"middle"' is not comparable to type 'undefined'.
tests/cases/compiler/controlFlowCaching.ts(62,13): error TS2532: Object is possibly 'undefined'.
tests/cases/compiler/controlFlowCaching.ts(62,25): error TS2339: Property 'y' does not exist on type 'never'.
==== tests/cases/compiler/controlFlowCaching.ts (19 errors) ====
// Repro for #8401
function f(dim, offsets, arr, acommon, centerAnchorLimit, g, has, lin) {
var isRtl = this._isRtl(); // chart mirroring
// prepare variable
var o = this.opt, ta = this.chart.theme.axis, position = o.position,
leftBottom = position !== "rightOrTop", rotation = o.rotation % 360,
start, stop, titlePos, titleRotation = 0, titleOffset, axisVector, tickVector, anchorOffset, labelOffset, labelAlign,
labelGap = this.chart.theme.axis.tick.labelGap,
taFont = o.font || (ta.majorTick && ta.majorTick.font) || (ta.tick && ta.tick.font),
taTitleFont = o.titleFont || (ta.title && ta.title.font),
taFontColor = o.fontColor || (ta.majorTick && ta.majorTick.fontColor) || (ta.tick && ta.tick.fontColor) || "black",
taTitleFontColor = o.titleFontColor || (ta.title && ta.title.fontColor) || "black",
taTitleGap = (o.titleGap == 0) ? 0 : o.titleGap || (ta.title && ta.title.gap) || 15,
taTitleOrientation = o.titleOrientation || (ta.title && ta.title.orientation) || "axis",
taMajorTick = this.chart.theme.getTick("major", o),
taMinorTick = this.chart.theme.getTick("minor", o),
taMicroTick = this.chart.theme.getTick("micro", o),
taStroke = "stroke" in o ? o.stroke : ta.stroke,
size = taFont ? g.normalizedLength(g.splitFontString(taFont).size) : 0,
cosr = Math.abs(Math.cos(rotation * Math.PI / 180)),
sinr = Math.abs(Math.sin(rotation * Math.PI / 180)),
tsize = taTitleFont ? g.normalizedLength(g.splitFontString(taTitleFont).size) : 0;
if (rotation < 0) {
rotation += 360;
}
var cachedLabelW = this._getMaxLabelSize();
cachedLabelW = cachedLabelW && cachedLabelW.majLabelW;
titleOffset = size * cosr + (cachedLabelW || 0) * sinr + labelGap + Math.max(taMajorTick.length > 0 ? taMajorTick.length : 0,
taMinorTick.length > 0 ? taMinorTick.length : 0) +
tsize + taTitleGap;
axisVector = { x: isRtl ? -1 : 1, y: 0 }; // chart mirroring
switch (rotation) {
default:
if (rotation < (90 - centerAnchorLimit)) {
labelOffset.y = leftBottom ? size : 0;
~~~~~~~~~~~
!!! error TS2532: Object is possibly 'undefined'.
~
!!! error TS2339: Property 'y' does not exist on type 'never'.
} else if (rotation < (90 + centerAnchorLimit)) {
labelOffset.x = -size * 0.4;
~~~~~~~~~~~
!!! error TS2532: Object is possibly 'undefined'.
~
!!! error TS2339: Property 'x' does not exist on type 'never'.
} else if (rotation < 180) {
labelOffset.y = leftBottom ? 0 : -size;
~~~~~~~~~~~
!!! error TS2532: Object is possibly 'undefined'.
~
!!! error TS2339: Property 'y' does not exist on type 'never'.
} else if (rotation < (270 - centerAnchorLimit)) {
labelOffset.y = leftBottom ? 0 : -size;
~~~~~~~~~~~
!!! error TS2532: Object is possibly 'undefined'.
~
!!! error TS2339: Property 'y' does not exist on type 'never'.
} else if (rotation < (270 + centerAnchorLimit)) {
labelOffset.y = leftBottom ? size * 0.4 : 0;
~~~~~~~~~~~
!!! error TS2532: Object is possibly 'undefined'.
~
!!! error TS2339: Property 'y' does not exist on type 'never'.
} else {
labelOffset.y = leftBottom ? size : 0;
~~~~~~~~~~~
!!! error TS2532: Object is possibly 'undefined'.
~
!!! error TS2339: Property 'y' does not exist on type 'never'.
}
}
titleRotation = (taTitleOrientation && taTitleOrientation == "away") ? 180 : 0;
titlePos.y = offsets.t - titleOffset + (titleRotation ? 0 : tsize);
~~~~~~~~
!!! error TS2532: Object is possibly 'undefined'.
~
!!! error TS2339: Property 'y' does not exist on type 'never'.
switch (labelAlign) {
case "start":
~~~~~~~
!!! error TS2678: Type '"start"' is not comparable to type 'undefined'.
labelAlign = "end";
break;
case "end":
~~~~~
!!! error TS2678: Type '"end"' is not comparable to type 'undefined'.
labelAlign = "start";
break;
case "middle":
~~~~~~~~
!!! error TS2678: Type '"middle"' is not comparable to type 'undefined'.
labelOffset.y -= size;
~~~~~~~~~~~
!!! error TS2532: Object is possibly 'undefined'.
~
!!! error TS2339: Property 'y' does not exist on type 'never'.
break;
}
let _ = rotation;
}
@@ -1,8 +1,8 @@
//// [controlFlowLetVar.ts]
//// [controlFlowJavascript.js]
declare let cond: boolean;
let cond = true;
// CFA for 'let' with no type annotation and initializer
// CFA for 'let' and no initializer
function f1() {
let x;
if (cond) {
@@ -14,7 +14,7 @@ function f1() {
const y = x; // string | number | undefined
}
// CFA for 'let' with no type annotation and 'undefined' initializer
// CFA for 'let' and 'undefined' initializer
function f2() {
let x = undefined;
if (cond) {
@@ -26,7 +26,7 @@ function f2() {
const y = x; // string | number | undefined
}
// CFA for 'let' with no type annotation and 'null' initializer
// CFA for 'let' and 'null' initializer
function f3() {
let x = null;
if (cond) {
@@ -38,19 +38,7 @@ function f3() {
const y = x; // string | number | null
}
// No CFA for 'let' with with type annotation
function f4() {
let x: any;
if (cond) {
x = 1;
}
if (cond) {
x = "hello";
}
const y = x; // any
}
// CFA for 'var' with no type annotation and initializer
// CFA for 'var' with no initializer
function f5() {
var x;
if (cond) {
@@ -62,7 +50,7 @@ function f5() {
const y = x; // string | number | undefined
}
// CFA for 'var' with no type annotation and 'undefined' initializer
// CFA for 'var' with 'undefined' initializer
function f6() {
var x = undefined;
if (cond) {
@@ -74,7 +62,7 @@ function f6() {
const y = x; // string | number | undefined
}
// CFA for 'var' with no type annotation and 'null' initializer
// CFA for 'var' with 'null' initializer
function f7() {
var x = null;
if (cond) {
@@ -86,18 +74,6 @@ function f7() {
const y = x; // string | number | null
}
// No CFA for 'var' with with type annotation
function f8() {
var x: any;
if (cond) {
x = 1;
}
if (cond) {
x = "hello";
}
const y = x; // any
}
// No CFA for captured outer variables
function f9() {
let x;
@@ -126,10 +102,12 @@ function f10() {
const f = () => {
const z = x; // any
};
}
}
//// [controlFlowLetVar.js]
// CFA for 'let' with no type annotation and initializer
//// [out.js]
var cond = true;
// CFA for 'let' and no initializer
function f1() {
var x;
if (cond) {
@@ -140,7 +118,7 @@ function f1() {
}
var y = x; // string | number | undefined
}
// CFA for 'let' with no type annotation and 'undefined' initializer
// CFA for 'let' and 'undefined' initializer
function f2() {
var x = undefined;
if (cond) {
@@ -151,7 +129,7 @@ function f2() {
}
var y = x; // string | number | undefined
}
// CFA for 'let' with no type annotation and 'null' initializer
// CFA for 'let' and 'null' initializer
function f3() {
var x = null;
if (cond) {
@@ -162,18 +140,7 @@ function f3() {
}
var y = x; // string | number | null
}
// No CFA for 'let' with with type annotation
function f4() {
var x;
if (cond) {
x = 1;
}
if (cond) {
x = "hello";
}
var y = x; // any
}
// CFA for 'var' with no type annotation and initializer
// CFA for 'var' with no initializer
function f5() {
var x;
if (cond) {
@@ -184,7 +151,7 @@ function f5() {
}
var y = x; // string | number | undefined
}
// CFA for 'var' with no type annotation and 'undefined' initializer
// CFA for 'var' with 'undefined' initializer
function f6() {
var x = undefined;
if (cond) {
@@ -195,7 +162,7 @@ function f6() {
}
var y = x; // string | number | undefined
}
// CFA for 'var' with no type annotation and 'null' initializer
// CFA for 'var' with 'null' initializer
function f7() {
var x = null;
if (cond) {
@@ -206,17 +173,6 @@ function f7() {
}
var y = x; // string | number | null
}
// No CFA for 'var' with with type annotation
function f8() {
var x;
if (cond) {
x = 1;
}
if (cond) {
x = "hello";
}
var y = x; // any
}
// No CFA for captured outer variables
function f9() {
var x;
@@ -0,0 +1,216 @@
=== tests/cases/compiler/controlFlowJavascript.js ===
let cond = true;
>cond : Symbol(cond, Decl(controlFlowJavascript.js, 1, 3))
// CFA for 'let' and no initializer
function f1() {
>f1 : Symbol(f1, Decl(controlFlowJavascript.js, 1, 16))
let x;
>x : Symbol(x, Decl(controlFlowJavascript.js, 5, 7))
if (cond) {
>cond : Symbol(cond, Decl(controlFlowJavascript.js, 1, 3))
x = 1;
>x : Symbol(x, Decl(controlFlowJavascript.js, 5, 7))
}
if (cond) {
>cond : Symbol(cond, Decl(controlFlowJavascript.js, 1, 3))
x = "hello";
>x : Symbol(x, Decl(controlFlowJavascript.js, 5, 7))
}
const y = x; // string | number | undefined
>y : Symbol(y, Decl(controlFlowJavascript.js, 12, 9))
>x : Symbol(x, Decl(controlFlowJavascript.js, 5, 7))
}
// CFA for 'let' and 'undefined' initializer
function f2() {
>f2 : Symbol(f2, Decl(controlFlowJavascript.js, 13, 1))
let x = undefined;
>x : Symbol(x, Decl(controlFlowJavascript.js, 17, 7))
>undefined : Symbol(undefined)
if (cond) {
>cond : Symbol(cond, Decl(controlFlowJavascript.js, 1, 3))
x = 1;
>x : Symbol(x, Decl(controlFlowJavascript.js, 17, 7))
}
if (cond) {
>cond : Symbol(cond, Decl(controlFlowJavascript.js, 1, 3))
x = "hello";
>x : Symbol(x, Decl(controlFlowJavascript.js, 17, 7))
}
const y = x; // string | number | undefined
>y : Symbol(y, Decl(controlFlowJavascript.js, 24, 9))
>x : Symbol(x, Decl(controlFlowJavascript.js, 17, 7))
}
// CFA for 'let' and 'null' initializer
function f3() {
>f3 : Symbol(f3, Decl(controlFlowJavascript.js, 25, 1))
let x = null;
>x : Symbol(x, Decl(controlFlowJavascript.js, 29, 7))
if (cond) {
>cond : Symbol(cond, Decl(controlFlowJavascript.js, 1, 3))
x = 1;
>x : Symbol(x, Decl(controlFlowJavascript.js, 29, 7))
}
if (cond) {
>cond : Symbol(cond, Decl(controlFlowJavascript.js, 1, 3))
x = "hello";
>x : Symbol(x, Decl(controlFlowJavascript.js, 29, 7))
}
const y = x; // string | number | null
>y : Symbol(y, Decl(controlFlowJavascript.js, 36, 9))
>x : Symbol(x, Decl(controlFlowJavascript.js, 29, 7))
}
// CFA for 'var' with no initializer
function f5() {
>f5 : Symbol(f5, Decl(controlFlowJavascript.js, 37, 1))
var x;
>x : Symbol(x, Decl(controlFlowJavascript.js, 41, 7))
if (cond) {
>cond : Symbol(cond, Decl(controlFlowJavascript.js, 1, 3))
x = 1;
>x : Symbol(x, Decl(controlFlowJavascript.js, 41, 7))
}
if (cond) {
>cond : Symbol(cond, Decl(controlFlowJavascript.js, 1, 3))
x = "hello";
>x : Symbol(x, Decl(controlFlowJavascript.js, 41, 7))
}
const y = x; // string | number | undefined
>y : Symbol(y, Decl(controlFlowJavascript.js, 48, 9))
>x : Symbol(x, Decl(controlFlowJavascript.js, 41, 7))
}
// CFA for 'var' with 'undefined' initializer
function f6() {
>f6 : Symbol(f6, Decl(controlFlowJavascript.js, 49, 1))
var x = undefined;
>x : Symbol(x, Decl(controlFlowJavascript.js, 53, 7))
>undefined : Symbol(undefined)
if (cond) {
>cond : Symbol(cond, Decl(controlFlowJavascript.js, 1, 3))
x = 1;
>x : Symbol(x, Decl(controlFlowJavascript.js, 53, 7))
}
if (cond) {
>cond : Symbol(cond, Decl(controlFlowJavascript.js, 1, 3))
x = "hello";
>x : Symbol(x, Decl(controlFlowJavascript.js, 53, 7))
}
const y = x; // string | number | undefined
>y : Symbol(y, Decl(controlFlowJavascript.js, 60, 9))
>x : Symbol(x, Decl(controlFlowJavascript.js, 53, 7))
}
// CFA for 'var' with 'null' initializer
function f7() {
>f7 : Symbol(f7, Decl(controlFlowJavascript.js, 61, 1))
var x = null;
>x : Symbol(x, Decl(controlFlowJavascript.js, 65, 7))
if (cond) {
>cond : Symbol(cond, Decl(controlFlowJavascript.js, 1, 3))
x = 1;
>x : Symbol(x, Decl(controlFlowJavascript.js, 65, 7))
}
if (cond) {
>cond : Symbol(cond, Decl(controlFlowJavascript.js, 1, 3))
x = "hello";
>x : Symbol(x, Decl(controlFlowJavascript.js, 65, 7))
}
const y = x; // string | number | null
>y : Symbol(y, Decl(controlFlowJavascript.js, 72, 9))
>x : Symbol(x, Decl(controlFlowJavascript.js, 65, 7))
}
// No CFA for captured outer variables
function f9() {
>f9 : Symbol(f9, Decl(controlFlowJavascript.js, 73, 1))
let x;
>x : Symbol(x, Decl(controlFlowJavascript.js, 77, 7))
if (cond) {
>cond : Symbol(cond, Decl(controlFlowJavascript.js, 1, 3))
x = 1;
>x : Symbol(x, Decl(controlFlowJavascript.js, 77, 7))
}
if (cond) {
>cond : Symbol(cond, Decl(controlFlowJavascript.js, 1, 3))
x = "hello";
>x : Symbol(x, Decl(controlFlowJavascript.js, 77, 7))
}
const y = x; // string | number | undefined
>y : Symbol(y, Decl(controlFlowJavascript.js, 84, 9))
>x : Symbol(x, Decl(controlFlowJavascript.js, 77, 7))
function f() {
>f : Symbol(f, Decl(controlFlowJavascript.js, 84, 16))
const z = x; // any
>z : Symbol(z, Decl(controlFlowJavascript.js, 86, 13))
>x : Symbol(x, Decl(controlFlowJavascript.js, 77, 7))
}
}
// No CFA for captured outer variables
function f10() {
>f10 : Symbol(f10, Decl(controlFlowJavascript.js, 88, 1))
let x;
>x : Symbol(x, Decl(controlFlowJavascript.js, 92, 7))
if (cond) {
>cond : Symbol(cond, Decl(controlFlowJavascript.js, 1, 3))
x = 1;
>x : Symbol(x, Decl(controlFlowJavascript.js, 92, 7))
}
if (cond) {
>cond : Symbol(cond, Decl(controlFlowJavascript.js, 1, 3))
x = "hello";
>x : Symbol(x, Decl(controlFlowJavascript.js, 92, 7))
}
const y = x; // string | number | undefined
>y : Symbol(y, Decl(controlFlowJavascript.js, 99, 9))
>x : Symbol(x, Decl(controlFlowJavascript.js, 92, 7))
const f = () => {
>f : Symbol(f, Decl(controlFlowJavascript.js, 100, 9))
const z = x; // any
>z : Symbol(z, Decl(controlFlowJavascript.js, 101, 13))
>x : Symbol(x, Decl(controlFlowJavascript.js, 92, 7))
};
}
@@ -1,9 +1,10 @@
=== tests/cases/compiler/controlFlowLetVar.ts ===
=== tests/cases/compiler/controlFlowJavascript.js ===
declare let cond: boolean;
let cond = true;
>cond : boolean
>true : true
// CFA for 'let' with no type annotation and initializer
// CFA for 'let' and no initializer
function f1() {
>f1 : () => void
@@ -27,11 +28,11 @@ function f1() {
>"hello" : "hello"
}
const y = x; // string | number | undefined
>y : string | number | undefined
>x : string | number | undefined
>y : string | number
>x : string | number
}
// CFA for 'let' with no type annotation and 'undefined' initializer
// CFA for 'let' and 'undefined' initializer
function f2() {
>f2 : () => void
@@ -56,11 +57,11 @@ function f2() {
>"hello" : "hello"
}
const y = x; // string | number | undefined
>y : string | number | undefined
>x : string | number | undefined
>y : string | number
>x : string | number
}
// CFA for 'let' with no type annotation and 'null' initializer
// CFA for 'let' and 'null' initializer
function f3() {
>f3 : () => void
@@ -85,39 +86,11 @@ function f3() {
>"hello" : "hello"
}
const y = x; // string | number | null
>y : string | number | null
>x : string | number | null
>y : string | number
>x : string | number
}
// No CFA for 'let' with with type annotation
function f4() {
>f4 : () => void
let x: any;
>x : any
if (cond) {
>cond : boolean
x = 1;
>x = 1 : 1
>x : any
>1 : 1
}
if (cond) {
>cond : boolean
x = "hello";
>x = "hello" : "hello"
>x : any
>"hello" : "hello"
}
const y = x; // any
>y : any
>x : any
}
// CFA for 'var' with no type annotation and initializer
// CFA for 'var' with no initializer
function f5() {
>f5 : () => void
@@ -141,11 +114,11 @@ function f5() {
>"hello" : "hello"
}
const y = x; // string | number | undefined
>y : string | number | undefined
>x : string | number | undefined
>y : string | number
>x : string | number
}
// CFA for 'var' with no type annotation and 'undefined' initializer
// CFA for 'var' with 'undefined' initializer
function f6() {
>f6 : () => void
@@ -170,11 +143,11 @@ function f6() {
>"hello" : "hello"
}
const y = x; // string | number | undefined
>y : string | number | undefined
>x : string | number | undefined
>y : string | number
>x : string | number
}
// CFA for 'var' with no type annotation and 'null' initializer
// CFA for 'var' with 'null' initializer
function f7() {
>f7 : () => void
@@ -199,36 +172,8 @@ function f7() {
>"hello" : "hello"
}
const y = x; // string | number | null
>y : string | number | null
>x : string | number | null
}
// No CFA for 'var' with with type annotation
function f8() {
>f8 : () => void
var x: any;
>x : any
if (cond) {
>cond : boolean
x = 1;
>x = 1 : 1
>x : any
>1 : 1
}
if (cond) {
>cond : boolean
x = "hello";
>x = "hello" : "hello"
>x : any
>"hello" : "hello"
}
const y = x; // any
>y : any
>x : any
>y : string | number
>x : string | number
}
// No CFA for captured outer variables
@@ -255,8 +200,8 @@ function f9() {
>"hello" : "hello"
}
const y = x; // string | number | undefined
>y : string | number | undefined
>x : string | number | undefined
>y : string | number
>x : string | number
function f() {
>f : () => void
@@ -291,8 +236,8 @@ function f10() {
>"hello" : "hello"
}
const y = x; // string | number | undefined
>y : string | number | undefined
>x : string | number | undefined
>y : string | number
>x : string | number
const f = () => {
>f : () => void
@@ -304,3 +249,4 @@ function f10() {
};
}
@@ -1,263 +0,0 @@
=== tests/cases/compiler/controlFlowLetVar.ts ===
declare let cond: boolean;
>cond : Symbol(cond, Decl(controlFlowLetVar.ts, 1, 11))
// CFA for 'let' with no type annotation and initializer
function f1() {
>f1 : Symbol(f1, Decl(controlFlowLetVar.ts, 1, 26))
let x;
>x : Symbol(x, Decl(controlFlowLetVar.ts, 5, 7))
if (cond) {
>cond : Symbol(cond, Decl(controlFlowLetVar.ts, 1, 11))
x = 1;
>x : Symbol(x, Decl(controlFlowLetVar.ts, 5, 7))
}
if (cond) {
>cond : Symbol(cond, Decl(controlFlowLetVar.ts, 1, 11))
x = "hello";
>x : Symbol(x, Decl(controlFlowLetVar.ts, 5, 7))
}
const y = x; // string | number | undefined
>y : Symbol(y, Decl(controlFlowLetVar.ts, 12, 9))
>x : Symbol(x, Decl(controlFlowLetVar.ts, 5, 7))
}
// CFA for 'let' with no type annotation and 'undefined' initializer
function f2() {
>f2 : Symbol(f2, Decl(controlFlowLetVar.ts, 13, 1))
let x = undefined;
>x : Symbol(x, Decl(controlFlowLetVar.ts, 17, 7))
>undefined : Symbol(undefined)
if (cond) {
>cond : Symbol(cond, Decl(controlFlowLetVar.ts, 1, 11))
x = 1;
>x : Symbol(x, Decl(controlFlowLetVar.ts, 17, 7))
}
if (cond) {
>cond : Symbol(cond, Decl(controlFlowLetVar.ts, 1, 11))
x = "hello";
>x : Symbol(x, Decl(controlFlowLetVar.ts, 17, 7))
}
const y = x; // string | number | undefined
>y : Symbol(y, Decl(controlFlowLetVar.ts, 24, 9))
>x : Symbol(x, Decl(controlFlowLetVar.ts, 17, 7))
}
// CFA for 'let' with no type annotation and 'null' initializer
function f3() {
>f3 : Symbol(f3, Decl(controlFlowLetVar.ts, 25, 1))
let x = null;
>x : Symbol(x, Decl(controlFlowLetVar.ts, 29, 7))
if (cond) {
>cond : Symbol(cond, Decl(controlFlowLetVar.ts, 1, 11))
x = 1;
>x : Symbol(x, Decl(controlFlowLetVar.ts, 29, 7))
}
if (cond) {
>cond : Symbol(cond, Decl(controlFlowLetVar.ts, 1, 11))
x = "hello";
>x : Symbol(x, Decl(controlFlowLetVar.ts, 29, 7))
}
const y = x; // string | number | null
>y : Symbol(y, Decl(controlFlowLetVar.ts, 36, 9))
>x : Symbol(x, Decl(controlFlowLetVar.ts, 29, 7))
}
// No CFA for 'let' with with type annotation
function f4() {
>f4 : Symbol(f4, Decl(controlFlowLetVar.ts, 37, 1))
let x: any;
>x : Symbol(x, Decl(controlFlowLetVar.ts, 41, 7))
if (cond) {
>cond : Symbol(cond, Decl(controlFlowLetVar.ts, 1, 11))
x = 1;
>x : Symbol(x, Decl(controlFlowLetVar.ts, 41, 7))
}
if (cond) {
>cond : Symbol(cond, Decl(controlFlowLetVar.ts, 1, 11))
x = "hello";
>x : Symbol(x, Decl(controlFlowLetVar.ts, 41, 7))
}
const y = x; // any
>y : Symbol(y, Decl(controlFlowLetVar.ts, 48, 9))
>x : Symbol(x, Decl(controlFlowLetVar.ts, 41, 7))
}
// CFA for 'var' with no type annotation and initializer
function f5() {
>f5 : Symbol(f5, Decl(controlFlowLetVar.ts, 49, 1))
var x;
>x : Symbol(x, Decl(controlFlowLetVar.ts, 53, 7))
if (cond) {
>cond : Symbol(cond, Decl(controlFlowLetVar.ts, 1, 11))
x = 1;
>x : Symbol(x, Decl(controlFlowLetVar.ts, 53, 7))
}
if (cond) {
>cond : Symbol(cond, Decl(controlFlowLetVar.ts, 1, 11))
x = "hello";
>x : Symbol(x, Decl(controlFlowLetVar.ts, 53, 7))
}
const y = x; // string | number | undefined
>y : Symbol(y, Decl(controlFlowLetVar.ts, 60, 9))
>x : Symbol(x, Decl(controlFlowLetVar.ts, 53, 7))
}
// CFA for 'var' with no type annotation and 'undefined' initializer
function f6() {
>f6 : Symbol(f6, Decl(controlFlowLetVar.ts, 61, 1))
var x = undefined;
>x : Symbol(x, Decl(controlFlowLetVar.ts, 65, 7))
>undefined : Symbol(undefined)
if (cond) {
>cond : Symbol(cond, Decl(controlFlowLetVar.ts, 1, 11))
x = 1;
>x : Symbol(x, Decl(controlFlowLetVar.ts, 65, 7))
}
if (cond) {
>cond : Symbol(cond, Decl(controlFlowLetVar.ts, 1, 11))
x = "hello";
>x : Symbol(x, Decl(controlFlowLetVar.ts, 65, 7))
}
const y = x; // string | number | undefined
>y : Symbol(y, Decl(controlFlowLetVar.ts, 72, 9))
>x : Symbol(x, Decl(controlFlowLetVar.ts, 65, 7))
}
// CFA for 'var' with no type annotation and 'null' initializer
function f7() {
>f7 : Symbol(f7, Decl(controlFlowLetVar.ts, 73, 1))
var x = null;
>x : Symbol(x, Decl(controlFlowLetVar.ts, 77, 7))
if (cond) {
>cond : Symbol(cond, Decl(controlFlowLetVar.ts, 1, 11))
x = 1;
>x : Symbol(x, Decl(controlFlowLetVar.ts, 77, 7))
}
if (cond) {
>cond : Symbol(cond, Decl(controlFlowLetVar.ts, 1, 11))
x = "hello";
>x : Symbol(x, Decl(controlFlowLetVar.ts, 77, 7))
}
const y = x; // string | number | null
>y : Symbol(y, Decl(controlFlowLetVar.ts, 84, 9))
>x : Symbol(x, Decl(controlFlowLetVar.ts, 77, 7))
}
// No CFA for 'var' with with type annotation
function f8() {
>f8 : Symbol(f8, Decl(controlFlowLetVar.ts, 85, 1))
var x: any;
>x : Symbol(x, Decl(controlFlowLetVar.ts, 89, 7))
if (cond) {
>cond : Symbol(cond, Decl(controlFlowLetVar.ts, 1, 11))
x = 1;
>x : Symbol(x, Decl(controlFlowLetVar.ts, 89, 7))
}
if (cond) {
>cond : Symbol(cond, Decl(controlFlowLetVar.ts, 1, 11))
x = "hello";
>x : Symbol(x, Decl(controlFlowLetVar.ts, 89, 7))
}
const y = x; // any
>y : Symbol(y, Decl(controlFlowLetVar.ts, 96, 9))
>x : Symbol(x, Decl(controlFlowLetVar.ts, 89, 7))
}
// No CFA for captured outer variables
function f9() {
>f9 : Symbol(f9, Decl(controlFlowLetVar.ts, 97, 1))
let x;
>x : Symbol(x, Decl(controlFlowLetVar.ts, 101, 7))
if (cond) {
>cond : Symbol(cond, Decl(controlFlowLetVar.ts, 1, 11))
x = 1;
>x : Symbol(x, Decl(controlFlowLetVar.ts, 101, 7))
}
if (cond) {
>cond : Symbol(cond, Decl(controlFlowLetVar.ts, 1, 11))
x = "hello";
>x : Symbol(x, Decl(controlFlowLetVar.ts, 101, 7))
}
const y = x; // string | number | undefined
>y : Symbol(y, Decl(controlFlowLetVar.ts, 108, 9))
>x : Symbol(x, Decl(controlFlowLetVar.ts, 101, 7))
function f() {
>f : Symbol(f, Decl(controlFlowLetVar.ts, 108, 16))
const z = x; // any
>z : Symbol(z, Decl(controlFlowLetVar.ts, 110, 13))
>x : Symbol(x, Decl(controlFlowLetVar.ts, 101, 7))
}
}
// No CFA for captured outer variables
function f10() {
>f10 : Symbol(f10, Decl(controlFlowLetVar.ts, 112, 1))
let x;
>x : Symbol(x, Decl(controlFlowLetVar.ts, 116, 7))
if (cond) {
>cond : Symbol(cond, Decl(controlFlowLetVar.ts, 1, 11))
x = 1;
>x : Symbol(x, Decl(controlFlowLetVar.ts, 116, 7))
}
if (cond) {
>cond : Symbol(cond, Decl(controlFlowLetVar.ts, 1, 11))
x = "hello";
>x : Symbol(x, Decl(controlFlowLetVar.ts, 116, 7))
}
const y = x; // string | number | undefined
>y : Symbol(y, Decl(controlFlowLetVar.ts, 123, 9))
>x : Symbol(x, Decl(controlFlowLetVar.ts, 116, 7))
const f = () => {
>f : Symbol(f, Decl(controlFlowLetVar.ts, 124, 9))
const z = x; // any
>z : Symbol(z, Decl(controlFlowLetVar.ts, 125, 13))
>x : Symbol(x, Decl(controlFlowLetVar.ts, 116, 7))
};
}
@@ -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;
@@ -14,7 +14,7 @@ var f6 = () => { return [<any>10]; }
function f1() {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i - 0] = arguments[_i];
args[_i] = arguments[_i];
}
}
function f2(x) { }
@@ -13,13 +13,13 @@ function foo2(...rest: any[]) {
function foo() {
var rest = [];
for (var _i = 0; _i < arguments.length; _i++) {
rest[_i - 0] = arguments[_i];
rest[_i] = arguments[_i];
}
}
function foo2() {
var rest = [];
for (var _i = 0; _i < arguments.length; _i++) {
rest[_i - 0] = arguments[_i];
rest[_i] = arguments[_i];
}
}
@@ -0,0 +1,9 @@
tests/cases/compiler/declarationEmitInterfaceWithNonEntityNameExpressionHeritage.ts(3,25): error TS2499: An interface can only extend an identifier/qualified-name with optional type arguments.
==== tests/cases/compiler/declarationEmitInterfaceWithNonEntityNameExpressionHeritage.ts (1 errors) ====
class A { }
interface Class extends (typeof A) { }
~~~~~~~~~~
!!! error TS2499: An interface can only extend an identifier/qualified-name with optional type arguments.
@@ -0,0 +1,18 @@
//// [declarationEmitInterfaceWithNonEntityNameExpressionHeritage.ts]
class A { }
interface Class extends (typeof A) { }
//// [declarationEmitInterfaceWithNonEntityNameExpressionHeritage.js]
var A = (function () {
function A() {
}
return A;
}());
//// [declarationEmitInterfaceWithNonEntityNameExpressionHeritage.d.ts]
declare class A {
}
interface Class {
}
@@ -0,0 +1,11 @@
tests/cases/compiler/declarationEmitTypeAliasTypeParameterExtendingUnknownSymbol.ts(2,18): error TS2304: Cannot find name 'Unknown'.
tests/cases/compiler/declarationEmitTypeAliasTypeParameterExtendingUnknownSymbol.ts(2,18): error TS4083: Type parameter 'T' of exported type alias has or is using private name 'Unknown'.
==== tests/cases/compiler/declarationEmitTypeAliasTypeParameterExtendingUnknownSymbol.ts (2 errors) ====
type A<T extends Unknown> = {}
~~~~~~~
!!! error TS2304: Cannot find name 'Unknown'.
~~~~~~~
!!! error TS4083: Type parameter 'T' of exported type alias has or is using private name 'Unknown'.
@@ -0,0 +1,5 @@
//// [declarationEmitTypeAliasTypeParameterExtendingUnknownSymbol.ts]
type A<T extends Unknown> = {}
//// [declarationEmitTypeAliasTypeParameterExtendingUnknownSymbol.js]
@@ -10,7 +10,7 @@ export default function f(...args: any[]) {
function f() {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i - 0] = arguments[_i];
args[_i] = arguments[_i];
}
}
Object.defineProperty(exports, "__esModule", { value: true });

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