Merge branch 'master' into 6229-known-length-tuples

This commit is contained in:
Nathan Shively-Sanders
2017-11-03 09:07:38 -07:00
247 changed files with 2874 additions and 1177 deletions
+8
View File
@@ -59,3 +59,11 @@ internal/
.idea
yarn.lock
.parallelperf.*
tests/cases/user/*/package-lock.json
tests/cases/user/*/node_modules/
tests/cases/user/*/**/*.js
tests/cases/user/*/**/*.js.map
tests/cases/user/*/**/*.d.ts
!tests/cases/user/zone.js/
!tests/cases/user/bignumber.js/
!tests/cases/user/discord.js/
+1 -1
View File
@@ -1106,7 +1106,7 @@ gulp.task("lint", "Runs tslint on the compiler sources. Optional arguments are:
const fileMatcher = cmdLineOptions.files;
const files = fileMatcher
? `src/**/${fileMatcher}`
: "Gulpfile.ts 'scripts/generateLocalizedDiagnosticMessages.ts' 'scripts/tslint/**/*.ts' 'src/**/*.ts' --exclude src/lib/es5.d.ts --exclude 'src/lib/*.generated.d.ts'";
: "Gulpfile.ts 'scripts/generateLocalizedDiagnosticMessages.ts' 'scripts/tslint/**/*.ts' 'src/**/*.ts' --exclude 'src/lib/*.d.ts'";
const cmd = `node node_modules/tslint/bin/tslint ${files} --formatters-dir ./built/local/tslint/formatters --format autolinkableStylish`;
console.log("Linting: " + cmd);
child_process.execSync(cmd, { stdio: [0, 1, 2] });
+2 -1
View File
@@ -105,6 +105,7 @@ var harnessCoreSources = [
"projectsRunner.ts",
"loggedIO.ts",
"rwcRunner.ts",
"userRunner.ts",
"test262Runner.ts",
"./parallel/shared.ts",
"./parallel/host.ts",
@@ -1282,7 +1283,7 @@ task("lint", ["build-rules"], () => {
const fileMatcher = process.env.f || process.env.file || process.env.files;
const files = fileMatcher
? `src/**/${fileMatcher}`
: "Gulpfile.ts 'scripts/generateLocalizedDiagnosticMessages.ts' 'scripts/tslint/**/*.ts' 'src/**/*.ts' --exclude src/lib/es5.d.ts --exclude 'src/lib/*.generated.d.ts'";
: "Gulpfile.ts 'scripts/generateLocalizedDiagnosticMessages.ts' 'scripts/tslint/**/*.ts' 'src/**/*.ts' --exclude 'src/lib/*.d.ts'";
const cmd = `node node_modules/tslint/bin/tslint ${files} --formatters-dir ./built/local/tslint/formatters --format autolinkableStylish`;
console.log("Linting: " + cmd);
jake.exec([cmd], { interactive: true }, () => {
-1
View File
@@ -64,7 +64,6 @@ module Commands {
}
if (path.charAt(1) === ":") {
if (path.charAt(2) === directorySeparator) return 3;
return 2;
}
return 0;
}
+7 -7
View File
@@ -1550,7 +1550,7 @@ namespace ts {
function setExportContextFlag(node: ModuleDeclaration | SourceFile) {
// A declaration source file or ambient module declaration that contains no export declarations (but possibly regular
// declarations with export modifiers) is an export context in which declarations are implicitly exported.
if (isInAmbientContext(node) && !hasExportDeclarations(node)) {
if (node.flags & NodeFlags.Ambient && !hasExportDeclarations(node)) {
node.flags |= NodeFlags.ExportContext;
}
else {
@@ -1726,7 +1726,7 @@ namespace ts {
node.originalKeywordKind >= SyntaxKind.FirstFutureReservedWord &&
node.originalKeywordKind <= SyntaxKind.LastFutureReservedWord &&
!isIdentifierName(node) &&
!isInAmbientContext(node)) {
!(node.flags & NodeFlags.Ambient)) {
// Report error only if there are no parse errors in file
if (!file.parseDiagnostics.length) {
@@ -2481,7 +2481,7 @@ namespace ts {
}
function bindParameter(node: ParameterDeclaration) {
if (inStrictMode && !isInAmbientContext(node)) {
if (inStrictMode && !(node.flags & NodeFlags.Ambient)) {
// It is a SyntaxError if the identifier eval or arguments appears within a FormalParameterList of a
// strict mode FunctionLikeDeclaration or FunctionExpression(13.1)
checkStrictModeEvalOrArguments(node, node.name);
@@ -2503,7 +2503,7 @@ namespace ts {
}
function bindFunctionDeclaration(node: FunctionDeclaration) {
if (!file.isDeclarationFile && !isInAmbientContext(node)) {
if (!file.isDeclarationFile && !(node.flags & NodeFlags.Ambient)) {
if (isAsyncFunction(node)) {
emitFlags |= NodeFlags.HasAsyncFunctions;
}
@@ -2520,7 +2520,7 @@ namespace ts {
}
function bindFunctionExpression(node: FunctionExpression) {
if (!file.isDeclarationFile && !isInAmbientContext(node)) {
if (!file.isDeclarationFile && !(node.flags & NodeFlags.Ambient)) {
if (isAsyncFunction(node)) {
emitFlags |= NodeFlags.HasAsyncFunctions;
}
@@ -2534,7 +2534,7 @@ namespace ts {
}
function bindPropertyOrMethodOrAccessor(node: Declaration, symbolFlags: SymbolFlags, symbolExcludes: SymbolFlags) {
if (!file.isDeclarationFile && !isInAmbientContext(node) && isAsyncFunction(node)) {
if (!file.isDeclarationFile && !(node.flags & NodeFlags.Ambient) && isAsyncFunction(node)) {
emitFlags |= NodeFlags.HasAsyncFunctions;
}
@@ -2583,7 +2583,7 @@ namespace ts {
// On the other side we do want to report errors on non-initialized 'lets' because of TDZ
const reportUnreachableCode =
!options.allowUnreachableCode &&
!isInAmbientContext(node) &&
!(node.flags & NodeFlags.Ambient) &&
(
node.kind !== SyntaxKind.VariableStatement ||
getCombinedNodeFlags((<VariableStatement>node).declarationList) & NodeFlags.BlockScoped ||
+78 -70
View File
@@ -692,7 +692,7 @@ namespace ts {
else {
// find a module that about to be augmented
// do not validate names of augmentations that are defined in ambient context
const moduleNotFoundError = !isInAmbientContext(moduleName.parent.parent)
const moduleNotFoundError = !(moduleName.parent.parent.flags & NodeFlags.Ambient)
? Diagnostics.Invalid_module_name_in_augmentation_module_0_cannot_be_found
: undefined;
let mainModule = resolveExternalModuleNameWorker(moduleName, moduleName, moduleNotFoundError, /*isForAugmentation*/ true);
@@ -797,7 +797,7 @@ namespace ts {
if ((modulekind && (declarationFile.externalModuleIndicator || useFile.externalModuleIndicator)) ||
(!compilerOptions.outFile && !compilerOptions.out) ||
isInTypeQuery(usage) ||
isInAmbientContext(declaration)) {
declaration.flags & NodeFlags.Ambient) {
// nodes are in different files and order cannot be determined
return true;
}
@@ -1385,7 +1385,7 @@ namespace ts {
Debug.assert(declaration !== undefined, "Declaration to checkResolvedBlockScopedVariable is undefined");
if (!isInAmbientContext(declaration) && !isBlockScopedNameDeclaredBeforeUse(declaration, errorLocation)) {
if (!(declaration.flags & NodeFlags.Ambient) && !isBlockScopedNameDeclaredBeforeUse(declaration, errorLocation)) {
if (result.flags & SymbolFlags.BlockScopedVariable) {
error(errorLocation, Diagnostics.Block_scoped_variable_0_used_before_its_declaration, declarationNameToString(getNameOfDeclaration(declaration)));
}
@@ -3950,7 +3950,7 @@ namespace ts {
const parent = getDeclarationContainer(node);
// If the node is not exported or it is not ambient module element (except import declaration)
if (!(getCombinedModifierFlags(node) & ModifierFlags.Export) &&
!(node.kind !== SyntaxKind.ImportEqualsDeclaration && parent.kind !== SyntaxKind.SourceFile && isInAmbientContext(parent))) {
!(node.kind !== SyntaxKind.ImportEqualsDeclaration && parent.kind !== SyntaxKind.SourceFile && parent.flags & NodeFlags.Ambient)) {
return isGlobalSourceFile(parent);
}
// Exported members/ambient module elements (exception import declaration) are visible if parent is visible
@@ -4328,7 +4328,7 @@ namespace ts {
if ((noImplicitAny || isInJavaScriptFile(declaration)) &&
declaration.kind === SyntaxKind.VariableDeclaration && !isBindingPattern(declaration.name) &&
!(getCombinedModifierFlags(declaration) & ModifierFlags.Export) && !isInAmbientContext(declaration)) {
!(getCombinedModifierFlags(declaration) & ModifierFlags.Export) && !(declaration.flags & NodeFlags.Ambient)) {
// 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.
@@ -5201,7 +5201,7 @@ namespace ts {
function isLiteralEnumMember(member: EnumMember) {
const expr = member.initializer;
if (!expr) {
return !isInAmbientContext(member);
return !(member.flags & NodeFlags.Ambient);
}
switch (expr.kind) {
case SyntaxKind.StringLiteral:
@@ -7447,9 +7447,12 @@ namespace ts {
return false;
}
function isSubtypeOfAny(candidate: Type, types: Type[]): boolean {
for (const type of types) {
if (candidate !== type && isTypeSubtypeOf(candidate, type)) {
function isSubtypeOfAny(source: Type, targets: Type[]): boolean {
for (const target of targets) {
if (source !== target && isTypeSubtypeOf(source, target) && (
!(getObjectFlags(getTargetType(source)) & ObjectFlags.Class) ||
!(getObjectFlags(getTargetType(target)) & ObjectFlags.Class) ||
isTypeDerivedFrom(source, target))) {
return true;
}
}
@@ -7596,11 +7599,11 @@ namespace ts {
}
}
// Add the given types to the given type set. Order is preserved, duplicates are removed,
// and nested types of the given kind are flattened into the set.
// Add the given types to the given type set. Order is preserved, freshness is removed from literal
// types, duplicates are removed, and nested types of the given kind are flattened into the set.
function addTypesToIntersection(typeSet: TypeSet, types: Type[]) {
for (const type of types) {
addTypeToIntersection(typeSet, type);
addTypeToIntersection(typeSet, getRegularTypeOfLiteralType(type));
}
}
@@ -8572,12 +8575,19 @@ namespace ts {
return isTypeRelatedTo(source, target, assignableRelation);
}
// A type S is considered to be an instance of a type T if S and T are the same type or if S is a
// subtype of T but not structurally identical to T. This specifically means that two distinct but
// structurally identical types (such as two classes) are not considered instances of each other.
function isTypeInstanceOf(source: Type, target: Type): boolean {
return getTargetType(source) === getTargetType(target) || isTypeSubtypeOf(source, target) && !isTypeIdenticalTo(source, target);
}
// An object type S is considered to be derived from an object type T if
// S is a union type and every constituent of S is derived from T,
// T is a union type and S is derived from at least one constituent of T, or
// T is one of the global types Object and Function and S is a subtype of T, or
// T occurs directly or indirectly in an 'extends' clause of S.
// Note that this check ignores type parameters and only considers the
// inheritance hierarchy.
function isTypeDerivedFrom(source: Type, target: Type): boolean {
return source.flags & TypeFlags.Union ? every((<UnionType>source).types, t => isTypeDerivedFrom(t, target)) :
target.flags & TypeFlags.Union ? some((<UnionType>target).types, t => isTypeDerivedFrom(source, t)) :
target === globalObjectType || target === globalFunctionType ? isTypeSubtypeOf(source, target) :
hasBaseType(source, getTargetType(target));
}
/**
* This is *not* a bi-directional relationship.
@@ -9611,7 +9621,7 @@ namespace ts {
if (relation === identityRelation) {
return propertiesIdenticalTo(source, target);
}
const requireOptionalProperties = relation === subtypeRelation && !isObjectLiteralType(source);
const requireOptionalProperties = relation === subtypeRelation && !isObjectLiteralType(source) && !isEmptyArrayLiteralType(source);
const unmatchedProperty = getUnmatchedProperty(source, target, requireOptionalProperties);
if (unmatchedProperty) {
if (reportErrors) {
@@ -10319,6 +10329,11 @@ namespace ts {
!(type.flags & TypeFlags.Nullable) && isTypeAssignableTo(type, anyReadonlyArrayType);
}
function isEmptyArrayLiteralType(type: Type): boolean {
const elementType = isArrayType(type) ? (<TypeReference>type).typeArguments[0] : undefined;
return elementType === undefinedWideningType || elementType === neverType;
}
function isTupleLikeType(type: Type): boolean {
return !!getPropertyOfType(type, "0" as __String);
}
@@ -10799,7 +10814,7 @@ namespace ts {
}
function getUnmatchedProperty(source: Type, target: Type, requireOptionalProperties: boolean) {
const properties = getPropertiesOfObjectType(target);
const properties = target.flags & TypeFlags.Intersection ? getPropertiesOfUnionOrIntersectionType(<IntersectionType>target) : getPropertiesOfObjectType(target);
for (const targetProp of properties) {
if (requireOptionalProperties || !(targetProp.flags & SymbolFlags.Optional)) {
const sourceProp = getPropertyOfType(source, targetProp.escapedName);
@@ -12422,7 +12437,7 @@ namespace ts {
}
if (targetType) {
return getNarrowedType(type, targetType, assumeTrue, isTypeInstanceOf);
return getNarrowedType(type, targetType, assumeTrue, isTypeDerivedFrom);
}
return type;
@@ -12752,7 +12767,7 @@ namespace ts {
const assumeInitialized = isParameter || isAlias || isOuterVariable ||
type !== autoType && type !== autoArrayType && (!strictNullChecks || (type.flags & TypeFlags.Any) !== 0 || isInTypeQuery(node) || node.parent.kind === SyntaxKind.ExportSpecifier) ||
node.parent.kind === SyntaxKind.NonNullExpression ||
isInAmbientContext(declaration);
declaration.flags & NodeFlags.Ambient;
const initialType = assumeInitialized ? (isParameter ? removeOptionalityFromDeclaredType(type, getRootDeclaration(declaration) as VariableLikeDeclaration) : type) :
type === autoType || type === autoArrayType ? undefinedType :
getNullableType(type, TypeFlags.Undefined);
@@ -13890,7 +13905,6 @@ namespace ts {
type.pattern = node;
return type;
}
const contextualType = getApparentTypeOfContextualType(node);
if (contextualType && contextualTypeIsTupleLikeType(contextualType)) {
const pattern = contextualType.pattern;
// If array literal is contextually typed by a binding pattern or an assignment pattern, pad the resulting
@@ -15225,7 +15239,7 @@ namespace ts {
}
else if (valueDeclaration.kind === SyntaxKind.ClassDeclaration &&
node.parent.kind !== SyntaxKind.TypeReference &&
!isInAmbientContext(valueDeclaration) &&
!(valueDeclaration.flags & NodeFlags.Ambient) &&
!isBlockScopedNameDeclaredBeforeUse(valueDeclaration, right)) {
error(right, Diagnostics.Class_0_used_before_its_declaration, idText(right));
}
@@ -17093,7 +17107,7 @@ namespace ts {
return type;
}
function isCommonJsRequire(node: Node) {
function isCommonJsRequire(node: Node): boolean {
if (!isRequireCall(node, /*checkArgumentIsStringLiteral*/ true)) {
return false;
}
@@ -17117,7 +17131,7 @@ namespace ts {
if (targetDeclarationKind !== SyntaxKind.Unknown) {
const decl = getDeclarationOfKind(resolvedRequire, targetDeclarationKind);
// function/variable declaration should be ambient
return isInAmbientContext(decl);
return !!(decl.flags & NodeFlags.Ambient);
}
return false;
}
@@ -18094,14 +18108,6 @@ namespace ts {
return (target.flags & TypeFlags.Nullable) !== 0 || isTypeComparableTo(source, target);
}
function getBestChoiceType(type1: Type, type2: Type): Type {
const firstAssignableToSecond = isTypeAssignableTo(type1, type2);
const secondAssignableToFirst = isTypeAssignableTo(type2, type1);
return secondAssignableToFirst && !firstAssignableToSecond ? type1 :
firstAssignableToSecond && !secondAssignableToFirst ? type2 :
getUnionType([type1, type2], /*subtypeReduction*/ true);
}
function checkBinaryExpression(node: BinaryExpression, checkMode?: CheckMode) {
return checkBinaryLikeExpression(node.left, node.operatorToken, node.right, checkMode, node);
}
@@ -18238,7 +18244,7 @@ namespace ts {
leftType;
case SyntaxKind.BarBarToken:
return getTypeFacts(leftType) & TypeFacts.Falsy ?
getBestChoiceType(removeDefinitelyFalsyTypes(leftType), rightType) :
getUnionType([removeDefinitelyFalsyTypes(leftType), rightType], /*subtypeReduction*/ true) :
leftType;
case SyntaxKind.EqualsToken:
checkAssignmentOperator(rightType);
@@ -18398,7 +18404,7 @@ namespace ts {
checkExpression(node.condition);
const type1 = checkExpression(node.whenTrue, checkMode);
const type2 = checkExpression(node.whenFalse, checkMode);
return getBestChoiceType(type1, type2);
return getUnionType([type1, type2], /*subtypeReduction*/ true);
}
function checkTemplateExpression(node: TemplateExpression): Type {
@@ -19243,7 +19249,7 @@ namespace ts {
checkDecorators(node);
checkSignatureDeclaration(node);
if (node.kind === SyntaxKind.GetAccessor) {
if (!isInAmbientContext(node) && nodeIsPresent(node.body) && (node.flags & NodeFlags.HasImplicitReturn)) {
if (!(node.flags & NodeFlags.Ambient) && nodeIsPresent(node.body) && (node.flags & NodeFlags.HasImplicitReturn)) {
if (!(node.flags & NodeFlags.HasExplicitReturn)) {
error(node.name, Diagnostics.A_get_accessor_must_return_a_value);
}
@@ -19426,7 +19432,7 @@ namespace ts {
}
function isPrivateWithinAmbient(node: Node): boolean {
return hasModifier(node, ModifierFlags.Private) && isInAmbientContext(node);
return hasModifier(node, ModifierFlags.Private) && !!(node.flags & NodeFlags.Ambient);
}
function getEffectiveDeclarationFlags(n: Node, flagsToCheck: ModifierFlags): ModifierFlags {
@@ -19437,7 +19443,7 @@ namespace ts {
if (n.parent.kind !== SyntaxKind.InterfaceDeclaration &&
n.parent.kind !== SyntaxKind.ClassDeclaration &&
n.parent.kind !== SyntaxKind.ClassExpression &&
isInAmbientContext(n)) {
n.flags & NodeFlags.Ambient) {
if (!(flags & ModifierFlags.Ambient)) {
// It is nested in an ambient context, which means it is automatically exported
flags |= ModifierFlags.Export;
@@ -19576,7 +19582,7 @@ namespace ts {
let multipleConstructorImplementation = false;
for (const current of declarations) {
const node = <FunctionLike>current;
const inAmbientContext = isInAmbientContext(node);
const inAmbientContext = node.flags & NodeFlags.Ambient;
const inAmbientContextOrInterface = node.parent.kind === SyntaxKind.InterfaceDeclaration || node.parent.kind === SyntaxKind.TypeLiteral || inAmbientContext;
if (inAmbientContextOrInterface) {
// check if declarations are consecutive only if they are non-ambient
@@ -20431,7 +20437,7 @@ namespace ts {
}
function checkUnusedLocalsAndParameters(node: Node): void {
if (node.parent.kind !== SyntaxKind.InterfaceDeclaration && noUnusedIdentifiers && !isInAmbientContext(node)) {
if (node.parent.kind !== SyntaxKind.InterfaceDeclaration && noUnusedIdentifiers && !(node.flags & NodeFlags.Ambient)) {
node.locals.forEach(local => {
if (!local.isReferenced) {
if (local.valueDeclaration && getRootDeclaration(local.valueDeclaration).kind === SyntaxKind.Parameter) {
@@ -20484,7 +20490,7 @@ namespace ts {
}
function checkUnusedClassMembers(node: ClassDeclaration | ClassExpression): void {
if (compilerOptions.noUnusedLocals && !isInAmbientContext(node)) {
if (compilerOptions.noUnusedLocals && !(node.flags & NodeFlags.Ambient)) {
if (node.members) {
for (const member of node.members) {
if (member.kind === SyntaxKind.MethodDeclaration || member.kind === SyntaxKind.PropertyDeclaration) {
@@ -20505,7 +20511,7 @@ namespace ts {
}
function checkUnusedTypeParameters(node: ClassDeclaration | ClassExpression | FunctionDeclaration | MethodDeclaration | FunctionExpression | ArrowFunction | ConstructorDeclaration | SignatureDeclaration | InterfaceDeclaration | TypeAliasDeclaration) {
if (compilerOptions.noUnusedLocals && !isInAmbientContext(node)) {
if (compilerOptions.noUnusedLocals && !(node.flags & NodeFlags.Ambient)) {
if (node.typeParameters) {
// Only report errors on the last declaration for the type parameter container;
// this ensures that all uses have been accounted for.
@@ -20524,7 +20530,7 @@ namespace ts {
}
function checkUnusedModuleMembers(node: ModuleDeclaration | SourceFile): void {
if (compilerOptions.noUnusedLocals && !isInAmbientContext(node)) {
if (compilerOptions.noUnusedLocals && !(node.flags & NodeFlags.Ambient)) {
node.locals.forEach(local => {
if (!local.isReferenced && !local.exportSymbol) {
for (const declaration of local.declarations) {
@@ -20557,7 +20563,7 @@ namespace ts {
function checkCollisionWithArgumentsInGeneratedCode(node: SignatureDeclaration) {
// no rest parameters \ declaration context \ overload - no codegen impact
if (!hasRestParameter(node) || isInAmbientContext(node) || nodeIsMissing((<FunctionLikeDeclaration>node).body)) {
if (!hasRestParameter(node) || node.flags & NodeFlags.Ambient || nodeIsMissing((<FunctionLikeDeclaration>node).body)) {
return;
}
@@ -20583,7 +20589,7 @@ namespace ts {
return false;
}
if (isInAmbientContext(node)) {
if (node.flags & NodeFlags.Ambient) {
// ambient context - no codegen impact
return false;
}
@@ -20648,7 +20654,7 @@ namespace ts {
// bubble up and find containing type
const enclosingClass = getContainingClass(node);
// if containing type was not found or it is ambient - exit (no codegen)
if (!enclosingClass || isInAmbientContext(enclosingClass)) {
if (!enclosingClass || enclosingClass.flags & NodeFlags.Ambient) {
return;
}
@@ -21963,7 +21969,7 @@ namespace ts {
checkClassForDuplicateDeclarations(node);
// Only check for reserved static identifiers on non-ambient context.
if (!isInAmbientContext(node)) {
if (!(node.flags & NodeFlags.Ambient)) {
checkClassForStaticPropertyNameConflicts(node);
}
@@ -22269,7 +22275,7 @@ namespace ts {
}
// In ambient enum declarations that specify no const modifier, enum member declarations that omit
// a value are considered computed members (as opposed to having auto-incremented values).
if (isInAmbientContext(member.parent) && !isConst(member.parent)) {
if (member.parent.flags & NodeFlags.Ambient && !isConst(member.parent)) {
return undefined;
}
// If the member declaration specifies no value, the member is considered a constant enum member.
@@ -22302,7 +22308,7 @@ namespace ts {
else if (isConstEnum) {
error(initializer, Diagnostics.In_const_enum_declarations_member_initializer_must_be_constant_expression);
}
else if (isInAmbientContext(member.parent)) {
else if (member.parent.flags & NodeFlags.Ambient) {
error(initializer, Diagnostics.In_ambient_enum_declarations_member_initializer_must_be_constant_expression);
}
else {
@@ -22415,7 +22421,7 @@ namespace ts {
computeEnumMemberValues(node);
const enumIsConst = isConst(node);
if (compilerOptions.isolatedModules && enumIsConst && isInAmbientContext(node)) {
if (compilerOptions.isolatedModules && enumIsConst && node.flags & NodeFlags.Ambient) {
error(node.name, Diagnostics.Ambient_const_enums_are_not_allowed_when_the_isolatedModules_flag_is_provided);
}
@@ -22467,7 +22473,7 @@ namespace ts {
for (const declaration of declarations) {
if ((declaration.kind === SyntaxKind.ClassDeclaration ||
(declaration.kind === SyntaxKind.FunctionDeclaration && nodeIsPresent((<FunctionLikeDeclaration>declaration).body))) &&
!isInAmbientContext(declaration)) {
!(declaration.flags & NodeFlags.Ambient)) {
return declaration;
}
}
@@ -22492,7 +22498,7 @@ namespace ts {
if (produceDiagnostics) {
// Grammar checking
const isGlobalAugmentation = isGlobalScopeAugmentation(node);
const inAmbientContext = isInAmbientContext(node);
const inAmbientContext = node.flags & NodeFlags.Ambient;
if (isGlobalAugmentation && !inAmbientContext) {
error(node.name, Diagnostics.Augmentations_for_the_global_scope_should_have_declare_modifier_unless_they_appear_in_already_ambient_context);
}
@@ -22711,7 +22717,7 @@ namespace ts {
if (compilerOptions.isolatedModules
&& node.kind === SyntaxKind.ExportSpecifier
&& !(target.flags & SymbolFlags.Value)
&& !isInAmbientContext(node)) {
&& !(node.flags & NodeFlags.Ambient)) {
error(node, Diagnostics.Cannot_re_export_a_type_when_the_isolatedModules_flag_is_provided);
}
}
@@ -22762,7 +22768,7 @@ namespace ts {
if (hasModifier(node, ModifierFlags.Export)) {
markExportAsReferenced(node);
}
if (isInternalModuleImportEqualsDeclaration(node)) {
if (node.moduleReference.kind !== SyntaxKind.ExternalModuleReference) {
const target = resolveAlias(getSymbolOfNode(node));
if (target !== unknownSymbol) {
if (target.flags & SymbolFlags.Value) {
@@ -22778,7 +22784,7 @@ namespace ts {
}
}
else {
if (modulekind >= ModuleKind.ES2015 && !isInAmbientContext(node)) {
if (modulekind >= ModuleKind.ES2015 && !(node.flags & NodeFlags.Ambient)) {
// Import equals declaration is deprecated in es6 or above
grammarErrorOnNode(node, Diagnostics.Import_assignment_cannot_be_used_when_targeting_ECMAScript_modules_Consider_using_import_Asterisk_as_ns_from_mod_import_a_from_mod_import_d_from_mod_or_another_module_format_instead);
}
@@ -22804,7 +22810,7 @@ namespace ts {
const inAmbientExternalModule = node.parent.kind === SyntaxKind.ModuleBlock && isAmbientModule(node.parent.parent);
const inAmbientNamespaceDeclaration = !inAmbientExternalModule && node.parent.kind === SyntaxKind.ModuleBlock &&
!node.moduleSpecifier && isInAmbientContext(node);
!node.moduleSpecifier && node.flags & NodeFlags.Ambient;
if (node.parent.kind !== SyntaxKind.SourceFile && !inAmbientExternalModule && !inAmbientNamespaceDeclaration) {
error(node, Diagnostics.Export_declarations_are_not_permitted_in_a_namespace);
}
@@ -22877,11 +22883,11 @@ namespace ts {
checkExternalModuleExports(container);
if (isInAmbientContext(node) && !isEntityNameExpression(node.expression)) {
if ((node.flags & NodeFlags.Ambient) && !isEntityNameExpression(node.expression)) {
grammarErrorOnNode(node.expression, Diagnostics.The_expression_of_an_export_assignment_must_be_an_identifier_or_qualified_name_in_an_ambient_context);
}
if (node.isExportEquals && !isInAmbientContext(node)) {
if (node.isExportEquals && !(node.flags & NodeFlags.Ambient)) {
if (modulekind >= ModuleKind.ES2015) {
// export assignment is not supported in es6 modules
grammarErrorOnNode(node, Diagnostics.Export_assignment_cannot_be_used_when_targeting_ECMAScript_modules_Consider_using_export_default_or_another_module_format_instead);
@@ -23645,6 +23651,8 @@ namespace ts {
return objectType && getPropertyOfType(objectType, escapeLeadingUnderscores((node as StringLiteral | NumericLiteral).text));
case SyntaxKind.DefaultKeyword:
case SyntaxKind.FunctionKeyword:
case SyntaxKind.EqualsGreaterThanToken:
return getSymbolOfNode(node.parent);
default:
@@ -24513,7 +24521,7 @@ namespace ts {
function checkExternalEmitHelpers(location: Node, helpers: ExternalEmitHelpers) {
if ((requestedExternalEmitHelpers & helpers) !== helpers && compilerOptions.importHelpers) {
const sourceFile = getSourceFileOfNode(location);
if (isEffectiveExternalModule(sourceFile, compilerOptions) && !isInAmbientContext(location)) {
if (isEffectiveExternalModule(sourceFile, compilerOptions) && !(location.flags & NodeFlags.Ambient)) {
const helpersModule = resolveHelpersModule(sourceFile, location);
if (helpersModule !== unknownSymbol) {
const uncheckedHelpers = helpers & ~requestedExternalEmitHelpers;
@@ -24715,7 +24723,7 @@ namespace ts {
else if (node.kind === SyntaxKind.Parameter) {
return grammarErrorOnNode(modifier, Diagnostics._0_modifier_cannot_appear_on_a_parameter, "declare");
}
else if (isInAmbientContext(node.parent) && node.parent.kind === SyntaxKind.ModuleBlock) {
else if ((node.parent.flags & NodeFlags.Ambient) && node.parent.kind === SyntaxKind.ModuleBlock) {
return grammarErrorOnNode(modifier, Diagnostics.A_declare_modifier_cannot_be_used_in_an_already_ambient_context);
}
flags |= ModifierFlags.Ambient;
@@ -24751,7 +24759,7 @@ namespace ts {
if (flags & ModifierFlags.Async) {
return grammarErrorOnNode(modifier, Diagnostics._0_modifier_already_seen, "async");
}
else if (flags & ModifierFlags.Ambient || isInAmbientContext(node.parent)) {
else if (flags & ModifierFlags.Ambient || node.parent.flags & NodeFlags.Ambient) {
return grammarErrorOnNode(modifier, Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async");
}
else if (node.kind === SyntaxKind.Parameter) {
@@ -25099,7 +25107,7 @@ namespace ts {
node.kind === SyntaxKind.FunctionDeclaration ||
node.kind === SyntaxKind.FunctionExpression ||
node.kind === SyntaxKind.MethodDeclaration);
if (isInAmbientContext(node)) {
if (node.flags & NodeFlags.Ambient) {
return grammarErrorOnNode(node.asteriskToken, Diagnostics.Generators_are_not_allowed_in_an_ambient_context);
}
if (!node.body) {
@@ -25286,7 +25294,7 @@ namespace ts {
if (languageVersion < ScriptTarget.ES5) {
return grammarErrorOnNode(accessor.name, Diagnostics.Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher);
}
else if (isInAmbientContext(accessor)) {
else if (accessor.flags & NodeFlags.Ambient) {
return grammarErrorOnNode(accessor.name, Diagnostics.An_accessor_cannot_be_declared_in_an_ambient_context);
}
else if (accessor.body === undefined && !hasModifier(accessor, ModifierFlags.Abstract)) {
@@ -25365,7 +25373,7 @@ namespace ts {
// However, property declarations disallow computed names in general,
// and accessors are not allowed in ambient contexts in general,
// so this error only really matters for methods.
if (isInAmbientContext(node)) {
if (node.flags & NodeFlags.Ambient) {
return checkGrammarForNonSymbolComputedProperty(node.name, Diagnostics.A_computed_property_name_in_an_ambient_context_must_directly_refer_to_a_built_in_symbol);
}
else if (!node.body) {
@@ -25460,7 +25468,7 @@ namespace ts {
function checkGrammarVariableDeclaration(node: VariableDeclaration) {
if (node.parent.parent.kind !== SyntaxKind.ForInStatement && node.parent.parent.kind !== SyntaxKind.ForOfStatement) {
if (isInAmbientContext(node)) {
if (node.flags & NodeFlags.Ambient) {
if (node.initializer) {
if (isConst(node) && !node.type) {
if (!isStringOrNumberLiteralExpression(node.initializer)) {
@@ -25490,7 +25498,7 @@ namespace ts {
}
if (compilerOptions.module !== ModuleKind.ES2015 && compilerOptions.module !== ModuleKind.ESNext && compilerOptions.module !== ModuleKind.System && !compilerOptions.noEmit &&
!isInAmbientContext(node.parent.parent) && hasModifier(node.parent.parent, ModifierFlags.Export)) {
!(node.parent.parent.flags & NodeFlags.Ambient) && hasModifier(node.parent.parent, ModifierFlags.Export)) {
checkESModuleMarker(node.name);
}
@@ -25649,7 +25657,7 @@ namespace ts {
}
}
if (isInAmbientContext(node) && node.initializer) {
if (node.flags & NodeFlags.Ambient && node.initializer) {
return grammarErrorOnFirstToken(node.initializer, Diagnostics.Initializers_are_not_allowed_in_ambient_contexts);
}
}
@@ -25692,11 +25700,11 @@ namespace ts {
}
function checkGrammarSourceFile(node: SourceFile): boolean {
return isInAmbientContext(node) && checkGrammarTopLevelElementsForRequiredDeclareModifier(node);
return !!(node.flags & NodeFlags.Ambient) && checkGrammarTopLevelElementsForRequiredDeclareModifier(node);
}
function checkGrammarStatementInAmbientContext(node: Node): boolean {
if (isInAmbientContext(node)) {
if (node.flags & NodeFlags.Ambient) {
// An accessors is already reported about the ambient context
if (isAccessor(node.parent)) {
return getNodeLinks(node).hasReportedStatementInAmbientContext = true;
-1
View File
@@ -1574,7 +1574,6 @@ namespace ts {
}
if (path.charCodeAt(1) === CharacterCodes.colon) {
if (path.charCodeAt(2) === CharacterCodes.slash) return 3;
return 2;
}
// Per RFC 1738 'file' URI schema has the shape file://<host>/<path>
// if <host> is omitted then it is assumed that host value is 'localhost',
+4
View File
@@ -3797,5 +3797,9 @@
"Infer parameter types from usage.": {
"category": "Message",
"code": 95012
},
"Convert to default import": {
"category": "Message",
"code": 95013
}
}
+1 -1
View File
@@ -2641,7 +2641,7 @@ namespace ts {
/**
* Gets a custom text range to use when emitting source maps.
*/
export function getSourceMapRange(node: Node) {
export function getSourceMapRange(node: Node): SourceMapRange {
const emitNode = node.emitNode;
return (emitNode && emitNode.sourceMapRange) || node;
}
+39 -8
View File
@@ -631,6 +631,7 @@ namespace ts {
}
export function parseIsolatedEntityName(content: string, languageVersion: ScriptTarget): EntityName {
// Choice of `isDeclarationFile` should be arbitrary
initializeState(content, languageVersion, /*syntaxCursor*/ undefined, ScriptKind.JS);
// Prime the scanner.
nextToken();
@@ -643,7 +644,7 @@ namespace ts {
export function parseJsonText(fileName: string, sourceText: string): JsonSourceFile {
initializeState(sourceText, ScriptTarget.ES2015, /*syntaxCursor*/ undefined, ScriptKind.JSON);
// Set source file so that errors will be reported with this file name
sourceFile = createSourceFile(fileName, ScriptTarget.ES2015, ScriptKind.JSON);
sourceFile = createSourceFile(fileName, ScriptTarget.ES2015, ScriptKind.JSON, /*isDeclaration*/ false);
const result = <JsonSourceFile>sourceFile;
// Prime the scanner.
@@ -685,7 +686,16 @@ namespace ts {
identifierCount = 0;
nodeCount = 0;
contextFlags = scriptKind === ScriptKind.JS || scriptKind === ScriptKind.JSX || scriptKind === ScriptKind.JSON ? NodeFlags.JavaScriptFile : NodeFlags.None;
switch (scriptKind) {
case ScriptKind.JS:
case ScriptKind.JSX:
case ScriptKind.JSON:
contextFlags = NodeFlags.JavaScriptFile;
break;
default:
contextFlags = NodeFlags.None;
break;
}
parseErrorBeforeNextFinishedNode = false;
// Initialize and prime the scanner before parsing the source elements.
@@ -709,7 +719,12 @@ namespace ts {
}
function parseSourceFileWorker(fileName: string, languageVersion: ScriptTarget, setParentNodes: boolean, scriptKind: ScriptKind): SourceFile {
sourceFile = createSourceFile(fileName, languageVersion, scriptKind);
const isDeclarationFile = isDeclarationFileName(fileName);
if (isDeclarationFile) {
contextFlags |= NodeFlags.Ambient;
}
sourceFile = createSourceFile(fileName, languageVersion, scriptKind, isDeclarationFile);
sourceFile.flags = contextFlags;
// Prime the scanner.
@@ -786,7 +801,7 @@ namespace ts {
}
}
function createSourceFile(fileName: string, languageVersion: ScriptTarget, scriptKind: ScriptKind): SourceFile {
function createSourceFile(fileName: string, languageVersion: ScriptTarget, scriptKind: ScriptKind, isDeclarationFile: boolean): SourceFile {
// code from createNode is inlined here so createNode won't have to deal with special case of creating source files
// this is quite rare comparing to other nodes and createNode should be as fast as possible
const sourceFile = <SourceFile>new SourceFileConstructor(SyntaxKind.SourceFile, /*pos*/ 0, /* end */ sourceText.length);
@@ -797,7 +812,7 @@ namespace ts {
sourceFile.languageVersion = languageVersion;
sourceFile.fileName = normalizePath(fileName);
sourceFile.languageVariant = getLanguageVariant(scriptKind);
sourceFile.isDeclarationFile = fileExtensionIs(sourceFile.fileName, Extension.Dts);
sourceFile.isDeclarationFile = isDeclarationFile;
sourceFile.scriptKind = scriptKind;
return sourceFile;
@@ -5135,6 +5150,18 @@ namespace ts {
const fullStart = getNodePos();
const decorators = parseDecorators();
const modifiers = parseModifiers();
if (some(modifiers, m => m.kind === SyntaxKind.DeclareKeyword)) {
for (const m of modifiers) {
m.flags |= NodeFlags.Ambient;
}
return doInsideOfContext(NodeFlags.Ambient, () => parseDeclarationWorker(fullStart, decorators, modifiers));
}
else {
return parseDeclarationWorker(fullStart, decorators, modifiers);
}
}
function parseDeclarationWorker(fullStart: number, decorators: NodeArray<Decorator> | undefined, modifiers: NodeArray<Modifier> | undefined): Statement {
switch (token()) {
case SyntaxKind.VarKeyword:
case SyntaxKind.LetKeyword:
@@ -5492,8 +5519,8 @@ namespace ts {
return false;
}
function parseDecorators(): NodeArray<Decorator> {
let list: Decorator[];
function parseDecorators(): NodeArray<Decorator> | undefined {
let list: Decorator[] | undefined;
const listPos = getNodePos();
while (true) {
const decoratorStart = getNodePos();
@@ -6177,7 +6204,7 @@ namespace ts {
export namespace JSDocParser {
export function parseJSDocTypeExpressionForTests(content: string, start: number, length: number): { jsDocTypeExpression: JSDocTypeExpression, diagnostics: Diagnostic[] } | undefined {
initializeState(content, ScriptTarget.Latest, /*_syntaxCursor:*/ undefined, ScriptKind.JS);
sourceFile = createSourceFile("file.js", ScriptTarget.Latest, ScriptKind.JS);
sourceFile = createSourceFile("file.js", ScriptTarget.Latest, ScriptKind.JS, /*isDeclarationFile*/ false);
scanner.setText(content, start, length);
currentToken = scanner.scan();
const jsDocTypeExpression = parseJSDocTypeExpression();
@@ -7507,4 +7534,8 @@ namespace ts {
Value = -1
}
}
function isDeclarationFileName(fileName: string): boolean {
return fileExtensionIs(fileName, Extension.Dts);
}
}
+20 -7
View File
@@ -69,9 +69,8 @@ namespace ts {
export const maxNumberOfFilesToIterateForInvalidation = 256;
interface GetResolutionWithResolvedFileName<T extends ResolutionWithFailedLookupLocations = ResolutionWithFailedLookupLocations, R extends ResolutionWithResolvedFileName = ResolutionWithResolvedFileName> {
(resolution: T): R;
}
type GetResolutionWithResolvedFileName<T extends ResolutionWithFailedLookupLocations = ResolutionWithFailedLookupLocations, R extends ResolutionWithResolvedFileName = ResolutionWithResolvedFileName> =
(resolution: T) => R;
export function createResolutionCache(resolutionHost: ResolutionCacheHost, rootDirForResolution: string): ResolutionCache {
let filesWithChangedSetOfUnresolvedImports: Path[] | undefined;
@@ -320,6 +319,10 @@ namespace ts {
return endsWith(dirPath, "/node_modules");
}
function isNodeModulesAtTypesDirectory(dirPath: Path) {
return endsWith(dirPath, "/node_modules/@types");
}
function isDirectoryAtleastAtLevelFromFSRoot(dirPath: Path, minLevels: number) {
for (let searchIndex = getRootLength(dirPath); minLevels > 0; minLevels--) {
searchIndex = dirPath.indexOf(directorySeparator, searchIndex) + 1;
@@ -560,11 +563,21 @@ namespace ts {
else {
// Some file or directory in the watching directory is created
// Return early if it does not have any of the watching extension or not the custom failed lookup path
if (!isPathWithDefaultFailedLookupExtension(fileOrDirectoryPath) && !customFailedLookupPaths.has(fileOrDirectoryPath)) {
return false;
const dirOfFileOrDirectory = getDirectoryPath(fileOrDirectoryPath);
if (isNodeModulesAtTypesDirectory(dirOfFileOrDirectory) || isNodeModulesDirectory(dirOfFileOrDirectory)) {
// Invalidate any resolution from this directory
isChangedFailedLookupLocation = location => {
const locationPath = resolutionHost.toPath(location);
return locationPath === fileOrDirectoryPath || startsWith(resolutionHost.toPath(location), fileOrDirectoryPath);
};
}
else {
if (!isPathWithDefaultFailedLookupExtension(fileOrDirectoryPath) && !customFailedLookupPaths.has(fileOrDirectoryPath)) {
return false;
}
// Resolution need to be invalidated if failed lookup location is same as the file or directory getting created
isChangedFailedLookupLocation = location => resolutionHost.toPath(location) === fileOrDirectoryPath;
}
// Resolution need to be invalidated if failed lookup location is same as the file or directory getting created
isChangedFailedLookupLocation = location => resolutionHost.toPath(location) === fileOrDirectoryPath;
}
const hasChangedFailedLookupLocation = (resolution: ResolutionWithFailedLookupLocations) => some(resolution.failedLookupLocations, isChangedFailedLookupLocation);
const invalidatedFilesCount = filesWithInvalidatedResolutions && filesWithInvalidatedResolutions.size;
+1 -3
View File
@@ -2,9 +2,7 @@
/// <reference path="diagnosticInformationMap.generated.ts"/>
namespace ts {
export interface ErrorCallback {
(message: DiagnosticMessage, length: number): void;
}
export type ErrorCallback = (message: DiagnosticMessage, length: number) => void;
/* @internal */
export function tokenIsIdentifierOrKeyword(token: SyntaxKind): boolean {
+7
View File
@@ -225,6 +225,13 @@ namespace ts {
if (parsed !== node) {
// If the node has been transformed by a `before` transformer, perform no ellision on it
// As the type information we would attempt to lookup to perform ellision is potentially unavailable for the synthesized nodes
// We do not reuse `visitorWorker`, as the ellidable statement syntax kinds are technically unrecognized by the switch-case in `visitTypeScript`,
// and will trigger debug failures when debug verbosity is turned up
if (node.transformFlags & TransformFlags.ContainsTypeScript) {
// This node contains TypeScript, so we should visit its children.
return visitEachChild(node, visitor, context);
}
// Otherwise, we can just return the node
return node;
}
switch (node.kind) {
+12 -11
View File
@@ -454,7 +454,8 @@ namespace ts {
/* @internal */
PossiblyContainsDynamicImport = 1 << 19,
JSDoc = 1 << 20, // If node was parsed inside jsdoc
/* @internal */ InWithStatement = 1 << 21, // If any ancestor of node was the `statement` of a WithStatement (not the `expression`)
/* @internal */ Ambient = 1 << 21, // If node was inside an ambient context -- a declaration file, or inside something with the `declare` modifier.
/* @internal */ InWithStatement = 1 << 22, // If any ancestor of node was the `statement` of a WithStatement (not the `expression`)
BlockScoped = Let | Const,
@@ -462,7 +463,7 @@ namespace ts {
ReachabilityAndEmitFlags = ReachabilityCheckFlags | HasAsyncFunctions,
// Parsing context flags
ContextFlags = DisallowInContext | YieldContext | DecoratorContext | AwaitContext | JavaScriptFile | InWithStatement,
ContextFlags = DisallowInContext | YieldContext | DecoratorContext | AwaitContext | JavaScriptFile | InWithStatement | Ambient,
// Exclude these flags when parsing a Type
TypeExcludesFlags = YieldContext | AwaitContext,
@@ -2471,9 +2472,13 @@ namespace ts {
readFile(path: string): string | undefined;
}
export interface WriteFileCallback {
(fileName: string, data: string, writeByteOrderMark: boolean, onError: ((message: string) => void) | undefined, sourceFiles: ReadonlyArray<SourceFile>): void;
}
export type WriteFileCallback = (
fileName: string,
data: string,
writeByteOrderMark: boolean,
onError: ((message: string) => void) | undefined,
sourceFiles: ReadonlyArray<SourceFile>,
) => void;
export class OperationCanceledException { }
@@ -3582,9 +3587,7 @@ namespace ts {
}
/* @internal */
export interface TypeMapper {
(t: TypeParameter): Type;
}
export type TypeMapper = (t: TypeParameter) => Type;
export const enum InferencePriority {
Contravariant = 1 << 0, // Inference from contravariant position
@@ -4193,9 +4196,7 @@ namespace ts {
}
/* @internal */
export interface HasInvalidatedResolution {
(sourceFile: Path): boolean;
}
export type HasInvalidatedResolution = (sourceFile: Path) => boolean;
export interface CompilerHost extends ModuleResolutionHost {
getSourceFile(fileName: string, languageVersion: ScriptTarget, onError?: (message: string) => void, shouldCreateNewSourceFile?: boolean): SourceFile | undefined;
-10
View File
@@ -1728,16 +1728,6 @@ namespace ts {
return false;
}
export function isInAmbientContext(node: Node): boolean {
while (node) {
if (hasModifier(node, ModifierFlags.Ambient) || (node.kind === SyntaxKind.SourceFile && (node as SourceFile).isDeclarationFile)) {
return true;
}
node = node.parent;
}
return false;
}
// True if the given identifier, string literal, or number literal is the name of a declaration node
export function isDeclarationName(name: Node): boolean {
switch (name.kind) {
+23 -22
View File
@@ -470,6 +470,10 @@ namespace FourSlash {
public select(startMarker: string, endMarker: string) {
const start = this.getMarkerByName(startMarker), end = this.getMarkerByName(endMarker);
ts.Debug.assert(start.fileName === end.fileName);
if (this.activeFile.fileName !== start.fileName) {
this.openFile(start.fileName);
}
this.goToPosition(start.position);
this.selectionEnd = end.position;
}
@@ -873,37 +877,34 @@ namespace FourSlash {
* @param spanIndex the index of the range that the completion item's replacement text span should match
*/
public verifyCompletionListDoesNotContain(entryId: ts.Completions.CompletionEntryIdentifier, expectedText?: string, expectedDocumentation?: string, expectedKind?: string, spanIndex?: number) {
const that = this;
let replacementSpan: ts.TextSpan;
if (spanIndex !== undefined) {
replacementSpan = this.getTextSpanForRangeAtIndex(spanIndex);
}
function filterByTextOrDocumentation(entry: ts.CompletionEntry) {
const details = that.getCompletionEntryDetails(entry.name);
const documentation = details && ts.displayPartsToString(details.documentation);
const text = details && ts.displayPartsToString(details.displayParts);
// If any of the expected values are undefined, assume that users don't
// care about them.
if (replacementSpan && !TestState.textSpansEqual(replacementSpan, entry.replacementSpan)) {
return false;
}
else if (expectedText && text !== expectedText) {
return false;
}
else if (expectedDocumentation && documentation !== expectedDocumentation) {
return false;
}
return true;
}
const completions = this.getCompletionListAtCaret();
if (completions) {
let filterCompletions = completions.entries.filter(e => e.name === entryId.name && e.source === entryId.source);
filterCompletions = expectedKind ? filterCompletions.filter(e => e.kind === expectedKind) : filterCompletions;
filterCompletions = filterCompletions.filter(filterByTextOrDocumentation);
filterCompletions = filterCompletions.filter(entry => {
const details = this.getCompletionEntryDetails(entry.name);
const documentation = details && ts.displayPartsToString(details.documentation);
const text = details && ts.displayPartsToString(details.displayParts);
// If any of the expected values are undefined, assume that users don't
// care about them.
if (replacementSpan && !TestState.textSpansEqual(replacementSpan, entry.replacementSpan)) {
return false;
}
else if (expectedText && text !== expectedText) {
return false;
}
else if (expectedDocumentation && documentation !== expectedDocumentation) {
return false;
}
return true;
});
if (filterCompletions.length !== 0) {
// After filtered using all present criterion, if there are still symbol left in the list
// then these symbols must meet the criterion for Not supposed to be in the list. So we
+12 -6
View File
@@ -479,7 +479,7 @@ namespace Utils {
}
namespace Harness {
export interface IO {
export interface Io {
newLine(): string;
getCurrentDirectory(): string;
useCaseSensitiveFileNames(): boolean;
@@ -502,7 +502,7 @@ namespace Harness {
tryEnableSourceMapsForHost?(): void;
getEnvironmentVariable?(name: string): string;
}
export let IO: IO;
export let IO: Io;
// harness always uses one kind of new line
// But note that `parseTestData` in `fourslash.ts` uses "\n"
@@ -784,9 +784,15 @@ namespace Harness {
? IO.newLine() + `//# sourceURL=${IO.resolvePath(tcServicesFileName)}`
: "");
export interface SourceMapEmitterCallback {
(emittedFile: string, emittedLine: number, emittedColumn: number, sourceFile: string, sourceLine: number, sourceColumn: number, sourceName: string): void;
}
export type SourceMapEmitterCallback = (
emittedFile: string,
emittedLine: number,
emittedColumn: number,
sourceFile: string,
sourceLine: number,
sourceColumn: number,
sourceName: string,
) => void;
// Settings
export let userSpecifiedRoot = "";
@@ -2145,7 +2151,7 @@ namespace Harness {
return filePath.indexOf(Harness.libFolder) === 0;
}
export function getDefaultLibraryFile(io: Harness.IO): Harness.Compiler.TestFile {
export function getDefaultLibraryFile(io: Harness.Io): Harness.Compiler.TestFile {
const libFile = Harness.userSpecifiedRoot + Harness.libFolder + Harness.Compiler.defaultLibFileName;
return { unitName: libFile, content: io.readFile(libFile) };
}
+3 -3
View File
@@ -544,9 +544,9 @@ namespace Harness.LanguageService {
getClassifier(): ts.Classifier { return new ClassifierShimProxy(this.factory.createClassifierShim(this.host)); }
getPreProcessedFileInfo(fileName: string, fileContents: string): ts.PreProcessedFileInfo {
let shimResult: {
referencedFiles: ts.IFileReference[];
typeReferenceDirectives: ts.IFileReference[];
importedFiles: ts.IFileReference[];
referencedFiles: ts.ShimsFileReference[];
typeReferenceDirectives: ts.ShimsFileReference[];
importedFiles: ts.ShimsFileReference[];
isLibFile: boolean;
};
+15 -15
View File
@@ -14,19 +14,19 @@ interface FileInformation {
interface FindFileResult {
}
interface IOLogFile {
interface IoLogFile {
path: string;
codepage: number;
result?: FileInformation;
}
interface IOLog {
interface IoLog {
timestamp: string;
arguments: string[];
executingPath: string;
currentDirectory: string;
useCustomLibraryFile?: boolean;
filesRead: IOLogFile[];
filesRead: IoLogFile[];
filesWritten: {
path: string;
contents?: string;
@@ -80,16 +80,16 @@ interface IOLog {
interface PlaybackControl {
startReplayFromFile(logFileName: string): void;
startReplayFromString(logContents: string): void;
startReplayFromData(log: IOLog): void;
startReplayFromData(log: IoLog): void;
endReplay(): void;
startRecord(logFileName: string): void;
endRecord(): void;
}
namespace Playback {
let recordLog: IOLog = undefined;
let replayLog: IOLog = undefined;
let replayFilesRead: ts.Map<IOLogFile> | undefined = undefined;
let recordLog: IoLog = undefined;
let replayLog: IoLog = undefined;
let replayFilesRead: ts.Map<IoLogFile> | undefined = undefined;
let recordLogFileNameBase = "";
interface Memoized<T> {
@@ -110,11 +110,11 @@ namespace Playback {
return run;
}
export interface PlaybackIO extends Harness.IO, PlaybackControl { }
export interface PlaybackIO extends Harness.Io, PlaybackControl { }
export interface PlaybackSystem extends ts.System, PlaybackControl { }
function createEmptyLog(): IOLog {
function createEmptyLog(): IoLog {
return {
timestamp: (new Date()).toString(),
arguments: [],
@@ -134,7 +134,7 @@ namespace Playback {
};
}
export function newStyleLogIntoOldStyleLog(log: IOLog, host: ts.System | Harness.IO, baseName: string) {
export function newStyleLogIntoOldStyleLog(log: IoLog, host: ts.System | Harness.Io, baseName: string) {
for (const file of log.filesAppended) {
if (file.contentsPath) {
file.contents = host.readFile(ts.combinePaths(baseName, file.contentsPath));
@@ -167,7 +167,7 @@ namespace Playback {
return path;
}
export function oldStyleLogIntoNewStyleLog(log: IOLog, writeFile: typeof Harness.IO.writeFile, baseTestName: string) {
export function oldStyleLogIntoNewStyleLog(log: IoLog, writeFile: typeof Harness.IO.writeFile, baseTestName: string) {
if (log.filesAppended) {
for (const file of log.filesAppended) {
if (file.contents !== undefined) {
@@ -210,8 +210,8 @@ namespace Playback {
}
function initWrapper(wrapper: PlaybackSystem, underlying: ts.System): void;
function initWrapper(wrapper: PlaybackIO, underlying: Harness.IO): void;
function initWrapper(wrapper: PlaybackSystem | PlaybackIO, underlying: ts.System | Harness.IO): void {
function initWrapper(wrapper: PlaybackIO, underlying: Harness.Io): void;
function initWrapper(wrapper: PlaybackSystem | PlaybackIO, underlying: ts.System | Harness.Io): void {
ts.forEach(Object.keys(underlying), prop => {
(<any>wrapper)[prop] = (<any>underlying)[prop];
});
@@ -261,7 +261,7 @@ namespace Playback {
}
};
function generateTsconfig(newLog: IOLog): undefined | { compilerOptions: ts.CompilerOptions, files: string[] } {
function generateTsconfig(newLog: IoLog): undefined | { compilerOptions: ts.CompilerOptions, files: string[] } {
if (newLog.filesRead.some(file => /tsconfig.+json$/.test(file.path))) {
return;
}
@@ -426,7 +426,7 @@ namespace Playback {
// console.log("Swallowed write operation during replay: " + name);
}
export function wrapIO(underlying: Harness.IO): PlaybackIO {
export function wrapIO(underlying: Harness.Io): PlaybackIO {
const wrapper: PlaybackIO = <any>{};
initWrapper(wrapper, underlying);
+13 -1
View File
@@ -18,6 +18,7 @@
/// <reference path="fourslashRunner.ts" />
/// <reference path="projectsRunner.ts" />
/// <reference path="rwcRunner.ts" />
/// <reference path="userRunner.ts" />
/// <reference path="harness.ts" />
/// <reference path="./parallel/shared.ts" />
@@ -59,6 +60,8 @@ function createRunner(kind: TestRunnerKind): RunnerBase {
return new RWCRunner();
case "test262":
return new Test262BaselineRunner();
case "user":
return new UserCodeRunner();
}
ts.Debug.fail(`Unknown runner kind ${kind}`);
}
@@ -175,6 +178,9 @@ function handleTestConfig() {
case "test262":
runners.push(new Test262BaselineRunner());
break;
case "user":
runners.push(new UserCodeRunner());
break;
}
}
}
@@ -196,6 +202,11 @@ function handleTestConfig() {
runners.push(new FourSlashRunner(FourSlashTestType.ShimsWithPreprocess));
runners.push(new FourSlashRunner(FourSlashTestType.Server));
// runners.push(new GeneratedFourslashRunner());
// CRON-only tests
if (Utils.getExecutionEnvironment() !== Utils.ExecutionEnvironment.Browser && process.env.TRAVIS_EVENT_TYPE === "cron") {
runners.push(new UserCodeRunner());
}
}
if (runUnitTests === undefined) {
runUnitTests = runners.length !== 1; // Don't run unit tests when running only one runner if unit tests were not explicitly asked for
@@ -215,8 +226,9 @@ function beginTests() {
}
}
let isWorker: boolean;
function startTestEnvironment() {
const isWorker = handleTestConfig();
isWorker = handleTestConfig();
if (Utils.getExecutionEnvironment() !== Utils.ExecutionEnvironment.Browser) {
if (isWorker) {
return Harness.Parallel.Worker.start();
+1 -1
View File
@@ -1,7 +1,7 @@
/// <reference path="harness.ts" />
type TestRunnerKind = CompilerTestKind | FourslashTestKind | "project" | "rwc" | "test262";
type TestRunnerKind = CompilerTestKind | FourslashTestKind | "project" | "rwc" | "test262" | "user";
type CompilerTestKind = "conformance" | "compiler";
type FourslashTestKind = "fourslash" | "fourslash-shims" | "fourslash-shims-pp" | "fourslash-server";
+2 -2
View File
@@ -6,7 +6,7 @@
/* tslint:disable:no-null-keyword */
namespace RWC {
function runWithIOLog(ioLog: IOLog, fn: (oldIO: Harness.IO) => void) {
function runWithIOLog(ioLog: IoLog, fn: (oldIO: Harness.Io) => void) {
const oldIO = Harness.IO;
const wrappedIO = Playback.wrapIO(oldIO);
@@ -58,7 +58,7 @@ namespace RWC {
this.timeout(800000); // Allow long timeouts for RWC compilations
let opts: ts.ParsedCommandLine;
const ioLog: IOLog = Playback.newStyleLogIntoOldStyleLog(JSON.parse(Harness.IO.readFile(`internal/cases/rwc/${jsonPath}/test.json`)), Harness.IO, `internal/cases/rwc/${baseName}`);
const ioLog: IoLog = Playback.newStyleLogIntoOldStyleLog(JSON.parse(Harness.IO.readFile(`internal/cases/rwc/${jsonPath}/test.json`)), Harness.IO, `internal/cases/rwc/${baseName}`);
currentDirectory = ioLog.currentDirectory;
useCustomLibraryFile = ioLog.useCustomLibraryFile;
runWithIOLog(ioLog, () => {
+1
View File
@@ -92,6 +92,7 @@
"projectsRunner.ts",
"loggedIO.ts",
"rwcRunner.ts",
"userRunner.ts",
"test262Runner.ts",
"./parallel/shared.ts",
"./parallel/host.ts",
+3 -3
View File
@@ -591,7 +591,7 @@ module m3 { }\
const index = 0;
const newTextAndChange = withInsert(oldText, index, "declare ");
compareTrees(oldText, newTextAndChange.text, newTextAndChange.textChangeRange, 3);
compareTrees(oldText, newTextAndChange.text, newTextAndChange.textChangeRange, 0);
});
it("Insert function above arrow function with comment", () => {
@@ -674,7 +674,7 @@ module m3 { }\
const oldText = ScriptSnapshot.fromString(source);
const newTextAndChange = withInsert(oldText, 0, "{");
compareTrees(oldText, newTextAndChange.text, newTextAndChange.textChangeRange, 9);
compareTrees(oldText, newTextAndChange.text, newTextAndChange.textChangeRange, 4);
});
it("Removing block around function declarations", () => {
@@ -683,7 +683,7 @@ module m3 { }\
const oldText = ScriptSnapshot.fromString(source);
const newTextAndChange = withDelete(oldText, 0, "{".length);
compareTrees(oldText, newTextAndChange.text, newTextAndChange.textChangeRange, 9);
compareTrees(oldText, newTextAndChange.text, newTextAndChange.textChangeRange, 4);
});
it("Moving methods from class to object literal", () => {
+23
View File
@@ -20,6 +20,15 @@ namespace ts {
};
return (file: ts.SourceFile) => file;
}
function replaceNumberWith2(context: ts.TransformationContext) {
function visitor(node: Node): Node {
if (isNumericLiteral(node)) {
return createNumericLiteral("2");
}
return visitEachChild(node, visitor, context);
}
return (file: ts.SourceFile) => visitNode(file, visitor);
}
function replaceIdentifiersNamedOldNameWithNewName(context: ts.TransformationContext) {
const previousOnSubstituteNode = context.onSubstituteNode;
@@ -101,6 +110,20 @@ namespace ts {
}).outputText;
});
testBaseline("transformTypesInExportDefault", () => {
return ts.transpileModule(`
export default (foo: string) => { return 1; }
`, {
transformers: {
before: [replaceNumberWith2],
},
compilerOptions: {
target: ts.ScriptTarget.ESNext,
newLine: NewLineKind.CarriageReturnLineFeed,
}
}).outputText;
});
testBaseline("synthesizedClassAndNamespaceCombination", () => {
return ts.transpileModule("", {
transformers: {
+1 -1
View File
@@ -1988,7 +1988,7 @@ declare module "fs" {
checkProgramActualFiles(watch(), mapDefined(files, f => f === configFile ? undefined : f.path));
file1.content = "var zz30 = 100;";
host.reloadFS(files, /*invokeDirectoryWatcherInsteadOfFileChanged*/ true);
host.reloadFS(files, { invokeDirectoryWatcherInsteadOfFileChanged: true });
host.runQueuedTimeoutCallbacks();
checkProgramActualFiles(watch(), mapDefined(files, f => f === configFile ? undefined : f.path));
@@ -3445,6 +3445,117 @@ namespace ts.projectSystem {
diags = session.executeCommand(getErrRequest).response as server.protocol.Diagnostic[];
verifyNoDiagnostics(diags);
});
function assertEvent(actualOutput: string, expectedEvent: protocol.Event, host: TestServerHost) {
assert.equal(actualOutput, server.formatMessage(expectedEvent, nullLogger, Utils.byteLength, host.newLine));
}
function checkErrorMessage(host: TestServerHost, eventName: "syntaxDiag" | "semanticDiag", diagnostics: protocol.DiagnosticEventBody) {
const outputs = host.getOutput();
assert.isTrue(outputs.length >= 1, outputs.toString());
const event: protocol.Event = {
seq: 0,
type: "event",
event: eventName,
body: diagnostics
};
assertEvent(outputs[0], event, host);
}
function checkCompleteEvent(host: TestServerHost, numberOfCurrentEvents: number, expectedSequenceId: number) {
const outputs = host.getOutput();
assert.equal(outputs.length, numberOfCurrentEvents, outputs.toString());
const event: protocol.RequestCompletedEvent = {
seq: 0,
type: "event",
event: "requestCompleted",
body: {
request_seq: expectedSequenceId
}
};
assertEvent(outputs[numberOfCurrentEvents - 1], event, host);
}
function checkProjectUpdatedInBackgroundEvent(host: TestServerHost, openFiles: string[]) {
const outputs = host.getOutput();
assert.equal(outputs.length, 1, outputs.toString());
const event: protocol.ProjectsUpdatedInBackgroundEvent = {
seq: 0,
type: "event",
event: "projectsUpdatedInBackground",
body: {
openFiles
}
};
assertEvent(outputs[0], event, host);
}
it("npm install @types works", () => {
const folderPath = "/a/b/projects/temp";
const file1: FileOrFolder = {
path: `${folderPath}/a.ts`,
content: 'import f = require("pad")'
};
const files = [file1, libFile];
const host = createServerHost(files);
const session = createSession(host, { canUseEvents: true });
const service = session.getProjectService();
session.executeCommandSeq<protocol.OpenRequest>({
command: server.CommandNames.Open,
arguments: {
file: file1.path,
fileContent: file1.content,
scriptKindName: "TS",
projectRootPath: folderPath
}
});
checkNumberOfProjects(service, { inferredProjects: 1 });
host.clearOutput();
const expectedSequenceId = session.getNextSeq();
session.executeCommandSeq<protocol.GeterrRequest>({
command: server.CommandNames.Geterr,
arguments: {
delay: 0,
files: [file1.path]
}
});
host.checkTimeoutQueueLengthAndRun(1);
checkErrorMessage(host, "syntaxDiag", { file: file1.path, diagnostics: [] });
host.clearOutput();
host.runQueuedImmediateCallbacks();
const moduleNotFound = Diagnostics.Cannot_find_module_0;
const startOffset = file1.content.indexOf('"') + 1;
checkErrorMessage(host, "semanticDiag", {
file: file1.path, diagnostics: [{
start: { line: 1, offset: startOffset },
end: { line: 1, offset: startOffset + '"pad"'.length },
text: formatStringFromArgs(moduleNotFound.message, ["pad"]),
code: moduleNotFound.code,
category: DiagnosticCategory[moduleNotFound.category].toLowerCase()
}]
});
checkCompleteEvent(host, 2, expectedSequenceId);
host.clearOutput();
const padIndex: FileOrFolder = {
path: `${folderPath}/node_modules/@types/pad/index.d.ts`,
content: "export = pad;declare function pad(length: number, text: string, char ?: string): string;"
};
files.push(padIndex);
host.reloadFS(files, { ignoreWatchInvokedWithTriggerAsFileCreate: true });
host.runQueuedTimeoutCallbacks();
checkProjectUpdatedInBackgroundEvent(host, [file1.path]);
host.clearOutput();
host.runQueuedTimeoutCallbacks();
checkErrorMessage(host, "syntaxDiag", { file: file1.path, diagnostics: [] });
host.clearOutput();
host.runQueuedImmediateCallbacks();
checkErrorMessage(host, "semanticDiag", { file: file1.path, diagnostics: [] });
});
});
describe("Configure file diagnostics events", () => {
+51
View File
@@ -0,0 +1,51 @@
/// <reference path="harness.ts"/>
/// <reference path="runnerbase.ts" />
class UserCodeRunner extends RunnerBase {
private static readonly testDir = "tests/cases/user/";
public enumerateTestFiles() {
return Harness.IO.getDirectories(UserCodeRunner.testDir);
}
public kind(): TestRunnerKind {
return "user";
}
/** Setup the runner's tests so that they are ready to be executed by the harness
* The first test should be a describe/it block that sets up the harness's compiler instance appropriately
*/
public initializeTests(): void {
// Read in and evaluate the test list
const testList = this.tests && this.tests.length ? this.tests : this.enumerateTestFiles();
describe(`${this.kind()} code samples`, () => {
for (let i = 0; i < testList.length; i++) {
this.runTest(testList[i]);
}
});
}
private runTest(directoryName: string) {
describe(directoryName, () => {
const cp = require("child_process");
const path = require("path");
it("should build successfully", () => {
const cwd = path.join(__dirname, "../../", UserCodeRunner.testDir, directoryName);
const timeout = 600000; // 10 minutes
const stdio = isWorker ? "pipe" : "inherit";
const install = cp.spawnSync(`npm`, ["i"], { cwd, timeout, shell: true, stdio });
if (install.status !== 0) throw new Error(`NPM Install for ${directoryName} failed!`);
Harness.Baseline.runBaseline(`${this.kind()}/${directoryName}.log`, () => {
const result = cp.spawnSync(`node`, ["../../../../built/local/tsc.js"], { cwd, timeout, shell: true });
return `Exit Code: ${result.status}
Standard output:
${result.stdout.toString().replace(/\r\n/g, "\n")}
Standard error:
${result.stderr.toString().replace(/\r\n/g, "\n")}`;
});
});
});
}
}
+14 -6
View File
@@ -226,6 +226,11 @@ interface Array<T> {}`
directoryName: string;
}
export interface ReloadWatchInvokeOptions {
invokeDirectoryWatcherInsteadOfFileChanged: boolean;
ignoreWatchInvokedWithTriggerAsFileCreate: boolean;
}
export class TestServerHost implements server.ServerHost, FormatDiagnosticsHost {
args: string[] = [];
@@ -270,7 +275,7 @@ interface Array<T> {}`
return s;
}
reloadFS(fileOrFolderList: ReadonlyArray<FileOrFolder>, invokeDirectoryWatcherInsteadOfFileChanged?: boolean) {
reloadFS(fileOrFolderList: ReadonlyArray<FileOrFolder>, options?: Partial<ReloadWatchInvokeOptions>) {
const mapNewLeaves = createMap<true>();
const isNewFs = this.fs.size === 0;
fileOrFolderList = fileOrFolderList.concat(this.withSafeList ? safeList : []);
@@ -291,7 +296,7 @@ interface Array<T> {}`
// Update file
if (currentEntry.content !== fileOrDirectory.content) {
currentEntry.content = fileOrDirectory.content;
if (invokeDirectoryWatcherInsteadOfFileChanged) {
if (options && options.invokeDirectoryWatcherInsteadOfFileChanged) {
this.invokeDirectoryWatcher(getDirectoryPath(currentEntry.fullPath), currentEntry.fullPath);
}
else {
@@ -314,7 +319,7 @@ interface Array<T> {}`
}
}
else {
this.ensureFileOrFolder(fileOrDirectory);
this.ensureFileOrFolder(fileOrDirectory, options && options.ignoreWatchInvokedWithTriggerAsFileCreate);
}
}
@@ -331,12 +336,12 @@ interface Array<T> {}`
}
}
ensureFileOrFolder(fileOrDirectory: FileOrFolder) {
ensureFileOrFolder(fileOrDirectory: FileOrFolder, ignoreWatchInvokedWithTriggerAsFileCreate?: boolean) {
if (isString(fileOrDirectory.content)) {
const file = this.toFile(fileOrDirectory);
Debug.assert(!this.fs.get(file.path));
const baseFolder = this.ensureFolder(getDirectoryPath(file.fullPath));
this.addFileOrFolderInFolder(baseFolder, file);
this.addFileOrFolderInFolder(baseFolder, file, ignoreWatchInvokedWithTriggerAsFileCreate);
}
else {
const fullPath = getNormalizedAbsolutePath(fileOrDirectory.path, this.currentDirectory);
@@ -365,10 +370,13 @@ interface Array<T> {}`
return folder;
}
private addFileOrFolderInFolder(folder: Folder, fileOrDirectory: File | Folder) {
private addFileOrFolderInFolder(folder: Folder, fileOrDirectory: File | Folder, ignoreWatch?: boolean) {
folder.entries.push(fileOrDirectory);
this.fs.set(fileOrDirectory.path, fileOrDirectory);
if (ignoreWatch) {
return;
}
if (isFile(fileOrDirectory)) {
this.invokeFileWatcher(fileOrDirectory.fullPath, FileWatcherEventKind.Created);
}
+779 -776
View File
File diff suppressed because it is too large Load Diff
+7 -1
View File
@@ -50,10 +50,16 @@ interface ArrayConstructor {
/**
* Creates an array from an array-like object.
* @param arrayLike An array-like object to convert to an array.
*/
from<T>(arrayLike: ArrayLike<T>): T[];
/**
* Creates an array from an iterable object.
* @param arrayLike An array-like object to convert to an array.
* @param mapfn A mapping function to call on every element of the array.
* @param thisArg Value of 'this' used to invoke the mapfn.
*/
from<T, U = T>(arrayLike: ArrayLike<T>, mapfn?: (v: T, k: number) => U, thisArg?: any): U[];
from<T, U>(arrayLike: ArrayLike<T>, mapfn: (v: T, k: number) => U, thisArg?: any): U[];
/**
* Returns a new array from a set of elements.
+7 -1
View File
@@ -48,13 +48,19 @@ interface Array<T> {
}
interface ArrayConstructor {
/**
* Creates an array from an iterable object.
* @param iterable An iterable object to convert to an array.
*/
from<T>(iterable: Iterable<T>): T[];
/**
* Creates an array from an iterable object.
* @param iterable An iterable object to convert to an array.
* @param mapfn A mapping function to call on every element of the array.
* @param thisArg Value of 'this' used to invoke the mapfn.
*/
from<T, U = T>(iterable: Iterable<T>, mapfn?: (v: T, k: number) => U, thisArg?: any): U[];
from<T, U>(iterable: Iterable<T>, mapfn: (v: T, k: number) => U, thisArg?: any): U[];
}
interface ReadonlyArray<T> {
+91 -87
View File
@@ -37,7 +37,7 @@ interface IDBIndexParameters {
interface IDBObjectStoreParameters {
autoIncrement?: boolean;
keyPath?: IDBKeyPath | null;
keyPath?: string | string[];
}
interface KeyAlgorithm {
@@ -74,7 +74,7 @@ interface RequestInit {
body?: any;
cache?: RequestCache;
credentials?: RequestCredentials;
headers?: Headers | string[][];
headers?: HeadersInit;
integrity?: string;
keepalive?: boolean;
method?: string;
@@ -86,7 +86,7 @@ interface RequestInit {
}
interface ResponseInit {
headers?: Headers | string[][];
headers?: HeadersInit;
status?: number;
statusText?: string;
}
@@ -441,10 +441,10 @@ 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: FileReader, ev: MSBaseReaderEventMap[K]) => any, useCapture?: boolean): void;
addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void;
removeEventListener<K extends keyof MSBaseReaderEventMap>(type: K, listener: (this: FileReader, ev: MSBaseReaderEventMap[K]) => any, useCapture?: boolean): void;
removeEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void;
addEventListener<K extends keyof MSBaseReaderEventMap>(type: K, listener: (this: FileReader, ev: MSBaseReaderEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void;
removeEventListener<K extends keyof MSBaseReaderEventMap>(type: K, listener: (this: FileReader, ev: MSBaseReaderEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void;
}
declare var FileReader: {
@@ -472,7 +472,7 @@ interface Headers {
declare var Headers: {
prototype: Headers;
new(init?: Headers | string[][] | object): Headers;
new(init?: HeadersInit): Headers;
};
interface IDBCursor {
@@ -524,11 +524,12 @@ interface IDBDatabase extends EventTarget {
createObjectStore(name: string, optionalParameters?: IDBObjectStoreParameters): IDBObjectStore;
deleteObjectStore(name: string): void;
transaction(storeNames: string | string[], mode?: IDBTransactionMode): IDBTransaction;
addEventListener(type: "versionchange", listener: (ev: IDBVersionChangeEvent) => 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;
removeEventListener<K extends keyof IDBDatabaseEventMap>(type: K, listener: (this: IDBDatabase, ev: IDBDatabaseEventMap[K]) => any, useCapture?: boolean): void;
removeEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void;
addEventListener(type: "versionchange", listener: (this: IDBDatabase, ev: IDBVersionChangeEvent) => any, options?: boolean | AddEventListenerOptions): void;
removeEventListener(type: "versionchange", listener: (this: IDBDatabase, ev: IDBVersionChangeEvent) => any, options?: boolean | EventListenerOptions): void;
addEventListener<K extends keyof IDBDatabaseEventMap>(type: K, listener: (this: IDBDatabase, ev: IDBDatabaseEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void;
removeEventListener<K extends keyof IDBDatabaseEventMap>(type: K, listener: (this: IDBDatabase, ev: IDBDatabaseEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void;
}
declare var IDBDatabase: {
@@ -612,10 +613,10 @@ interface IDBOpenDBRequestEventMap extends IDBRequestEventMap {
interface IDBOpenDBRequest extends IDBRequest {
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;
removeEventListener<K extends keyof IDBOpenDBRequestEventMap>(type: K, listener: (this: IDBOpenDBRequest, ev: IDBOpenDBRequestEventMap[K]) => any, useCapture?: boolean): void;
removeEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void;
addEventListener<K extends keyof IDBOpenDBRequestEventMap>(type: K, listener: (this: IDBOpenDBRequest, ev: IDBOpenDBRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void;
removeEventListener<K extends keyof IDBOpenDBRequestEventMap>(type: K, listener: (this: IDBOpenDBRequest, ev: IDBOpenDBRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void;
}
declare var IDBOpenDBRequest: {
@@ -636,10 +637,10 @@ interface IDBRequest extends EventTarget {
readonly result: any;
source: IDBObjectStore | IDBIndex | IDBCursor;
readonly transaction: IDBTransaction;
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;
removeEventListener<K extends keyof IDBRequestEventMap>(type: K, listener: (this: IDBRequest, ev: IDBRequestEventMap[K]) => any, useCapture?: boolean): void;
removeEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void;
addEventListener<K extends keyof IDBRequestEventMap>(type: K, listener: (this: IDBRequest, ev: IDBRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void;
removeEventListener<K extends keyof IDBRequestEventMap>(type: K, listener: (this: IDBRequest, ev: IDBRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void;
}
declare var IDBRequest: {
@@ -665,10 +666,10 @@ interface IDBTransaction extends EventTarget {
readonly READ_ONLY: string;
readonly READ_WRITE: string;
readonly VERSION_CHANGE: string;
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;
removeEventListener<K extends keyof IDBTransactionEventMap>(type: K, listener: (this: IDBTransaction, ev: IDBTransactionEventMap[K]) => any, useCapture?: boolean): void;
removeEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void;
addEventListener<K extends keyof IDBTransactionEventMap>(type: K, listener: (this: IDBTransaction, ev: IDBTransactionEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void;
removeEventListener<K extends keyof IDBTransactionEventMap>(type: K, listener: (this: IDBTransaction, ev: IDBTransactionEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void;
}
declare var IDBTransaction: {
@@ -733,10 +734,10 @@ interface MessagePort extends EventTarget {
close(): void;
postMessage(message?: any, transfer?: any[]): void;
start(): 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;
removeEventListener<K extends keyof MessagePortEventMap>(type: K, listener: (this: MessagePort, ev: MessagePortEventMap[K]) => any, useCapture?: boolean): void;
removeEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void;
addEventListener<K extends keyof MessagePortEventMap>(type: K, listener: (this: MessagePort, ev: MessagePortEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void;
removeEventListener<K extends keyof MessagePortEventMap>(type: K, listener: (this: MessagePort, ev: MessagePortEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void;
}
declare var MessagePort: {
@@ -764,10 +765,10 @@ interface Notification extends EventTarget {
readonly tag: string;
readonly title: string;
close(): void;
addEventListener<K extends keyof NotificationEventMap>(type: K, listener: (this: Notification, ev: NotificationEventMap[K]) => any, useCapture?: boolean): void;
addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void;
removeEventListener<K extends keyof NotificationEventMap>(type: K, listener: (this: Notification, ev: NotificationEventMap[K]) => any, useCapture?: boolean): void;
removeEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void;
addEventListener<K extends keyof NotificationEventMap>(type: K, listener: (this: Notification, ev: NotificationEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void;
removeEventListener<K extends keyof NotificationEventMap>(type: K, listener: (this: Notification, ev: NotificationEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void;
}
declare var Notification: {
@@ -994,10 +995,10 @@ interface ServiceWorker extends EventTarget, AbstractWorker {
readonly scriptURL: USVString;
readonly state: ServiceWorkerState;
postMessage(message: any, transfer?: any[]): void;
addEventListener<K extends keyof ServiceWorkerEventMap>(type: K, listener: (this: ServiceWorker, ev: ServiceWorkerEventMap[K]) => any, useCapture?: boolean): void;
addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void;
removeEventListener<K extends keyof ServiceWorkerEventMap>(type: K, listener: (this: ServiceWorker, ev: ServiceWorkerEventMap[K]) => any, useCapture?: boolean): void;
removeEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void;
addEventListener<K extends keyof ServiceWorkerEventMap>(type: K, listener: (this: ServiceWorker, ev: ServiceWorkerEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void;
removeEventListener<K extends keyof ServiceWorkerEventMap>(type: K, listener: (this: ServiceWorker, ev: ServiceWorkerEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void;
}
declare var ServiceWorker: {
@@ -1021,10 +1022,10 @@ interface ServiceWorkerRegistration extends EventTarget {
showNotification(title: string, options?: NotificationOptions): Promise<void>;
unregister(): Promise<boolean>;
update(): Promise<void>;
addEventListener<K extends keyof ServiceWorkerRegistrationEventMap>(type: K, listener: (this: ServiceWorkerRegistration, ev: ServiceWorkerRegistrationEventMap[K]) => any, useCapture?: boolean): void;
addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void;
removeEventListener<K extends keyof ServiceWorkerRegistrationEventMap>(type: K, listener: (this: ServiceWorkerRegistration, ev: ServiceWorkerRegistrationEventMap[K]) => any, useCapture?: boolean): void;
removeEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void;
addEventListener<K extends keyof ServiceWorkerRegistrationEventMap>(type: K, listener: (this: ServiceWorkerRegistration, ev: ServiceWorkerRegistrationEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void;
removeEventListener<K extends keyof ServiceWorkerRegistrationEventMap>(type: K, listener: (this: ServiceWorkerRegistration, ev: ServiceWorkerRegistrationEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void;
}
declare var ServiceWorkerRegistration: {
@@ -1089,10 +1090,10 @@ interface WebSocket extends EventTarget {
readonly CLOSING: number;
readonly CONNECTING: number;
readonly OPEN: number;
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;
removeEventListener<K extends keyof WebSocketEventMap>(type: K, listener: (this: WebSocket, ev: WebSocketEventMap[K]) => any, useCapture?: boolean): void;
removeEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void;
addEventListener<K extends keyof WebSocketEventMap>(type: K, listener: (this: WebSocket, ev: WebSocketEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void;
removeEventListener<K extends keyof WebSocketEventMap>(type: K, listener: (this: WebSocket, ev: WebSocketEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void;
}
declare var WebSocket: {
@@ -1112,10 +1113,10 @@ interface Worker extends EventTarget, AbstractWorker {
onmessage: (this: Worker, ev: MessageEvent) => any;
postMessage(message: any, transfer?: any[]): void;
terminate(): 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;
removeEventListener<K extends keyof WorkerEventMap>(type: K, listener: (this: Worker, ev: WorkerEventMap[K]) => any, useCapture?: boolean): void;
removeEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void;
addEventListener<K extends keyof WorkerEventMap>(type: K, listener: (this: Worker, ev: WorkerEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void;
removeEventListener<K extends keyof WorkerEventMap>(type: K, listener: (this: Worker, ev: WorkerEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void;
}
declare var Worker: {
@@ -1155,10 +1156,10 @@ interface XMLHttpRequest extends EventTarget, XMLHttpRequestEventTarget {
readonly LOADING: number;
readonly OPENED: number;
readonly UNSENT: number;
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;
removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, useCapture?: boolean): void;
removeEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void;
addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void;
removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void;
}
declare var XMLHttpRequest: {
@@ -1172,10 +1173,10 @@ declare var XMLHttpRequest: {
};
interface XMLHttpRequestUpload extends EventTarget, XMLHttpRequestEventTarget {
addEventListener<K extends keyof XMLHttpRequestEventTargetEventMap>(type: K, listener: (this: XMLHttpRequestUpload, ev: XMLHttpRequestEventTargetEventMap[K]) => any, useCapture?: boolean): void;
addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void;
removeEventListener<K extends keyof XMLHttpRequestEventTargetEventMap>(type: K, listener: (this: XMLHttpRequestUpload, ev: XMLHttpRequestEventTargetEventMap[K]) => any, useCapture?: boolean): void;
removeEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void;
addEventListener<K extends keyof XMLHttpRequestEventTargetEventMap>(type: K, listener: (this: XMLHttpRequestUpload, ev: XMLHttpRequestEventTargetEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void;
removeEventListener<K extends keyof XMLHttpRequestEventTargetEventMap>(type: K, listener: (this: XMLHttpRequestUpload, ev: XMLHttpRequestEventTargetEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void;
}
declare var XMLHttpRequestUpload: {
@@ -1189,10 +1190,10 @@ interface AbstractWorkerEventMap {
interface AbstractWorker {
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;
removeEventListener<K extends keyof AbstractWorkerEventMap>(type: K, listener: (this: AbstractWorker, ev: AbstractWorkerEventMap[K]) => any, useCapture?: boolean): void;
removeEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void;
addEventListener<K extends keyof AbstractWorkerEventMap>(type: K, listener: (this: AbstractWorker, ev: AbstractWorkerEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void;
removeEventListener<K extends keyof AbstractWorkerEventMap>(type: K, listener: (this: AbstractWorker, ev: AbstractWorkerEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void;
}
interface Body {
@@ -1229,10 +1230,10 @@ interface MSBaseReader {
readonly DONE: number;
readonly EMPTY: number;
readonly LOADING: number;
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;
removeEventListener<K extends keyof MSBaseReaderEventMap>(type: K, listener: (this: MSBaseReader, ev: MSBaseReaderEventMap[K]) => any, useCapture?: boolean): void;
removeEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void;
addEventListener<K extends keyof MSBaseReaderEventMap>(type: K, listener: (this: MSBaseReader, ev: MSBaseReaderEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void;
removeEventListener<K extends keyof MSBaseReaderEventMap>(type: K, listener: (this: MSBaseReader, ev: MSBaseReaderEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void;
}
interface NavigatorBeacon {
@@ -1286,10 +1287,10 @@ interface XMLHttpRequestEventTarget {
onloadstart: (this: XMLHttpRequest, ev: Event) => any;
onprogress: (this: XMLHttpRequest, ev: ProgressEvent) => any;
ontimeout: (this: XMLHttpRequest, 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;
removeEventListener<K extends keyof XMLHttpRequestEventTargetEventMap>(type: K, listener: (this: XMLHttpRequestEventTarget, ev: XMLHttpRequestEventTargetEventMap[K]) => any, useCapture?: boolean): void;
removeEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void;
addEventListener<K extends keyof XMLHttpRequestEventTargetEventMap>(type: K, listener: (this: XMLHttpRequestEventTarget, ev: XMLHttpRequestEventTargetEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void;
removeEventListener<K extends keyof XMLHttpRequestEventTargetEventMap>(type: K, listener: (this: XMLHttpRequestEventTarget, ev: XMLHttpRequestEventTargetEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void;
}
interface Client {
@@ -1324,10 +1325,10 @@ interface DedicatedWorkerGlobalScope extends WorkerGlobalScope {
onmessage: (this: DedicatedWorkerGlobalScope, ev: MessageEvent) => any;
close(): void;
postMessage(message: any, transfer?: any[]): 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;
removeEventListener<K extends keyof DedicatedWorkerGlobalScopeEventMap>(type: K, listener: (this: DedicatedWorkerGlobalScope, ev: DedicatedWorkerGlobalScopeEventMap[K]) => any, useCapture?: boolean): void;
removeEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void;
addEventListener<K extends keyof DedicatedWorkerGlobalScopeEventMap>(type: K, listener: (this: DedicatedWorkerGlobalScope, ev: DedicatedWorkerGlobalScopeEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void;
removeEventListener<K extends keyof DedicatedWorkerGlobalScopeEventMap>(type: K, listener: (this: DedicatedWorkerGlobalScope, ev: DedicatedWorkerGlobalScopeEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void;
}
declare var DedicatedWorkerGlobalScope: {
@@ -1437,10 +1438,10 @@ interface ServiceWorkerGlobalScope extends WorkerGlobalScope {
onsync: (this: ServiceWorkerGlobalScope, ev: SyncEvent) => any;
readonly registration: ServiceWorkerRegistration;
skipWaiting(): Promise<void>;
addEventListener<K extends keyof ServiceWorkerGlobalScopeEventMap>(type: K, listener: (this: ServiceWorkerGlobalScope, ev: ServiceWorkerGlobalScopeEventMap[K]) => any, useCapture?: boolean): void;
addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void;
removeEventListener<K extends keyof ServiceWorkerGlobalScopeEventMap>(type: K, listener: (this: ServiceWorkerGlobalScope, ev: ServiceWorkerGlobalScopeEventMap[K]) => any, useCapture?: boolean): void;
removeEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void;
addEventListener<K extends keyof ServiceWorkerGlobalScopeEventMap>(type: K, listener: (this: ServiceWorkerGlobalScope, ev: ServiceWorkerGlobalScopeEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void;
removeEventListener<K extends keyof ServiceWorkerGlobalScopeEventMap>(type: K, listener: (this: ServiceWorkerGlobalScope, ev: ServiceWorkerGlobalScopeEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void;
}
declare var ServiceWorkerGlobalScope: {
@@ -1484,10 +1485,10 @@ interface WorkerGlobalScope extends EventTarget, WorkerUtils, WindowConsole, Glo
msWriteProfilerMark(profilerMarkName: string): void;
createImageBitmap(image: ImageBitmap | ImageData | Blob, options?: ImageBitmapOptions): Promise<ImageBitmap>;
createImageBitmap(image: ImageBitmap | ImageData | Blob, sx: number, sy: number, sw: number, sh: number, options?: ImageBitmapOptions): Promise<ImageBitmap>;
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;
removeEventListener<K extends keyof WorkerGlobalScopeEventMap>(type: K, listener: (this: WorkerGlobalScope, ev: WorkerGlobalScopeEventMap[K]) => any, useCapture?: boolean): void;
removeEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void;
addEventListener<K extends keyof WorkerGlobalScopeEventMap>(type: K, listener: (this: WorkerGlobalScope, ev: WorkerGlobalScopeEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void;
removeEventListener<K extends keyof WorkerGlobalScopeEventMap>(type: K, listener: (this: WorkerGlobalScope, ev: WorkerGlobalScopeEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void;
}
declare var WorkerGlobalScope: {
@@ -1544,8 +1545,10 @@ interface BroadcastChannel extends EventTarget {
onmessageerror: (ev: MessageEvent) => any;
close(): void;
postMessage(message: any): void;
addEventListener<K extends keyof BroadcastChannelEventMap>(type: K, listener: (this: BroadcastChannel, ev: BroadcastChannelEventMap[K]) => any, useCapture?: boolean): void;
addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void;
addEventListener<K extends keyof BroadcastChannelEventMap>(type: K, listener: (this: BroadcastChannel, ev: BroadcastChannelEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void;
removeEventListener<K extends keyof BroadcastChannelEventMap>(type: K, listener: (this: BroadcastChannel, ev: BroadcastChannelEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void;
}
declare var BroadcastChannel: {
@@ -1875,10 +1878,10 @@ declare function btoa(rawString: string): string;
declare var console: Console;
declare function fetch(input: RequestInfo, init?: RequestInit): Promise<Response>;
declare function dispatchEvent(evt: Event): boolean;
declare function addEventListener<K extends keyof DedicatedWorkerGlobalScopeEventMap>(type: K, listener: (this: DedicatedWorkerGlobalScope, ev: DedicatedWorkerGlobalScopeEventMap[K]) => any, useCapture?: boolean): void;
declare function addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void;
declare function removeEventListener<K extends keyof DedicatedWorkerGlobalScopeEventMap>(type: K, listener: (this: DedicatedWorkerGlobalScope, ev: DedicatedWorkerGlobalScopeEventMap[K]) => any, useCapture?: boolean): void;
declare function removeEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void;
declare function addEventListener<K extends keyof DedicatedWorkerGlobalScopeEventMap>(type: K, listener: (this: DedicatedWorkerGlobalScope, ev: DedicatedWorkerGlobalScopeEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
declare function addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void;
declare function removeEventListener<K extends keyof DedicatedWorkerGlobalScopeEventMap>(type: K, listener: (this: DedicatedWorkerGlobalScope, ev: DedicatedWorkerGlobalScopeEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
declare function removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void;
type AlgorithmIdentifier = string | Algorithm;
type BodyInit = any;
type IDBKeyPath = string;
@@ -1887,6 +1890,7 @@ type USVString = string;
type IDBValidKey = number | string | Date | IDBArrayKey;
type BufferSource = ArrayBuffer | ArrayBufferView;
type FormDataEntryValue = string | File;
type HeadersInit = string[][] | { [key: string]: string };
type IDBCursorDirection = "next" | "nextunique" | "prev" | "prevunique";
type IDBRequestReadyState = "pending" | "done";
type IDBTransactionMode = "readonly" | "readwrite" | "versionchange";
+2 -2
View File
@@ -192,8 +192,8 @@ namespace ts.server {
};
}
getCompletionEntryDetails(fileName: string, position: number, entryName: string): CompletionEntryDetails {
const args: protocol.CompletionDetailsRequestArgs = { ...this.createFileLocationRequestArgs(fileName, position), entryNames: [entryName] };
getCompletionEntryDetails(fileName: string, position: number, entryName: string, _options: FormatCodeOptions | FormatCodeSettings | undefined, source: string | undefined): CompletionEntryDetails {
const args: protocol.CompletionDetailsRequestArgs = { ...this.createFileLocationRequestArgs(fileName, position), entryNames: [{ name: entryName, source }] };
const request = this.processRequest<protocol.CompletionDetailsRequest>(CommandNames.CompletionDetails, args);
const response = this.processResponse<protocol.CompletionDetailsResponse>(request);
+1 -3
View File
@@ -78,9 +78,7 @@ namespace ts.server {
export type ProjectServiceEvent = ProjectsUpdatedInBackgroundEvent | ConfigFileDiagEvent | ProjectLanguageServiceStateEvent | ProjectInfoTelemetryEvent;
export interface ProjectServiceEventHandler {
(event: ProjectServiceEvent): void;
}
export type ProjectServiceEventHandler = (event: ProjectServiceEvent) => void;
export interface SafeList {
[name: string]: { match: RegExp, exclude?: (string | number)[][], types?: string[] };
+1 -3
View File
@@ -98,9 +98,7 @@ namespace ts.server {
getExternalFiles?(proj: Project): string[];
}
export interface PluginModuleFactory {
(mod: { typescript: typeof ts }): PluginModule;
}
export type PluginModuleFactory = (mod: { typescript: typeof ts }) => PluginModule;
/**
* The project root can be script info - if root is present,
+9 -9
View File
@@ -10,7 +10,7 @@ namespace ts.server {
charCount(): number;
lineCount(): number;
isLeaf(): this is LineLeaf;
walk(rangeStart: number, rangeLength: number, walkFns: ILineIndexWalker): void;
walk(rangeStart: number, rangeLength: number, walkFns: LineIndexWalker): void;
}
export interface AbsolutePositionAndLineText {
@@ -27,7 +27,7 @@ namespace ts.server {
PostEnd
}
interface ILineIndexWalker {
interface LineIndexWalker {
goSubtree: boolean;
done: boolean;
leaf(relativeStart: number, relativeLength: number, lineCollection: LineLeaf): void;
@@ -37,7 +37,7 @@ namespace ts.server {
parent: LineNode, nodeType: CharRangeSection): void;
}
class EditWalker implements ILineIndexWalker {
class EditWalker implements LineIndexWalker {
goSubtree = true;
get done() { return false; }
@@ -429,7 +429,7 @@ namespace ts.server {
}
}
walk(rangeStart: number, rangeLength: number, walkFns: ILineIndexWalker) {
walk(rangeStart: number, rangeLength: number, walkFns: LineIndexWalker) {
this.root.walk(rangeStart, rangeLength, walkFns);
}
@@ -458,7 +458,7 @@ namespace ts.server {
const walkFns = {
goSubtree: true,
done: false,
leaf(this: ILineIndexWalker, relativeStart: number, relativeLength: number, ll: LineLeaf) {
leaf(this: LineIndexWalker, relativeStart: number, relativeLength: number, ll: LineLeaf) {
if (!f(ll, relativeStart, relativeLength)) {
this.done = true;
}
@@ -580,7 +580,7 @@ namespace ts.server {
}
}
private execWalk(rangeStart: number, rangeLength: number, walkFns: ILineIndexWalker, childIndex: number, nodeType: CharRangeSection) {
private execWalk(rangeStart: number, rangeLength: number, walkFns: LineIndexWalker, childIndex: number, nodeType: CharRangeSection) {
if (walkFns.pre) {
walkFns.pre(rangeStart, rangeLength, this.children[childIndex], this, nodeType);
}
@@ -596,14 +596,14 @@ namespace ts.server {
return walkFns.done;
}
private skipChild(relativeStart: number, relativeLength: number, childIndex: number, walkFns: ILineIndexWalker, nodeType: CharRangeSection) {
private skipChild(relativeStart: number, relativeLength: number, childIndex: number, walkFns: LineIndexWalker, nodeType: CharRangeSection) {
if (walkFns.pre && (!walkFns.done)) {
walkFns.pre(relativeStart, relativeLength, this.children[childIndex], this, nodeType);
walkFns.goSubtree = true;
}
}
walk(rangeStart: number, rangeLength: number, walkFns: ILineIndexWalker) {
walk(rangeStart: number, rangeLength: number, walkFns: LineIndexWalker) {
// assume (rangeStart < this.totalChars) && (rangeLength <= this.totalChars)
let childIndex = 0;
let childCharCount = this.children[childIndex].charCount();
@@ -814,7 +814,7 @@ namespace ts.server {
return true;
}
walk(rangeStart: number, rangeLength: number, walkFns: ILineIndexWalker) {
walk(rangeStart: number, rangeLength: number, walkFns: LineIndexWalker) {
walkFns.leaf(rangeStart, rangeLength, this);
}
+3 -3
View File
@@ -3,7 +3,7 @@
/// <reference path="session.ts" />
namespace ts.server {
interface IOSessionOptions {
interface IoSessionOptions {
host: ServerHost;
cancellationToken: ServerCancellationToken;
canUseEvents: boolean;
@@ -529,7 +529,7 @@ namespace ts.server {
}
class IOSession extends Session {
constructor(options: IOSessionOptions) {
constructor(options: IoSessionOptions) {
const { host, installerEventPort, globalTypingsCacheLocation, typingSafeListLocation, typesMapLocation, npmLocation, canUseEvents } = options;
const typingsInstaller = disableAutomaticTypingAcquisition
? undefined
@@ -933,7 +933,7 @@ namespace ts.server {
const disableAutomaticTypingAcquisition = hasArgument("--disableAutomaticTypingAcquisition");
const telemetryEnabled = hasArgument(Arguments.EnableTelemetry);
const options: IOSessionOptions = {
const options: IoSessionOptions = {
host: sys,
cancellationToken,
installerEventPort: eventPort,
+1
View File
@@ -5,6 +5,7 @@ namespace ts.server {
projectRootPath: Path;
}
// tslint:disable-next-line interface-name (for backwards-compatibility)
export interface ITypingsInstaller {
isKnownTypesPackageName(name: string): boolean;
installPackage(options: InstallPackageOptionsWithProjectRootPath): Promise<ApplyCodeActionCommandResult>;
@@ -248,7 +248,7 @@ namespace ts.server.typingsInstaller {
this.log.writeLine(`Npm config file: '${npmConfigPath}' is missing, creating new one...`);
}
this.ensureDirectoryExists(directory, this.installTypingHost);
this.installTypingHost.writeFile(npmConfigPath, "{}");
this.installTypingHost.writeFile(npmConfigPath, '{ "description": "", "repository": "", "license": "" }');
}
}
+1 -1
View File
@@ -31,7 +31,7 @@ namespace ts.BreakpointResolver {
}
// Cannot set breakpoint in ambient declarations
if (isInAmbientContext(tokenAtLocation)) {
if (tokenAtLocation.flags & NodeFlags.Ambient) {
return undefined;
}
@@ -4,9 +4,9 @@
namespace ts.formatting {
export class RuleOperationContext {
private readonly customContextChecks: { (context: FormattingContext): boolean; }[];
private readonly customContextChecks: ((context: FormattingContext) => boolean)[];
constructor(...funcs: { (context: FormattingContext): boolean; }[]) {
constructor(...funcs: ((context: FormattingContext) => boolean)[]) {
this.customContextChecks = funcs;
}
+1 -1
View File
@@ -335,7 +335,7 @@ namespace ts.refactor.extractSymbol {
return [createDiagnosticForNode(nodeToCheck, Messages.StatementOrExpressionExpected)];
}
if (isInAmbientContext(nodeToCheck)) {
if (nodeToCheck.flags & NodeFlags.Ambient) {
return [createDiagnosticForNode(nodeToCheck, Messages.CannotExtractAmbientBlock)];
}
+1
View File
@@ -2,3 +2,4 @@
/// <reference path="convertFunctionToEs6Class.ts" />
/// <reference path="extractSymbol.ts" />
/// <reference path="installTypesForPackage.ts" />
/// <reference path="useDefaultImport.ts" />
@@ -0,0 +1,96 @@
/* @internal */
namespace ts.refactor.installTypesForPackage {
const actionName = "Convert to default import";
const useDefaultImport: Refactor = {
name: actionName,
description: getLocaleSpecificMessage(Diagnostics.Convert_to_default_import),
getEditsForAction,
getAvailableActions,
};
registerRefactor(useDefaultImport);
function getAvailableActions(context: RefactorContext): ApplicableRefactorInfo[] | undefined {
const { file, startPosition, program } = context;
if (!program.getCompilerOptions().allowSyntheticDefaultImports) {
return undefined;
}
const importInfo = getConvertibleImportAtPosition(file, startPosition);
if (!importInfo) {
return undefined;
}
const module = ts.getResolvedModule(file, importInfo.moduleSpecifier.text);
const resolvedFile = program.getSourceFile(module.resolvedFileName);
if (!(resolvedFile.externalModuleIndicator && isExportAssignment(resolvedFile.externalModuleIndicator) && resolvedFile.externalModuleIndicator.isExportEquals)) {
return undefined;
}
return [
{
name: useDefaultImport.name,
description: useDefaultImport.description,
actions: [
{
description: useDefaultImport.description,
name: actionName,
},
],
},
];
}
function getEditsForAction(context: RefactorContext, _actionName: string): RefactorEditInfo | undefined {
const { file, startPosition } = context;
Debug.assertEqual(actionName, _actionName);
const importInfo = getConvertibleImportAtPosition(file, startPosition);
if (!importInfo) {
return undefined;
}
const { importStatement, name, moduleSpecifier } = importInfo;
const newImportClause = createImportClause(name, /*namedBindings*/ undefined);
const newImportStatement = ts.createImportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, newImportClause, moduleSpecifier);
return {
edits: textChanges.ChangeTracker.with(context, t => t.replaceNode(file, importStatement, newImportStatement)),
renameFilename: undefined,
renameLocation: undefined,
};
}
function getConvertibleImportAtPosition(
file: SourceFile,
startPosition: number,
): { importStatement: AnyImportSyntax, name: Identifier, moduleSpecifier: StringLiteral } | undefined {
let node = getTokenAtPosition(file, startPosition, /*includeJsDocComment*/ false);
while (true) {
switch (node.kind) {
case SyntaxKind.ImportEqualsDeclaration:
const eq = node as ImportEqualsDeclaration;
const { moduleReference } = eq;
return moduleReference.kind === SyntaxKind.ExternalModuleReference && isStringLiteral(moduleReference.expression)
? { importStatement: eq, name: eq.name, moduleSpecifier: moduleReference.expression }
: undefined;
case SyntaxKind.ImportDeclaration:
const d = node as ImportDeclaration;
const { importClause } = d;
return !importClause.name && importClause.namedBindings.kind === SyntaxKind.NamespaceImport && isStringLiteral(d.moduleSpecifier)
? { importStatement: d, name: importClause.namedBindings.name, moduleSpecifier: d.moduleSpecifier }
: undefined;
// For known child node kinds of convertible imports, try again with parent node.
case SyntaxKind.NamespaceImport:
case SyntaxKind.ExternalModuleReference:
case SyntaxKind.ImportKeyword:
case SyntaxKind.Identifier:
case SyntaxKind.StringLiteral:
case SyntaxKind.AsteriskToken:
break;
default:
return undefined;
}
node = node.parent;
}
}
}
+5 -1
View File
@@ -41,6 +41,7 @@ namespace ts {
kind === SyntaxKind.Identifier ? new IdentifierObject(SyntaxKind.Identifier, pos, end) :
new TokenObject(kind, pos, end);
node.parent = parent;
node.flags = parent.flags & NodeFlags.ContextFlags;
return node;
}
@@ -276,7 +277,10 @@ namespace ts {
}
public getText(sourceFile?: SourceFile): string {
return (sourceFile || this.getSourceFile()).text.substring(this.getStart(), this.getEnd());
if (!sourceFile) {
sourceFile = this.getSourceFile();
}
return sourceFile.text.substring(this.getStart(sourceFile), this.getEnd());
}
public getChildCount(): number {
+3 -3
View File
@@ -106,7 +106,7 @@ namespace ts {
///
// Note: This is being using by the host (VS) and is marshaled back and forth.
// When changing this make sure the changes are reflected in the managed side as well
export interface IFileReference {
export interface ShimsFileReference {
path: string;
position: number;
length: number;
@@ -1104,11 +1104,11 @@ namespace ts {
);
}
private convertFileReferences(refs: FileReference[]): IFileReference[] {
private convertFileReferences(refs: FileReference[]): ShimsFileReference[] {
if (!refs) {
return undefined;
}
const result: IFileReference[] = [];
const result: ShimsFileReference[] = [];
for (const ref of refs) {
result.push({
path: normalizeSlashes(ref.fileName),
+4 -2
View File
@@ -489,8 +489,10 @@ namespace ts.SymbolDisplay {
addNewLineIfDisplayPartsExist();
if (symbolKind) {
pushTypePart(symbolKind);
displayParts.push(spacePart());
addFullSymbolName(symbol);
if (!some(symbol.declarations, d => isArrowFunction(d) || (isFunctionExpression(d) || isClassExpression(d)) && !d.name)) {
displayParts.push(spacePart());
addFullSymbolName(symbol);
}
}
}
+1
View File
@@ -86,6 +86,7 @@ namespace ts {
* snapshot is observably immutable. i.e. the same calls with the same parameters will return
* the same values.
*/
// tslint:disable-next-line interface-name
export interface IScriptSnapshot {
/** Gets a portion of the script snapshot specified by [start, end). */
getText(start: number, end: number): string;
+1 -1
View File
@@ -947,7 +947,7 @@ namespace ts {
if (flags & ModifierFlags.Static) result.push(ScriptElementKindModifier.staticModifier);
if (flags & ModifierFlags.Abstract) result.push(ScriptElementKindModifier.abstractModifier);
if (flags & ModifierFlags.Export) result.push(ScriptElementKindModifier.exportedModifier);
if (isInAmbientContext(node)) result.push(ScriptElementKindModifier.ambientModifier);
if (node.flags & NodeFlags.Ambient) result.push(ScriptElementKindModifier.ambientModifier);
return result.length > 0 ? result.join(",") : ScriptElementKindModifier.none;
}
+7 -15
View File
@@ -411,7 +411,7 @@ declare namespace ts {
BlockScoped = 3,
ReachabilityCheckFlags = 384,
ReachabilityAndEmitFlags = 1408,
ContextFlags = 2193408,
ContextFlags = 6387712,
TypeExcludesFlags = 20480,
}
enum ModifierFlags {
@@ -1623,9 +1623,7 @@ declare namespace ts {
fileExists(path: string): boolean;
readFile(path: string): string | undefined;
}
interface WriteFileCallback {
(fileName: string, data: string, writeByteOrderMark: boolean, onError: ((message: string) => void) | undefined, sourceFiles: ReadonlyArray<SourceFile>): void;
}
type WriteFileCallback = (fileName: string, data: string, writeByteOrderMark: boolean, onError: ((message: string) => void) | undefined, sourceFiles: ReadonlyArray<SourceFile>) => void;
class OperationCanceledException {
}
interface CancellationToken {
@@ -3096,9 +3094,7 @@ declare namespace ts {
function isGetAccessor(node: Node): node is GetAccessorDeclaration;
}
declare namespace ts {
interface ErrorCallback {
(message: DiagnosticMessage, length: number): void;
}
type ErrorCallback = (message: DiagnosticMessage, length: number) => void;
interface Scanner {
getStartPos(): number;
getToken(): SyntaxKind;
@@ -7146,11 +7142,9 @@ declare namespace ts.server {
create(createInfo: PluginCreateInfo): LanguageService;
getExternalFiles?(proj: Project): string[];
}
interface PluginModuleFactory {
(mod: {
typescript: typeof ts;
}): PluginModule;
}
type PluginModuleFactory = (mod: {
typescript: typeof ts;
}) => PluginModule;
/**
* The project root can be script info - if root is present,
* or it could be just normalized path if root wasnt present on the host(only for non inferred project)
@@ -7420,9 +7414,7 @@ declare namespace ts.server {
readonly dts: number;
}
type ProjectServiceEvent = ProjectsUpdatedInBackgroundEvent | ConfigFileDiagEvent | ProjectLanguageServiceStateEvent | ProjectInfoTelemetryEvent;
interface ProjectServiceEventHandler {
(event: ProjectServiceEvent): void;
}
type ProjectServiceEventHandler = (event: ProjectServiceEvent) => void;
interface SafeList {
[name: string]: {
match: RegExp;
+3 -7
View File
@@ -411,7 +411,7 @@ declare namespace ts {
BlockScoped = 3,
ReachabilityCheckFlags = 384,
ReachabilityAndEmitFlags = 1408,
ContextFlags = 2193408,
ContextFlags = 6387712,
TypeExcludesFlags = 20480,
}
enum ModifierFlags {
@@ -1623,9 +1623,7 @@ declare namespace ts {
fileExists(path: string): boolean;
readFile(path: string): string | undefined;
}
interface WriteFileCallback {
(fileName: string, data: string, writeByteOrderMark: boolean, onError: ((message: string) => void) | undefined, sourceFiles: ReadonlyArray<SourceFile>): void;
}
type WriteFileCallback = (fileName: string, data: string, writeByteOrderMark: boolean, onError: ((message: string) => void) | undefined, sourceFiles: ReadonlyArray<SourceFile>) => void;
class OperationCanceledException {
}
interface CancellationToken {
@@ -2759,9 +2757,7 @@ declare namespace ts {
let sys: System;
}
declare namespace ts {
interface ErrorCallback {
(message: DiagnosticMessage, length: number): void;
}
type ErrorCallback = (message: DiagnosticMessage, length: number) => void;
interface Scanner {
getStartPos(): number;
getToken(): SyntaxKind;
@@ -55,8 +55,8 @@ var myList: MyList<number>;
>MyList : MyList<T>
var xs = [list, myList]; // {}[]
>xs : List<number>[]
>[list, myList] : List<number>[]
>xs : (List<number> | MyList<number>)[]
>[list, myList] : (List<number> | MyList<number>)[]
>list : List<number>
>myList : MyList<number>
@@ -0,0 +1,13 @@
tests/cases/compiler/declarationEmitRelativeModuleError.ts(5,16): error TS2436: Ambient module declaration cannot specify relative module name.
==== tests/cases/compiler/declarationEmitRelativeModuleError.ts (1 errors) ====
declare module "b:block" { // <-- no error anymore
}
declare module "b:/block" { // <-- still an error
~~~~~~~~~~
!!! error TS2436: Ambient module declaration cannot specify relative module name.
}
@@ -0,0 +1,10 @@
//// [declarationEmitRelativeModuleError.ts]
declare module "b:block" { // <-- no error anymore
}
declare module "b:/block" { // <-- still an error
}
//// [declarationEmitRelativeModuleError.js]
@@ -0,0 +1,9 @@
=== tests/cases/compiler/declarationEmitRelativeModuleError.ts ===
declare module "b:block" { // <-- no error anymore
No type information for this code.
No type information for this code.}
No type information for this code.
No type information for this code.declare module "b:/block" { // <-- still an error
No type information for this code.
No type information for this code.}
No type information for this code.
@@ -0,0 +1,9 @@
=== tests/cases/compiler/declarationEmitRelativeModuleError.ts ===
declare module "b:block" { // <-- no error anymore
No type information for this code.
No type information for this code.}
No type information for this code.
No type information for this code.declare module "b:/block" { // <-- still an error
No type information for this code.
No type information for this code.}
No type information for this code.
@@ -866,9 +866,9 @@ define(function () {
>'UnknownMobile' : "UnknownMobile"
isArray = ('isArray' in Array) ?
>isArray = ('isArray' in Array) ? Array.isArray : function (value) { return Object.prototype.toString.call(value) === '[object Array]'; } : (value: any) => boolean
>isArray = ('isArray' in Array) ? Array.isArray : function (value) { return Object.prototype.toString.call(value) === '[object Array]'; } : (arg: any) => arg is any[]
>isArray : any
>('isArray' in Array) ? Array.isArray : function (value) { return Object.prototype.toString.call(value) === '[object Array]'; } : (value: any) => boolean
>('isArray' in Array) ? Array.isArray : function (value) { return Object.prototype.toString.call(value) === '[object Array]'; } : (arg: any) => arg is any[]
>('isArray' in Array) : boolean
>'isArray' in Array : boolean
>'isArray' : "isArray"
@@ -0,0 +1,13 @@
//// [freshLiteralTypesInIntersections.ts]
// Repro from #19657
declare function func<A extends string, B extends A>(a: A, b: B[]): (ab: A & B) => void;
const q = func("x" as "x" | "y", ["x"]);
q("x");
//// [freshLiteralTypesInIntersections.js]
"use strict";
// Repro from #19657
var q = func("x", ["x"]);
q("x");
@@ -0,0 +1,23 @@
=== tests/cases/compiler/freshLiteralTypesInIntersections.ts ===
// Repro from #19657
declare function func<A extends string, B extends A>(a: A, b: B[]): (ab: A & B) => void;
>func : Symbol(func, Decl(freshLiteralTypesInIntersections.ts, 0, 0))
>A : Symbol(A, Decl(freshLiteralTypesInIntersections.ts, 2, 22))
>B : Symbol(B, Decl(freshLiteralTypesInIntersections.ts, 2, 39))
>A : Symbol(A, Decl(freshLiteralTypesInIntersections.ts, 2, 22))
>a : Symbol(a, Decl(freshLiteralTypesInIntersections.ts, 2, 53))
>A : Symbol(A, Decl(freshLiteralTypesInIntersections.ts, 2, 22))
>b : Symbol(b, Decl(freshLiteralTypesInIntersections.ts, 2, 58))
>B : Symbol(B, Decl(freshLiteralTypesInIntersections.ts, 2, 39))
>ab : Symbol(ab, Decl(freshLiteralTypesInIntersections.ts, 2, 69))
>A : Symbol(A, Decl(freshLiteralTypesInIntersections.ts, 2, 22))
>B : Symbol(B, Decl(freshLiteralTypesInIntersections.ts, 2, 39))
const q = func("x" as "x" | "y", ["x"]);
>q : Symbol(q, Decl(freshLiteralTypesInIntersections.ts, 3, 5))
>func : Symbol(func, Decl(freshLiteralTypesInIntersections.ts, 0, 0))
q("x");
>q : Symbol(q, Decl(freshLiteralTypesInIntersections.ts, 3, 5))
@@ -0,0 +1,30 @@
=== tests/cases/compiler/freshLiteralTypesInIntersections.ts ===
// Repro from #19657
declare function func<A extends string, B extends A>(a: A, b: B[]): (ab: A & B) => void;
>func : <A extends string, B extends A>(a: A, b: B[]) => (ab: A & B) => void
>A : A
>B : B
>A : A
>a : A
>A : A
>b : B[]
>B : B
>ab : A & B
>A : A
>B : B
const q = func("x" as "x" | "y", ["x"]);
>q : (ab: "x") => void
>func("x" as "x" | "y", ["x"]) : (ab: "x") => void
>func : <A extends string, B extends A>(a: A, b: B[]) => (ab: A & B) => void
>"x" as "x" | "y" : "x" | "y"
>"x" : "x"
>["x"] : "x"[]
>"x" : "x"
q("x");
>q("x") : void
>q : (ab: "x") => void
>"x" : "x"
@@ -0,0 +1,25 @@
//// [intersectionTypeInference3.ts]
// Repro from #19682
type Nominal<Kind extends string, Type> = Type & {
[Symbol.species]: Kind;
};
type A = Nominal<'A', string>;
declare const a: Set<A>;
declare const b: Set<A>;
const c1 = Array.from(a).concat(Array.from(b));
// Simpler repro
declare function from<T>(): T[];
const c2: ReadonlyArray<A> = from();
//// [intersectionTypeInference3.js]
"use strict";
// Repro from #19682
const c1 = Array.from(a).concat(Array.from(b));
const c2 = from();
@@ -0,0 +1,57 @@
=== tests/cases/conformance/types/intersection/intersectionTypeInference3.ts ===
// Repro from #19682
type Nominal<Kind extends string, Type> = Type & {
>Nominal : Symbol(Nominal, Decl(intersectionTypeInference3.ts, 0, 0))
>Kind : Symbol(Kind, Decl(intersectionTypeInference3.ts, 2, 13))
>Type : Symbol(Type, Decl(intersectionTypeInference3.ts, 2, 33))
>Type : Symbol(Type, Decl(intersectionTypeInference3.ts, 2, 33))
[Symbol.species]: Kind;
>Symbol.species : Symbol(SymbolConstructor.species, Decl(lib.es2015.symbol.wellknown.d.ts, --, --))
>Symbol : Symbol(Symbol, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --))
>species : Symbol(SymbolConstructor.species, Decl(lib.es2015.symbol.wellknown.d.ts, --, --))
>Kind : Symbol(Kind, Decl(intersectionTypeInference3.ts, 2, 13))
};
type A = Nominal<'A', string>;
>A : Symbol(A, Decl(intersectionTypeInference3.ts, 4, 2))
>Nominal : Symbol(Nominal, Decl(intersectionTypeInference3.ts, 0, 0))
declare const a: Set<A>;
>a : Symbol(a, Decl(intersectionTypeInference3.ts, 8, 13))
>Set : Symbol(Set, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.collection.d.ts, --, --), Decl(lib.es2015.collection.d.ts, --, --))
>A : Symbol(A, Decl(intersectionTypeInference3.ts, 4, 2))
declare const b: Set<A>;
>b : Symbol(b, Decl(intersectionTypeInference3.ts, 9, 13))
>Set : Symbol(Set, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.collection.d.ts, --, --), Decl(lib.es2015.collection.d.ts, --, --))
>A : Symbol(A, Decl(intersectionTypeInference3.ts, 4, 2))
const c1 = Array.from(a).concat(Array.from(b));
>c1 : Symbol(c1, Decl(intersectionTypeInference3.ts, 11, 5))
>Array.from(a).concat : Symbol(Array.concat, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
>Array.from : Symbol(ArrayConstructor.from, Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --))
>Array : Symbol(Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --))
>from : Symbol(ArrayConstructor.from, Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --))
>a : Symbol(a, Decl(intersectionTypeInference3.ts, 8, 13))
>concat : Symbol(Array.concat, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
>Array.from : Symbol(ArrayConstructor.from, Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --))
>Array : Symbol(Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --))
>from : Symbol(ArrayConstructor.from, Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --))
>b : Symbol(b, Decl(intersectionTypeInference3.ts, 9, 13))
// Simpler repro
declare function from<T>(): T[];
>from : Symbol(from, Decl(intersectionTypeInference3.ts, 11, 47))
>T : Symbol(T, Decl(intersectionTypeInference3.ts, 15, 22))
>T : Symbol(T, Decl(intersectionTypeInference3.ts, 15, 22))
const c2: ReadonlyArray<A> = from();
>c2 : Symbol(c2, Decl(intersectionTypeInference3.ts, 16, 5))
>ReadonlyArray : Symbol(ReadonlyArray, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --))
>A : Symbol(A, Decl(intersectionTypeInference3.ts, 4, 2))
>from : Symbol(from, Decl(intersectionTypeInference3.ts, 11, 47))
@@ -0,0 +1,61 @@
=== tests/cases/conformance/types/intersection/intersectionTypeInference3.ts ===
// Repro from #19682
type Nominal<Kind extends string, Type> = Type & {
>Nominal : Nominal<Kind, Type>
>Kind : Kind
>Type : Type
>Type : Type
[Symbol.species]: Kind;
>Symbol.species : symbol
>Symbol : SymbolConstructor
>species : symbol
>Kind : Kind
};
type A = Nominal<'A', string>;
>A : Nominal<"A", string>
>Nominal : Nominal<Kind, Type>
declare const a: Set<A>;
>a : Set<Nominal<"A", string>>
>Set : Set<T>
>A : Nominal<"A", string>
declare const b: Set<A>;
>b : Set<Nominal<"A", string>>
>Set : Set<T>
>A : Nominal<"A", string>
const c1 = Array.from(a).concat(Array.from(b));
>c1 : Nominal<"A", string>[]
>Array.from(a).concat(Array.from(b)) : Nominal<"A", string>[]
>Array.from(a).concat : { (...items: ReadonlyArray<Nominal<"A", string>>[]): Nominal<"A", string>[]; (...items: (Nominal<"A", string> | ReadonlyArray<Nominal<"A", string>>)[]): Nominal<"A", string>[]; }
>Array.from(a) : Nominal<"A", string>[]
>Array.from : { <T>(iterable: Iterable<T>): T[]; <T, U>(iterable: Iterable<T>, mapfn: (v: T, k: number) => U, thisArg?: any): U[]; <T>(arrayLike: ArrayLike<T>): T[]; <T, U>(arrayLike: ArrayLike<T>, mapfn: (v: T, k: number) => U, thisArg?: any): U[]; }
>Array : ArrayConstructor
>from : { <T>(iterable: Iterable<T>): T[]; <T, U>(iterable: Iterable<T>, mapfn: (v: T, k: number) => U, thisArg?: any): U[]; <T>(arrayLike: ArrayLike<T>): T[]; <T, U>(arrayLike: ArrayLike<T>, mapfn: (v: T, k: number) => U, thisArg?: any): U[]; }
>a : Set<Nominal<"A", string>>
>concat : { (...items: ReadonlyArray<Nominal<"A", string>>[]): Nominal<"A", string>[]; (...items: (Nominal<"A", string> | ReadonlyArray<Nominal<"A", string>>)[]): Nominal<"A", string>[]; }
>Array.from(b) : Nominal<"A", string>[]
>Array.from : { <T>(iterable: Iterable<T>): T[]; <T, U>(iterable: Iterable<T>, mapfn: (v: T, k: number) => U, thisArg?: any): U[]; <T>(arrayLike: ArrayLike<T>): T[]; <T, U>(arrayLike: ArrayLike<T>, mapfn: (v: T, k: number) => U, thisArg?: any): U[]; }
>Array : ArrayConstructor
>from : { <T>(iterable: Iterable<T>): T[]; <T, U>(iterable: Iterable<T>, mapfn: (v: T, k: number) => U, thisArg?: any): U[]; <T>(arrayLike: ArrayLike<T>): T[]; <T, U>(arrayLike: ArrayLike<T>, mapfn: (v: T, k: number) => U, thisArg?: any): U[]; }
>b : Set<Nominal<"A", string>>
// Simpler repro
declare function from<T>(): T[];
>from : <T>() => T[]
>T : T
>T : T
const c2: ReadonlyArray<A> = from();
>c2 : ReadonlyArray<Nominal<"A", string>>
>ReadonlyArray : ReadonlyArray<T>
>A : Nominal<"A", string>
>from() : Nominal<"A", string>[]
>from : <T>() => T[]
@@ -6,9 +6,9 @@ function f(x: number, y: number, z: number) {
>z : Symbol(z, Decl(modularizeLibrary_ErrorFromUsingWellknownSymbolWithOutES6WellknownSymbolLib.ts, 0, 32))
return Array.from(arguments);
>Array.from : Symbol(ArrayConstructor.from, Decl(lib.es2015.core.d.ts, --, --))
>Array.from : Symbol(ArrayConstructor.from, Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --))
>Array : Symbol(Array, Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
>from : Symbol(ArrayConstructor.from, Decl(lib.es2015.core.d.ts, --, --))
>from : Symbol(ArrayConstructor.from, Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --))
>arguments : Symbol(arguments)
}
@@ -7,9 +7,9 @@ function f(x: number, y: number, z: number) {
return Array.from(arguments);
>Array.from(arguments) : any[]
>Array.from : <T, U = T>(arrayLike: ArrayLike<T>, mapfn?: (v: T, k: number) => U, thisArg?: any) => U[]
>Array.from : { <T>(arrayLike: ArrayLike<T>): T[]; <T, U>(arrayLike: ArrayLike<T>, mapfn: (v: T, k: number) => U, thisArg?: any): U[]; }
>Array : ArrayConstructor
>from : <T, U = T>(arrayLike: ArrayLike<T>, mapfn?: (v: T, k: number) => U, thisArg?: any) => U[]
>from : { <T>(arrayLike: ArrayLike<T>): T[]; <T, U>(arrayLike: ArrayLike<T>, mapfn: (v: T, k: number) => U, thisArg?: any): U[]; }
>arguments : IArguments
}
@@ -7,9 +7,9 @@ function f(x: number, y: number, z: number) {
>z : Symbol(z, Decl(modularizeLibrary_NoErrorDuplicateLibOptions1.ts, 1, 32))
return Array.from(arguments);
>Array.from : Symbol(ArrayConstructor.from, Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --))
>Array.from : Symbol(ArrayConstructor.from, Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --))
>Array : Symbol(Array, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
>from : Symbol(ArrayConstructor.from, Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --))
>from : Symbol(ArrayConstructor.from, Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --))
>arguments : Symbol(arguments)
}
@@ -8,9 +8,9 @@ function f(x: number, y: number, z: number) {
return Array.from(arguments);
>Array.from(arguments) : any[]
>Array.from : { <T, U = T>(iterable: Iterable<T>, mapfn?: (v: T, k: number) => U, thisArg?: any): U[]; <T, U = T>(arrayLike: ArrayLike<T>, mapfn?: (v: T, k: number) => U, thisArg?: any): U[]; }
>Array.from : { <T>(iterable: Iterable<T>): T[]; <T, U>(iterable: Iterable<T>, mapfn: (v: T, k: number) => U, thisArg?: any): U[]; <T>(arrayLike: ArrayLike<T>): T[]; <T, U>(arrayLike: ArrayLike<T>, mapfn: (v: T, k: number) => U, thisArg?: any): U[]; }
>Array : ArrayConstructor
>from : { <T, U = T>(iterable: Iterable<T>, mapfn?: (v: T, k: number) => U, thisArg?: any): U[]; <T, U = T>(arrayLike: ArrayLike<T>, mapfn?: (v: T, k: number) => U, thisArg?: any): U[]; }
>from : { <T>(iterable: Iterable<T>): T[]; <T, U>(iterable: Iterable<T>, mapfn: (v: T, k: number) => U, thisArg?: any): U[]; <T>(arrayLike: ArrayLike<T>): T[]; <T, U>(arrayLike: ArrayLike<T>, mapfn: (v: T, k: number) => U, thisArg?: any): U[]; }
>arguments : IArguments
}
@@ -7,9 +7,9 @@ function f(x: number, y: number, z: number) {
>z : Symbol(z, Decl(modularizeLibrary_NoErrorDuplicateLibOptions2.ts, 1, 32))
return Array.from(arguments);
>Array.from : Symbol(ArrayConstructor.from, Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --))
>Array.from : Symbol(ArrayConstructor.from, Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --))
>Array : Symbol(Array, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
>from : Symbol(ArrayConstructor.from, Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --))
>from : Symbol(ArrayConstructor.from, Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --))
>arguments : Symbol(arguments)
}
@@ -8,9 +8,9 @@ function f(x: number, y: number, z: number) {
return Array.from(arguments);
>Array.from(arguments) : any[]
>Array.from : { <T, U = T>(iterable: Iterable<T>, mapfn?: (v: T, k: number) => U, thisArg?: any): U[]; <T, U = T>(arrayLike: ArrayLike<T>, mapfn?: (v: T, k: number) => U, thisArg?: any): U[]; }
>Array.from : { <T>(iterable: Iterable<T>): T[]; <T, U>(iterable: Iterable<T>, mapfn: (v: T, k: number) => U, thisArg?: any): U[]; <T>(arrayLike: ArrayLike<T>): T[]; <T, U>(arrayLike: ArrayLike<T>, mapfn: (v: T, k: number) => U, thisArg?: any): U[]; }
>Array : ArrayConstructor
>from : { <T, U = T>(iterable: Iterable<T>, mapfn?: (v: T, k: number) => U, thisArg?: any): U[]; <T, U = T>(arrayLike: ArrayLike<T>, mapfn?: (v: T, k: number) => U, thisArg?: any): U[]; }
>from : { <T>(iterable: Iterable<T>): T[]; <T, U>(iterable: Iterable<T>, mapfn: (v: T, k: number) => U, thisArg?: any): U[]; <T>(arrayLike: ArrayLike<T>): T[]; <T, U>(arrayLike: ArrayLike<T>, mapfn: (v: T, k: number) => U, thisArg?: any): U[]; }
>arguments : IArguments
}
@@ -7,9 +7,9 @@ function f(x: number, y: number, z: number) {
>z : Symbol(z, Decl(modularizeLibrary_TargetES5UsingES6Lib.ts, 1, 32))
return Array.from(arguments);
>Array.from : Symbol(ArrayConstructor.from, Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --))
>Array.from : Symbol(ArrayConstructor.from, Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --))
>Array : Symbol(Array, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
>from : Symbol(ArrayConstructor.from, Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --))
>from : Symbol(ArrayConstructor.from, Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --))
>arguments : Symbol(arguments)
}
@@ -8,9 +8,9 @@ function f(x: number, y: number, z: number) {
return Array.from(arguments);
>Array.from(arguments) : any[]
>Array.from : { <T, U = T>(iterable: Iterable<T>, mapfn?: (v: T, k: number) => U, thisArg?: any): U[]; <T, U = T>(arrayLike: ArrayLike<T>, mapfn?: (v: T, k: number) => U, thisArg?: any): U[]; }
>Array.from : { <T>(iterable: Iterable<T>): T[]; <T, U>(iterable: Iterable<T>, mapfn: (v: T, k: number) => U, thisArg?: any): U[]; <T>(arrayLike: ArrayLike<T>): T[]; <T, U>(arrayLike: ArrayLike<T>, mapfn: (v: T, k: number) => U, thisArg?: any): U[]; }
>Array : ArrayConstructor
>from : { <T, U = T>(iterable: Iterable<T>, mapfn?: (v: T, k: number) => U, thisArg?: any): U[]; <T, U = T>(arrayLike: ArrayLike<T>, mapfn?: (v: T, k: number) => U, thisArg?: any): U[]; }
>from : { <T>(iterable: Iterable<T>): T[]; <T, U>(iterable: Iterable<T>, mapfn: (v: T, k: number) => U, thisArg?: any): U[]; <T>(arrayLike: ArrayLike<T>): T[]; <T, U>(arrayLike: ArrayLike<T>, mapfn: (v: T, k: number) => U, thisArg?: any): U[]; }
>arguments : IArguments
}
@@ -7,9 +7,9 @@ function f(x: number, y: number, z: number) {
>z : Symbol(z, Decl(modularizeLibrary_TargetES6UsingES6Lib.ts, 1, 32))
return Array.from(arguments);
>Array.from : Symbol(ArrayConstructor.from, Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --))
>Array.from : Symbol(ArrayConstructor.from, Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --))
>Array : Symbol(Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --))
>from : Symbol(ArrayConstructor.from, Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --))
>from : Symbol(ArrayConstructor.from, Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --))
>arguments : Symbol(arguments)
}
@@ -8,9 +8,9 @@ function f(x: number, y: number, z: number) {
return Array.from(arguments);
>Array.from(arguments) : any[]
>Array.from : { <T, U = T>(iterable: Iterable<T>, mapfn?: (v: T, k: number) => U, thisArg?: any): U[]; <T, U = T>(arrayLike: ArrayLike<T>, mapfn?: (v: T, k: number) => U, thisArg?: any): U[]; }
>Array.from : { <T>(iterable: Iterable<T>): T[]; <T, U>(iterable: Iterable<T>, mapfn: (v: T, k: number) => U, thisArg?: any): U[]; <T>(arrayLike: ArrayLike<T>): T[]; <T, U>(arrayLike: ArrayLike<T>, mapfn: (v: T, k: number) => U, thisArg?: any): U[]; }
>Array : ArrayConstructor
>from : { <T, U = T>(iterable: Iterable<T>, mapfn?: (v: T, k: number) => U, thisArg?: any): U[]; <T, U = T>(arrayLike: ArrayLike<T>, mapfn?: (v: T, k: number) => U, thisArg?: any): U[]; }
>from : { <T>(iterable: Iterable<T>): T[]; <T, U>(iterable: Iterable<T>, mapfn: (v: T, k: number) => U, thisArg?: any): U[]; <T>(arrayLike: ArrayLike<T>): T[]; <T, U>(arrayLike: ArrayLike<T>, mapfn: (v: T, k: number) => U, thisArg?: any): U[]; }
>arguments : IArguments
}
@@ -7,9 +7,9 @@ function f(x: number, y: number, z: number) {
>z : Symbol(z, Decl(modularizeLibrary_UsingES5LibAndES6ArrayLib.ts, 1, 32))
return Array.from(arguments);
>Array.from : Symbol(ArrayConstructor.from, Decl(lib.es2015.core.d.ts, --, --))
>Array.from : Symbol(ArrayConstructor.from, Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --))
>Array : Symbol(Array, Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
>from : Symbol(ArrayConstructor.from, Decl(lib.es2015.core.d.ts, --, --))
>from : Symbol(ArrayConstructor.from, Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --))
>arguments : Symbol(arguments)
}
@@ -8,9 +8,9 @@ function f(x: number, y: number, z: number) {
return Array.from(arguments);
>Array.from(arguments) : any[]
>Array.from : <T, U = T>(arrayLike: ArrayLike<T>, mapfn?: (v: T, k: number) => U, thisArg?: any) => U[]
>Array.from : { <T>(arrayLike: ArrayLike<T>): T[]; <T, U>(arrayLike: ArrayLike<T>, mapfn: (v: T, k: number) => U, thisArg?: any): U[]; }
>Array : ArrayConstructor
>from : <T, U = T>(arrayLike: ArrayLike<T>, mapfn?: (v: T, k: number) => U, thisArg?: any) => U[]
>from : { <T>(arrayLike: ArrayLike<T>): T[]; <T, U>(arrayLike: ArrayLike<T>, mapfn: (v: T, k: number) => U, thisArg?: any): U[]; }
>arguments : IArguments
}
@@ -6,9 +6,9 @@ function f(x: number, y: number, z: number) {
>z : Symbol(z, Decl(modularizeLibrary_UsingES5LibES6ArrayLibES6WellknownSymbolLib.ts, 0, 32))
return Array.from(arguments);
>Array.from : Symbol(ArrayConstructor.from, Decl(lib.es2015.core.d.ts, --, --))
>Array.from : Symbol(ArrayConstructor.from, Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --))
>Array : Symbol(Array, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
>from : Symbol(ArrayConstructor.from, Decl(lib.es2015.core.d.ts, --, --))
>from : Symbol(ArrayConstructor.from, Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --))
>arguments : Symbol(arguments)
}
@@ -7,9 +7,9 @@ function f(x: number, y: number, z: number) {
return Array.from(arguments);
>Array.from(arguments) : any[]
>Array.from : <T, U = T>(arrayLike: ArrayLike<T>, mapfn?: (v: T, k: number) => U, thisArg?: any) => U[]
>Array.from : { <T>(arrayLike: ArrayLike<T>): T[]; <T, U>(arrayLike: ArrayLike<T>, mapfn: (v: T, k: number) => U, thisArg?: any): U[]; }
>Array : ArrayConstructor
>from : <T, U = T>(arrayLike: ArrayLike<T>, mapfn?: (v: T, k: number) => U, thisArg?: any) => U[]
>from : { <T>(arrayLike: ArrayLike<T>): T[]; <T, U>(arrayLike: ArrayLike<T>, mapfn: (v: T, k: number) => U, thisArg?: any): U[]; }
>arguments : IArguments
}
@@ -1,6 +1,5 @@
tests/cases/conformance/types/typeRelationships/instanceOf/narrowingGenericTypeFromInstanceof01.ts(13,17): error TS2345: Argument of type 'A<T> | B<T>' is not assignable to parameter of type 'A<T>'.
Type 'B<T>' is not assignable to type 'A<T>'.
Property 'a' is missing in type 'B<T>'.
tests/cases/conformance/types/typeRelationships/instanceOf/narrowingGenericTypeFromInstanceof01.ts(13,17): error TS2345: Argument of type 'B<T>' is not assignable to parameter of type 'A<{}>'.
Property 'a' is missing in type 'B<T>'.
==== tests/cases/conformance/types/typeRelationships/instanceOf/narrowingGenericTypeFromInstanceof01.ts (1 errors) ====
@@ -18,9 +17,8 @@ tests/cases/conformance/types/typeRelationships/instanceOf/narrowingGenericTypeF
if (x instanceof B) {
acceptA(x);
~
!!! error TS2345: Argument of type 'A<T> | B<T>' is not assignable to parameter of type 'A<T>'.
!!! error TS2345: Type 'B<T>' is not assignable to type 'A<T>'.
!!! error TS2345: Property 'a' is missing in type 'B<T>'.
!!! error TS2345: Argument of type 'B<T>' is not assignable to parameter of type 'A<{}>'.
!!! error TS2345: Property 'a' is missing in type 'B<T>'.
}
if (x instanceof A) {
@@ -43,7 +43,7 @@ function test<T>(x: A<T> | B<T>) {
acceptA(x);
>acceptA(x) : any
>acceptA : <T>(a: A<T>) => void
>x : A<T> | B<T>
>x : B<T>
}
if (x instanceof A) {
@@ -65,7 +65,7 @@ function test<T>(x: A<T> | B<T>) {
acceptB(x);
>acceptB(x) : void
>acceptB : <T>(b: B<T>) => void
>x : A<T> | B<T>
>x : B<T>
}
if (x instanceof B) {
@@ -76,6 +76,6 @@ function test<T>(x: A<T> | B<T>) {
acceptB(x);
>acceptB(x) : void
>acceptB : <T>(b: B<T>) => void
>x : A<T> | B<T>
>x : B<T>
}
}
@@ -28,8 +28,8 @@ var e: Ellement;
>Ellement : Symbol(Ellement, Decl(nonContextuallyTypedLogicalOr.ts, 3, 1))
(c || e).dummy;
>(c || e).dummy : Symbol(Contextual.dummy, Decl(nonContextuallyTypedLogicalOr.ts, 0, 22))
>(c || e).dummy : Symbol(dummy, Decl(nonContextuallyTypedLogicalOr.ts, 0, 22), Decl(nonContextuallyTypedLogicalOr.ts, 5, 20))
>c : Symbol(c, Decl(nonContextuallyTypedLogicalOr.ts, 10, 3))
>e : Symbol(e, Decl(nonContextuallyTypedLogicalOr.ts, 11, 3))
>dummy : Symbol(Contextual.dummy, Decl(nonContextuallyTypedLogicalOr.ts, 0, 22))
>dummy : Symbol(dummy, Decl(nonContextuallyTypedLogicalOr.ts, 0, 22), Decl(nonContextuallyTypedLogicalOr.ts, 5, 20))
@@ -29,8 +29,8 @@ var e: Ellement;
(c || e).dummy;
>(c || e).dummy : any
>(c || e) : Contextual
>c || e : Contextual
>(c || e) : Contextual | Ellement
>c || e : Contextual | Ellement
>c : Contextual
>e : Ellement
>dummy : any
@@ -1,12 +1,9 @@
tests/cases/conformance/parser/ecmascript5/ConstructorDeclarations/parserConstructorDeclaration4.ts(2,3): error TS1031: 'declare' modifier cannot appear on a class element.
tests/cases/conformance/parser/ecmascript5/ConstructorDeclarations/parserConstructorDeclaration4.ts(2,25): error TS1183: An implementation cannot be declared in ambient contexts.
==== tests/cases/conformance/parser/ecmascript5/ConstructorDeclarations/parserConstructorDeclaration4.ts (2 errors) ====
==== tests/cases/conformance/parser/ecmascript5/ConstructorDeclarations/parserConstructorDeclaration4.ts (1 errors) ====
class C {
declare constructor() { }
~~~~~~~
!!! error TS1031: 'declare' modifier cannot appear on a class element.
~
!!! error TS1183: An implementation cannot be declared in ambient contexts.
}
@@ -1,9 +1,12 @@
tests/cases/conformance/parser/ecmascript5/MemberAccessorDeclarations/parserMemberAccessorDeclaration11.ts(2,5): error TS1031: 'declare' modifier cannot appear on a class element.
tests/cases/conformance/parser/ecmascript5/MemberAccessorDeclarations/parserMemberAccessorDeclaration11.ts(2,17): error TS2378: A 'get' accessor must return a value.
==== tests/cases/conformance/parser/ecmascript5/MemberAccessorDeclarations/parserMemberAccessorDeclaration11.ts (1 errors) ====
==== tests/cases/conformance/parser/ecmascript5/MemberAccessorDeclarations/parserMemberAccessorDeclaration11.ts (2 errors) ====
class C {
declare get Foo() { }
~~~~~~~
!!! error TS1031: 'declare' modifier cannot appear on a class element.
~~~
!!! error TS2378: A 'get' accessor must return a value.
}
@@ -1,12 +1,9 @@
tests/cases/conformance/parser/ecmascript5/MemberFunctionDeclarations/parserMemberFunctionDeclaration5.ts(2,5): error TS1031: 'declare' modifier cannot appear on a class element.
tests/cases/conformance/parser/ecmascript5/MemberFunctionDeclarations/parserMemberFunctionDeclaration5.ts(2,19): error TS1183: An implementation cannot be declared in ambient contexts.
==== tests/cases/conformance/parser/ecmascript5/MemberFunctionDeclarations/parserMemberFunctionDeclaration5.ts (2 errors) ====
==== tests/cases/conformance/parser/ecmascript5/MemberFunctionDeclarations/parserMemberFunctionDeclaration5.ts (1 errors) ====
class C {
declare Foo() { }
~~~~~~~
!!! error TS1031: 'declare' modifier cannot appear on a class element.
~
!!! error TS1183: An implementation cannot be declared in ambient contexts.
}
@@ -0,0 +1 @@
export default (foo) => { return 2; };
@@ -1,9 +1,9 @@
tests/cases/conformance/jsx/file.tsx(9,33): error TS2322: Type '{ a: number; }' is not assignable to type 'IntrinsicAttributes & { b: {}; a: number; }'.
Type '{ a: number; }' is not assignable to type '{ b: {}; a: number; }'.
Property 'b' is missing in type '{ a: number; }'.
tests/cases/conformance/jsx/file.tsx(10,33): error TS2322: Type 'T' is not assignable to type 'IntrinsicAttributes & { b: number; a: {}; }'.
Type '{ b: number; }' is not assignable to type 'IntrinsicAttributes & { b: number; a: {}; }'.
Type '{ b: number; }' is not assignable to type '{ b: number; a: {}; }'.
tests/cases/conformance/jsx/file.tsx(10,33): error TS2322: Type 'T' is not assignable to type 'IntrinsicAttributes & { b: {}; a: {}; }'.
Type '{ b: number; }' is not assignable to type 'IntrinsicAttributes & { b: {}; a: {}; }'.
Type '{ b: number; }' is not assignable to type '{ b: {}; a: {}; }'.
Property 'a' is missing in type '{ b: number; }'.
Type 'T' is not assignable to type 'IntrinsicAttributes'.
Type '{ b: number; }' has no properties in common with type 'IntrinsicAttributes'.
@@ -25,9 +25,9 @@ tests/cases/conformance/jsx/file.tsx(10,33): error TS2322: Type 'T' is not assig
!!! error TS2322: Property 'b' is missing in type '{ a: number; }'.
let a2 = <OverloadComponent {...arg1} ignore-prop /> // missing a
~~~~~~~~~~~~~~~~~~~~~
!!! error TS2322: Type 'T' is not assignable to type 'IntrinsicAttributes & { b: number; a: {}; }'.
!!! error TS2322: Type '{ b: number; }' is not assignable to type 'IntrinsicAttributes & { b: number; a: {}; }'.
!!! error TS2322: Type '{ b: number; }' is not assignable to type '{ b: number; a: {}; }'.
!!! error TS2322: Type 'T' is not assignable to type 'IntrinsicAttributes & { b: {}; a: {}; }'.
!!! error TS2322: Type '{ b: number; }' is not assignable to type 'IntrinsicAttributes & { b: {}; a: {}; }'.
!!! error TS2322: Type '{ b: number; }' is not assignable to type '{ b: {}; a: {}; }'.
!!! error TS2322: Property 'a' is missing in type '{ b: number; }'.
!!! error TS2322: Type 'T' is not assignable to type 'IntrinsicAttributes'.
!!! error TS2322: Type '{ b: number; }' has no properties in common with type 'IntrinsicAttributes'.
+6
View File
@@ -0,0 +1,6 @@
Exit Code: 0
Standard output:
Standard error:
+6
View File
@@ -0,0 +1,6 @@
Exit Code: 0
Standard output:
Standard error:
+6
View File
@@ -0,0 +1,6 @@
Exit Code: 0
Standard output:
Standard error:
@@ -0,0 +1,6 @@
Exit Code: 0
Standard output:
Standard error:
@@ -0,0 +1,6 @@
Exit Code: 0
Standard output:
Standard error:
@@ -0,0 +1,13 @@
Exit Code: 2
Standard output:
node_modules/electron/electron.d.ts(5390,13): error TS2430: Interface 'WebviewTag' incorrectly extends interface 'HTMLElement'.
Types of property 'addEventListener' are incompatible.
Type '{ (event: "load-commit", listener: (event: LoadCommitEvent) => void, useCapture?: boolean | undef...' is not assignable to type '{ <K extends "error" | "waiting" | "progress" | "ended" | "change" | "input" | "select" | "abort"...'.
Types of parameters 'listener' and 'listener' are incompatible.
Type 'EventListenerOrEventListenerObject' is not assignable to type '(event: LoadCommitEvent) => void'.
Type 'EventListenerObject' is not assignable to type '(event: LoadCommitEvent) => void'.
Type 'EventListenerObject' provides no match for the signature '(event: LoadCommitEvent): void'.
Standard error:
@@ -0,0 +1,6 @@
Exit Code: 0
Standard output:
Standard error:
@@ -0,0 +1,6 @@
Exit Code: 0
Standard output:
Standard error:
@@ -0,0 +1,6 @@
Exit Code: 0
Standard output:
Standard error:
@@ -0,0 +1,6 @@
Exit Code: 0
Standard output:
Standard error:
@@ -0,0 +1,6 @@
Exit Code: 0
Standard output:
Standard error:
@@ -0,0 +1,6 @@
Exit Code: 0
Standard output:
Standard error:
+6
View File
@@ -0,0 +1,6 @@
Exit Code: 0
Standard output:
Standard error:

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