mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Merge branch 'master' of https://github.com/microsoft/TypeScript into feat/add-outlining-spans-for-object-destructuring-elements
This commit is contained in:
+1
-1
@@ -2,7 +2,7 @@
|
||||
"name": "typescript",
|
||||
"author": "Microsoft Corp.",
|
||||
"homepage": "https://www.typescriptlang.org/",
|
||||
"version": "3.9.0",
|
||||
"version": "4.0.0",
|
||||
"license": "Apache-2.0",
|
||||
"description": "TypeScript is a language for application scale JavaScript development",
|
||||
"keywords": [
|
||||
|
||||
@@ -320,16 +320,6 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
function setValueDeclaration(symbol: Symbol, node: Declaration): void {
|
||||
const { valueDeclaration } = symbol;
|
||||
if (!valueDeclaration ||
|
||||
(isAssignmentDeclaration(valueDeclaration) && !isAssignmentDeclaration(node)) ||
|
||||
(valueDeclaration.kind !== node.kind && isEffectiveModuleDeclaration(valueDeclaration))) {
|
||||
// other kinds of value declarations take precedence over modules and assignment declarations
|
||||
symbol.valueDeclaration = node;
|
||||
}
|
||||
}
|
||||
|
||||
// Should not be called on a declaration with a computed property name,
|
||||
// unless it is a well known Symbol.
|
||||
function getDeclarationName(node: Declaration): __String | undefined {
|
||||
|
||||
+190
-56
@@ -55,7 +55,9 @@ namespace ts {
|
||||
|
||||
const enum WideningKind {
|
||||
Normal,
|
||||
GeneratorYield
|
||||
FunctionReturn,
|
||||
GeneratorNext,
|
||||
GeneratorYield,
|
||||
}
|
||||
|
||||
const enum TypeFacts {
|
||||
@@ -1113,12 +1115,8 @@ namespace ts {
|
||||
target.constEnumOnlyModule = false;
|
||||
}
|
||||
target.flags |= source.flags;
|
||||
if (source.valueDeclaration &&
|
||||
(!target.valueDeclaration ||
|
||||
isAssignmentDeclaration(target.valueDeclaration) && !isAssignmentDeclaration(source.valueDeclaration) ||
|
||||
isEffectiveModuleDeclaration(target.valueDeclaration) && !isEffectiveModuleDeclaration(source.valueDeclaration))) {
|
||||
// other kinds of value declarations take precedence over modules and assignment declarations
|
||||
target.valueDeclaration = source.valueDeclaration;
|
||||
if (source.valueDeclaration) {
|
||||
setValueDeclaration(target, source.valueDeclaration);
|
||||
}
|
||||
addRange(target.declarations, source.declarations);
|
||||
if (source.members) {
|
||||
@@ -1423,9 +1421,10 @@ namespace ts {
|
||||
return true;
|
||||
}
|
||||
if (isUsedInFunctionOrInstanceProperty(usage, declaration)) {
|
||||
if (compilerOptions.target === ScriptTarget.ESNext && !!compilerOptions.useDefineForClassFields && getContainingClass(declaration)) {
|
||||
return (isPropertyDeclaration(declaration) || isParameterPropertyDeclaration(declaration, declaration.parent)) &&
|
||||
!isPropertyImmediatelyReferencedWithinDeclaration(declaration, usage, /*stopAtAnyPropertyDeclaration*/ true);
|
||||
if (compilerOptions.target === ScriptTarget.ESNext && !!compilerOptions.useDefineForClassFields
|
||||
&& getContainingClass(declaration)
|
||||
&& (isPropertyDeclaration(declaration) || isParameterPropertyDeclaration(declaration, declaration.parent))) {
|
||||
return !isPropertyImmediatelyReferencedWithinDeclaration(declaration, usage, /*stopAtAnyPropertyDeclaration*/ true);
|
||||
}
|
||||
else {
|
||||
return true;
|
||||
@@ -1526,6 +1525,63 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
function useOuterVariableScopeInParameter(result: Symbol, location: Node, lastLocation: Node) {
|
||||
const target = getEmitScriptTarget(compilerOptions);
|
||||
const functionLocation = <FunctionLikeDeclaration>location;
|
||||
if (isParameter(lastLocation) && functionLocation.body && result.valueDeclaration.pos >= functionLocation.body.pos && result.valueDeclaration.end <= functionLocation.body.end) {
|
||||
// check for several cases where we introduce temporaries that require moving the name/initializer of the parameter to the body
|
||||
// - static field in a class expression
|
||||
// - optional chaining pre-es2020
|
||||
// - nullish coalesce pre-es2020
|
||||
// - spread assignment in binding pattern pre-es2017
|
||||
if (target >= ScriptTarget.ES2015) {
|
||||
const links = getNodeLinks(functionLocation);
|
||||
if (links.declarationRequiresScopeChange === undefined) {
|
||||
links.declarationRequiresScopeChange = forEach(functionLocation.parameters, requiresScopeChange) || false;
|
||||
}
|
||||
return !links.declarationRequiresScopeChange;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
||||
function requiresScopeChange(node: ParameterDeclaration): boolean {
|
||||
return requiresScopeChangeWorker(node.name)
|
||||
|| !!node.initializer && requiresScopeChangeWorker(node.initializer);
|
||||
}
|
||||
|
||||
function requiresScopeChangeWorker(node: Node): boolean {
|
||||
switch (node.kind) {
|
||||
case SyntaxKind.ArrowFunction:
|
||||
case SyntaxKind.FunctionExpression:
|
||||
case SyntaxKind.FunctionDeclaration:
|
||||
case SyntaxKind.Constructor:
|
||||
// do not descend into these
|
||||
return false;
|
||||
case SyntaxKind.MethodDeclaration:
|
||||
case SyntaxKind.GetAccessor:
|
||||
case SyntaxKind.SetAccessor:
|
||||
case SyntaxKind.PropertyAssignment:
|
||||
return requiresScopeChangeWorker((node as MethodDeclaration | AccessorDeclaration | PropertyAssignment).name);
|
||||
case SyntaxKind.PropertyDeclaration:
|
||||
// static properties in classes introduce temporary variables
|
||||
if (hasStaticModifier(node)) {
|
||||
return target < ScriptTarget.ESNext || !compilerOptions.useDefineForClassFields;
|
||||
}
|
||||
return requiresScopeChangeWorker((node as PropertyDeclaration).name);
|
||||
default:
|
||||
// null coalesce and optional chain pre-es2020 produce temporary variables
|
||||
if (isNullishCoalesce(node) || isOptionalChain(node)) {
|
||||
return target < ScriptTarget.ES2020;
|
||||
}
|
||||
if (isBindingElement(node) && node.dotDotDotToken && isObjectBindingPattern(node.parent)) {
|
||||
return target < ScriptTarget.ES2017;
|
||||
}
|
||||
if (isTypeNode(node)) return false;
|
||||
return forEachChild(node, requiresScopeChangeWorker) || false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolve a given name for a given meaning at a given location. An error is reported if the name was not found and
|
||||
* the nameNotFoundMessage argument is not undefined. Returns the resolved symbol, or undefined if no symbol with
|
||||
@@ -1560,7 +1616,7 @@ namespace ts {
|
||||
let lastLocation: Node | undefined;
|
||||
let lastSelfReferenceLocation: Node | undefined;
|
||||
let propertyWithInvalidInitializer: Node | undefined;
|
||||
let associatedDeclarationForContainingInitializer: ParameterDeclaration | BindingElement | undefined;
|
||||
let associatedDeclarationForContainingInitializerOrBindingName: ParameterDeclaration | BindingElement | undefined;
|
||||
let withinDeferredContext = false;
|
||||
const errorLocation = location;
|
||||
let grandparent: Node;
|
||||
@@ -1589,9 +1645,7 @@ namespace ts {
|
||||
}
|
||||
if (meaning & result.flags & SymbolFlags.Variable) {
|
||||
// expression inside parameter will lookup as normal variable scope when targeting es2015+
|
||||
const functionLocation = <FunctionLikeDeclaration>location;
|
||||
if (compilerOptions.target && compilerOptions.target >= ScriptTarget.ES2015 && isParameter(lastLocation) &&
|
||||
functionLocation.body && result.valueDeclaration.pos >= functionLocation.body.pos && result.valueDeclaration.end <= functionLocation.body.end) {
|
||||
if (useOuterVariableScopeInParameter(result, location, lastLocation)) {
|
||||
useResult = false;
|
||||
}
|
||||
else if (result.flags & SymbolFlags.FunctionScopedVariable) {
|
||||
@@ -1819,15 +1873,21 @@ namespace ts {
|
||||
location = getJSDocHost(location);
|
||||
break;
|
||||
case SyntaxKind.Parameter:
|
||||
if (lastLocation && lastLocation === (location as ParameterDeclaration).initializer) {
|
||||
associatedDeclarationForContainingInitializer = location as ParameterDeclaration;
|
||||
if (lastLocation && (
|
||||
lastLocation === (location as ParameterDeclaration).initializer ||
|
||||
lastLocation === (location as ParameterDeclaration).name && isBindingPattern(lastLocation))) {
|
||||
if (!associatedDeclarationForContainingInitializerOrBindingName) {
|
||||
associatedDeclarationForContainingInitializerOrBindingName = location as ParameterDeclaration;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case SyntaxKind.BindingElement:
|
||||
if (lastLocation && lastLocation === (location as BindingElement).initializer) {
|
||||
if (lastLocation && (
|
||||
lastLocation === (location as BindingElement).initializer ||
|
||||
lastLocation === (location as BindingElement).name && isBindingPattern(lastLocation))) {
|
||||
const root = getRootDeclaration(location);
|
||||
if (root.kind === SyntaxKind.Parameter) {
|
||||
associatedDeclarationForContainingInitializer = location as BindingElement;
|
||||
associatedDeclarationForContainingInitializerOrBindingName = location as BindingElement;
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -1938,17 +1998,17 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
// If we're in a parameter initializer, we can't reference the values of the parameter whose initializer we're within or parameters to the right
|
||||
if (result && associatedDeclarationForContainingInitializer && !withinDeferredContext && (meaning & SymbolFlags.Value) === SymbolFlags.Value) {
|
||||
// If we're in a parameter initializer or binding name, we can't reference the values of the parameter whose initializer we're within or parameters to the right
|
||||
if (result && associatedDeclarationForContainingInitializerOrBindingName && !withinDeferredContext && (meaning & SymbolFlags.Value) === SymbolFlags.Value) {
|
||||
const candidate = getMergedSymbol(getLateBoundSymbol(result));
|
||||
const root = (getRootDeclaration(associatedDeclarationForContainingInitializer) as ParameterDeclaration);
|
||||
const root = (getRootDeclaration(associatedDeclarationForContainingInitializerOrBindingName) as ParameterDeclaration);
|
||||
// A parameter initializer or binding pattern initializer within a parameter cannot refer to itself
|
||||
if (candidate === getSymbolOfNode(associatedDeclarationForContainingInitializer)) {
|
||||
error(errorLocation, Diagnostics.Parameter_0_cannot_be_referenced_in_its_initializer, declarationNameToString(associatedDeclarationForContainingInitializer.name));
|
||||
if (candidate === getSymbolOfNode(associatedDeclarationForContainingInitializerOrBindingName)) {
|
||||
error(errorLocation, Diagnostics.Parameter_0_cannot_reference_itself, declarationNameToString(associatedDeclarationForContainingInitializerOrBindingName.name));
|
||||
}
|
||||
// And it cannot refer to any declarations which come after it
|
||||
else if (candidate.valueDeclaration && candidate.valueDeclaration.pos > associatedDeclarationForContainingInitializer.pos && root.parent.locals && lookup(root.parent.locals, candidate.escapedName, meaning) === candidate) {
|
||||
error(errorLocation, Diagnostics.Initializer_of_parameter_0_cannot_reference_identifier_1_declared_after_it, declarationNameToString(associatedDeclarationForContainingInitializer.name), declarationNameToString(<Identifier>errorLocation));
|
||||
else if (candidate.valueDeclaration && candidate.valueDeclaration.pos > associatedDeclarationForContainingInitializerOrBindingName.pos && root.parent.locals && lookup(root.parent.locals, candidate.escapedName, meaning) === candidate) {
|
||||
error(errorLocation, Diagnostics.Parameter_0_cannot_reference_identifier_1_declared_after_it, declarationNameToString(associatedDeclarationForContainingInitializerOrBindingName.name), declarationNameToString(<Identifier>errorLocation));
|
||||
}
|
||||
}
|
||||
if (result && errorLocation && meaning & SymbolFlags.Value && result.flags & SymbolFlags.Alias) {
|
||||
@@ -3453,12 +3513,16 @@ namespace ts {
|
||||
return mapDefined(candidates, candidate => getAliasForSymbolInContainer(candidate, symbol) ? candidate : undefined);
|
||||
|
||||
function fileSymbolIfFileSymbolExportEqualsContainer(d: Declaration) {
|
||||
const fileSymbol = getExternalModuleContainer(d);
|
||||
const exported = fileSymbol && fileSymbol.exports && fileSymbol.exports.get(InternalSymbolName.ExportEquals);
|
||||
return exported && container && getSymbolIfSameReference(exported, container) ? fileSymbol : undefined;
|
||||
return container && getFileSymbolIfFileSymbolExportEqualsContainer(d, container);
|
||||
}
|
||||
}
|
||||
|
||||
function getFileSymbolIfFileSymbolExportEqualsContainer(d: Declaration, container: Symbol) {
|
||||
const fileSymbol = getExternalModuleContainer(d);
|
||||
const exported = fileSymbol && fileSymbol.exports && fileSymbol.exports.get(InternalSymbolName.ExportEquals);
|
||||
return exported && getSymbolIfSameReference(exported, container) ? fileSymbol : undefined;
|
||||
}
|
||||
|
||||
function getAliasForSymbolInContainer(container: Symbol, symbol: Symbol) {
|
||||
if (container === getParentOfSymbol(symbol)) {
|
||||
// fast path, `symbol` is either already the alias or isn't aliased
|
||||
@@ -5074,7 +5138,13 @@ namespace ts {
|
||||
}
|
||||
|
||||
function getSpecifierForModuleSymbol(symbol: Symbol, context: NodeBuilderContext) {
|
||||
const file = getDeclarationOfKind<SourceFile>(symbol, SyntaxKind.SourceFile);
|
||||
let file = getDeclarationOfKind<SourceFile>(symbol, SyntaxKind.SourceFile);
|
||||
if (!file) {
|
||||
const equivalentFileSymbol = firstDefined(symbol.declarations, d => getFileSymbolIfFileSymbolExportEqualsContainer(d, symbol));
|
||||
if (equivalentFileSymbol) {
|
||||
file = getDeclarationOfKind<SourceFile>(equivalentFileSymbol, SyntaxKind.SourceFile);
|
||||
}
|
||||
}
|
||||
if (file && file.moduleName !== undefined) {
|
||||
// Use the amd name if it is available
|
||||
return file.moduleName;
|
||||
@@ -5458,7 +5528,7 @@ namespace ts {
|
||||
function serializeReturnTypeForSignature(context: NodeBuilderContext, type: Type, signature: Signature, includePrivateSymbol?: (s: Symbol) => void, bundled?: boolean) {
|
||||
if (type !== errorType && context.enclosingDeclaration) {
|
||||
const annotation = signature.declaration && getEffectiveReturnTypeNode(signature.declaration);
|
||||
if (!!findAncestor(annotation, n => n === context.enclosingDeclaration) && annotation && getTypeFromTypeNode(annotation) === type) {
|
||||
if (!!findAncestor(annotation, n => n === context.enclosingDeclaration) && annotation && instantiateType(getTypeFromTypeNode(annotation), signature.mapper) === type) {
|
||||
const result = serializeExistingTypeNode(context, annotation, includePrivateSymbol, bundled);
|
||||
if (result) {
|
||||
return result;
|
||||
@@ -6026,14 +6096,19 @@ namespace ts {
|
||||
serializeAsNamespaceDeclaration(realMembers, localName, modifierFlags, !!(symbol.flags & (SymbolFlags.Function | SymbolFlags.Assignment)));
|
||||
}
|
||||
if (length(mergedMembers)) {
|
||||
const containingFile = getSourceFileOfNode(context.enclosingDeclaration);
|
||||
const localName = getInternalSymbolName(symbol, symbolName);
|
||||
const nsBody = createModuleBlock([createExportDeclaration(
|
||||
/*decorators*/ undefined,
|
||||
/*modifiers*/ undefined,
|
||||
createNamedExports(map(filter(mergedMembers, n => n.escapedName !== InternalSymbolName.ExportEquals), s => {
|
||||
createNamedExports(mapDefined(filter(mergedMembers, n => n.escapedName !== InternalSymbolName.ExportEquals), s => {
|
||||
const name = unescapeLeadingUnderscores(s.escapedName);
|
||||
const localName = getInternalSymbolName(s, name);
|
||||
const aliasDecl = s.declarations && getDeclarationOfAliasSymbol(s);
|
||||
if (containingFile && (aliasDecl ? containingFile !== getSourceFileOfNode(aliasDecl) : !some(s.declarations, d => getSourceFileOfNode(d) === containingFile))) {
|
||||
context.tracker?.reportNonlocalAugmentation?.(containingFile, symbol, s);
|
||||
return undefined;
|
||||
}
|
||||
const target = aliasDecl && getTargetOfAliasDeclaration(aliasDecl, /*dontRecursivelyResolve*/ true);
|
||||
includePrivateSymbol(target || s);
|
||||
const targetName = target ? getInternalSymbolName(target, unescapeLeadingUnderscores(target.escapedName)) : localName;
|
||||
@@ -6210,7 +6285,7 @@ namespace ts {
|
||||
...!length(baseTypes) ? [] : [createHeritageClause(SyntaxKind.ExtendsKeyword, map(baseTypes, b => serializeBaseType(b, staticBaseType, localName)))],
|
||||
...!length(implementsTypes) ? [] : [createHeritageClause(SyntaxKind.ImplementsKeyword, map(implementsTypes, b => serializeBaseType(b, staticBaseType, localName)))]
|
||||
];
|
||||
const symbolProps = getPropertiesOfType(classType);
|
||||
const symbolProps = getNonInterhitedProperties(classType, baseTypes, getPropertiesOfType(classType));
|
||||
const publicSymbolProps = filter(symbolProps, s => {
|
||||
// `valueDeclaration` could be undefined if inherited from
|
||||
// a union/intersection base type, but inherited properties
|
||||
@@ -7302,8 +7377,8 @@ namespace ts {
|
||||
if (strictNullChecks && declaration.flags & NodeFlags.Ambient && isParameterDeclaration(declaration)) {
|
||||
parentType = getNonNullableType(parentType);
|
||||
}
|
||||
// Filter `undefined` from the type we check against if the parent has an initializer (which handles the `undefined` case implicitly)
|
||||
else if (strictNullChecks && pattern.parent.initializer) {
|
||||
// Filter `undefined` from the type we check against if the parent has an initializer and that initializer is not possibly `undefined`
|
||||
else if (strictNullChecks && pattern.parent.initializer && !(getTypeFacts(getTypeOfInitializer(pattern.parent.initializer)) & TypeFacts.EQUndefined)) {
|
||||
parentType = getTypeWithFacts(parentType, TypeFacts.NEUndefined);
|
||||
}
|
||||
|
||||
@@ -7645,11 +7720,38 @@ namespace ts {
|
||||
resolvedSymbol.exports = createSymbolTable();
|
||||
}
|
||||
(resolvedSymbol || symbol).exports!.forEach((s, name) => {
|
||||
if (members.has(name)) {
|
||||
const exportedMember = exportedType.members.get(name)!;
|
||||
const union = createSymbol(s.flags | exportedMember.flags, name);
|
||||
union.type = getUnionType([getTypeOfSymbol(s), getTypeOfSymbol(exportedMember)]);
|
||||
members.set(name, union);
|
||||
const exportedMember = members.get(name)!;
|
||||
if (exportedMember && exportedMember !== s) {
|
||||
if (s.flags & SymbolFlags.Value) {
|
||||
// If the member has an additional value-like declaration, union the types from the two declarations,
|
||||
// but issue an error if they occurred in two different files. The purpose is to support a JS file with
|
||||
// a pattern like:
|
||||
//
|
||||
// module.exports = { a: true };
|
||||
// module.exports.a = 3;
|
||||
//
|
||||
// but we may have a JS file with `module.exports = { a: true }` along with a TypeScript module augmentation
|
||||
// declaring an `export const a: number`. In that case, we issue a duplicate identifier error, because
|
||||
// it's unclear what that's supposed to mean, so it's probably a mistake.
|
||||
if (getSourceFileOfNode(s.valueDeclaration) !== getSourceFileOfNode(exportedMember.valueDeclaration)) {
|
||||
const unescapedName = unescapeLeadingUnderscores(s.escapedName);
|
||||
const exportedMemberName = tryCast(exportedMember.valueDeclaration, isNamedDeclaration)?.name || exportedMember.valueDeclaration;
|
||||
addRelatedInfo(
|
||||
error(s.valueDeclaration, Diagnostics.Duplicate_identifier_0, unescapedName),
|
||||
createDiagnosticForNode(exportedMemberName, Diagnostics._0_was_also_declared_here, unescapedName));
|
||||
addRelatedInfo(
|
||||
error(exportedMemberName, Diagnostics.Duplicate_identifier_0, unescapedName),
|
||||
createDiagnosticForNode(s.valueDeclaration, Diagnostics._0_was_also_declared_here, unescapedName));
|
||||
}
|
||||
const union = createSymbol(s.flags | exportedMember.flags, name);
|
||||
union.type = getUnionType([getTypeOfSymbol(s), getTypeOfSymbol(exportedMember)]);
|
||||
union.valueDeclaration = exportedMember.valueDeclaration;
|
||||
union.declarations = concatenate(exportedMember.declarations, s.declarations);
|
||||
members.set(name, union);
|
||||
}
|
||||
else {
|
||||
members.set(name, mergeSymbol(s, exportedMember));
|
||||
}
|
||||
}
|
||||
else {
|
||||
members.set(name, s);
|
||||
@@ -16537,7 +16639,7 @@ namespace ts {
|
||||
if (!targetProperty) continue outer;
|
||||
if (sourceProperty === targetProperty) continue;
|
||||
// We compare the source property to the target in the context of a single discriminant type.
|
||||
const related = propertyRelatedTo(source, target, sourceProperty, targetProperty, _ => combination[i], /*reportErrors*/ false, IntersectionState.None);
|
||||
const related = propertyRelatedTo(source, target, sourceProperty, targetProperty, _ => combination[i], /*reportErrors*/ false, IntersectionState.None, /*skipOptional*/ strictNullChecks || relation === comparableRelation);
|
||||
// If the target property could not be found, or if the properties were not related,
|
||||
// then this constituent is not a match.
|
||||
if (!related) {
|
||||
@@ -16635,7 +16737,7 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
function propertyRelatedTo(source: Type, target: Type, sourceProp: Symbol, targetProp: Symbol, getTypeOfSourceProperty: (sym: Symbol) => Type, reportErrors: boolean, intersectionState: IntersectionState): Ternary {
|
||||
function propertyRelatedTo(source: Type, target: Type, sourceProp: Symbol, targetProp: Symbol, getTypeOfSourceProperty: (sym: Symbol) => Type, reportErrors: boolean, intersectionState: IntersectionState, skipOptional: boolean): Ternary {
|
||||
const sourcePropFlags = getDeclarationModifierFlagsFromSymbol(sourceProp);
|
||||
const targetPropFlags = getDeclarationModifierFlagsFromSymbol(targetProp);
|
||||
if (sourcePropFlags & ModifierFlags.Private || targetPropFlags & ModifierFlags.Private) {
|
||||
@@ -16678,7 +16780,7 @@ namespace ts {
|
||||
return Ternary.False;
|
||||
}
|
||||
// When checking for comparability, be more lenient with optional properties.
|
||||
if (relation !== comparableRelation && sourceProp.flags & SymbolFlags.Optional && !(targetProp.flags & SymbolFlags.Optional)) {
|
||||
if (!skipOptional && sourceProp.flags & SymbolFlags.Optional && !(targetProp.flags & SymbolFlags.Optional)) {
|
||||
// TypeScript 1.0 spec (April 2014): 3.8.3
|
||||
// S is a subtype of a type T, and T is a supertype of S if ...
|
||||
// S' and T are object types and, for each member M in T..
|
||||
@@ -16808,7 +16910,7 @@ namespace ts {
|
||||
if (!(targetProp.flags & SymbolFlags.Prototype) && (!numericNamesOnly || isNumericLiteralName(name) || name === "length")) {
|
||||
const sourceProp = getPropertyOfType(source, name);
|
||||
if (sourceProp && sourceProp !== targetProp) {
|
||||
const related = propertyRelatedTo(source, target, sourceProp, targetProp, getTypeOfSymbol, reportErrors, intersectionState);
|
||||
const related = propertyRelatedTo(source, target, sourceProp, targetProp, getTypeOfSymbol, reportErrors, intersectionState, relation === comparableRelation);
|
||||
if (!related) {
|
||||
return Ternary.False;
|
||||
}
|
||||
@@ -18091,7 +18193,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
function reportErrorsFromWidening(declaration: Declaration, type: Type, wideningKind?: WideningKind) {
|
||||
if (produceDiagnostics && noImplicitAny && getObjectFlags(type) & ObjectFlags.ContainsWideningType) {
|
||||
if (produceDiagnostics && noImplicitAny && getObjectFlags(type) & ObjectFlags.ContainsWideningType && (!wideningKind || !getContextualSignatureForFunctionLikeDeclaration(declaration as FunctionLikeDeclaration))) {
|
||||
// Report implicit any error within type if possible, otherwise report error on declaration
|
||||
if (!reportWideningErrorsInType(type)) {
|
||||
reportImplicitAny(declaration, type, wideningKind);
|
||||
@@ -20453,7 +20555,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
function narrowByInKeyword(type: Type, literal: LiteralExpression, assumeTrue: boolean) {
|
||||
if (type.flags & (TypeFlags.Union | TypeFlags.Object | TypeFlags.Intersection) || isThisTypeParameter(type)) {
|
||||
if (type.flags & (TypeFlags.Union | TypeFlags.Object) || isThisTypeParameter(type)) {
|
||||
const propName = escapeLeadingUnderscores(literal.text);
|
||||
return filterType(type, t => isTypePresencePossible(t, propName, assumeTrue));
|
||||
}
|
||||
@@ -27046,15 +27148,13 @@ namespace ts {
|
||||
}
|
||||
|
||||
if (returnType || yieldType || nextType) {
|
||||
const contextualSignature = getContextualSignatureForFunctionLikeDeclaration(func);
|
||||
if (!contextualSignature) {
|
||||
if (yieldType) reportErrorsFromWidening(func, yieldType, WideningKind.GeneratorYield);
|
||||
if (returnType) reportErrorsFromWidening(func, returnType);
|
||||
if (nextType) reportErrorsFromWidening(func, nextType);
|
||||
}
|
||||
if (yieldType) reportErrorsFromWidening(func, yieldType, WideningKind.GeneratorYield);
|
||||
if (returnType) reportErrorsFromWidening(func, returnType, WideningKind.FunctionReturn);
|
||||
if (nextType) reportErrorsFromWidening(func, nextType, WideningKind.GeneratorNext);
|
||||
if (returnType && isUnitType(returnType) ||
|
||||
yieldType && isUnitType(yieldType) ||
|
||||
nextType && isUnitType(nextType)) {
|
||||
const contextualSignature = getContextualSignatureForFunctionLikeDeclaration(func);
|
||||
const contextualType = !contextualSignature ? undefined :
|
||||
contextualSignature === getSignatureFromDeclaration(func) ? isGenerator ? undefined : returnType :
|
||||
instantiateContextualType(getReturnTypeOfSignature(contextualSignature), func);
|
||||
@@ -27582,12 +27682,23 @@ namespace ts {
|
||||
}
|
||||
const links = getNodeLinks(expr);
|
||||
const symbol = getExportSymbolOfValueSymbolIfExported(links.resolvedSymbol);
|
||||
if (symbol && isReadonlySymbol(symbol)) {
|
||||
error(expr, Diagnostics.The_operand_of_a_delete_operator_cannot_be_a_read_only_property);
|
||||
if (symbol) {
|
||||
if (isReadonlySymbol(symbol)) {
|
||||
error(expr, Diagnostics.The_operand_of_a_delete_operator_cannot_be_a_read_only_property);
|
||||
}
|
||||
|
||||
checkDeleteExpressionMustBeOptional(expr, getTypeOfSymbol(symbol));
|
||||
}
|
||||
return booleanType;
|
||||
}
|
||||
|
||||
function checkDeleteExpressionMustBeOptional(expr: AccessExpression, type: Type) {
|
||||
const AnyOrUnknownOrNeverFlags = TypeFlags.AnyOrUnknown | TypeFlags.Never;
|
||||
if (strictNullChecks && !(type.flags & AnyOrUnknownOrNeverFlags) && !(getFalsyFlags(type) & TypeFlags.Undefined)) {
|
||||
error(expr, Diagnostics.The_operand_of_a_delete_operator_must_be_optional);
|
||||
}
|
||||
}
|
||||
|
||||
function checkTypeOfExpression(node: TypeOfExpression): Type {
|
||||
checkExpression(node.expression);
|
||||
return typeofType;
|
||||
@@ -29676,8 +29787,9 @@ namespace ts {
|
||||
// - The constructor declares parameter properties
|
||||
// or the containing class declares instance member variables with initializers.
|
||||
const superCallShouldBeFirst =
|
||||
some((<ClassDeclaration>node.parent).members, isInstancePropertyWithInitializerOrPrivateIdentifierProperty) ||
|
||||
some(node.parameters, p => hasModifier(p, ModifierFlags.ParameterPropertyModifier));
|
||||
(compilerOptions.target !== ScriptTarget.ESNext || !compilerOptions.useDefineForClassFields) &&
|
||||
(some((<ClassDeclaration>node.parent).members, isInstancePropertyWithInitializerOrPrivateIdentifierProperty) ||
|
||||
some(node.parameters, p => hasModifier(p, ModifierFlags.ParameterPropertyModifier)));
|
||||
|
||||
// Skip past any prologue directives to find the first statement
|
||||
// to ensure that it was a super call.
|
||||
@@ -31830,7 +31942,9 @@ namespace ts {
|
||||
let childExpression = childNode.parent;
|
||||
while (testedExpression && childExpression) {
|
||||
|
||||
if (isIdentifier(testedExpression) && isIdentifier(childExpression)) {
|
||||
if (isIdentifier(testedExpression) && isIdentifier(childExpression) ||
|
||||
testedExpression.kind === SyntaxKind.ThisKeyword && childExpression.kind === SyntaxKind.ThisKeyword
|
||||
) {
|
||||
return getSymbolAtLocation(testedExpression) === getSymbolAtLocation(childExpression);
|
||||
}
|
||||
|
||||
@@ -33480,6 +33594,26 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
function getNonInterhitedProperties(type: InterfaceType, baseTypes: BaseType[], properties: Symbol[]) {
|
||||
if (!length(baseTypes)) {
|
||||
return properties;
|
||||
}
|
||||
const seen = createUnderscoreEscapedMap<Symbol>();
|
||||
forEach(properties, p => { seen.set(p.escapedName, p); });
|
||||
|
||||
for (const base of baseTypes) {
|
||||
const properties = getPropertiesOfType(getTypeWithThisArgument(base, type.thisType));
|
||||
for (const prop of properties) {
|
||||
const existing = seen.get(prop.escapedName);
|
||||
if (existing && !isPropertyIdenticalTo(existing, prop)) {
|
||||
seen.delete(prop.escapedName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return arrayFrom(seen.values());
|
||||
}
|
||||
|
||||
function checkInheritedPropertiesAreIdentical(type: InterfaceType, typeNode: Node): boolean {
|
||||
const baseTypes = getBaseTypes(type);
|
||||
if (baseTypes.length < 2) {
|
||||
|
||||
@@ -844,6 +844,28 @@ namespace ts {
|
||||
return to;
|
||||
}
|
||||
|
||||
/**
|
||||
* Combines two arrays, values, or undefineds into the smallest container that can accommodate the resulting set:
|
||||
*
|
||||
* ```
|
||||
* undefined -> undefined -> undefined
|
||||
* T -> undefined -> T
|
||||
* T -> T -> T[]
|
||||
* T[] -> undefined -> T[] (no-op)
|
||||
* T[] -> T -> T[] (append)
|
||||
* T[] -> T[] -> T[] (concatenate)
|
||||
* ```
|
||||
*/
|
||||
export function combine<T>(xs: T | readonly T[] | undefined, ys: T | readonly T[] | undefined): T | readonly T[] | undefined;
|
||||
export function combine<T>(xs: T | T[] | undefined, ys: T | T[] | undefined): T | T[] | undefined;
|
||||
export function combine<T>(xs: T | T[] | undefined, ys: T | T[] | undefined) {
|
||||
if (xs === undefined) return ys;
|
||||
if (ys === undefined) return xs;
|
||||
if (isArray(xs)) return isArray(ys) ? concatenate(xs, ys) : append(xs, ys);
|
||||
if (isArray(ys)) return append(ys, xs);
|
||||
return [xs, ys];
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the actual offset into an array for a relative offset. Negative offsets indicate a
|
||||
* position offset from the end of the array.
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
namespace ts {
|
||||
// WARNING: The script `configurePrerelease.ts` uses a regexp to parse out these values.
|
||||
// If changing the text in this section, be sure to test `configurePrerelease` too.
|
||||
export const versionMajorMinor = "3.9";
|
||||
export const versionMajorMinor = "4.0";
|
||||
/** The version of the TypeScript compiler release */
|
||||
export const version = `${versionMajorMinor}.0-dev`;
|
||||
|
||||
|
||||
@@ -1477,11 +1477,11 @@
|
||||
"category": "Error",
|
||||
"code": 2371
|
||||
},
|
||||
"Parameter '{0}' cannot be referenced in its initializer.": {
|
||||
"Parameter '{0}' cannot reference itself.": {
|
||||
"category": "Error",
|
||||
"code": 2372
|
||||
},
|
||||
"Initializer of parameter '{0}' cannot reference identifier '{1}' declared after it.": {
|
||||
"Parameter '{0}' cannot reference identifier '{1}' declared after it.": {
|
||||
"category": "Error",
|
||||
"code": 2373
|
||||
},
|
||||
@@ -2963,6 +2963,10 @@
|
||||
"category": "Error",
|
||||
"code": 2789
|
||||
},
|
||||
"The operand of a 'delete' operator must be optional.": {
|
||||
"category": "Error",
|
||||
"code": 2790
|
||||
},
|
||||
|
||||
"Import declaration '{0}' is using private name '{1}'.": {
|
||||
"category": "Error",
|
||||
@@ -4384,6 +4388,14 @@
|
||||
"category": "Error",
|
||||
"code": 6231
|
||||
},
|
||||
"Declaration augments declaration in another file. This cannot be serialized.": {
|
||||
"category": "Error",
|
||||
"code": 6232
|
||||
},
|
||||
"This is the declaration being augmented. Consider moving the augmenting declaration into the same file.": {
|
||||
"category": "Error",
|
||||
"code": 6233
|
||||
},
|
||||
|
||||
"Projects to reference": {
|
||||
"category": "Message",
|
||||
|
||||
+23
-9
@@ -2366,16 +2366,10 @@ namespace ts {
|
||||
|
||||
function emitParenthesizedExpression(node: ParenthesizedExpression) {
|
||||
const openParenPos = emitTokenWithComment(SyntaxKind.OpenParenToken, node.pos, writePunctuation, node);
|
||||
const leadingNewlines = preserveSourceNewlines && getLeadingLineTerminatorCount(node, [node.expression], ListFormat.None);
|
||||
if (leadingNewlines) {
|
||||
writeLinesAndIndent(leadingNewlines, /*writeLinesIfNotIndenting*/ false);
|
||||
}
|
||||
const indented = writeLineSeparatorsAndIndentBefore(node.expression, node);
|
||||
emitExpression(node.expression);
|
||||
const trailingNewlines = preserveSourceNewlines && getClosingLineTerminatorCount(node, [node.expression], ListFormat.None);
|
||||
if (trailingNewlines) {
|
||||
writeLine(trailingNewlines);
|
||||
}
|
||||
decreaseIndentIf(leadingNewlines);
|
||||
writeLineSeparatorsAfter(node.expression, node);
|
||||
decreaseIndentIf(indented);
|
||||
emitTokenWithComment(SyntaxKind.CloseParenToken, node.expression ? node.expression.end : openParenPos, writePunctuation, node);
|
||||
}
|
||||
|
||||
@@ -3293,12 +3287,15 @@ namespace ts {
|
||||
writePunctuation("<");
|
||||
|
||||
if (isJsxOpeningElement(node)) {
|
||||
const indented = writeLineSeparatorsAndIndentBefore(node.tagName, node);
|
||||
emitJsxTagName(node.tagName);
|
||||
emitTypeArguments(node, node.typeArguments);
|
||||
if (node.attributes.properties && node.attributes.properties.length > 0) {
|
||||
writeSpace();
|
||||
}
|
||||
emit(node.attributes);
|
||||
writeLineSeparatorsAfter(node.attributes, node);
|
||||
decreaseIndentIf(indented);
|
||||
}
|
||||
|
||||
writePunctuation(">");
|
||||
@@ -4302,6 +4299,7 @@ namespace ts {
|
||||
return getEffectiveLines(
|
||||
includeComments => getLinesBetweenPositionAndPrecedingNonWhitespaceCharacter(
|
||||
firstChild.pos,
|
||||
parentNode.pos,
|
||||
currentSourceFile!,
|
||||
includeComments));
|
||||
}
|
||||
@@ -4359,6 +4357,7 @@ namespace ts {
|
||||
return getEffectiveLines(
|
||||
includeComments => getLinesBetweenPositionAndNextNonWhitespaceCharacter(
|
||||
lastChild.end,
|
||||
parentNode.end,
|
||||
currentSourceFile!,
|
||||
includeComments));
|
||||
}
|
||||
@@ -4398,6 +4397,21 @@ namespace ts {
|
||||
return lines;
|
||||
}
|
||||
|
||||
function writeLineSeparatorsAndIndentBefore(node: Node, parent: Node): boolean {
|
||||
const leadingNewlines = preserveSourceNewlines && getLeadingLineTerminatorCount(parent, [node], ListFormat.None);
|
||||
if (leadingNewlines) {
|
||||
writeLinesAndIndent(leadingNewlines, /*writeLinesIfNotIndenting*/ false);
|
||||
}
|
||||
return !!leadingNewlines;
|
||||
}
|
||||
|
||||
function writeLineSeparatorsAfter(node: Node, parent: Node) {
|
||||
const trailingNewlines = preserveSourceNewlines && getClosingLineTerminatorCount(parent, [node], ListFormat.None);
|
||||
if (trailingNewlines) {
|
||||
writeLine(trailingNewlines);
|
||||
}
|
||||
}
|
||||
|
||||
function synthesizedNodeStartsOnNewLine(node: Node, format: ListFormat) {
|
||||
if (nodeIsSynthesized(node)) {
|
||||
const startsOnNewLine = getStartsOnNewLine(node);
|
||||
|
||||
@@ -4,11 +4,14 @@ namespace ts {
|
||||
enableEmitNotification: noop,
|
||||
enableSubstitution: noop,
|
||||
endLexicalEnvironment: returnUndefined,
|
||||
getCompilerOptions: notImplemented,
|
||||
getCompilerOptions: () => ({}),
|
||||
getEmitHost: notImplemented,
|
||||
getEmitResolver: notImplemented,
|
||||
setLexicalEnvironmentFlags: noop,
|
||||
getLexicalEnvironmentFlags: () => 0,
|
||||
hoistFunctionDeclaration: noop,
|
||||
hoistVariableDeclaration: noop,
|
||||
addInitializationStatement: noop,
|
||||
isEmitNotificationEnabled: notImplemented,
|
||||
isSubstitutionEnabled: notImplemented,
|
||||
onEmitNode: noop,
|
||||
@@ -852,13 +855,13 @@ namespace ts {
|
||||
* This function needs to be called whenever we transform the statement
|
||||
* list of a source file, namespace, or function-like body.
|
||||
*/
|
||||
export function addCustomPrologue(target: Statement[], source: readonly Statement[], statementOffset: number, visitor?: (node: Node) => VisitResult<Node>): number;
|
||||
export function addCustomPrologue(target: Statement[], source: readonly Statement[], statementOffset: number | undefined, visitor?: (node: Node) => VisitResult<Node>): number | undefined;
|
||||
export function addCustomPrologue(target: Statement[], source: readonly Statement[], statementOffset: number | undefined, visitor?: (node: Node) => VisitResult<Node>): number | undefined {
|
||||
export function addCustomPrologue(target: Statement[], source: readonly Statement[], statementOffset: number, visitor?: (node: Node) => VisitResult<Node>, filter?: (node: Node) => boolean): number;
|
||||
export function addCustomPrologue(target: Statement[], source: readonly Statement[], statementOffset: number | undefined, visitor?: (node: Node) => VisitResult<Node>, filter?: (node: Node) => boolean): number | undefined;
|
||||
export function addCustomPrologue(target: Statement[], source: readonly Statement[], statementOffset: number | undefined, visitor?: (node: Node) => VisitResult<Node>, filter: (node: Node) => boolean = returnTrue): number | undefined {
|
||||
const numStatements = source.length;
|
||||
while (statementOffset !== undefined && statementOffset < numStatements) {
|
||||
const statement = source[statementOffset];
|
||||
if (getEmitFlags(statement) & EmitFlags.CustomPrologue) {
|
||||
if (getEmitFlags(statement) & EmitFlags.CustomPrologue && filter(statement)) {
|
||||
append(target, visitor ? visitNode(statement, visitor, isStatement) : statement);
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -148,8 +148,12 @@ namespace ts {
|
||||
const enabledSyntaxKindFeatures = new Array<SyntaxKindFeatureFlags>(SyntaxKind.Count);
|
||||
let lexicalEnvironmentVariableDeclarations: VariableDeclaration[];
|
||||
let lexicalEnvironmentFunctionDeclarations: FunctionDeclaration[];
|
||||
let lexicalEnvironmentStatements: Statement[];
|
||||
let lexicalEnvironmentFlags = LexicalEnvironmentFlags.None;
|
||||
let lexicalEnvironmentVariableDeclarationsStack: VariableDeclaration[][] = [];
|
||||
let lexicalEnvironmentFunctionDeclarationsStack: FunctionDeclaration[][] = [];
|
||||
let lexicalEnvironmentStatementsStack: Statement[][] = [];
|
||||
let lexicalEnvironmentFlagsStack: LexicalEnvironmentFlags[] = [];
|
||||
let lexicalEnvironmentStackOffset = 0;
|
||||
let lexicalEnvironmentSuspended = false;
|
||||
let emitHelpers: EmitHelper[] | undefined;
|
||||
@@ -168,8 +172,11 @@ namespace ts {
|
||||
suspendLexicalEnvironment,
|
||||
resumeLexicalEnvironment,
|
||||
endLexicalEnvironment,
|
||||
setLexicalEnvironmentFlags,
|
||||
getLexicalEnvironmentFlags,
|
||||
hoistVariableDeclaration,
|
||||
hoistFunctionDeclaration,
|
||||
addInitializationStatement,
|
||||
requestEmitHelper,
|
||||
readEmitHelpers,
|
||||
enableSubstitution,
|
||||
@@ -313,6 +320,9 @@ namespace ts {
|
||||
else {
|
||||
lexicalEnvironmentVariableDeclarations.push(decl);
|
||||
}
|
||||
if (lexicalEnvironmentFlags & LexicalEnvironmentFlags.InParameters) {
|
||||
lexicalEnvironmentFlags |= LexicalEnvironmentFlags.VariablesHoistedInParameters;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -321,6 +331,7 @@ namespace ts {
|
||||
function hoistFunctionDeclaration(func: FunctionDeclaration): void {
|
||||
Debug.assert(state > TransformationState.Uninitialized, "Cannot modify the lexical environment during initialization.");
|
||||
Debug.assert(state < TransformationState.Completed, "Cannot modify the lexical environment after transformation has completed.");
|
||||
setEmitFlags(func, EmitFlags.CustomPrologue);
|
||||
if (!lexicalEnvironmentFunctionDeclarations) {
|
||||
lexicalEnvironmentFunctionDeclarations = [func];
|
||||
}
|
||||
@@ -329,6 +340,21 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds an initialization statement to the top of the lexical environment.
|
||||
*/
|
||||
function addInitializationStatement(node: Statement): void {
|
||||
Debug.assert(state > TransformationState.Uninitialized, "Cannot modify the lexical environment during initialization.");
|
||||
Debug.assert(state < TransformationState.Completed, "Cannot modify the lexical environment after transformation has completed.");
|
||||
setEmitFlags(node, EmitFlags.CustomPrologue);
|
||||
if (!lexicalEnvironmentStatements) {
|
||||
lexicalEnvironmentStatements = [node];
|
||||
}
|
||||
else {
|
||||
lexicalEnvironmentStatements.push(node);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Starts a new lexical environment. Any existing hoisted variable or function declarations
|
||||
* are pushed onto a stack, and the related storage variables are reset.
|
||||
@@ -344,9 +370,13 @@ namespace ts {
|
||||
// transformation.
|
||||
lexicalEnvironmentVariableDeclarationsStack[lexicalEnvironmentStackOffset] = lexicalEnvironmentVariableDeclarations;
|
||||
lexicalEnvironmentFunctionDeclarationsStack[lexicalEnvironmentStackOffset] = lexicalEnvironmentFunctionDeclarations;
|
||||
lexicalEnvironmentStatementsStack[lexicalEnvironmentStackOffset] = lexicalEnvironmentStatements;
|
||||
lexicalEnvironmentFlagsStack[lexicalEnvironmentStackOffset] = lexicalEnvironmentFlags;
|
||||
lexicalEnvironmentStackOffset++;
|
||||
lexicalEnvironmentVariableDeclarations = undefined!;
|
||||
lexicalEnvironmentFunctionDeclarations = undefined!;
|
||||
lexicalEnvironmentStatements = undefined!;
|
||||
lexicalEnvironmentFlags = LexicalEnvironmentFlags.None;
|
||||
}
|
||||
|
||||
/** Suspends the current lexical environment, usually after visiting a parameter list. */
|
||||
@@ -375,7 +405,9 @@ namespace ts {
|
||||
Debug.assert(!lexicalEnvironmentSuspended, "Lexical environment is suspended.");
|
||||
|
||||
let statements: Statement[] | undefined;
|
||||
if (lexicalEnvironmentVariableDeclarations || lexicalEnvironmentFunctionDeclarations) {
|
||||
if (lexicalEnvironmentVariableDeclarations ||
|
||||
lexicalEnvironmentFunctionDeclarations ||
|
||||
lexicalEnvironmentStatements) {
|
||||
if (lexicalEnvironmentFunctionDeclarations) {
|
||||
statements = [...lexicalEnvironmentFunctionDeclarations];
|
||||
}
|
||||
@@ -395,19 +427,42 @@ namespace ts {
|
||||
statements.push(statement);
|
||||
}
|
||||
}
|
||||
|
||||
if (lexicalEnvironmentStatements) {
|
||||
if (!statements) {
|
||||
statements = [...lexicalEnvironmentStatements];
|
||||
}
|
||||
else {
|
||||
statements = [...statements, ...lexicalEnvironmentStatements];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Restore the previous lexical environment.
|
||||
lexicalEnvironmentStackOffset--;
|
||||
lexicalEnvironmentVariableDeclarations = lexicalEnvironmentVariableDeclarationsStack[lexicalEnvironmentStackOffset];
|
||||
lexicalEnvironmentFunctionDeclarations = lexicalEnvironmentFunctionDeclarationsStack[lexicalEnvironmentStackOffset];
|
||||
lexicalEnvironmentStatements = lexicalEnvironmentStatementsStack[lexicalEnvironmentStackOffset];
|
||||
lexicalEnvironmentFlags = lexicalEnvironmentFlagsStack[lexicalEnvironmentStackOffset];
|
||||
if (lexicalEnvironmentStackOffset === 0) {
|
||||
lexicalEnvironmentVariableDeclarationsStack = [];
|
||||
lexicalEnvironmentFunctionDeclarationsStack = [];
|
||||
lexicalEnvironmentStatementsStack = [];
|
||||
lexicalEnvironmentFlagsStack = [];
|
||||
}
|
||||
return statements;
|
||||
}
|
||||
|
||||
function setLexicalEnvironmentFlags(flags: LexicalEnvironmentFlags, value: boolean): void {
|
||||
lexicalEnvironmentFlags = value ?
|
||||
lexicalEnvironmentFlags | flags :
|
||||
lexicalEnvironmentFlags & ~flags;
|
||||
}
|
||||
|
||||
function getLexicalEnvironmentFlags(): LexicalEnvironmentFlags {
|
||||
return lexicalEnvironmentFlags;
|
||||
}
|
||||
|
||||
function requestEmitHelper(helper: EmitHelper): void {
|
||||
Debug.assert(state > TransformationState.Uninitialized, "Cannot modify the transformation context during initialization.");
|
||||
Debug.assert(state < TransformationState.Completed, "Cannot modify the transformation context after transformation has completed.");
|
||||
|
||||
@@ -606,7 +606,7 @@ namespace ts {
|
||||
createConstructor(
|
||||
/*decorators*/ undefined,
|
||||
/*modifiers*/ undefined,
|
||||
parameters,
|
||||
parameters ?? [],
|
||||
body
|
||||
),
|
||||
constructor || node
|
||||
|
||||
@@ -76,7 +76,8 @@ namespace ts {
|
||||
reportLikelyUnsafeImportRequiredError,
|
||||
moduleResolverHost: host,
|
||||
trackReferencedAmbientModule,
|
||||
trackExternalModuleSymbolOfImportTypeNode
|
||||
trackExternalModuleSymbolOfImportTypeNode,
|
||||
reportNonlocalAugmentation
|
||||
};
|
||||
let errorNameNode: DeclarationName | undefined;
|
||||
|
||||
@@ -190,6 +191,17 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
function reportNonlocalAugmentation(containingFile: SourceFile, parentSymbol: Symbol, symbol: Symbol) {
|
||||
const primaryDeclaration = find(parentSymbol.declarations, d => getSourceFileOfNode(d) === containingFile)!;
|
||||
const augmentingDeclarations = filter(symbol.declarations, d => getSourceFileOfNode(d) !== containingFile);
|
||||
for (const augmentations of augmentingDeclarations) {
|
||||
context.addDiagnostic(addRelatedInfo(
|
||||
createDiagnosticForNode(augmentations, Diagnostics.Declaration_augments_declaration_in_another_file_This_cannot_be_serialized),
|
||||
createDiagnosticForNode(primaryDeclaration, Diagnostics.This_is_the_declaration_being_augmented_Consider_moving_the_augmenting_declaration_into_the_same_file)
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
function transformDeclarationsForJS(sourceFile: SourceFile, bundled?: boolean) {
|
||||
const oldDiag = getSymbolAccessibilityDiagnostic;
|
||||
getSymbolAccessibilityDiagnostic = (s) => ({
|
||||
|
||||
@@ -1853,6 +1853,8 @@ namespace ts {
|
||||
// ensureUseStrict is false because no new prologue-directive should be added.
|
||||
// addStandardPrologue will put already-existing directives at the beginning of the target statement-array
|
||||
statementOffset = addStandardPrologue(prologue, body.statements, /*ensureUseStrict*/ false);
|
||||
statementOffset = addCustomPrologue(statements, body.statements, statementOffset, visitor, isHoistedFunction);
|
||||
statementOffset = addCustomPrologue(statements, body.statements, statementOffset, visitor, isHoistedVariableStatement);
|
||||
}
|
||||
|
||||
multiLine = addDefaultValueAssignmentsIfNeeded(statements, node) || multiLine;
|
||||
|
||||
@@ -5,6 +5,38 @@ namespace ts {
|
||||
AsyncMethodsWithSuper = 1 << 0
|
||||
}
|
||||
|
||||
// Facts we track as we traverse the tree
|
||||
const enum HierarchyFacts {
|
||||
None = 0,
|
||||
|
||||
//
|
||||
// Ancestor facts
|
||||
//
|
||||
|
||||
HasLexicalThis = 1 << 0,
|
||||
IterationContainer = 1 << 1,
|
||||
// NOTE: do not add more ancestor flags without also updating AncestorFactsMask below.
|
||||
|
||||
//
|
||||
// Ancestor masks
|
||||
//
|
||||
|
||||
AncestorFactsMask = (IterationContainer << 1) - 1,
|
||||
|
||||
SourceFileIncludes = HasLexicalThis,
|
||||
SourceFileExcludes = IterationContainer,
|
||||
StrictModeSourceFileIncludes = None,
|
||||
|
||||
ClassOrFunctionIncludes = HasLexicalThis,
|
||||
ClassOrFunctionExcludes = IterationContainer,
|
||||
|
||||
ArrowFunctionIncludes = None,
|
||||
ArrowFunctionExcludes = ClassOrFunctionExcludes,
|
||||
|
||||
IterationStatementIncludes = IterationContainer,
|
||||
IterationStatementExcludes = None,
|
||||
}
|
||||
|
||||
export function transformES2018(context: TransformationContext) {
|
||||
const {
|
||||
resumeLexicalEnvironment,
|
||||
@@ -26,7 +58,7 @@ namespace ts {
|
||||
let enabledSubstitutions: ESNextSubstitutionFlags;
|
||||
let enclosingFunctionFlags: FunctionFlags;
|
||||
let enclosingSuperContainerFlags: NodeCheckFlags = 0;
|
||||
let hasLexicalThis: boolean;
|
||||
let hierarchyFacts: HierarchyFacts = 0;
|
||||
|
||||
let currentSourceFile: SourceFile;
|
||||
let taggedTemplateStringDeclarations: VariableDeclaration[];
|
||||
@@ -40,6 +72,30 @@ namespace ts {
|
||||
|
||||
return chainBundle(transformSourceFile);
|
||||
|
||||
function affectsSubtree(excludeFacts: HierarchyFacts, includeFacts: HierarchyFacts) {
|
||||
return hierarchyFacts !== (hierarchyFacts & ~excludeFacts | includeFacts);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the `HierarchyFacts` for this node prior to visiting this node's subtree, returning the facts set prior to modification.
|
||||
* @param excludeFacts The existing `HierarchyFacts` to reset before visiting the subtree.
|
||||
* @param includeFacts The new `HierarchyFacts` to set before visiting the subtree.
|
||||
*/
|
||||
function enterSubtree(excludeFacts: HierarchyFacts, includeFacts: HierarchyFacts) {
|
||||
const ancestorFacts = hierarchyFacts;
|
||||
hierarchyFacts = (hierarchyFacts & ~excludeFacts | includeFacts) & HierarchyFacts.AncestorFactsMask;
|
||||
return ancestorFacts;
|
||||
}
|
||||
|
||||
/**
|
||||
* Restores the `HierarchyFacts` for this node's ancestor after visiting this node's
|
||||
* subtree.
|
||||
* @param ancestorFacts The `HierarchyFacts` of the ancestor to restore after visiting the subtree.
|
||||
*/
|
||||
function exitSubtree(ancestorFacts: HierarchyFacts) {
|
||||
hierarchyFacts = ancestorFacts;
|
||||
}
|
||||
|
||||
function recordTaggedTemplateString(temp: Identifier) {
|
||||
taggedTemplateStringDeclarations = append(
|
||||
taggedTemplateStringDeclarations,
|
||||
@@ -75,11 +131,11 @@ namespace ts {
|
||||
return node;
|
||||
}
|
||||
|
||||
function doWithLexicalThis<T, U>(cb: (value: T) => U, value: T) {
|
||||
if (!hasLexicalThis) {
|
||||
hasLexicalThis = true;
|
||||
function doWithHierarchyFacts<T, U>(cb: (value: T) => U, value: T, excludeFacts: HierarchyFacts, includeFacts: HierarchyFacts) {
|
||||
if (affectsSubtree(excludeFacts, includeFacts)) {
|
||||
const ancestorFacts = enterSubtree(excludeFacts, includeFacts);
|
||||
const result = cb(value);
|
||||
hasLexicalThis = false;
|
||||
exitSubtree(ancestorFacts);
|
||||
return result;
|
||||
}
|
||||
return cb(value);
|
||||
@@ -112,26 +168,66 @@ namespace ts {
|
||||
return visitVariableStatement(node as VariableStatement);
|
||||
case SyntaxKind.VariableDeclaration:
|
||||
return visitVariableDeclaration(node as VariableDeclaration);
|
||||
case SyntaxKind.DoStatement:
|
||||
case SyntaxKind.WhileStatement:
|
||||
case SyntaxKind.ForInStatement:
|
||||
return doWithHierarchyFacts(
|
||||
visitDefault,
|
||||
node,
|
||||
HierarchyFacts.IterationStatementExcludes,
|
||||
HierarchyFacts.IterationStatementIncludes);
|
||||
case SyntaxKind.ForOfStatement:
|
||||
return visitForOfStatement(node as ForOfStatement, /*outermostLabeledStatement*/ undefined);
|
||||
case SyntaxKind.ForStatement:
|
||||
return visitForStatement(node as ForStatement);
|
||||
return doWithHierarchyFacts(
|
||||
visitForStatement,
|
||||
node as ForStatement,
|
||||
HierarchyFacts.IterationStatementExcludes,
|
||||
HierarchyFacts.IterationStatementIncludes);
|
||||
case SyntaxKind.VoidExpression:
|
||||
return visitVoidExpression(node as VoidExpression);
|
||||
case SyntaxKind.Constructor:
|
||||
return doWithLexicalThis(visitConstructorDeclaration, node as ConstructorDeclaration);
|
||||
return doWithHierarchyFacts(
|
||||
visitConstructorDeclaration,
|
||||
node as ConstructorDeclaration,
|
||||
HierarchyFacts.ClassOrFunctionExcludes,
|
||||
HierarchyFacts.ClassOrFunctionIncludes);
|
||||
case SyntaxKind.MethodDeclaration:
|
||||
return doWithLexicalThis(visitMethodDeclaration, node as MethodDeclaration);
|
||||
return doWithHierarchyFacts(
|
||||
visitMethodDeclaration,
|
||||
node as MethodDeclaration,
|
||||
HierarchyFacts.ClassOrFunctionExcludes,
|
||||
HierarchyFacts.ClassOrFunctionIncludes);
|
||||
case SyntaxKind.GetAccessor:
|
||||
return doWithLexicalThis(visitGetAccessorDeclaration, node as GetAccessorDeclaration);
|
||||
return doWithHierarchyFacts(
|
||||
visitGetAccessorDeclaration,
|
||||
node as GetAccessorDeclaration,
|
||||
HierarchyFacts.ClassOrFunctionExcludes,
|
||||
HierarchyFacts.ClassOrFunctionIncludes);
|
||||
case SyntaxKind.SetAccessor:
|
||||
return doWithLexicalThis(visitSetAccessorDeclaration, node as SetAccessorDeclaration);
|
||||
return doWithHierarchyFacts(
|
||||
visitSetAccessorDeclaration,
|
||||
node as SetAccessorDeclaration,
|
||||
HierarchyFacts.ClassOrFunctionExcludes,
|
||||
HierarchyFacts.ClassOrFunctionIncludes);
|
||||
case SyntaxKind.FunctionDeclaration:
|
||||
return doWithLexicalThis(visitFunctionDeclaration, node as FunctionDeclaration);
|
||||
return doWithHierarchyFacts(
|
||||
visitFunctionDeclaration,
|
||||
node as FunctionDeclaration,
|
||||
HierarchyFacts.ClassOrFunctionExcludes,
|
||||
HierarchyFacts.ClassOrFunctionIncludes);
|
||||
case SyntaxKind.FunctionExpression:
|
||||
return doWithLexicalThis(visitFunctionExpression, node as FunctionExpression);
|
||||
return doWithHierarchyFacts(
|
||||
visitFunctionExpression,
|
||||
node as FunctionExpression,
|
||||
HierarchyFacts.ClassOrFunctionExcludes,
|
||||
HierarchyFacts.ClassOrFunctionIncludes);
|
||||
case SyntaxKind.ArrowFunction:
|
||||
return visitArrowFunction(node as ArrowFunction);
|
||||
return doWithHierarchyFacts(
|
||||
visitArrowFunction,
|
||||
node as ArrowFunction,
|
||||
HierarchyFacts.ArrowFunctionExcludes,
|
||||
HierarchyFacts.ArrowFunctionIncludes);
|
||||
case SyntaxKind.Parameter:
|
||||
return visitParameter(node as ParameterDeclaration);
|
||||
case SyntaxKind.ExpressionStatement:
|
||||
@@ -152,7 +248,11 @@ namespace ts {
|
||||
return visitEachChild(node, visitor, context);
|
||||
case SyntaxKind.ClassDeclaration:
|
||||
case SyntaxKind.ClassExpression:
|
||||
return doWithLexicalThis(visitDefault, node);
|
||||
return doWithHierarchyFacts(
|
||||
visitDefault,
|
||||
node,
|
||||
HierarchyFacts.ClassOrFunctionExcludes,
|
||||
HierarchyFacts.ClassOrFunctionIncludes);
|
||||
default:
|
||||
return visitEachChild(node, visitor, context);
|
||||
}
|
||||
@@ -231,7 +331,7 @@ namespace ts {
|
||||
if (statement.kind === SyntaxKind.ForOfStatement && (<ForOfStatement>statement).awaitModifier) {
|
||||
return visitForOfStatement(<ForOfStatement>statement, node);
|
||||
}
|
||||
return restoreEnclosingLabel(visitEachChild(statement, visitor, context), node);
|
||||
return restoreEnclosingLabel(visitNode(statement, visitor, isStatement, liftToBlock), node);
|
||||
}
|
||||
return visitEachChild(node, visitor, context);
|
||||
}
|
||||
@@ -311,14 +411,20 @@ namespace ts {
|
||||
}
|
||||
|
||||
function visitSourceFile(node: SourceFile): SourceFile {
|
||||
const ancestorFacts = enterSubtree(
|
||||
HierarchyFacts.SourceFileExcludes,
|
||||
isEffectiveStrictModeSourceFile(node, compilerOptions) ?
|
||||
HierarchyFacts.StrictModeSourceFileIncludes :
|
||||
HierarchyFacts.SourceFileIncludes);
|
||||
exportedVariableStatement = false;
|
||||
hasLexicalThis = !isEffectiveStrictModeSourceFile(node, compilerOptions);
|
||||
const visited = visitEachChild(node, visitor, context);
|
||||
const statement = concatenate(visited.statements, taggedTemplateStringDeclarations && [
|
||||
createVariableStatement(/*modifiers*/ undefined,
|
||||
createVariableDeclarationList(taggedTemplateStringDeclarations))
|
||||
]);
|
||||
return updateSourceFileNode(visited, setTextRange(createNodeArray(statement), node.statements));
|
||||
const result = updateSourceFileNode(visited, setTextRange(createNodeArray(statement), node.statements));
|
||||
exitSubtree(ancestorFacts);
|
||||
return result;
|
||||
}
|
||||
|
||||
function visitTaggedTemplateExpression(node: TaggedTemplateExpression) {
|
||||
@@ -441,15 +547,15 @@ namespace ts {
|
||||
* @param node A ForOfStatement.
|
||||
*/
|
||||
function visitForOfStatement(node: ForOfStatement, outermostLabeledStatement: LabeledStatement | undefined): VisitResult<Statement> {
|
||||
const ancestorFacts = enterSubtree(HierarchyFacts.IterationStatementExcludes, HierarchyFacts.IterationStatementIncludes);
|
||||
if (node.initializer.transformFlags & TransformFlags.ContainsObjectRestOrSpread) {
|
||||
node = transformForOfStatementWithObjectRest(node);
|
||||
}
|
||||
if (node.awaitModifier) {
|
||||
return transformForAwaitOfStatement(node, outermostLabeledStatement);
|
||||
}
|
||||
else {
|
||||
return restoreEnclosingLabel(visitEachChild(node, visitor, context), outermostLabeledStatement);
|
||||
}
|
||||
const result = node.awaitModifier ?
|
||||
transformForAwaitOfStatement(node, outermostLabeledStatement, ancestorFacts) :
|
||||
restoreEnclosingLabel(visitEachChild(node, visitor, context), outermostLabeledStatement);
|
||||
exitSubtree(ancestorFacts);
|
||||
return result;
|
||||
}
|
||||
|
||||
function transformForOfStatementWithObjectRest(node: ForOfStatement) {
|
||||
@@ -528,7 +634,7 @@ namespace ts {
|
||||
: createAwait(expression);
|
||||
}
|
||||
|
||||
function transformForAwaitOfStatement(node: ForOfStatement, outermostLabeledStatement: LabeledStatement | undefined) {
|
||||
function transformForAwaitOfStatement(node: ForOfStatement, outermostLabeledStatement: LabeledStatement | undefined, ancestorFacts: HierarchyFacts) {
|
||||
const expression = visitNode(node.expression, visitor, isExpression);
|
||||
const iterator = isIdentifier(expression) ? getGeneratedNameForNode(expression) : createTempVariable(/*recordTempVariable*/ undefined);
|
||||
const result = isIdentifier(expression) ? getGeneratedNameForNode(iterator) : createTempVariable(/*recordTempVariable*/ undefined);
|
||||
@@ -544,13 +650,18 @@ namespace ts {
|
||||
hoistVariableDeclaration(errorRecord);
|
||||
hoistVariableDeclaration(returnMethod);
|
||||
|
||||
// if we are enclosed in an outer loop ensure we reset 'errorRecord' per each iteration
|
||||
const initializer = ancestorFacts & HierarchyFacts.IterationContainer ?
|
||||
inlineExpressions([createAssignment(errorRecord, createVoidZero()), callValues]) :
|
||||
callValues;
|
||||
|
||||
const forStatement = setEmitFlags(
|
||||
setTextRange(
|
||||
createFor(
|
||||
/*initializer*/ setEmitFlags(
|
||||
setTextRange(
|
||||
createVariableDeclarationList([
|
||||
setTextRange(createVariableDeclaration(iterator, /*type*/ undefined, callValues), node.expression),
|
||||
setTextRange(createVariableDeclaration(iterator, /*type*/ undefined, initializer), node.expression),
|
||||
createVariableDeclaration(result)
|
||||
]),
|
||||
node.expression
|
||||
@@ -809,7 +920,7 @@ namespace ts {
|
||||
visitLexicalEnvironment(node.body!.statements, visitor, context, statementOffset)
|
||||
)
|
||||
),
|
||||
hasLexicalThis
|
||||
!!(hierarchyFacts & HierarchyFacts.HasLexicalThis)
|
||||
)
|
||||
);
|
||||
|
||||
@@ -1115,7 +1226,7 @@ namespace ts {
|
||||
context.requestEmitHelper(asyncGeneratorHelper);
|
||||
|
||||
// Mark this node as originally an async function
|
||||
(generatorFunc.emitNode || (generatorFunc.emitNode = {} as EmitNode)).flags |= EmitFlags.AsyncFunctionBody;
|
||||
(generatorFunc.emitNode || (generatorFunc.emitNode = {} as EmitNode)).flags |= EmitFlags.AsyncFunctionBody | EmitFlags.ReuseTempVariableScope;
|
||||
|
||||
return createCall(
|
||||
getUnscopedHelperName("__asyncGenerator"),
|
||||
|
||||
+192
-188
@@ -1,209 +1,213 @@
|
||||
/*@internal*/
|
||||
namespace ts {
|
||||
export function transformES2020(context: TransformationContext) {
|
||||
const {
|
||||
hoistVariableDeclaration,
|
||||
} = context;
|
||||
export function transformES2020(context: TransformationContext) {
|
||||
const {
|
||||
hoistVariableDeclaration,
|
||||
} = context;
|
||||
|
||||
return chainBundle(transformSourceFile);
|
||||
return chainBundle(transformSourceFile);
|
||||
|
||||
function transformSourceFile(node: SourceFile) {
|
||||
if (node.isDeclarationFile) {
|
||||
return node;
|
||||
}
|
||||
function transformSourceFile(node: SourceFile) {
|
||||
if (node.isDeclarationFile) {
|
||||
return node;
|
||||
}
|
||||
|
||||
return visitEachChild(node, visitor, context);
|
||||
}
|
||||
return visitEachChild(node, visitor, context);
|
||||
}
|
||||
|
||||
function visitor(node: Node): VisitResult<Node> {
|
||||
if ((node.transformFlags & TransformFlags.ContainsES2020) === 0) {
|
||||
return node;
|
||||
}
|
||||
switch (node.kind) {
|
||||
case SyntaxKind.PropertyAccessExpression:
|
||||
case SyntaxKind.ElementAccessExpression:
|
||||
case SyntaxKind.CallExpression:
|
||||
if (node.flags & NodeFlags.OptionalChain) {
|
||||
const updated = visitOptionalExpression(node as OptionalChain, /*captureThisArg*/ false, /*isDelete*/ false);
|
||||
Debug.assertNotNode(updated, isSyntheticReference);
|
||||
return updated;
|
||||
}
|
||||
return visitEachChild(node, visitor, context);
|
||||
case SyntaxKind.BinaryExpression:
|
||||
if ((<BinaryExpression>node).operatorToken.kind === SyntaxKind.QuestionQuestionToken) {
|
||||
return transformNullishCoalescingExpression(<BinaryExpression>node);
|
||||
}
|
||||
return visitEachChild(node, visitor, context);
|
||||
case SyntaxKind.DeleteExpression:
|
||||
return visitDeleteExpression(node as DeleteExpression);
|
||||
default:
|
||||
return visitEachChild(node, visitor, context);
|
||||
}
|
||||
}
|
||||
function visitor(node: Node): VisitResult<Node> {
|
||||
if ((node.transformFlags & TransformFlags.ContainsES2020) === 0) {
|
||||
return node;
|
||||
}
|
||||
switch (node.kind) {
|
||||
case SyntaxKind.PropertyAccessExpression:
|
||||
case SyntaxKind.ElementAccessExpression:
|
||||
case SyntaxKind.CallExpression:
|
||||
if (node.flags & NodeFlags.OptionalChain) {
|
||||
const updated = visitOptionalExpression(node as OptionalChain, /*captureThisArg*/ false, /*isDelete*/ false);
|
||||
Debug.assertNotNode(updated, isSyntheticReference);
|
||||
return updated;
|
||||
}
|
||||
return visitEachChild(node, visitor, context);
|
||||
case SyntaxKind.BinaryExpression:
|
||||
if ((<BinaryExpression>node).operatorToken.kind === SyntaxKind.QuestionQuestionToken) {
|
||||
return transformNullishCoalescingExpression(<BinaryExpression>node);
|
||||
}
|
||||
return visitEachChild(node, visitor, context);
|
||||
case SyntaxKind.DeleteExpression:
|
||||
return visitDeleteExpression(node as DeleteExpression);
|
||||
default:
|
||||
return visitEachChild(node, visitor, context);
|
||||
}
|
||||
}
|
||||
|
||||
function flattenChain(chain: OptionalChain) {
|
||||
Debug.assertNotNode(chain, isNonNullChain);
|
||||
const links: OptionalChain[] = [chain];
|
||||
while (!chain.questionDotToken && !isTaggedTemplateExpression(chain)) {
|
||||
chain = cast(skipPartiallyEmittedExpressions(chain.expression), isOptionalChain);
|
||||
Debug.assertNotNode(chain, isNonNullChain);
|
||||
links.unshift(chain);
|
||||
}
|
||||
return { expression: chain.expression, chain: links };
|
||||
}
|
||||
function flattenChain(chain: OptionalChain) {
|
||||
Debug.assertNotNode(chain, isNonNullChain);
|
||||
const links: OptionalChain[] = [chain];
|
||||
while (!chain.questionDotToken && !isTaggedTemplateExpression(chain)) {
|
||||
chain = cast(skipPartiallyEmittedExpressions(chain.expression), isOptionalChain);
|
||||
Debug.assertNotNode(chain, isNonNullChain);
|
||||
links.unshift(chain);
|
||||
}
|
||||
return { expression: chain.expression, chain: links };
|
||||
}
|
||||
|
||||
function visitNonOptionalParenthesizedExpression(node: ParenthesizedExpression, captureThisArg: boolean, isDelete: boolean): Expression {
|
||||
const expression = visitNonOptionalExpression(node.expression, captureThisArg, isDelete);
|
||||
if (isSyntheticReference(expression)) {
|
||||
// `(a.b)` -> { expression `((_a = a).b)`, thisArg: `_a` }
|
||||
// `(a[b])` -> { expression `((_a = a)[b])`, thisArg: `_a` }
|
||||
return createSyntheticReferenceExpression(updateParen(node, expression.expression), expression.thisArg);
|
||||
}
|
||||
return updateParen(node, expression);
|
||||
}
|
||||
function visitNonOptionalParenthesizedExpression(node: ParenthesizedExpression, captureThisArg: boolean, isDelete: boolean): Expression {
|
||||
const expression = visitNonOptionalExpression(node.expression, captureThisArg, isDelete);
|
||||
if (isSyntheticReference(expression)) {
|
||||
// `(a.b)` -> { expression `((_a = a).b)`, thisArg: `_a` }
|
||||
// `(a[b])` -> { expression `((_a = a)[b])`, thisArg: `_a` }
|
||||
return createSyntheticReferenceExpression(updateParen(node, expression.expression), expression.thisArg);
|
||||
}
|
||||
return updateParen(node, expression);
|
||||
}
|
||||
|
||||
function visitNonOptionalPropertyOrElementAccessExpression(node: AccessExpression, captureThisArg: boolean, isDelete: boolean): Expression {
|
||||
if (isOptionalChain(node)) {
|
||||
// If `node` is an optional chain, then it is the outermost chain of an optional expression.
|
||||
return visitOptionalExpression(node, captureThisArg, isDelete);
|
||||
}
|
||||
function visitNonOptionalPropertyOrElementAccessExpression(node: AccessExpression, captureThisArg: boolean, isDelete: boolean): Expression {
|
||||
if (isOptionalChain(node)) {
|
||||
// If `node` is an optional chain, then it is the outermost chain of an optional expression.
|
||||
return visitOptionalExpression(node, captureThisArg, isDelete);
|
||||
}
|
||||
|
||||
let expression: Expression = visitNode(node.expression, visitor, isExpression);
|
||||
Debug.assertNotNode(expression, isSyntheticReference);
|
||||
let expression: Expression = visitNode(node.expression, visitor, isExpression);
|
||||
Debug.assertNotNode(expression, isSyntheticReference);
|
||||
|
||||
let thisArg: Expression | undefined;
|
||||
if (captureThisArg) {
|
||||
if (shouldCaptureInTempVariable(expression)) {
|
||||
thisArg = createTempVariable(hoistVariableDeclaration);
|
||||
expression = createAssignment(thisArg, expression);
|
||||
}
|
||||
else {
|
||||
thisArg = expression;
|
||||
}
|
||||
}
|
||||
let thisArg: Expression | undefined;
|
||||
if (captureThisArg) {
|
||||
if (shouldCaptureInTempVariable(expression)) {
|
||||
thisArg = createTempVariable(hoistVariableDeclaration);
|
||||
expression = createAssignment(thisArg, expression);
|
||||
// if (inParameterInitializer) tempVariableInParameter = true;
|
||||
}
|
||||
else {
|
||||
thisArg = expression;
|
||||
}
|
||||
}
|
||||
|
||||
expression = node.kind === SyntaxKind.PropertyAccessExpression
|
||||
? updatePropertyAccess(node, expression, visitNode(node.name, visitor, isIdentifier))
|
||||
: updateElementAccess(node, expression, visitNode(node.argumentExpression, visitor, isExpression));
|
||||
return thisArg ? createSyntheticReferenceExpression(expression, thisArg) : expression;
|
||||
}
|
||||
expression = node.kind === SyntaxKind.PropertyAccessExpression
|
||||
? updatePropertyAccess(node, expression, visitNode(node.name, visitor, isIdentifier))
|
||||
: updateElementAccess(node, expression, visitNode(node.argumentExpression, visitor, isExpression));
|
||||
return thisArg ? createSyntheticReferenceExpression(expression, thisArg) : expression;
|
||||
}
|
||||
|
||||
function visitNonOptionalCallExpression(node: CallExpression, captureThisArg: boolean): Expression {
|
||||
if (isOptionalChain(node)) {
|
||||
// If `node` is an optional chain, then it is the outermost chain of an optional expression.
|
||||
return visitOptionalExpression(node, captureThisArg, /*isDelete*/ false);
|
||||
}
|
||||
return visitEachChild(node, visitor, context);
|
||||
}
|
||||
function visitNonOptionalCallExpression(node: CallExpression, captureThisArg: boolean): Expression {
|
||||
if (isOptionalChain(node)) {
|
||||
// If `node` is an optional chain, then it is the outermost chain of an optional expression.
|
||||
return visitOptionalExpression(node, captureThisArg, /*isDelete*/ false);
|
||||
}
|
||||
return visitEachChild(node, visitor, context);
|
||||
}
|
||||
|
||||
function visitNonOptionalExpression(node: Expression, captureThisArg: boolean, isDelete: boolean): Expression {
|
||||
switch (node.kind) {
|
||||
case SyntaxKind.ParenthesizedExpression: return visitNonOptionalParenthesizedExpression(node as ParenthesizedExpression, captureThisArg, isDelete);
|
||||
case SyntaxKind.PropertyAccessExpression:
|
||||
case SyntaxKind.ElementAccessExpression: return visitNonOptionalPropertyOrElementAccessExpression(node as AccessExpression, captureThisArg, isDelete);
|
||||
case SyntaxKind.CallExpression: return visitNonOptionalCallExpression(node as CallExpression, captureThisArg);
|
||||
default: return visitNode(node, visitor, isExpression);
|
||||
}
|
||||
}
|
||||
function visitNonOptionalExpression(node: Expression, captureThisArg: boolean, isDelete: boolean): Expression {
|
||||
switch (node.kind) {
|
||||
case SyntaxKind.ParenthesizedExpression: return visitNonOptionalParenthesizedExpression(node as ParenthesizedExpression, captureThisArg, isDelete);
|
||||
case SyntaxKind.PropertyAccessExpression:
|
||||
case SyntaxKind.ElementAccessExpression: return visitNonOptionalPropertyOrElementAccessExpression(node as AccessExpression, captureThisArg, isDelete);
|
||||
case SyntaxKind.CallExpression: return visitNonOptionalCallExpression(node as CallExpression, captureThisArg);
|
||||
default: return visitNode(node, visitor, isExpression);
|
||||
}
|
||||
}
|
||||
|
||||
function visitOptionalExpression(node: OptionalChain, captureThisArg: boolean, isDelete: boolean): Expression {
|
||||
const { expression, chain } = flattenChain(node);
|
||||
const left = visitNonOptionalExpression(expression, isCallChain(chain[0]), /*isDelete*/ false);
|
||||
const leftThisArg = isSyntheticReference(left) ? left.thisArg : undefined;
|
||||
let leftExpression = isSyntheticReference(left) ? left.expression : left;
|
||||
let capturedLeft: Expression = leftExpression;
|
||||
if (shouldCaptureInTempVariable(leftExpression)) {
|
||||
capturedLeft = createTempVariable(hoistVariableDeclaration);
|
||||
leftExpression = createAssignment(capturedLeft, leftExpression);
|
||||
}
|
||||
let rightExpression = capturedLeft;
|
||||
let thisArg: Expression | undefined;
|
||||
for (let i = 0; i < chain.length; i++) {
|
||||
const segment = chain[i];
|
||||
switch (segment.kind) {
|
||||
case SyntaxKind.PropertyAccessExpression:
|
||||
case SyntaxKind.ElementAccessExpression:
|
||||
if (i === chain.length - 1 && captureThisArg) {
|
||||
if (shouldCaptureInTempVariable(rightExpression)) {
|
||||
thisArg = createTempVariable(hoistVariableDeclaration);
|
||||
rightExpression = createAssignment(thisArg, rightExpression);
|
||||
}
|
||||
else {
|
||||
thisArg = rightExpression;
|
||||
}
|
||||
}
|
||||
rightExpression = segment.kind === SyntaxKind.PropertyAccessExpression
|
||||
? createPropertyAccess(rightExpression, visitNode(segment.name, visitor, isIdentifier))
|
||||
: createElementAccess(rightExpression, visitNode(segment.argumentExpression, visitor, isExpression));
|
||||
break;
|
||||
case SyntaxKind.CallExpression:
|
||||
if (i === 0 && leftThisArg) {
|
||||
rightExpression = createFunctionCall(
|
||||
rightExpression,
|
||||
leftThisArg.kind === SyntaxKind.SuperKeyword ? createThis() : leftThisArg,
|
||||
visitNodes(segment.arguments, visitor, isExpression)
|
||||
);
|
||||
}
|
||||
else {
|
||||
rightExpression = createCall(
|
||||
rightExpression,
|
||||
/*typeArguments*/ undefined,
|
||||
visitNodes(segment.arguments, visitor, isExpression)
|
||||
);
|
||||
}
|
||||
break;
|
||||
}
|
||||
setOriginalNode(rightExpression, segment);
|
||||
}
|
||||
function visitOptionalExpression(node: OptionalChain, captureThisArg: boolean, isDelete: boolean): Expression {
|
||||
const { expression, chain } = flattenChain(node);
|
||||
const left = visitNonOptionalExpression(expression, isCallChain(chain[0]), /*isDelete*/ false);
|
||||
const leftThisArg = isSyntheticReference(left) ? left.thisArg : undefined;
|
||||
let leftExpression = isSyntheticReference(left) ? left.expression : left;
|
||||
let capturedLeft: Expression = leftExpression;
|
||||
if (shouldCaptureInTempVariable(leftExpression)) {
|
||||
capturedLeft = createTempVariable(hoistVariableDeclaration);
|
||||
leftExpression = createAssignment(capturedLeft, leftExpression);
|
||||
// if (inParameterInitializer) tempVariableInParameter = true;
|
||||
}
|
||||
let rightExpression = capturedLeft;
|
||||
let thisArg: Expression | undefined;
|
||||
for (let i = 0; i < chain.length; i++) {
|
||||
const segment = chain[i];
|
||||
switch (segment.kind) {
|
||||
case SyntaxKind.PropertyAccessExpression:
|
||||
case SyntaxKind.ElementAccessExpression:
|
||||
if (i === chain.length - 1 && captureThisArg) {
|
||||
if (shouldCaptureInTempVariable(rightExpression)) {
|
||||
thisArg = createTempVariable(hoistVariableDeclaration);
|
||||
rightExpression = createAssignment(thisArg, rightExpression);
|
||||
// if (inParameterInitializer) tempVariableInParameter = true;
|
||||
}
|
||||
else {
|
||||
thisArg = rightExpression;
|
||||
}
|
||||
}
|
||||
rightExpression = segment.kind === SyntaxKind.PropertyAccessExpression
|
||||
? createPropertyAccess(rightExpression, visitNode(segment.name, visitor, isIdentifier))
|
||||
: createElementAccess(rightExpression, visitNode(segment.argumentExpression, visitor, isExpression));
|
||||
break;
|
||||
case SyntaxKind.CallExpression:
|
||||
if (i === 0 && leftThisArg) {
|
||||
rightExpression = createFunctionCall(
|
||||
rightExpression,
|
||||
leftThisArg.kind === SyntaxKind.SuperKeyword ? createThis() : leftThisArg,
|
||||
visitNodes(segment.arguments, visitor, isExpression)
|
||||
);
|
||||
}
|
||||
else {
|
||||
rightExpression = createCall(
|
||||
rightExpression,
|
||||
/*typeArguments*/ undefined,
|
||||
visitNodes(segment.arguments, visitor, isExpression)
|
||||
);
|
||||
}
|
||||
break;
|
||||
}
|
||||
setOriginalNode(rightExpression, segment);
|
||||
}
|
||||
|
||||
const target = isDelete
|
||||
? createConditional(createNotNullCondition(leftExpression, capturedLeft, /*invert*/ true), createTrue(), createDelete(rightExpression))
|
||||
: createConditional(createNotNullCondition(leftExpression, capturedLeft, /*invert*/ true), createVoidZero(), rightExpression);
|
||||
return thisArg ? createSyntheticReferenceExpression(target, thisArg) : target;
|
||||
}
|
||||
const target = isDelete
|
||||
? createConditional(createNotNullCondition(leftExpression, capturedLeft, /*invert*/ true), createTrue(), createDelete(rightExpression))
|
||||
: createConditional(createNotNullCondition(leftExpression, capturedLeft, /*invert*/ true), createVoidZero(), rightExpression);
|
||||
return thisArg ? createSyntheticReferenceExpression(target, thisArg) : target;
|
||||
}
|
||||
|
||||
function createNotNullCondition(left: Expression, right: Expression, invert?: boolean) {
|
||||
return createBinary(
|
||||
createBinary(
|
||||
left,
|
||||
createToken(invert ? SyntaxKind.EqualsEqualsEqualsToken : SyntaxKind.ExclamationEqualsEqualsToken),
|
||||
createNull()
|
||||
),
|
||||
createToken(invert ? SyntaxKind.BarBarToken : SyntaxKind.AmpersandAmpersandToken),
|
||||
createBinary(
|
||||
right,
|
||||
createToken(invert ? SyntaxKind.EqualsEqualsEqualsToken : SyntaxKind.ExclamationEqualsEqualsToken),
|
||||
createVoidZero()
|
||||
)
|
||||
);
|
||||
}
|
||||
function createNotNullCondition(left: Expression, right: Expression, invert?: boolean) {
|
||||
return createBinary(
|
||||
createBinary(
|
||||
left,
|
||||
createToken(invert ? SyntaxKind.EqualsEqualsEqualsToken : SyntaxKind.ExclamationEqualsEqualsToken),
|
||||
createNull()
|
||||
),
|
||||
createToken(invert ? SyntaxKind.BarBarToken : SyntaxKind.AmpersandAmpersandToken),
|
||||
createBinary(
|
||||
right,
|
||||
createToken(invert ? SyntaxKind.EqualsEqualsEqualsToken : SyntaxKind.ExclamationEqualsEqualsToken),
|
||||
createVoidZero()
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
function transformNullishCoalescingExpression(node: BinaryExpression) {
|
||||
let left = visitNode(node.left, visitor, isExpression);
|
||||
let right = left;
|
||||
if (shouldCaptureInTempVariable(left)) {
|
||||
right = createTempVariable(hoistVariableDeclaration);
|
||||
left = createAssignment(right, left);
|
||||
}
|
||||
return createConditional(
|
||||
createNotNullCondition(left, right),
|
||||
right,
|
||||
visitNode(node.right, visitor, isExpression),
|
||||
);
|
||||
}
|
||||
function transformNullishCoalescingExpression(node: BinaryExpression) {
|
||||
let left = visitNode(node.left, visitor, isExpression);
|
||||
let right = left;
|
||||
if (shouldCaptureInTempVariable(left)) {
|
||||
right = createTempVariable(hoistVariableDeclaration);
|
||||
left = createAssignment(right, left);
|
||||
// if (inParameterInitializer) tempVariableInParameter = true;
|
||||
}
|
||||
return createConditional(
|
||||
createNotNullCondition(left, right),
|
||||
right,
|
||||
visitNode(node.right, visitor, isExpression),
|
||||
);
|
||||
}
|
||||
|
||||
function shouldCaptureInTempVariable(expression: Expression): boolean {
|
||||
// don't capture identifiers and `this` in a temporary variable
|
||||
// `super` cannot be captured as it's no real variable
|
||||
return !isIdentifier(expression) &&
|
||||
expression.kind !== SyntaxKind.ThisKeyword &&
|
||||
expression.kind !== SyntaxKind.SuperKeyword;
|
||||
}
|
||||
function shouldCaptureInTempVariable(expression: Expression): boolean {
|
||||
// don't capture identifiers and `this` in a temporary variable
|
||||
// `super` cannot be captured as it's no real variable
|
||||
return !isIdentifier(expression) &&
|
||||
expression.kind !== SyntaxKind.ThisKeyword &&
|
||||
expression.kind !== SyntaxKind.SuperKeyword;
|
||||
}
|
||||
|
||||
function visitDeleteExpression(node: DeleteExpression) {
|
||||
return isOptionalChain(skipParentheses(node.expression))
|
||||
? setOriginalNode(visitNonOptionalExpression(node.expression, /*captureThisArg*/ false, /*isDelete*/ true), node)
|
||||
: updateDelete(node, visitNode(node.expression, visitor, isExpression));
|
||||
}
|
||||
}
|
||||
function visitDeleteExpression(node: DeleteExpression) {
|
||||
return isOptionalChain(skipParentheses(node.expression))
|
||||
? setOriginalNode(visitNonOptionalExpression(node.expression, /*captureThisArg*/ false, /*isDelete*/ true), node)
|
||||
: updateDelete(node, visitNode(node.expression, visitor, isExpression));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4323,6 +4323,7 @@ namespace ts {
|
||||
instantiations?: Map<Type>; // Instantiations of generic type alias (undefined if non-generic)
|
||||
isExhaustive?: boolean; // Is node an exhaustive switch statement
|
||||
skipDirectInference?: true; // Flag set by the API `getContextualType` call on a node when `Completions` is passed to force the checker to skip making inferences to a node's type
|
||||
declarationRequiresScopeChange?: boolean; // Set by `useOuterVariableScopeInParameter` in checker when downlevel emit would change the name resolution scope inside of a parameter.
|
||||
}
|
||||
|
||||
export const enum TypeFlags {
|
||||
@@ -5994,6 +5995,13 @@ namespace ts {
|
||||
set?: Expression;
|
||||
}
|
||||
|
||||
/* @internal */
|
||||
export const enum LexicalEnvironmentFlags {
|
||||
None = 0,
|
||||
InParameters = 1 << 0, // currently visiting a parameter list
|
||||
VariablesHoistedInParameters = 1 << 1 // a temp variable was hoisted while visiting a parameter list
|
||||
}
|
||||
|
||||
export interface TransformationContext {
|
||||
/*@internal*/ getEmitResolver(): EmitResolver;
|
||||
/*@internal*/ getEmitHost(): EmitHost;
|
||||
@@ -6004,6 +6012,9 @@ namespace ts {
|
||||
/** Starts a new lexical environment. */
|
||||
startLexicalEnvironment(): void;
|
||||
|
||||
/* @internal */ setLexicalEnvironmentFlags(flags: LexicalEnvironmentFlags, value: boolean): void;
|
||||
/* @internal */ getLexicalEnvironmentFlags(): LexicalEnvironmentFlags;
|
||||
|
||||
/** Suspends the current lexical environment, usually after visiting a parameter list. */
|
||||
suspendLexicalEnvironment(): void;
|
||||
|
||||
@@ -6019,6 +6030,10 @@ namespace ts {
|
||||
/** Hoists a variable declaration to the containing scope. */
|
||||
hoistVariableDeclaration(node: Identifier): void;
|
||||
|
||||
/** Adds an initialization statement to the top of the lexical environment. */
|
||||
/* @internal */
|
||||
addInitializationStatement(node: Statement): void;
|
||||
|
||||
/** Records a request for a non-scoped emit helper in the current context. */
|
||||
requestEmitHelper(helper: EmitHelper): void;
|
||||
|
||||
@@ -6468,6 +6483,7 @@ namespace ts {
|
||||
moduleResolverHost?: ModuleSpecifierResolutionHost & { getCommonSourceDirectory(): string };
|
||||
trackReferencedAmbientModule?(decl: ModuleDeclaration, symbol: Symbol): void;
|
||||
trackExternalModuleSymbolOfImportTypeNode?(symbol: Symbol): void;
|
||||
reportNonlocalAugmentation?(containingFile: SourceFile, parentSymbol: Symbol, augmentingSymbol: Symbol): void;
|
||||
}
|
||||
|
||||
export interface TextSpan {
|
||||
|
||||
@@ -1092,6 +1092,26 @@ namespace ts {
|
||||
&& (<ExpressionStatement>node).expression.kind === SyntaxKind.StringLiteral;
|
||||
}
|
||||
|
||||
export function isCustomPrologue(node: Statement) {
|
||||
return !!(getEmitFlags(node) & EmitFlags.CustomPrologue);
|
||||
}
|
||||
|
||||
export function isHoistedFunction(node: Statement) {
|
||||
return isCustomPrologue(node)
|
||||
&& isFunctionDeclaration(node);
|
||||
}
|
||||
|
||||
function isHoistedVariable(node: VariableDeclaration) {
|
||||
return isIdentifier(node.name)
|
||||
&& !node.initializer;
|
||||
}
|
||||
|
||||
export function isHoistedVariableStatement(node: Statement) {
|
||||
return isCustomPrologue(node)
|
||||
&& isVariableStatement(node)
|
||||
&& every(node.declarationList.declarations, isHoistedVariable);
|
||||
}
|
||||
|
||||
export function getLeadingCommentRangesOfNode(node: Node, sourceFileOfNode: SourceFile) {
|
||||
return node.kind !== SyntaxKind.JsxText ? getLeadingCommentRanges(sourceFileOfNode.text, node.pos) : undefined;
|
||||
}
|
||||
@@ -2294,6 +2314,17 @@ namespace ts {
|
||||
!!getJSDocTypeTag(expr.parent);
|
||||
}
|
||||
|
||||
export function setValueDeclaration(symbol: Symbol, node: Declaration): void {
|
||||
const { valueDeclaration } = symbol;
|
||||
if (!valueDeclaration ||
|
||||
!(node.flags & NodeFlags.Ambient && !(valueDeclaration.flags & NodeFlags.Ambient)) &&
|
||||
(isAssignmentDeclaration(valueDeclaration) && !isAssignmentDeclaration(node)) ||
|
||||
(valueDeclaration.kind !== node.kind && isEffectiveModuleDeclaration(valueDeclaration))) {
|
||||
// other kinds of value declarations take precedence over modules and assignment declarations
|
||||
symbol.valueDeclaration = node;
|
||||
}
|
||||
}
|
||||
|
||||
export function isFunctionSymbol(symbol: Symbol | undefined) {
|
||||
if (!symbol || !symbol.valueDeclaration) {
|
||||
return false;
|
||||
@@ -4780,19 +4811,19 @@ namespace ts {
|
||||
return positionIsSynthesized(range.pos) ? -1 : skipTrivia(sourceFile.text, range.pos, /*stopAfterLineBreak*/ false, includeComments);
|
||||
}
|
||||
|
||||
export function getLinesBetweenPositionAndPrecedingNonWhitespaceCharacter(pos: number, sourceFile: SourceFile, includeComments?: boolean) {
|
||||
export function getLinesBetweenPositionAndPrecedingNonWhitespaceCharacter(pos: number, stopPos: number, sourceFile: SourceFile, includeComments?: boolean) {
|
||||
const startPos = skipTrivia(sourceFile.text, pos, /*stopAfterLineBreak*/ false, includeComments);
|
||||
const prevPos = getPreviousNonWhitespacePosition(startPos, sourceFile);
|
||||
return getLinesBetweenPositions(sourceFile, prevPos || 0, startPos);
|
||||
const prevPos = getPreviousNonWhitespacePosition(startPos, stopPos, sourceFile);
|
||||
return getLinesBetweenPositions(sourceFile, prevPos ?? stopPos, startPos);
|
||||
}
|
||||
|
||||
export function getLinesBetweenPositionAndNextNonWhitespaceCharacter(pos: number, sourceFile: SourceFile, includeComments?: boolean) {
|
||||
export function getLinesBetweenPositionAndNextNonWhitespaceCharacter(pos: number, stopPos: number, sourceFile: SourceFile, includeComments?: boolean) {
|
||||
const nextPos = skipTrivia(sourceFile.text, pos, /*stopAfterLineBreak*/ false, includeComments);
|
||||
return getLinesBetweenPositions(sourceFile, pos, nextPos);
|
||||
return getLinesBetweenPositions(sourceFile, pos, Math.min(stopPos, nextPos));
|
||||
}
|
||||
|
||||
function getPreviousNonWhitespacePosition(pos: number, sourceFile: SourceFile) {
|
||||
while (pos-- > 0) {
|
||||
function getPreviousNonWhitespacePosition(pos: number, stopPos = 0, sourceFile: SourceFile) {
|
||||
while (pos-- > stopPos) {
|
||||
if (!isWhiteSpaceLike(sourceFile.text.charCodeAt(pos))) {
|
||||
return pos;
|
||||
}
|
||||
|
||||
+93
-4
@@ -520,11 +520,18 @@ namespace ts {
|
||||
return result;
|
||||
}
|
||||
|
||||
function findSpanEnd<T>(array: readonly T[], test: (value: T) => boolean, start: number) {
|
||||
let i = start;
|
||||
while (i < array.length && test(array[i])) {
|
||||
i++;
|
||||
}
|
||||
return i;
|
||||
}
|
||||
|
||||
/**
|
||||
* Merges generated lexical declarations into a new statement list.
|
||||
*/
|
||||
export function mergeLexicalEnvironment(statements: NodeArray<Statement>, declarations: readonly Statement[] | undefined): NodeArray<Statement>;
|
||||
|
||||
/**
|
||||
* Appends generated lexical declarations to an array of statements.
|
||||
*/
|
||||
@@ -534,9 +541,91 @@ namespace ts {
|
||||
return statements;
|
||||
}
|
||||
|
||||
return isNodeArray(statements)
|
||||
? setTextRange(createNodeArray(insertStatementsAfterStandardPrologue(statements.slice(), declarations)), statements)
|
||||
: insertStatementsAfterStandardPrologue(statements, declarations);
|
||||
// When we merge new lexical statements into an existing statement list, we merge them in the following manner:
|
||||
//
|
||||
// Given:
|
||||
//
|
||||
// | Left | Right |
|
||||
// |------------------------------------|-------------------------------------|
|
||||
// | [standard prologues (left)] | [standard prologues (right)] |
|
||||
// | [hoisted functions (left)] | [hoisted functions (right)] |
|
||||
// | [hoisted variables (left)] | [hoisted variables (right)] |
|
||||
// | [lexical init statements (left)] | [lexical init statements (right)] |
|
||||
// | [other statements (left)] | |
|
||||
//
|
||||
// The resulting statement list will be:
|
||||
//
|
||||
// | Result |
|
||||
// |-------------------------------------|
|
||||
// | [standard prologues (right)] |
|
||||
// | [standard prologues (left)] |
|
||||
// | [hoisted functions (right)] |
|
||||
// | [hoisted functions (left)] |
|
||||
// | [hoisted variables (right)] |
|
||||
// | [hoisted variables (left)] |
|
||||
// | [lexical init statements (right)] |
|
||||
// | [lexical init statements (left)] |
|
||||
// | [other statements (left)] |
|
||||
//
|
||||
// NOTE: It is expected that new lexical init statements must be evaluated before existing lexical init statements,
|
||||
// as the prior transformation may depend on the evaluation of the lexical init statements to be in the correct state.
|
||||
|
||||
// find standard prologues on left in the following order: standard directives, hoisted functions, hoisted variables, other custom
|
||||
const leftStandardPrologueEnd = findSpanEnd(statements, isPrologueDirective, 0);
|
||||
const leftHoistedFunctionsEnd = findSpanEnd(statements, isHoistedFunction, leftStandardPrologueEnd);
|
||||
const leftHoistedVariablesEnd = findSpanEnd(statements, isHoistedVariableStatement, leftHoistedFunctionsEnd);
|
||||
|
||||
// find standard prologues on right in the following order: standard directives, hoisted functions, hoisted variables, other custom
|
||||
const rightStandardPrologueEnd = findSpanEnd(declarations, isPrologueDirective, 0);
|
||||
const rightHoistedFunctionsEnd = findSpanEnd(declarations, isHoistedFunction, rightStandardPrologueEnd);
|
||||
const rightHoistedVariablesEnd = findSpanEnd(declarations, isHoistedVariableStatement, rightHoistedFunctionsEnd);
|
||||
const rightCustomPrologueEnd = findSpanEnd(declarations, isCustomPrologue, rightHoistedVariablesEnd);
|
||||
Debug.assert(rightCustomPrologueEnd === declarations.length, "Expected declarations to be valid standard or custom prologues");
|
||||
|
||||
// splice prologues from the right into the left. We do this in reverse order
|
||||
// so that we don't need to recompute the index on the left when we insert items.
|
||||
const left = isNodeArray(statements) ? statements.slice() : statements;
|
||||
|
||||
// splice other custom prologues from right into left
|
||||
if (rightCustomPrologueEnd > rightHoistedVariablesEnd) {
|
||||
left.splice(leftHoistedVariablesEnd, 0, ...declarations.slice(rightHoistedVariablesEnd, rightCustomPrologueEnd));
|
||||
}
|
||||
|
||||
// splice hoisted variables from right into left
|
||||
if (rightHoistedVariablesEnd > rightHoistedFunctionsEnd) {
|
||||
left.splice(leftHoistedFunctionsEnd, 0, ...declarations.slice(rightHoistedFunctionsEnd, rightHoistedVariablesEnd));
|
||||
}
|
||||
|
||||
// splice hoisted functions from right into left
|
||||
if (rightHoistedFunctionsEnd > rightStandardPrologueEnd) {
|
||||
left.splice(leftStandardPrologueEnd, 0, ...declarations.slice(rightStandardPrologueEnd, rightHoistedFunctionsEnd));
|
||||
}
|
||||
|
||||
// splice standard prologues from right into left (that are not already in left)
|
||||
if (rightStandardPrologueEnd > 0) {
|
||||
if (leftStandardPrologueEnd === 0) {
|
||||
left.splice(0, 0, ...declarations.slice(0, rightStandardPrologueEnd));
|
||||
}
|
||||
else {
|
||||
const leftPrologues = createMap<boolean>();
|
||||
for (let i = 0; i < leftStandardPrologueEnd; i++) {
|
||||
const leftPrologue = statements[i] as PrologueDirective;
|
||||
leftPrologues.set(leftPrologue.expression.text, true);
|
||||
}
|
||||
for (let i = rightStandardPrologueEnd - 1; i >= 0; i--) {
|
||||
const rightPrologue = declarations[i] as PrologueDirective;
|
||||
if (!leftPrologues.has(rightPrologue.expression.text)) {
|
||||
left.unshift(rightPrologue);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (isNodeArray(statements)) {
|
||||
return setTextRange(createNodeArray(left, statements.hasTrailingComma), statements);
|
||||
}
|
||||
|
||||
return statements;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -149,13 +149,124 @@ namespace ts {
|
||||
* Starts a new lexical environment and visits a parameter list, suspending the lexical
|
||||
* environment upon completion.
|
||||
*/
|
||||
export function visitParameterList(nodes: NodeArray<ParameterDeclaration>, visitor: Visitor, context: TransformationContext, nodesVisitor?: <T extends Node>(nodes: NodeArray<T>, visitor: Visitor, test?: (node: Node) => boolean, start?: number, count?: number) => NodeArray<T>): NodeArray<ParameterDeclaration>;
|
||||
export function visitParameterList(nodes: NodeArray<ParameterDeclaration> | undefined, visitor: Visitor, context: TransformationContext, nodesVisitor?: <T extends Node>(nodes: NodeArray<T> | undefined, visitor: Visitor, test?: (node: Node) => boolean, start?: number, count?: number) => NodeArray<T> | undefined): NodeArray<ParameterDeclaration> | undefined;
|
||||
export function visitParameterList(nodes: NodeArray<ParameterDeclaration> | undefined, visitor: Visitor, context: TransformationContext, nodesVisitor = visitNodes) {
|
||||
let updated: NodeArray<ParameterDeclaration> | undefined;
|
||||
context.startLexicalEnvironment();
|
||||
const updated = nodesVisitor(nodes, visitor, isParameterDeclaration);
|
||||
if (nodes) {
|
||||
context.setLexicalEnvironmentFlags(LexicalEnvironmentFlags.InParameters, true);
|
||||
updated = nodesVisitor(nodes, visitor, isParameterDeclaration);
|
||||
|
||||
// As of ES2015, any runtime execution of that occurs in for a parameter (such as evaluating an
|
||||
// initializer or a binding pattern), occurs in its own lexical scope. As a result, any expression
|
||||
// that we might transform that introduces a temporary variable would fail as the temporary variable
|
||||
// exists in a different lexical scope. To address this, we move any binding patterns and initializers
|
||||
// in a parameter list to the body if we detect a variable being hoisted while visiting a parameter list
|
||||
// when the emit target is greater than ES2015.
|
||||
if (context.getLexicalEnvironmentFlags() & LexicalEnvironmentFlags.VariablesHoistedInParameters &&
|
||||
getEmitScriptTarget(context.getCompilerOptions()) >= ScriptTarget.ES2015) {
|
||||
updated = addDefaultValueAssignmentsIfNeeded(updated, context);
|
||||
}
|
||||
context.setLexicalEnvironmentFlags(LexicalEnvironmentFlags.InParameters, false);
|
||||
}
|
||||
context.suspendLexicalEnvironment();
|
||||
return updated;
|
||||
}
|
||||
|
||||
function addDefaultValueAssignmentsIfNeeded(parameters: NodeArray<ParameterDeclaration>, context: TransformationContext) {
|
||||
let result: ParameterDeclaration[] | undefined;
|
||||
for (let i = 0; i < parameters.length; i++) {
|
||||
const parameter = parameters[i];
|
||||
const updated = addDefaultValueAssignmentIfNeeded(parameter, context);
|
||||
if (result || updated !== parameter) {
|
||||
if (!result) result = parameters.slice(0, i);
|
||||
result[i] = updated;
|
||||
}
|
||||
}
|
||||
if (result) {
|
||||
return setTextRange(createNodeArray(result, parameters.hasTrailingComma), parameters);
|
||||
}
|
||||
return parameters;
|
||||
}
|
||||
|
||||
function addDefaultValueAssignmentIfNeeded(parameter: ParameterDeclaration, context: TransformationContext) {
|
||||
// A rest parameter cannot have a binding pattern or an initializer,
|
||||
// so let's just ignore it.
|
||||
return parameter.dotDotDotToken ? parameter :
|
||||
isBindingPattern(parameter.name) ? addDefaultValueAssignmentForBindingPattern(parameter, context) :
|
||||
parameter.initializer ? addDefaultValueAssignmentForInitializer(parameter, parameter.name, parameter.initializer, context) :
|
||||
parameter;
|
||||
}
|
||||
|
||||
function addDefaultValueAssignmentForBindingPattern(parameter: ParameterDeclaration, context: TransformationContext) {
|
||||
context.addInitializationStatement(
|
||||
createVariableStatement(
|
||||
/*modifiers*/ undefined,
|
||||
createVariableDeclarationList([
|
||||
createVariableDeclaration(
|
||||
parameter.name,
|
||||
parameter.type,
|
||||
parameter.initializer ?
|
||||
createConditional(
|
||||
createStrictEquality(
|
||||
getGeneratedNameForNode(parameter),
|
||||
createVoidZero()
|
||||
),
|
||||
parameter.initializer,
|
||||
getGeneratedNameForNode(parameter)
|
||||
) :
|
||||
getGeneratedNameForNode(parameter)
|
||||
),
|
||||
])
|
||||
)
|
||||
);
|
||||
return updateParameter(parameter,
|
||||
parameter.decorators,
|
||||
parameter.modifiers,
|
||||
parameter.dotDotDotToken,
|
||||
getGeneratedNameForNode(parameter),
|
||||
parameter.questionToken,
|
||||
parameter.type,
|
||||
/*initializer*/ undefined);
|
||||
}
|
||||
|
||||
function addDefaultValueAssignmentForInitializer(parameter: ParameterDeclaration, name: Identifier, initializer: Expression, context: TransformationContext) {
|
||||
context.addInitializationStatement(
|
||||
createIf(
|
||||
createTypeCheck(getSynthesizedClone(name), "undefined"),
|
||||
setEmitFlags(
|
||||
setTextRange(
|
||||
createBlock([
|
||||
createExpressionStatement(
|
||||
setEmitFlags(
|
||||
setTextRange(
|
||||
createAssignment(
|
||||
setEmitFlags(getMutableClone(name), EmitFlags.NoSourceMap),
|
||||
setEmitFlags(initializer, EmitFlags.NoSourceMap | getEmitFlags(initializer) | EmitFlags.NoComments)
|
||||
),
|
||||
parameter
|
||||
),
|
||||
EmitFlags.NoComments
|
||||
)
|
||||
)
|
||||
]),
|
||||
parameter
|
||||
),
|
||||
EmitFlags.SingleLine | EmitFlags.NoTrailingSourceMap | EmitFlags.NoTokenSourceMaps | EmitFlags.NoComments
|
||||
)
|
||||
)
|
||||
);
|
||||
return updateParameter(parameter,
|
||||
parameter.decorators,
|
||||
parameter.modifiers,
|
||||
parameter.dotDotDotToken,
|
||||
parameter.name,
|
||||
parameter.questionToken,
|
||||
parameter.type,
|
||||
/*initializer*/ undefined);
|
||||
}
|
||||
|
||||
/**
|
||||
* Resumes a suspended lexical environment and visits a function body, ending the lexical
|
||||
* environment and merging hoisted declarations upon completion.
|
||||
|
||||
Vendored
-9
@@ -42,15 +42,6 @@ interface Array<T> {
|
||||
* @param end If not specified, length of the this object is used as its default value.
|
||||
*/
|
||||
copyWithin(target: number, start: number, end?: number): this;
|
||||
|
||||
/**
|
||||
* Removes elements from an array and, if necessary, inserts new elements in their place, returning the deleted elements.
|
||||
* @param start The zero-based location in the array from which to start removing elements.
|
||||
* @param deleteCount The number of elements to remove. If deleteCount is omitted, or if its value is equal to or larger
|
||||
* than array.length - start (that is, if it is equal to or greater than the number of elements left in the array,
|
||||
* starting at start), then all the elements from start to the end of the array will be deleted.
|
||||
*/
|
||||
splice(start: number, deleteCount?: number): T[];
|
||||
}
|
||||
|
||||
interface ArrayConstructor {
|
||||
|
||||
Vendored
+1
-1
@@ -1254,7 +1254,7 @@ interface Array<T> {
|
||||
* @param start The zero-based location in the array from which to start removing elements.
|
||||
* @param deleteCount The number of elements to remove.
|
||||
*/
|
||||
splice(start: number, deleteCount: number): T[];
|
||||
splice(start: number, deleteCount?: number): T[];
|
||||
/**
|
||||
* Removes elements from an array and, if necessary, inserts new elements in their place, returning the deleted elements.
|
||||
* @param start The zero-based location in the array from which to start removing elements.
|
||||
|
||||
@@ -1180,7 +1180,7 @@
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[Add 'export {}' to make this file into a module]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[添加 "export {}" 以将此文件变为模块]]></Val>
|
||||
<Val><![CDATA[添加 "export {}",将此文件变为模块]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
@@ -3193,7 +3193,7 @@
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[Compiler reserves name '{0}' when emitting private identifier downlevel.]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[当发出专用标识符下层时,编译器预留名称 "{0}"。]]></Val>
|
||||
<Val><![CDATA[当发出专用标识符下层时,编译器会预留名称“{0}”。]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
@@ -4996,7 +4996,7 @@
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[File '{0}' has an unsupported extension. The only supported extensions are {1}.]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[文件 "{0}" 具有不受支持的扩展名。支持的扩展名只有 {1}。]]></Val>
|
||||
<Val><![CDATA[文件“{0}”具有不受支持的扩展名。仅支持 {1} 扩展名。]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
@@ -5641,7 +5641,7 @@
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[Import default '{0}' from module "{1}"]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[从模块 "{1}" 导入默认的 "{0}"]]></Val>
|
||||
<Val><![CDATA[从模块“{1}”导入默认的“{0}”]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
@@ -7188,6 +7188,15 @@
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";Only_numeric_enums_can_have_computed_members_but_this_expression_has_type_0_If_you_do_not_need_exhau_18033" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[Only numeric enums can have computed members, but this expression has type '{0}'. If you do not need exhaustiveness checks, consider using an object literal instead.]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[只有数字枚举可具有计算成员,但此表达式的类型为“{0}”。如果不需要全面性检查,请考虑改用对象文本。]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword_2340" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[Only public and protected methods of the base class are accessible via the 'super' keyword.]]></Val>
|
||||
@@ -7399,7 +7408,7 @@
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[Overload {0} of {1}, '{2}', gave the following error.]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[{1} 个重载 中的第 {0} 个("{2}")出现了以下错误。]]></Val>
|
||||
<Val><![CDATA[第 {0} 个重载(共 {1} 个),“{2}”,出现以下错误。]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
@@ -10188,6 +10197,15 @@
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";The_operand_of_a_delete_operator_must_be_optional_2790" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[The operand of a 'delete' operator must be optional.]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA["delete" 运算符的操作数必须是可选的。]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";The_operand_of_an_increment_or_decrement_operator_may_not_be_an_optional_property_access_2777" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[The operand of an increment or decrement operator may not be an optional property access.]]></Val>
|
||||
@@ -10312,7 +10330,7 @@
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[The shadowing declaration of '{0}' is defined here]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[在此处定义了 "{0}" 的隐藏声明]]></Val>
|
||||
<Val><![CDATA[在此处定义了“{0}”的阴影声明]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
@@ -10759,7 +10777,7 @@
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[Type '{0}' is missing the following properties from type '{1}': {2}]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[类型 "{0}" 缺少类型 "{1}" 中的以下属性: {2}]]></Val>
|
||||
<Val><![CDATA[类型“{0}”缺少类型“{1}”中的以下属性: {2}]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
@@ -10768,7 +10786,7 @@
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[Type '{0}' is missing the following properties from type '{1}': {2}, and {3} more.]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[类型 "{0}" 缺少类型 "{1}" 的以下属性: {2} 及其他 {3} 项。]]></Val>
|
||||
<Val><![CDATA[类型“{0}”缺少类型“{1}”的以下属性: {2} 及其他 {3} 项。]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
@@ -11107,7 +11125,7 @@
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[Type originates at this import. A namespace-style import cannot be called or constructed, and will cause a failure at runtime. Consider using a default import or import require here instead.]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[此导入产生的类型。无法调用或构造命名空间样式的导入,这类导入将在运行时导致失败。请考虑改为使用默认导入或这里需要的导入。]]></Val>
|
||||
<Val><![CDATA[此导入产生的类型。无法调用或构造命名空间样式的导入,这类导入将在运行时导致失败。请考虑改为使用默认导入或此处需要的导入。]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
@@ -11668,7 +11686,7 @@
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[Using compiler options of project reference redirect '{0}'.]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[使用项目引用重定向 "{0}" 的编译器选项。]]></Val>
|
||||
<Val><![CDATA[使用项目引用重定向“{0}”的编译器选项。]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
|
||||
@@ -1180,7 +1180,7 @@
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[Add 'export {}' to make this file into a module]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[新增 'export {}' 以將此檔案設為模組]]></Val>
|
||||
<Val><![CDATA[新增 'export {}' 以將此檔案轉為模組]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
@@ -3193,7 +3193,7 @@
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[Compiler reserves name '{0}' when emitting private identifier downlevel.]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[在下層發出私人識別碼時,編譯器會保留名稱 '{0}'。]]></Val>
|
||||
<Val><![CDATA[降級發出私人識別碼時,編譯器會保留名稱 '{0}'。]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
@@ -7188,6 +7188,15 @@
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";Only_numeric_enums_can_have_computed_members_but_this_expression_has_type_0_If_you_do_not_need_exhau_18033" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[Only numeric enums can have computed members, but this expression has type '{0}'. If you do not need exhaustiveness checks, consider using an object literal instead.]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[只有數值列舉才可以有計算成員,但此運算式的類型為 '{0}'。若您不需要詳細檢查,請考慮改用物件常值。]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword_2340" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[Only public and protected methods of the base class are accessible via the 'super' keyword.]]></Val>
|
||||
@@ -7399,7 +7408,7 @@
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[Overload {0} of {1}, '{2}', gave the following error.]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[{1} 的多載 {0},'{2}',發生下列錯誤。]]></Val>
|
||||
<Val><![CDATA[多載 {0} (共 {1}),'{2}',發生下列錯誤。]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
@@ -7822,7 +7831,7 @@
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[Prefix with 'declare']]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[在開頭放置 'declare']]></Val>
|
||||
<Val><![CDATA[以 'declare' 開頭]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
@@ -10312,7 +10321,7 @@
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[The shadowing declaration of '{0}' is defined here]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA['{0}' 的陰影宣告定義於此處]]></Val>
|
||||
<Val><![CDATA['{0}' 的隱蔽宣告定義於此處]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
@@ -10759,7 +10768,7 @@
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[Type '{0}' is missing the following properties from type '{1}': {2}]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[類型 '{0}' 缺少類型 '{1}' 中的下列屬性: {2}]]></Val>
|
||||
<Val><![CDATA[類型 '{0}' 在類型 '{1}' 中缺少下列屬性: {2}]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
@@ -10768,7 +10777,7 @@
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[Type '{0}' is missing the following properties from type '{1}': {2}, and {3} more.]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[類型 '{0}' 缺少類型 '{1}' 中的下列屬性: {2},以及另外 {3} 個。]]></Val>
|
||||
<Val><![CDATA[類型 '{0}' 在類型 '{1}' 中缺少下列屬性: {2},以及另外 {3} 個。]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
@@ -11107,7 +11116,7 @@
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[Type originates at this import. A namespace-style import cannot be called or constructed, and will cause a failure at runtime. Consider using a default import or import require here instead.]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[類型源自此匯入。無法呼叫或建構命名空間樣式的匯入,而且可能會在執行階段導致失敗。請考慮改用預設匯入或此處要求的匯入。]]></Val>
|
||||
<Val><![CDATA[類型源自此匯入。無法呼叫或建構命名空間樣式的匯入,而且可能會在執行階段導致失敗。請考慮改用預設匯入或於此處匯入 require。]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
|
||||
@@ -3202,7 +3202,7 @@
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[Compiler reserves name '{0}' when emitting private identifier downlevel.]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[Kompilátor si rezervuje název {0} při generování nižší úrovně privátního identifikátoru.]]></Val>
|
||||
<Val><![CDATA[Kompilátor si rezervuje název {0} při generování privátního identifikátoru pro nižší úroveň.]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
@@ -5650,7 +5650,7 @@
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[Import default '{0}' from module "{1}"]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[Importovat výchozí {0} z modulu {1}]]></Val>
|
||||
<Val><![CDATA[Importovat výchozí hodnotu {0} z modulu {1}]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
@@ -10206,6 +10206,15 @@
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";The_operand_of_a_delete_operator_must_be_optional_2790" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[The operand of a 'delete' operator must be optional.]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[Operand operátoru delete musí být nepovinný.]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";The_operand_of_an_increment_or_decrement_operator_may_not_be_an_optional_property_access_2777" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[The operand of an increment or decrement operator may not be an optional property access.]]></Val>
|
||||
@@ -10330,7 +10339,7 @@
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[The shadowing declaration of '{0}' is defined here]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[Překrývající se deklarace {0} je definovaná tady.]]></Val>
|
||||
<Val><![CDATA[Překrývající deklarace {0} je definovaná tady.]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
@@ -11125,7 +11134,7 @@
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[Type originates at this import. A namespace-style import cannot be called or constructed, and will cause a failure at runtime. Consider using a default import or import require here instead.]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[Typ pochází z tohoto importu. Import stylu oboru názvů není možné zavolat ani vytvořit a při běhu způsobí chybu. Zvažte možnost použít tady místo toho výchozí import nebo požadavek na import.]]></Val>
|
||||
<Val><![CDATA[Typ pochází z tohoto importu. Import stylu oboru názvů není možné zavolat ani vytvořit a při běhu způsobí chybu. Zvažte možnost použít tady místo toho výchozí import nebo importovat require.]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
@@ -11686,7 +11695,7 @@
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[Using compiler options of project reference redirect '{0}'.]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[Používají se možnosti kompilátoru přesměrování odkazu projektu {0}.]]></Val>
|
||||
<Val><![CDATA[Using compiler options of project reference redirect '{0}'.]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
|
||||
@@ -7185,6 +7185,15 @@
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";Only_numeric_enums_can_have_computed_members_but_this_expression_has_type_0_If_you_do_not_need_exhau_18033" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[Only numeric enums can have computed members, but this expression has type '{0}'. If you do not need exhaustiveness checks, consider using an object literal instead.]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[Nur numerische Enumerationen können berechnete Member umfassen, aber dieser Ausdruck weist den Typ "{0}" auf. Wenn Sie keine Vollständigkeitsprüfung benötigen, erwägen Sie stattdessen die Verwendung eines Objektliterals.]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword_2340" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[Only public and protected methods of the base class are accessible via the 'super' keyword.]]></Val>
|
||||
|
||||
@@ -445,7 +445,7 @@
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA['A label is not allowed here.]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[Aquí no se permite una etiqueta.]]></Val>
|
||||
<Val><![CDATA[No se permite una etiqueta aquí.]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
@@ -1189,7 +1189,7 @@
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[Add 'export {}' to make this file into a module]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[Agregar "export {}" para convertir este archivo en un módulo]]></Val>
|
||||
<Val><![CDATA[Agregar "export {}" para transformar este archivo en un módulo]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
@@ -3205,7 +3205,7 @@
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[Compiler reserves name '{0}' when emitting private identifier downlevel.]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[El compilador reserva el nombre "{0}" al emitir un identificador privado en el nivel inferior.]]></Val>
|
||||
<Val><![CDATA[El compilador reserva el nombre "{0}" al emitir un identificador privado válido para versiones anteriores.]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
@@ -7200,6 +7200,15 @@
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";Only_numeric_enums_can_have_computed_members_but_this_expression_has_type_0_If_you_do_not_need_exhau_18033" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[Only numeric enums can have computed members, but this expression has type '{0}'. If you do not need exhaustiveness checks, consider using an object literal instead.]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[Solo las enumeraciones numéricas pueden tener miembros calculados, pero esta expresión tiene el tipo "{0}". Si no requiere comprobaciones de exhaustividad, considere la posibilidad de usar un literal de objeto en su lugar.]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword_2340" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[Only public and protected methods of the base class are accessible via the 'super' keyword.]]></Val>
|
||||
@@ -10200,6 +10209,15 @@
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";The_operand_of_a_delete_operator_must_be_optional_2790" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[The operand of a 'delete' operator must be optional.]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[El operando de un operador "delete" debe ser opcional.]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";The_operand_of_an_increment_or_decrement_operator_may_not_be_an_optional_property_access_2777" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[The operand of an increment or decrement operator may not be an optional property access.]]></Val>
|
||||
@@ -10324,7 +10342,7 @@
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[The shadowing declaration of '{0}' is defined here]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[La declaración de reemplazo de "{0}" se define aquí.]]></Val>
|
||||
<Val><![CDATA[La declaración que ensombrece a "{0}" se define aquí.]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
@@ -11119,7 +11137,7 @@
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[Type originates at this import. A namespace-style import cannot be called or constructed, and will cause a failure at runtime. Consider using a default import or import require here instead.]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[El tipo se origina en esta importación. No se puede construir ni llamar a una importación de estilo de espacio de nombres y provocará un error en tiempo de ejecución. Considere la posibilidad de usar una importación predeterminada o requerir la importación aquí.]]></Val>
|
||||
<Val><![CDATA[El tipo se origina en esta importación. No se puede construir ni llamar a una importación de estilo de espacio de nombres y provocará un error en tiempo de ejecución. Considere la posibilidad de usar una importación predeterminada o require aquí en su lugar.]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
@@ -11680,7 +11698,7 @@
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[Using compiler options of project reference redirect '{0}'.]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[El uso de las opciones del compilador de la referencia del proyecto redirige "{0}".]]></Val>
|
||||
<Val><![CDATA[Uso de las opciones del compilador de redireccionamiento de la referencia del proyecto "{0}".]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
|
||||
@@ -445,7 +445,7 @@
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA['A label is not allowed here.]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA['Étiquette non autorisée ici.]]></Val>
|
||||
<Val><![CDATA[Étiquette non autorisée ici.]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
@@ -3205,7 +3205,7 @@
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[Compiler reserves name '{0}' when emitting private identifier downlevel.]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[Le compilateur réserve le nom '{0}' quand il émet un identificateur privé de niveau inférieur.]]></Val>
|
||||
<Val><![CDATA[Le compilateur réserve le nom '{0}' quand il émet un identificateur privé pour une version antérieure.]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
@@ -7200,6 +7200,15 @@
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";Only_numeric_enums_can_have_computed_members_but_this_expression_has_type_0_If_you_do_not_need_exhau_18033" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[Only numeric enums can have computed members, but this expression has type '{0}'. If you do not need exhaustiveness checks, consider using an object literal instead.]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[Seules les enums numériques peuvent avoir des membres calculés, mais cette expression a le type '{0}'. Si vous n'avez pas besoin de contrôles d'exhaustivité, utilisez un littéral d'objet à la place.]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword_2340" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[Only public and protected methods of the base class are accessible via the 'super' keyword.]]></Val>
|
||||
@@ -7411,7 +7420,7 @@
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[Overload {0} of {1}, '{2}', gave the following error.]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[La surcharge {0} de {1}, '{2}', a généré l'erreur suivante.]]></Val>
|
||||
<Val><![CDATA[La surcharge {0} sur {1}, '{2}', a généré l'erreur suivante.]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
@@ -11119,7 +11128,7 @@
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[Type originates at this import. A namespace-style import cannot be called or constructed, and will cause a failure at runtime. Consider using a default import or import require here instead.]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[Le type provient de cette importation. Impossible d'appeler ou de construire une importation de style d'espace de noms, ce qui va entraîner un échec au moment de l'exécution. À la place, utilisez une importation par défaut ou une obligation d'importation ici.]]></Val>
|
||||
<Val><![CDATA[Le type provient de cette importation. Impossible d'appeler ou de construire une importation de style d'espace de noms, ce qui va entraîner un échec au moment de l'exécution. À la place, utilisez ici une importation par défaut ou une importation avec require.]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
|
||||
@@ -1180,7 +1180,7 @@
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[Add 'export {}' to make this file into a module]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[Aggiungere 'export {}' per creare questo file in un modulo]]></Val>
|
||||
<Val><![CDATA[Aggiungere 'export {}' per trasformare questo file in un modulo]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
@@ -3193,7 +3193,7 @@
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[Compiler reserves name '{0}' when emitting private identifier downlevel.]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[Il compilatore riserva il nome '{0}' quando si crea l'identificatore provato di livello inferiore.]]></Val>
|
||||
<Val><![CDATA[Il compilatore riserva il nome '{0}' quando si crea l'identificatore privato per browser meno recenti.]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
@@ -7831,7 +7831,7 @@
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[Prefix with 'declare']]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[Aggiungere 'declare' come prefisso]]></Val>
|
||||
<Val><![CDATA[Aggiungere il prefisso 'declare']]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
@@ -10321,7 +10321,7 @@
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[The shadowing declaration of '{0}' is defined here]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[La dichiarazione di shadowing di '{0}' viene definita in questo punto]]></Val>
|
||||
<Val><![CDATA[La dichiarazione di oscuramento di '{0}' viene definita in questo punto]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
@@ -11116,7 +11116,7 @@
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[Type originates at this import. A namespace-style import cannot be called or constructed, and will cause a failure at runtime. Consider using a default import or import require here instead.]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[Il tipo è originato in corrispondenza di questa importazione. Non è possibile chiamare o costruire un'importazione di tipo spazio dei nomi e verrà restituito un errore in fase di esecuzione. Provare a usare un'importazione o un'importazione predefinita in questo punto.]]></Val>
|
||||
<Val><![CDATA[Il tipo è originato in corrispondenza di questa importazione. Non è possibile chiamare o costruire un'importazione di tipo spazio dei nomi e verrà restituito un errore in fase di esecuzione. Provare a usare un'importazione predefinita o un'importazione di require in questo punto.]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
@@ -11677,7 +11677,7 @@
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[Using compiler options of project reference redirect '{0}'.]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[Verranno usate le opzione del compilatore del progetto per fare riferimento al reindirizzamento '{0}'.]]></Val>
|
||||
<Val><![CDATA[Using compiler options of project reference redirect '{0}'.]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
|
||||
@@ -436,7 +436,7 @@
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA['A label is not allowed here.]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA['A ラベルはここでは使用できません。]]></Val>
|
||||
<Val><![CDATA[A ラベルはここでは使用できません。]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
@@ -1180,7 +1180,7 @@
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[Add 'export {}' to make this file into a module]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA['export {}' を追加して、このファイルをモジュールに含める]]></Val>
|
||||
<Val><![CDATA['export {}' を追加して、このファイルをモジュールにする]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
@@ -3193,7 +3193,7 @@
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[Compiler reserves name '{0}' when emitting private identifier downlevel.]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[private 識別子を下位レベルで出力するときに、コンパイラは名前 '{0}' を予約します。]]></Val>
|
||||
<Val><![CDATA[private 識別子を下位レベルに生成するときに、コンパイラは名前 '{0}' を予約します。]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
@@ -7188,6 +7188,15 @@
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";Only_numeric_enums_can_have_computed_members_but_this_expression_has_type_0_If_you_do_not_need_exhau_18033" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[Only numeric enums can have computed members, but this expression has type '{0}'. If you do not need exhaustiveness checks, consider using an object literal instead.]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[計算されたメンバーを使用できるのは数値列挙型のみですが、この式には '{0}' 型があります。網羅性チェックが不要な場合は、代わりにオブジェクト リテラルを使用することをご検討ください。]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword_2340" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[Only public and protected methods of the base class are accessible via the 'super' keyword.]]></Val>
|
||||
@@ -7399,7 +7408,7 @@
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[Overload {0} of {1}, '{2}', gave the following error.]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[{1}、'{2}' の {0} のオーバーロードにより、次のエラーが発生しました。]]></Val>
|
||||
<Val><![CDATA[{1} 中 {0} のオーバーロード, '{2}' により、次のエラーが発生しました。]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
@@ -11107,7 +11116,7 @@
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[Type originates at this import. A namespace-style import cannot be called or constructed, and will cause a failure at runtime. Consider using a default import or import require here instead.]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[型はこのインポートで生成されます。名前空間スタイルのインポートは、呼び出すこともコンストラクトすることもできず、実行時にエラーが発生します。代わりに、ここで既定のインポートまたはインポートの要求を使用することを検討してください。]]></Val>
|
||||
<Val><![CDATA[型はこのインポートで生成されます。名前空間スタイルのインポートは、呼び出すこともコンストラクトすることもできず、実行時にエラーが発生します。代わりに、ここで既定のインポートまたはインポートの require を使用することを検討してください。]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
@@ -11668,7 +11677,7 @@
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[Using compiler options of project reference redirect '{0}'.]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[プロジェクト参照リダイレクト '{0}' のコンパイラ オプションを使用します。]]></Val>
|
||||
<Val><![CDATA[Using compiler options of project reference redirect '{0}'.]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
|
||||
@@ -436,7 +436,7 @@
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA['A label is not allowed here.]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA['여기서는 레이블을 사용할 수 없습니다.]]></Val>
|
||||
<Val><![CDATA[여기서는 레이블을 사용할 수 없습니다.]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
@@ -7188,6 +7188,15 @@
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";Only_numeric_enums_can_have_computed_members_but_this_expression_has_type_0_If_you_do_not_need_exhau_18033" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[Only numeric enums can have computed members, but this expression has type '{0}'. If you do not need exhaustiveness checks, consider using an object literal instead.]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[숫자 열거형에는 컴퓨팅된 구성원만 사용할 수 있는데 이 식에는 '{0}' 형식이 있습니다. 전체 검사가 필요하지 않은 경우에는 개체 리터럴을 대신 사용해 보세요.]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword_2340" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[Only public and protected methods of the base class are accessible via the 'super' keyword.]]></Val>
|
||||
@@ -7399,7 +7408,7 @@
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[Overload {0} of {1}, '{2}', gave the following error.]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[{1}, '{2}'의 오버로드 {0}에서 다음 오류가 발생했습니다.]]></Val>
|
||||
<Val><![CDATA[오버로드 {0}/{1}('{2}')에서 다음 오류가 발생했습니다.]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
@@ -10768,7 +10777,7 @@
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[Type '{0}' is missing the following properties from type '{1}': {2}, and {3} more.]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA['{0}' 형식에 '{1}' 형식의 {2}, {3} 속성 등이 없습니다.]]></Val>
|
||||
<Val><![CDATA['{0}' 형식에 '{1}' 형식의 {2} 외 {3}개 속성이 없습니다.]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
@@ -11107,7 +11116,7 @@
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[Type originates at this import. A namespace-style import cannot be called or constructed, and will cause a failure at runtime. Consider using a default import or import require here instead.]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[형식이 이 가져오기에서 시작됩니다. 네임스페이스 스타일 가져오기는 호출하거나 생성할 수 없으며, 런타임에 오류를 초래합니다. 여기서는 대신 기본 가져오기 또는 가져오기 필요를 사용하는 것이 좋습니다.]]></Val>
|
||||
<Val><![CDATA[형식이 이 가져오기에서 시작됩니다. 네임스페이스 스타일 가져오기는 호출하거나 생성할 수 없으며, 런타임에 오류를 초래합니다. 여기서는 대신 기본 가져오기 또는 가져오기 require를 사용하는 것이 좋습니다.]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
|
||||
@@ -3186,7 +3186,7 @@
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[Compiler reserves name '{0}' when emitting private identifier downlevel.]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[O compilador reserva o nome '{0}' ao emitir um nível inferior de identificador privado.]]></Val>
|
||||
<Val><![CDATA[O compilador reserva o nome '{0}' ao emitir um identificador privado para versões anteriores.]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
@@ -7821,7 +7821,7 @@
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[Prefix with 'declare']]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[Prefixo com 'declare']]></Val>
|
||||
<Val><![CDATA[Prefixar com 'declare']]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
@@ -10187,6 +10187,15 @@
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";The_operand_of_a_delete_operator_must_be_optional_2790" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[The operand of a 'delete' operator must be optional.]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[O operando de um operador 'delete' precisa ser opcional.]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";The_operand_of_an_increment_or_decrement_operator_may_not_be_an_optional_property_access_2777" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[The operand of an increment or decrement operator may not be an optional property access.]]></Val>
|
||||
@@ -11106,7 +11115,7 @@
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[Type originates at this import. A namespace-style import cannot be called or constructed, and will cause a failure at runtime. Consider using a default import or import require here instead.]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[O tipo se origina nessa importação. Uma importação de estilo de namespace não pode ser chamada nem construída e causará uma falha no runtime. Considere usar uma importação padrão ou solicite uma importação aqui.]]></Val>
|
||||
<Val><![CDATA[O tipo se origina nessa importação. Uma importação de estilo de namespace não pode ser chamada nem construída e causará uma falha no runtime. Considere usar uma importação padrão ou importe require aqui.]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
@@ -11667,7 +11676,7 @@
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[Using compiler options of project reference redirect '{0}'.]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[Usando opções de compilador de redirecionamento de referência de projeto '{0}'.]]></Val>
|
||||
<Val><![CDATA[Using compiler options of project reference redirect '{0}'.]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
|
||||
@@ -7187,6 +7187,15 @@
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";Only_numeric_enums_can_have_computed_members_but_this_expression_has_type_0_If_you_do_not_need_exhau_18033" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[Only numeric enums can have computed members, but this expression has type '{0}'. If you do not need exhaustiveness checks, consider using an object literal instead.]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[Только числовые перечисления могут иметь вычисляемые элементы, но это выражение имеет тип "{0}". Если вы не хотите проверять полноту, рекомендуется использовать вместо этого объектный литерал.]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword_2340" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[Only public and protected methods of the base class are accessible via the 'super' keyword.]]></Val>
|
||||
|
||||
@@ -7181,6 +7181,15 @@
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";Only_numeric_enums_can_have_computed_members_but_this_expression_has_type_0_If_you_do_not_need_exhau_18033" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[Only numeric enums can have computed members, but this expression has type '{0}'. If you do not need exhaustiveness checks, consider using an object literal instead.]]></Val>
|
||||
<Tgt Cat="Text" Stat="Loc" Orig="New">
|
||||
<Val><![CDATA[Yalnızca sayısal sabit listelerinde hesaplanmış üyeler olabilir ancak bu ifadede '{0}' türü var. Kapsamlılık denetimleri gerekmiyorsa bunun yerine bir nesne sabit değeri kullanmayı düşünebilirsiniz.]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
</Item>
|
||||
<Item ItemId=";Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword_2340" ItemType="0" PsrId="306" Leaf="true">
|
||||
<Str Cat="Text">
|
||||
<Val><![CDATA[Only public and protected methods of the base class are accessible via the 'super' keyword.]]></Val>
|
||||
|
||||
@@ -2784,7 +2784,7 @@ namespace ts.server.protocol {
|
||||
/**
|
||||
* Arguments for navto request message.
|
||||
*/
|
||||
export interface NavtoRequestArgs extends FileRequestArgs {
|
||||
export interface NavtoRequestArgs {
|
||||
/**
|
||||
* Search term to navigate to from current location; term can
|
||||
* be '.*' or an identifier prefix.
|
||||
@@ -2794,6 +2794,10 @@ namespace ts.server.protocol {
|
||||
* Optional limit on the number of items to return.
|
||||
*/
|
||||
maxResultCount?: number;
|
||||
/**
|
||||
* The file for the request (absolute pathname required).
|
||||
*/
|
||||
file?: string;
|
||||
/**
|
||||
* Optional flag to indicate we want results for just the current file
|
||||
* or the entire project.
|
||||
@@ -2809,7 +2813,7 @@ namespace ts.server.protocol {
|
||||
* match the search term given in argument 'searchTerm'. The
|
||||
* context for the search is given by the named file.
|
||||
*/
|
||||
export interface NavtoRequest extends FileRequest {
|
||||
export interface NavtoRequest extends Request {
|
||||
command: CommandTypes.Navto;
|
||||
arguments: NavtoRequestArgs;
|
||||
}
|
||||
|
||||
+40
-27
@@ -304,7 +304,7 @@ namespace ts.server {
|
||||
projects,
|
||||
defaultProject,
|
||||
/*initialLocation*/ undefined,
|
||||
({ project }, tryAddToTodo) => {
|
||||
(project, _, tryAddToTodo) => {
|
||||
for (const output of action(project)) {
|
||||
if (!contains(outputs, output, resultsEqual) && !tryAddToTodo(project, getLocation(output))) {
|
||||
outputs.push(output);
|
||||
@@ -329,7 +329,7 @@ namespace ts.server {
|
||||
projects,
|
||||
defaultProject,
|
||||
initialLocation,
|
||||
({ project, location }, tryAddToTodo) => {
|
||||
(project, location, tryAddToTodo) => {
|
||||
for (const output of project.getLanguageService().findRenameLocations(location.fileName, location.pos, findInStrings, findInComments, hostPreferences.providePrefixAndSuffixTextForRename) || emptyArray) {
|
||||
if (!contains(outputs, output, documentSpansEqual) && !tryAddToTodo(project, documentSpanLocation(output))) {
|
||||
outputs.push(output);
|
||||
@@ -358,7 +358,7 @@ namespace ts.server {
|
||||
projects,
|
||||
defaultProject,
|
||||
initialLocation,
|
||||
({ project, location }, getMappedLocation) => {
|
||||
(project, location, getMappedLocation) => {
|
||||
for (const outputReferencedSymbol of project.getLanguageService().findReferences(location.fileName, location.pos) || emptyArray) {
|
||||
const mappedDefinitionFile = getMappedLocation(project, documentSpanLocation(outputReferencedSymbol.definition));
|
||||
const definition: ReferencedSymbolDefinitionInfo = mappedDefinitionFile === undefined ?
|
||||
@@ -408,7 +408,8 @@ namespace ts.server {
|
||||
}
|
||||
|
||||
type CombineProjectOutputCallback<TLocation extends DocumentPosition | undefined> = (
|
||||
where: ProjectAndLocation<TLocation>,
|
||||
project: Project,
|
||||
location: TLocation,
|
||||
getMappedLocation: (project: Project, location: DocumentPosition) => DocumentPosition | undefined,
|
||||
) => void;
|
||||
|
||||
@@ -422,9 +423,9 @@ namespace ts.server {
|
||||
let toDo: ProjectAndLocation<TLocation>[] | undefined;
|
||||
const seenProjects = createMap<true>();
|
||||
forEachProjectInProjects(projects, initialLocation && initialLocation.fileName, (project, path) => {
|
||||
// TLocation shoud be either `DocumentPosition` or `undefined`. Since `initialLocation` is `TLocation` this cast should be valid.
|
||||
// TLocation should be either `DocumentPosition` or `undefined`. Since `initialLocation` is `TLocation` this cast should be valid.
|
||||
const location = (initialLocation ? { fileName: path, pos: initialLocation.pos } : undefined) as TLocation;
|
||||
toDo = callbackProjectAndLocation({ project, location }, projectService, toDo, seenProjects, cb);
|
||||
toDo = callbackProjectAndLocation(project, location, projectService, toDo, seenProjects, cb);
|
||||
});
|
||||
|
||||
// After initial references are collected, go over every other project and see if it has a reference for the symbol definition.
|
||||
@@ -442,14 +443,16 @@ namespace ts.server {
|
||||
if (!addToSeen(seenProjects, project)) return;
|
||||
const definition = mapDefinitionInProject(defaultDefinition, project, getGeneratedDefinition, getSourceDefinition);
|
||||
if (definition) {
|
||||
toDo = callbackProjectAndLocation<TLocation>({ project, location: definition as TLocation }, projectService, toDo, seenProjects, cb);
|
||||
toDo = callbackProjectAndLocation<TLocation>(project, definition as TLocation, projectService, toDo, seenProjects, cb);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
while (toDo && toDo.length) {
|
||||
toDo = callbackProjectAndLocation(Debug.checkDefined(toDo.pop()), projectService, toDo, seenProjects, cb);
|
||||
const next = toDo.pop();
|
||||
Debug.assertIsDefined(next);
|
||||
toDo = callbackProjectAndLocation(next.project, next.location, projectService, toDo, seenProjects, cb);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -487,31 +490,33 @@ namespace ts.server {
|
||||
}
|
||||
|
||||
function callbackProjectAndLocation<TLocation extends DocumentPosition | undefined>(
|
||||
projectAndLocation: ProjectAndLocation<TLocation>,
|
||||
project: Project,
|
||||
location: TLocation,
|
||||
projectService: ProjectService,
|
||||
toDo: ProjectAndLocation<TLocation>[] | undefined,
|
||||
seenProjects: Map<true>,
|
||||
cb: CombineProjectOutputCallback<TLocation>,
|
||||
): ProjectAndLocation<TLocation>[] | undefined {
|
||||
const { project, location } = projectAndLocation;
|
||||
if (project.getCancellationToken().isCancellationRequested()) return undefined; // Skip rest of toDo if cancelled
|
||||
// If this is not the file we were actually looking, return rest of the toDo
|
||||
if (isLocationProjectReferenceRedirect(project, location)) return toDo;
|
||||
cb(projectAndLocation, (project, location) => {
|
||||
addToSeen(seenProjects, projectAndLocation.project);
|
||||
const originalLocation = projectService.getOriginalLocationEnsuringConfiguredProject(project, location);
|
||||
cb(project, location, (innerProject, location) => {
|
||||
addToSeen(seenProjects, project);
|
||||
const originalLocation = projectService.getOriginalLocationEnsuringConfiguredProject(innerProject, location);
|
||||
if (!originalLocation) return undefined;
|
||||
|
||||
const originalScriptInfo = projectService.getScriptInfo(originalLocation.fileName)!;
|
||||
toDo = toDo || [];
|
||||
|
||||
for (const project of originalScriptInfo.containingProjects) {
|
||||
addToTodo({ project, location: originalLocation as TLocation }, toDo, seenProjects);
|
||||
addToTodo(project, originalLocation as TLocation, toDo, seenProjects);
|
||||
}
|
||||
const symlinkedProjectsMap = projectService.getSymlinkedProjects(originalScriptInfo);
|
||||
if (symlinkedProjectsMap) {
|
||||
symlinkedProjectsMap.forEach((symlinkedProjects, symlinkedPath) => {
|
||||
for (const symlinkedProject of symlinkedProjects) addToTodo({ project: symlinkedProject, location: { fileName: symlinkedPath, pos: originalLocation.pos } as TLocation }, toDo!, seenProjects);
|
||||
for (const symlinkedProject of symlinkedProjects) {
|
||||
addToTodo(symlinkedProject, { fileName: symlinkedPath, pos: originalLocation.pos } as TLocation, toDo!, seenProjects);
|
||||
}
|
||||
});
|
||||
}
|
||||
return originalLocation === location ? undefined : originalLocation;
|
||||
@@ -519,8 +524,8 @@ namespace ts.server {
|
||||
return toDo;
|
||||
}
|
||||
|
||||
function addToTodo<TLocation extends DocumentPosition | undefined>(projectAndLocation: ProjectAndLocation<TLocation>, toDo: Push<ProjectAndLocation<TLocation>>, seenProjects: Map<true>): void {
|
||||
if (addToSeen(seenProjects, projectAndLocation.project)) toDo.push(projectAndLocation);
|
||||
function addToTodo<TLocation extends DocumentPosition | undefined>(project: Project, location: TLocation, toDo: Push<ProjectAndLocation<TLocation>>, seenProjects: Map<true>): void {
|
||||
if (addToSeen(seenProjects, project)) toDo.push({ project, location });
|
||||
}
|
||||
|
||||
function addToSeen(seenProjects: Map<true>, project: Project) {
|
||||
@@ -1323,7 +1328,7 @@ namespace ts.server {
|
||||
// filter handles case when 'projects' is undefined
|
||||
projects = filter(projects, p => p.languageServiceEnabled && !p.isOrphan());
|
||||
if (!ignoreNoProjectError && (!projects || !projects.length) && !symLinkedProjects) {
|
||||
this.projectService.logErrorForScriptInfoNotFound(args.file);
|
||||
this.projectService.logErrorForScriptInfoNotFound(args.file ?? args.projectFileName);
|
||||
return Errors.ThrowNoProject();
|
||||
}
|
||||
return symLinkedProjects ? { projects: projects!, symLinkedProjects } : projects!; // TODO: GH#18217
|
||||
@@ -1335,6 +1340,9 @@ namespace ts.server {
|
||||
if (project) {
|
||||
return project;
|
||||
}
|
||||
if (!args.file) {
|
||||
return Errors.ThrowNoProject();
|
||||
}
|
||||
}
|
||||
const info = this.projectService.getScriptInfo(args.file)!;
|
||||
return info.getDefaultProject();
|
||||
@@ -1894,20 +1902,25 @@ namespace ts.server {
|
||||
}
|
||||
|
||||
private getFullNavigateToItems(args: protocol.NavtoRequestArgs): readonly NavigateToItem[] {
|
||||
const { currentFileOnly, searchValue, maxResultCount } = args;
|
||||
const { currentFileOnly, searchValue, maxResultCount, projectFileName } = args;
|
||||
if (currentFileOnly) {
|
||||
const { file, project } = this.getFileAndProject(args);
|
||||
Debug.assertDefined(args.file);
|
||||
const { file, project } = this.getFileAndProject(args as protocol.FileRequestArgs);
|
||||
return project.getLanguageService().getNavigateToItems(searchValue, maxResultCount, file);
|
||||
}
|
||||
else {
|
||||
return combineProjectOutputWhileOpeningReferencedProjects<NavigateToItem>(
|
||||
this.getProjects(args),
|
||||
this.getDefaultProject(args),
|
||||
project =>
|
||||
project.getLanguageService().getNavigateToItems(searchValue, maxResultCount, /*fileName*/ undefined, /*excludeDts*/ project.isNonTsProject()),
|
||||
documentSpanLocation,
|
||||
else if (!args.file && !projectFileName) {
|
||||
return combineProjectOutputFromEveryProject(
|
||||
this.projectService,
|
||||
project => project.getLanguageService().getNavigateToItems(searchValue, maxResultCount, /*filename*/ undefined, /*excludeDts*/ project.isNonTsProject()),
|
||||
navigateToItemIsEqualTo);
|
||||
}
|
||||
const fileArgs = args as protocol.FileRequestArgs;
|
||||
return combineProjectOutputWhileOpeningReferencedProjects<NavigateToItem>(
|
||||
this.getProjects(fileArgs),
|
||||
this.getDefaultProject(fileArgs),
|
||||
project => project.getLanguageService().getNavigateToItems(searchValue, maxResultCount, /*fileName*/ undefined, /*excludeDts*/ project.isNonTsProject()),
|
||||
documentSpanLocation,
|
||||
navigateToItemIsEqualTo);
|
||||
|
||||
function navigateToItemIsEqualTo(a: NavigateToItem, b: NavigateToItem): boolean {
|
||||
if (a === b) {
|
||||
|
||||
@@ -16,6 +16,7 @@ namespace ts.codefix {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
const newLineCharacter = sourceFile.checkJsDirective ? "" : getNewLineOrDefaultFromHost(host, formatContext.options);
|
||||
const fixes: CodeFixAction[] = [
|
||||
// fixId unnecessary because adding `// @ts-nocheck` even once will ignore every error in the file.
|
||||
createCodeFixActionWithoutFixAll(
|
||||
@@ -23,7 +24,7 @@ namespace ts.codefix {
|
||||
[createFileTextChanges(sourceFile.fileName, [
|
||||
createTextChange(sourceFile.checkJsDirective
|
||||
? createTextSpanFromBounds(sourceFile.checkJsDirective.pos, sourceFile.checkJsDirective.end)
|
||||
: createTextSpan(0, 0), `// @ts-nocheck${getNewLineOrDefaultFromHost(host, formatContext.options)}`),
|
||||
: createTextSpan(0, 0), `// @ts-nocheck${newLineCharacter}`),
|
||||
])],
|
||||
Diagnostics.Disable_checking_for_this_file),
|
||||
];
|
||||
|
||||
@@ -45,7 +45,6 @@ namespace ts.codefix {
|
||||
// Keys are import clause node IDs.
|
||||
const addToExisting = createMap<{ readonly importClauseOrBindingPattern: ImportClause | ObjectBindingPattern, defaultImport: string | undefined; readonly namedImports: string[], canUseTypeOnlyImport: boolean }>();
|
||||
const newImports = createMap<Mutable<ImportsCollection & { useRequire: boolean }>>();
|
||||
let lastModuleSpecifier: string | undefined;
|
||||
return { addImportFromDiagnostic, addImportFromExportedSymbol, writeFixes };
|
||||
|
||||
function addImportFromDiagnostic(diagnostic: DiagnosticWithLocation, context: CodeFixContextBase) {
|
||||
@@ -97,7 +96,6 @@ namespace ts.codefix {
|
||||
let entry = newImports.get(moduleSpecifier);
|
||||
if (!entry) {
|
||||
newImports.set(moduleSpecifier, entry = { namedImports: [], namespaceLikeImport: undefined, typeOnly, useRequire });
|
||||
lastModuleSpecifier = moduleSpecifier;
|
||||
}
|
||||
else {
|
||||
// An import clause can only be type-only if every import fix contributing to it can be type-only.
|
||||
@@ -135,10 +133,15 @@ namespace ts.codefix {
|
||||
addToExisting.forEach(({ importClauseOrBindingPattern, defaultImport, namedImports, canUseTypeOnlyImport }) => {
|
||||
doAddExistingFix(changeTracker, sourceFile, importClauseOrBindingPattern, defaultImport, namedImports, canUseTypeOnlyImport);
|
||||
});
|
||||
|
||||
let newDeclarations: Statement | readonly Statement[] | undefined;
|
||||
newImports.forEach(({ useRequire, ...imports }, moduleSpecifier) => {
|
||||
const addDeclarations = useRequire ? addNewRequires : addNewImports;
|
||||
addDeclarations(changeTracker, sourceFile, moduleSpecifier, quotePreference, imports, /*blankLineBetween*/ lastModuleSpecifier === moduleSpecifier);
|
||||
const getDeclarations = useRequire ? getNewRequires : getNewImports;
|
||||
newDeclarations = combine(newDeclarations, getDeclarations(moduleSpecifier, quotePreference, imports));
|
||||
});
|
||||
if (newDeclarations) {
|
||||
insertImports(changeTracker, sourceFile, newDeclarations, /*blankLineBetween*/ true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -631,11 +634,11 @@ namespace ts.codefix {
|
||||
}
|
||||
case ImportFixKind.AddNew: {
|
||||
const { importKind, moduleSpecifier, typeOnly, useRequire } = fix;
|
||||
const addDeclarations = useRequire ? addNewRequires : addNewImports;
|
||||
const getDeclarations = useRequire ? getNewRequires : getNewImports;
|
||||
const importsCollection = importKind === ImportKind.Default ? { defaultImport: symbolName, typeOnly } :
|
||||
importKind === ImportKind.Named ? { namedImports: [symbolName], typeOnly } :
|
||||
{ namespaceLikeImport: { importKind, name: symbolName }, typeOnly };
|
||||
addDeclarations(changes, sourceFile, moduleSpecifier, quotePreference, importsCollection, /*blankLineBetween*/ true);
|
||||
insertImports(changes, sourceFile, getDeclarations(moduleSpecifier, quotePreference, importsCollection), /*blankLineBetween*/ true);
|
||||
return [importKind === ImportKind.Default ? Diagnostics.Import_default_0_from_module_1 : Diagnostics.Import_0_from_module_1, symbolName, moduleSpecifier];
|
||||
}
|
||||
default:
|
||||
@@ -717,13 +720,13 @@ namespace ts.codefix {
|
||||
readonly name: string;
|
||||
};
|
||||
}
|
||||
function addNewImports(changes: textChanges.ChangeTracker, sourceFile: SourceFile, moduleSpecifier: string, quotePreference: QuotePreference, imports: ImportsCollection, blankLineBetween: boolean): void {
|
||||
function getNewImports(moduleSpecifier: string, quotePreference: QuotePreference, imports: ImportsCollection): Statement | readonly Statement[] {
|
||||
const quotedModuleSpecifier = makeStringLiteral(moduleSpecifier, quotePreference);
|
||||
let statements: Statement | readonly Statement[] | undefined;
|
||||
if (imports.defaultImport !== undefined || imports.namedImports?.length) {
|
||||
insertImport(changes, sourceFile,
|
||||
makeImport(
|
||||
imports.defaultImport === undefined ? undefined : createIdentifier(imports.defaultImport),
|
||||
imports.namedImports?.map(n => createImportSpecifier(/*propertyName*/ undefined, createIdentifier(n))), moduleSpecifier, quotePreference, imports.typeOnly), /*blankLineBetween*/ blankLineBetween);
|
||||
statements = combine(statements, makeImport(
|
||||
imports.defaultImport === undefined ? undefined : createIdentifier(imports.defaultImport),
|
||||
imports.namedImports?.map(n => createImportSpecifier(/*propertyName*/ undefined, createIdentifier(n))), moduleSpecifier, quotePreference, imports.typeOnly));
|
||||
}
|
||||
const { namespaceLikeImport, typeOnly } = imports;
|
||||
if (namespaceLikeImport) {
|
||||
@@ -741,12 +744,14 @@ namespace ts.codefix {
|
||||
createNamespaceImport(createIdentifier(namespaceLikeImport.name)),
|
||||
typeOnly),
|
||||
quotedModuleSpecifier);
|
||||
insertImport(changes, sourceFile, declaration, /*blankLineBetween*/ blankLineBetween);
|
||||
statements = combine(statements, declaration);
|
||||
}
|
||||
return Debug.checkDefined(statements);
|
||||
}
|
||||
|
||||
function addNewRequires(changes: textChanges.ChangeTracker, sourceFile: SourceFile, moduleSpecifier: string, quotePreference: QuotePreference, imports: ImportsCollection, blankLineBetween: boolean) {
|
||||
function getNewRequires(moduleSpecifier: string, quotePreference: QuotePreference, imports: ImportsCollection): Statement | readonly Statement[] {
|
||||
const quotedModuleSpecifier = makeStringLiteral(moduleSpecifier, quotePreference);
|
||||
let statements: Statement | readonly Statement[] | undefined;
|
||||
// const { default: foo, bar, etc } = require('./mod');
|
||||
if (imports.defaultImport || imports.namedImports?.length) {
|
||||
const bindingElements = imports.namedImports?.map(name => createBindingElement(/*dotDotDotToken*/ undefined, /*propertyName*/ undefined, name)) || [];
|
||||
@@ -754,13 +759,14 @@ namespace ts.codefix {
|
||||
bindingElements.unshift(createBindingElement(/*dotDotDotToken*/ undefined, "default", imports.defaultImport));
|
||||
}
|
||||
const declaration = createConstEqualsRequireDeclaration(createObjectBindingPattern(bindingElements), quotedModuleSpecifier);
|
||||
insertImport(changes, sourceFile, declaration, blankLineBetween);
|
||||
statements = combine(statements, declaration);
|
||||
}
|
||||
// const foo = require('./mod');
|
||||
if (imports.namespaceLikeImport) {
|
||||
const declaration = createConstEqualsRequireDeclaration(imports.namespaceLikeImport.name, quotedModuleSpecifier);
|
||||
insertImport(changes, sourceFile, declaration, blankLineBetween);
|
||||
statements = combine(statements, declaration);
|
||||
}
|
||||
return Debug.checkDefined(statements);
|
||||
}
|
||||
|
||||
function createConstEqualsRequireDeclaration(name: string | ObjectBindingPattern, quotedModuleSpecifier: StringLiteral): VariableStatement {
|
||||
|
||||
@@ -603,7 +603,7 @@ namespace ts.codefix {
|
||||
|
||||
switch (node.parent.kind) {
|
||||
case SyntaxKind.ExpressionStatement:
|
||||
addCandidateType(usage, checker.getVoidType());
|
||||
inferTypeFromExpressionStatement(node, usage);
|
||||
break;
|
||||
case SyntaxKind.PostfixUnaryExpression:
|
||||
usage.isNumber = true;
|
||||
@@ -661,6 +661,10 @@ namespace ts.codefix {
|
||||
}
|
||||
}
|
||||
|
||||
function inferTypeFromExpressionStatement(node: Expression, usage: Usage): void {
|
||||
addCandidateType(usage, isCallExpression(node) ? checker.getVoidType() : checker.getAnyType());
|
||||
}
|
||||
|
||||
function inferTypeFromPrefixUnaryExpression(node: PrefixUnaryExpression, usage: Usage): void {
|
||||
switch (node.operator) {
|
||||
case SyntaxKind.PlusPlusToken:
|
||||
@@ -960,10 +964,7 @@ namespace ts.codefix {
|
||||
if (usage.numberIndex) {
|
||||
types.push(checker.createArrayType(combineFromUsage(usage.numberIndex)));
|
||||
}
|
||||
if (usage.properties && usage.properties.size
|
||||
|| usage.calls && usage.calls.length
|
||||
|| usage.constructs && usage.constructs.length
|
||||
|| usage.stringIndex) {
|
||||
if (usage.properties?.size || usage.calls?.length || usage.constructs?.length || usage.stringIndex) {
|
||||
types.push(inferStructuralType(usage));
|
||||
}
|
||||
|
||||
|
||||
@@ -2427,7 +2427,8 @@ namespace ts.Completions {
|
||||
return baseSymbols.filter(propertySymbol =>
|
||||
!existingMemberNames.has(propertySymbol.escapedName) &&
|
||||
!!propertySymbol.declarations &&
|
||||
!(getDeclarationModifierFlagsFromSymbol(propertySymbol) & ModifierFlags.Private));
|
||||
!(getDeclarationModifierFlagsFromSymbol(propertySymbol) & ModifierFlags.Private) &&
|
||||
!isPrivateIdentifierPropertyDeclaration(propertySymbol.valueDeclaration));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2684,10 +2685,16 @@ namespace ts.Completions {
|
||||
return cls;
|
||||
}
|
||||
break;
|
||||
case SyntaxKind.Identifier: // class c extends React.Component { a: () => 1\n compon| }
|
||||
case SyntaxKind.Identifier: {
|
||||
// class c { public prop = c| }
|
||||
if (isPropertyDeclaration(location.parent) && location.parent.initializer === location) {
|
||||
return undefined;
|
||||
}
|
||||
// class c extends React.Component { a: () => 1\n compon| }
|
||||
if (isFromObjectTypeDeclaration(location)) {
|
||||
return findAncestor(location, isObjectTypeDeclaration);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!contextToken) return undefined;
|
||||
|
||||
@@ -199,6 +199,7 @@ namespace ts.OutliningElementsCollector {
|
||||
case SyntaxKind.InterfaceDeclaration:
|
||||
case SyntaxKind.EnumDeclaration:
|
||||
case SyntaxKind.CaseBlock:
|
||||
case SyntaxKind.TypeLiteral:
|
||||
case SyntaxKind.ObjectBindingPattern:
|
||||
return spanForNode(n);
|
||||
case SyntaxKind.CaseClause:
|
||||
|
||||
@@ -121,7 +121,7 @@ namespace ts.refactor {
|
||||
const quotePreference = getQuotePreference(oldFile, preferences);
|
||||
const importsFromNewFile = createOldFileImportsFromNewFile(usage.oldFileImportsFromNewFile, newModuleName, useEs6ModuleSyntax, quotePreference);
|
||||
if (importsFromNewFile) {
|
||||
insertImport(changes, oldFile, importsFromNewFile, /*blankLineBetween*/ true);
|
||||
insertImports(changes, oldFile, importsFromNewFile, /*blankLineBetween*/ true);
|
||||
}
|
||||
|
||||
deleteUnusedOldImports(oldFile, toMove.all, changes, usage.unusedImportsFromOldFile, checker);
|
||||
|
||||
@@ -156,7 +156,18 @@ namespace ts {
|
||||
}
|
||||
|
||||
function isPromiseHandler(node: Node): node is CallExpression {
|
||||
return isCallExpression(node) && (hasPropertyAccessExpressionWithName(node, "then") || hasPropertyAccessExpressionWithName(node, "catch"));
|
||||
return isCallExpression(node) && (
|
||||
hasPropertyAccessExpressionWithName(node, "then") && hasSupportedNumberOfArguments(node) ||
|
||||
hasPropertyAccessExpressionWithName(node, "catch"));
|
||||
}
|
||||
|
||||
function hasSupportedNumberOfArguments(node: CallExpression) {
|
||||
if (node.arguments.length > 2) return false;
|
||||
if (node.arguments.length < 2) return true;
|
||||
return some(node.arguments, arg => {
|
||||
return arg.kind === SyntaxKind.NullKeyword ||
|
||||
isIdentifier(arg) && arg.text === "undefined";
|
||||
});
|
||||
}
|
||||
|
||||
// should be kept up to date with getTransformationBody in convertToAsyncFunction.ts
|
||||
|
||||
@@ -349,11 +349,25 @@ namespace ts.textChanges {
|
||||
}
|
||||
|
||||
public insertNodeAtTopOfFile(sourceFile: SourceFile, newNode: Statement, blankLineBetween: boolean): void {
|
||||
this.insertAtTopOfFile(sourceFile, newNode, blankLineBetween);
|
||||
}
|
||||
|
||||
public insertNodesAtTopOfFile(sourceFile: SourceFile, newNodes: readonly Statement[], blankLineBetween: boolean): void {
|
||||
this.insertAtTopOfFile(sourceFile, newNodes, blankLineBetween);
|
||||
}
|
||||
|
||||
private insertAtTopOfFile(sourceFile: SourceFile, insert: Statement | readonly Statement[], blankLineBetween: boolean): void {
|
||||
const pos = getInsertionPositionAtSourceFileTop(sourceFile);
|
||||
this.insertNodeAt(sourceFile, pos, newNode, {
|
||||
const options = {
|
||||
prefix: pos === 0 ? undefined : this.newLineCharacter,
|
||||
suffix: (isLineBreak(sourceFile.text.charCodeAt(pos)) ? "" : this.newLineCharacter) + (blankLineBetween ? this.newLineCharacter : ""),
|
||||
});
|
||||
};
|
||||
if (isArray(insert)) {
|
||||
this.insertNodesAt(sourceFile, pos, insert, options);
|
||||
}
|
||||
else {
|
||||
this.insertNodeAt(sourceFile, pos, insert, options);
|
||||
}
|
||||
}
|
||||
|
||||
public insertFirstParameter(sourceFile: SourceFile, parameters: NodeArray<ParameterDeclaration>, newParam: ParameterDeclaration): void {
|
||||
@@ -434,7 +448,7 @@ namespace ts.textChanges {
|
||||
}
|
||||
}
|
||||
else {
|
||||
endNode = node.kind !== SyntaxKind.VariableDeclaration && node.questionToken ? node.questionToken : node.name;
|
||||
endNode = (node.kind === SyntaxKind.VariableDeclaration ? node.exclamationToken : node.questionToken) ?? node.name;
|
||||
}
|
||||
|
||||
this.insertNodeAt(sourceFile, endNode.end, type, { prefix: ": " });
|
||||
@@ -873,7 +887,7 @@ namespace ts.textChanges {
|
||||
|
||||
namespace changesToText {
|
||||
export function getTextChangesFromChanges(changes: readonly Change[], newLineCharacter: string, formatContext: formatting.FormatContext, validate: ValidateNonFormattedText | undefined): FileTextChanges[] {
|
||||
return group(changes, c => c.sourceFile.path).map(changesInFile => {
|
||||
return mapDefined(group(changes, c => c.sourceFile.path), changesInFile => {
|
||||
const sourceFile = changesInFile[0].sourceFile;
|
||||
// order changes by start position
|
||||
// If the start position is the same, put the shorter range first, since an empty range (x, x) may precede (x, y) but not vice-versa.
|
||||
@@ -883,9 +897,20 @@ namespace ts.textChanges {
|
||||
Debug.assert(normalized[i].range.end <= normalized[i + 1].range.pos, "Changes overlap", () =>
|
||||
`${JSON.stringify(normalized[i].range)} and ${JSON.stringify(normalized[i + 1].range)}`);
|
||||
}
|
||||
const textChanges = normalized.map(c =>
|
||||
createTextChange(createTextSpanFromRange(c.range), computeNewText(c, sourceFile, newLineCharacter, formatContext, validate)));
|
||||
return { fileName: sourceFile.fileName, textChanges };
|
||||
|
||||
const textChanges = mapDefined(normalized, c => {
|
||||
const span = createTextSpanFromRange(c.range);
|
||||
const newText = computeNewText(c, sourceFile, newLineCharacter, formatContext, validate);
|
||||
|
||||
// Filter out redundant changes.
|
||||
if (span.length === newText.length && stringContainsAt(sourceFile.text, newText, span.start)) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
return createTextChange(span, newText);
|
||||
});
|
||||
|
||||
return textChanges.length > 0 ? { fileName: sourceFile.fileName, textChanges } : undefined;
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -1871,14 +1871,23 @@ namespace ts {
|
||||
return node.modifiers && find(node.modifiers, m => m.kind === kind);
|
||||
}
|
||||
|
||||
export function insertImport(changes: textChanges.ChangeTracker, sourceFile: SourceFile, importDecl: Statement, blankLineBetween: boolean): void {
|
||||
const importKindPredicate = importDecl.kind === SyntaxKind.VariableStatement ? isRequireVariableDeclarationStatement : isAnyImportSyntax;
|
||||
export function insertImports(changes: textChanges.ChangeTracker, sourceFile: SourceFile, imports: Statement | readonly Statement[], blankLineBetween: boolean): void {
|
||||
const decl = isArray(imports) ? imports[0] : imports;
|
||||
const importKindPredicate = decl.kind === SyntaxKind.VariableStatement ? isRequireVariableDeclarationStatement : isAnyImportSyntax;
|
||||
const lastImportDeclaration = findLast(sourceFile.statements, statement => importKindPredicate(statement));
|
||||
if (lastImportDeclaration) {
|
||||
changes.insertNodeAfter(sourceFile, lastImportDeclaration, importDecl);
|
||||
if (isArray(imports)) {
|
||||
changes.insertNodesAfter(sourceFile, lastImportDeclaration, imports);
|
||||
}
|
||||
else {
|
||||
changes.insertNodeAfter(sourceFile, lastImportDeclaration, imports);
|
||||
}
|
||||
}
|
||||
else if (isArray(imports)) {
|
||||
changes.insertNodesAtTopOfFile(sourceFile, imports, blankLineBetween);
|
||||
}
|
||||
else {
|
||||
changes.insertNodeAtTopOfFile(sourceFile, importDecl, blankLineBetween);
|
||||
changes.insertNodeAtTopOfFile(sourceFile, imports, blankLineBetween);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2818,6 +2827,35 @@ namespace ts {
|
||||
return symbol.name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Useful to check whether a string contains another string at a specific index
|
||||
* without allocating another string or traversing the entire contents of the outer string.
|
||||
*
|
||||
* This function is useful in place of either of the following:
|
||||
*
|
||||
* ```ts
|
||||
* // Allocates
|
||||
* haystack.substr(startIndex, needle.length) === needle
|
||||
*
|
||||
* // Full traversal
|
||||
* haystack.indexOf(needle, startIndex) === startIndex
|
||||
* ```
|
||||
*
|
||||
* @param haystack The string that potentially contains `needle`.
|
||||
* @param needle The string whose content might sit within `haystack`.
|
||||
* @param startIndex The index within `haystack` to start searching for `needle`.
|
||||
*/
|
||||
export function stringContainsAt(haystack: string, needle: string, startIndex: number) {
|
||||
const needleLength = needle.length;
|
||||
if (needleLength + startIndex > haystack.length) {
|
||||
return false;
|
||||
}
|
||||
for (let i = 0; i < needleLength; i++) {
|
||||
if (needle.charCodeAt(i) !== haystack.charCodeAt(i + startIndex)) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
export function startsWithUnderscore(name: string): boolean {
|
||||
return name.charCodeAt(0) === CharacterCodes._;
|
||||
}
|
||||
|
||||
@@ -558,13 +558,13 @@ function [#|f|]():void{
|
||||
}
|
||||
`
|
||||
);
|
||||
_testConvertToAsyncFunction("convertToAsyncFunction_Rej", `
|
||||
_testConvertToAsyncFunctionFailed("convertToAsyncFunction_Rej", `
|
||||
function [#|f|]():Promise<void> {
|
||||
return fetch('https://typescriptlang.org').then(result => { console.log(result); }, rejection => { console.log("rejected:", rejection); });
|
||||
}
|
||||
`
|
||||
);
|
||||
_testConvertToAsyncFunction("convertToAsyncFunction_RejRef", `
|
||||
_testConvertToAsyncFunctionFailed("convertToAsyncFunction_RejRef", `
|
||||
function [#|f|]():Promise<void> {
|
||||
return fetch('https://typescriptlang.org').then(res, rej);
|
||||
}
|
||||
@@ -576,7 +576,7 @@ function rej(err){
|
||||
}
|
||||
`
|
||||
);
|
||||
_testConvertToAsyncFunction("convertToAsyncFunction_RejNoBrackets", `
|
||||
_testConvertToAsyncFunctionFailed("convertToAsyncFunction_RejNoBrackets", `
|
||||
function [#|f|]():Promise<void> {
|
||||
return fetch('https://typescriptlang.org').then(result => console.log(result), rejection => console.log("rejected:", rejection));
|
||||
}
|
||||
@@ -1238,7 +1238,7 @@ function [#|f|]() {
|
||||
}
|
||||
`);
|
||||
|
||||
_testConvertToAsyncFunction("convertToAsyncFunction_ResRejNoArgsArrow", `
|
||||
_testConvertToAsyncFunctionFailed("convertToAsyncFunction_ResRejNoArgsArrow", `
|
||||
function [#|f|]() {
|
||||
return Promise.resolve().then(() => 1, () => "a");
|
||||
}
|
||||
@@ -1436,5 +1436,10 @@ function [#|get|]() {
|
||||
.catch<APIResponse<{ email: string }>>(() => ({ success: false }));
|
||||
}
|
||||
`);
|
||||
|
||||
_testConvertToAsyncFunctionFailed("convertToAsyncFunction_threeArguments", `
|
||||
function [#|f|]() {
|
||||
return Promise.resolve().then(undefined, undefined, () => 1);
|
||||
}`);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -285,6 +285,7 @@ namespace ts {
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
describe("Baselines", () => {
|
||||
|
||||
const libFile = {
|
||||
@@ -327,6 +328,16 @@ export const Other = 1;
|
||||
assert.isEmpty(changes);
|
||||
});
|
||||
|
||||
it("doesn't return any changes when the text would be identical", () => {
|
||||
const testFile = {
|
||||
path: "/a.ts",
|
||||
content: `import { f } from 'foo';\nf();`
|
||||
};
|
||||
const languageService = makeLanguageService(testFile);
|
||||
const changes = languageService.organizeImports({ type: "file", fileName: testFile.path }, testFormatSettings, emptyOptions);
|
||||
assert.isEmpty(changes);
|
||||
});
|
||||
|
||||
testOrganizeImports("Renamed_used",
|
||||
{
|
||||
path: "/test.ts",
|
||||
@@ -366,6 +377,16 @@ D();
|
||||
},
|
||||
libFile);
|
||||
|
||||
it("doesn't return any changes when the text would be identical", () => {
|
||||
const testFile = {
|
||||
path: "/a.ts",
|
||||
content: `import { f } from 'foo';\nf();`
|
||||
};
|
||||
const languageService = makeLanguageService(testFile);
|
||||
const changes = languageService.organizeImports({ type: "file", fileName: testFile.path }, testFormatSettings, emptyOptions);
|
||||
assert.isEmpty(changes);
|
||||
});
|
||||
|
||||
testOrganizeImports("Unused_All",
|
||||
{
|
||||
path: "/test.ts",
|
||||
@@ -377,14 +398,17 @@ import D from "lib";
|
||||
},
|
||||
libFile);
|
||||
|
||||
testOrganizeImports("Unused_Empty",
|
||||
{
|
||||
it("Unused_Empty", () => {
|
||||
const testFile = {
|
||||
path: "/test.ts",
|
||||
content: `
|
||||
import { } from "lib";
|
||||
`,
|
||||
},
|
||||
libFile);
|
||||
};
|
||||
const languageService = makeLanguageService(testFile);
|
||||
const changes = languageService.organizeImports({ type: "file", fileName: testFile.path }, testFormatSettings, emptyOptions);
|
||||
assert.isEmpty(changes);
|
||||
});
|
||||
|
||||
testOrganizeImports("Unused_false_positive_module_augmentation",
|
||||
{
|
||||
@@ -414,25 +438,33 @@ declare module 'caseless' {
|
||||
test(name: KeyType): boolean;
|
||||
}
|
||||
}`
|
||||
});
|
||||
});
|
||||
|
||||
testOrganizeImports("Unused_false_positive_shorthand_assignment",
|
||||
{
|
||||
it("Unused_false_positive_shorthand_assignment", () => {
|
||||
const testFile = {
|
||||
path: "/test.ts",
|
||||
content: `
|
||||
import { x } from "a";
|
||||
const o = { x };
|
||||
`
|
||||
});
|
||||
};
|
||||
const languageService = makeLanguageService(testFile);
|
||||
const changes = languageService.organizeImports({ type: "file", fileName: testFile.path }, testFormatSettings, emptyOptions);
|
||||
assert.isEmpty(changes);
|
||||
});
|
||||
|
||||
testOrganizeImports("Unused_false_positive_export_shorthand",
|
||||
{
|
||||
it("Unused_false_positive_export_shorthand", () => {
|
||||
const testFile = {
|
||||
path: "/test.ts",
|
||||
content: `
|
||||
import { x } from "a";
|
||||
export { x };
|
||||
`
|
||||
});
|
||||
};
|
||||
const languageService = makeLanguageService(testFile);
|
||||
const changes = languageService.organizeImports({ type: "file", fileName: testFile.path }, testFormatSettings, emptyOptions);
|
||||
assert.isEmpty(changes);
|
||||
});
|
||||
|
||||
testOrganizeImports("MoveToTop",
|
||||
{
|
||||
|
||||
@@ -63,7 +63,7 @@ namespace ts.projectSystem {
|
||||
};
|
||||
const aDts: File = {
|
||||
path: "/a/bin/a.d.ts",
|
||||
// Need to mangle the sourceMappingURL part or it breaks the build
|
||||
// ${""} is needed to mangle the sourceMappingURL part or it breaks the build
|
||||
content: `export declare function fnA(): void;\nexport interface IfaceA {\n}\nexport declare const instanceA: IfaceA;\n//# source${""}MappingURL=a.d.ts.map`,
|
||||
};
|
||||
|
||||
@@ -86,7 +86,7 @@ namespace ts.projectSystem {
|
||||
content: JSON.stringify(bDtsMapContent),
|
||||
};
|
||||
const bDts: File = {
|
||||
// Need to mangle the sourceMappingURL part or it breaks the build
|
||||
// ${""} is need to mangle the sourceMappingURL part so it doesn't break the build
|
||||
path: "/b/bin/b.d.ts",
|
||||
content: `export declare function fnB(): void;\n//# source${""}MappingURL=b.d.ts.map`,
|
||||
};
|
||||
@@ -114,7 +114,7 @@ namespace ts.projectSystem {
|
||||
})
|
||||
};
|
||||
|
||||
function makeSampleProjects(addUserTsConfig?: boolean) {
|
||||
function makeSampleProjects(addUserTsConfig?: boolean, keepAllFiles?: boolean) {
|
||||
const host = createServerHost([aTs, aTsconfig, aDtsMap, aDts, bTsconfig, bTs, bDtsMap, bDts, ...(addUserTsConfig ? [userTsForConfigProject, userTsconfig] : [userTs]), dummyFile]);
|
||||
const session = createSession(host);
|
||||
|
||||
@@ -122,7 +122,9 @@ namespace ts.projectSystem {
|
||||
checkDeclarationFiles(bTs, session, [bDtsMap, bDts]);
|
||||
|
||||
// Testing what happens if we delete the original sources.
|
||||
host.deleteFile(bTs.path);
|
||||
if (!keepAllFiles) {
|
||||
host.deleteFile(bTs.path);
|
||||
}
|
||||
|
||||
openFilesForSession([userTs], session);
|
||||
const service = session.getProjectService();
|
||||
@@ -322,6 +324,64 @@ namespace ts.projectSystem {
|
||||
verifyATsConfigOriginalProject(session);
|
||||
});
|
||||
|
||||
it("navigateToAll -- when neither file nor project is specified", () => {
|
||||
const session = makeSampleProjects(/*addUserTsConfig*/ true, /*keepAllFiles*/ true);
|
||||
const response = executeSessionRequest<protocol.NavtoRequest, protocol.NavtoResponse>(session, CommandNames.Navto, { file: undefined, searchValue: "fn" });
|
||||
assert.deepEqual<readonly protocol.NavtoItem[] | undefined>(response, [
|
||||
{
|
||||
...protocolFileSpanFromSubstring({
|
||||
file: bTs,
|
||||
text: "export function fnB() {}"
|
||||
}),
|
||||
name: "fnB",
|
||||
matchKind: "prefix",
|
||||
isCaseSensitive: true,
|
||||
kind: ScriptElementKind.functionElement,
|
||||
kindModifiers: "export",
|
||||
},
|
||||
{
|
||||
...protocolFileSpanFromSubstring({
|
||||
file: aTs,
|
||||
text: "export function fnA() {}"
|
||||
}),
|
||||
name: "fnA",
|
||||
matchKind: "prefix",
|
||||
isCaseSensitive: true,
|
||||
kind: ScriptElementKind.functionElement,
|
||||
kindModifiers: "export",
|
||||
},
|
||||
{
|
||||
...protocolFileSpanFromSubstring({
|
||||
file: userTs,
|
||||
text: "export function fnUser() { a.fnA(); b.fnB(); a.instanceA; }"
|
||||
}),
|
||||
name: "fnUser",
|
||||
matchKind: "prefix",
|
||||
isCaseSensitive: true,
|
||||
kind: ScriptElementKind.functionElement,
|
||||
kindModifiers: "export",
|
||||
}
|
||||
]);
|
||||
});
|
||||
|
||||
it("navigateToAll -- when file is not specified but project is", () => {
|
||||
const session = makeSampleProjects(/*addUserTsConfig*/ true, /*keepAllFiles*/ true);
|
||||
const response = executeSessionRequest<protocol.NavtoRequest, protocol.NavtoResponse>(session, CommandNames.Navto, { projectFileName: bTsconfig.path, file: undefined, searchValue: "fn" });
|
||||
assert.deepEqual<readonly protocol.NavtoItem[] | undefined>(response, [
|
||||
{
|
||||
...protocolFileSpanFromSubstring({
|
||||
file: bTs,
|
||||
text: "export function fnB() {}"
|
||||
}),
|
||||
name: "fnB",
|
||||
matchKind: "prefix",
|
||||
isCaseSensitive: true,
|
||||
kind: ScriptElementKind.functionElement,
|
||||
kindModifiers: "export",
|
||||
}
|
||||
]);
|
||||
});
|
||||
|
||||
const referenceATs = (aTs: File): protocol.ReferencesResponseItem => makeReferenceItem({
|
||||
file: aTs,
|
||||
isDefinition: true,
|
||||
|
||||
@@ -246,7 +246,9 @@ namespace ts.server.typingsInstaller {
|
||||
const installer = new NodeTypingsInstaller(globalTypingsCacheLocation!, typingSafeListLocation!, typesMapLocation!, npmLocation, validateDefaultNpmLocation, /*throttleLimit*/5, log); // TODO: GH#18217
|
||||
installer.listen();
|
||||
|
||||
function indent(newline: string, str: string): string {
|
||||
return `${newline} ` + str.replace(/\r?\n/, `${newline} `);
|
||||
function indent(newline: string, str: string | undefined): string {
|
||||
return str && str.length
|
||||
? `${newline} ` + str.replace(/\r?\n/, `${newline} `)
|
||||
: "";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration3_es6.ts(1,20): error TS2372: Parameter 'yield' cannot be referenced in its initializer.
|
||||
tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration3_es6.ts(1,20): error TS2372: Parameter 'yield' cannot reference itself.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration3_es6.ts (1 errors) ====
|
||||
function f(yield = yield) {
|
||||
~~~~~
|
||||
!!! error TS2372: Parameter 'yield' cannot be referenced in its initializer.
|
||||
!!! error TS2372: Parameter 'yield' cannot reference itself.
|
||||
}
|
||||
+9
-4
@@ -14,7 +14,7 @@ and limitations under the License.
|
||||
***************************************************************************** */
|
||||
|
||||
declare namespace ts {
|
||||
const versionMajorMinor = "3.9";
|
||||
const versionMajorMinor = "4.0";
|
||||
/** The version of the TypeScript compiler release */
|
||||
const version: string;
|
||||
/**
|
||||
@@ -4460,7 +4460,8 @@ declare namespace ts {
|
||||
* Starts a new lexical environment and visits a parameter list, suspending the lexical
|
||||
* environment upon completion.
|
||||
*/
|
||||
function visitParameterList(nodes: NodeArray<ParameterDeclaration> | undefined, visitor: Visitor, context: TransformationContext, nodesVisitor?: typeof visitNodes): NodeArray<ParameterDeclaration>;
|
||||
function visitParameterList(nodes: NodeArray<ParameterDeclaration>, visitor: Visitor, context: TransformationContext, nodesVisitor?: <T extends Node>(nodes: NodeArray<T>, visitor: Visitor, test?: (node: Node) => boolean, start?: number, count?: number) => NodeArray<T>): NodeArray<ParameterDeclaration>;
|
||||
function visitParameterList(nodes: NodeArray<ParameterDeclaration> | undefined, visitor: Visitor, context: TransformationContext, nodesVisitor?: <T extends Node>(nodes: NodeArray<T> | undefined, visitor: Visitor, test?: (node: Node) => boolean, start?: number, count?: number) => NodeArray<T> | undefined): NodeArray<ParameterDeclaration> | undefined;
|
||||
/**
|
||||
* Resumes a suspended lexical environment and visits a function body, ending the lexical
|
||||
* environment and merging hoisted declarations upon completion.
|
||||
@@ -8319,7 +8320,7 @@ declare namespace ts.server.protocol {
|
||||
/**
|
||||
* Arguments for navto request message.
|
||||
*/
|
||||
interface NavtoRequestArgs extends FileRequestArgs {
|
||||
interface NavtoRequestArgs {
|
||||
/**
|
||||
* Search term to navigate to from current location; term can
|
||||
* be '.*' or an identifier prefix.
|
||||
@@ -8329,6 +8330,10 @@ declare namespace ts.server.protocol {
|
||||
* Optional limit on the number of items to return.
|
||||
*/
|
||||
maxResultCount?: number;
|
||||
/**
|
||||
* The file for the request (absolute pathname required).
|
||||
*/
|
||||
file?: string;
|
||||
/**
|
||||
* Optional flag to indicate we want results for just the current file
|
||||
* or the entire project.
|
||||
@@ -8342,7 +8347,7 @@ declare namespace ts.server.protocol {
|
||||
* match the search term given in argument 'searchTerm'. The
|
||||
* context for the search is given by the named file.
|
||||
*/
|
||||
interface NavtoRequest extends FileRequest {
|
||||
interface NavtoRequest extends Request {
|
||||
command: CommandTypes.Navto;
|
||||
arguments: NavtoRequestArgs;
|
||||
}
|
||||
|
||||
+3
-2
@@ -14,7 +14,7 @@ and limitations under the License.
|
||||
***************************************************************************** */
|
||||
|
||||
declare namespace ts {
|
||||
const versionMajorMinor = "3.9";
|
||||
const versionMajorMinor = "4.0";
|
||||
/** The version of the TypeScript compiler release */
|
||||
const version: string;
|
||||
/**
|
||||
@@ -4460,7 +4460,8 @@ declare namespace ts {
|
||||
* Starts a new lexical environment and visits a parameter list, suspending the lexical
|
||||
* environment upon completion.
|
||||
*/
|
||||
function visitParameterList(nodes: NodeArray<ParameterDeclaration> | undefined, visitor: Visitor, context: TransformationContext, nodesVisitor?: typeof visitNodes): NodeArray<ParameterDeclaration>;
|
||||
function visitParameterList(nodes: NodeArray<ParameterDeclaration>, visitor: Visitor, context: TransformationContext, nodesVisitor?: <T extends Node>(nodes: NodeArray<T>, visitor: Visitor, test?: (node: Node) => boolean, start?: number, count?: number) => NodeArray<T>): NodeArray<ParameterDeclaration>;
|
||||
function visitParameterList(nodes: NodeArray<ParameterDeclaration> | undefined, visitor: Visitor, context: TransformationContext, nodesVisitor?: <T extends Node>(nodes: NodeArray<T> | undefined, visitor: Visitor, test?: (node: Node) => boolean, start?: number, count?: number) => NodeArray<T> | undefined): NodeArray<ParameterDeclaration> | undefined;
|
||||
/**
|
||||
* Resumes a suspended lexical environment and visits a function body, ending the lexical
|
||||
* environment and merging hoisted declarations upon completion.
|
||||
|
||||
@@ -4,9 +4,9 @@ var arr: string[] | number[];
|
||||
|
||||
arr.splice(1, 1);
|
||||
>arr.splice(1, 1) : string[] | number[]
|
||||
>arr.splice : { (start: number, deleteCount: number): string[]; (start: number, deleteCount: number, ...items: string[]): string[]; } | { (start: number, deleteCount: number): number[]; (start: number, deleteCount: number, ...items: number[]): number[]; }
|
||||
>arr.splice : { (start: number, deleteCount?: number): string[]; (start: number, deleteCount: number, ...items: string[]): string[]; } | { (start: number, deleteCount?: number): number[]; (start: number, deleteCount: number, ...items: number[]): number[]; }
|
||||
>arr : string[] | number[]
|
||||
>splice : { (start: number, deleteCount: number): string[]; (start: number, deleteCount: number, ...items: string[]): string[]; } | { (start: number, deleteCount: number): number[]; (start: number, deleteCount: number, ...items: number[]): number[]; }
|
||||
>splice : { (start: number, deleteCount?: number): string[]; (start: number, deleteCount: number, ...items: string[]): string[]; } | { (start: number, deleteCount?: number): number[]; (start: number, deleteCount: number, ...items: number[]): number[]; }
|
||||
>1 : 1
|
||||
>1 : 1
|
||||
|
||||
|
||||
+13
-6
@@ -1,10 +1,11 @@
|
||||
tests/cases/conformance/classes/propertyMemberDeclarations/assignParameterPropertyToPropertyDeclarationESNext.ts(2,16): error TS2729: Property 'bar' is used before its initialization.
|
||||
tests/cases/conformance/classes/propertyMemberDeclarations/assignParameterPropertyToPropertyDeclarationESNext.ts(3,16): error TS2729: Property 'foo' is used before its initialization.
|
||||
tests/cases/conformance/classes/propertyMemberDeclarations/assignParameterPropertyToPropertyDeclarationESNext.ts(9,17): error TS2729: Property 'baz' is used before its initialization.
|
||||
tests/cases/conformance/classes/propertyMemberDeclarations/assignParameterPropertyToPropertyDeclarationESNext.ts(10,16): error TS2729: Property 'foo' is used before its initialization.
|
||||
tests/cases/conformance/classes/propertyMemberDeclarations/assignParameterPropertyToPropertyDeclarationESNext.ts(6,19): error TS2729: Property 'm3' is used before its initialization.
|
||||
tests/cases/conformance/classes/propertyMemberDeclarations/assignParameterPropertyToPropertyDeclarationESNext.ts(12,17): error TS2729: Property 'baz' is used before its initialization.
|
||||
tests/cases/conformance/classes/propertyMemberDeclarations/assignParameterPropertyToPropertyDeclarationESNext.ts(13,16): error TS2729: Property 'foo' is used before its initialization.
|
||||
|
||||
|
||||
==== tests/cases/conformance/classes/propertyMemberDeclarations/assignParameterPropertyToPropertyDeclarationESNext.ts (4 errors) ====
|
||||
==== tests/cases/conformance/classes/propertyMemberDeclarations/assignParameterPropertyToPropertyDeclarationESNext.ts (5 errors) ====
|
||||
class C {
|
||||
qux = this.bar // should error
|
||||
~~~
|
||||
@@ -13,20 +14,26 @@ tests/cases/conformance/classes/propertyMemberDeclarations/assignParameterProper
|
||||
bar = this.foo // should error
|
||||
~~~
|
||||
!!! error TS2729: Property 'foo' is used before its initialization.
|
||||
!!! related TS2728 tests/cases/conformance/classes/propertyMemberDeclarations/assignParameterPropertyToPropertyDeclarationESNext.ts:8:17: 'foo' is declared here.
|
||||
!!! related TS2728 tests/cases/conformance/classes/propertyMemberDeclarations/assignParameterPropertyToPropertyDeclarationESNext.ts:11:17: 'foo' is declared here.
|
||||
quiz = this.bar // ok
|
||||
quench = this.m1() // ok
|
||||
quanch = this.m3() // should error
|
||||
~~
|
||||
!!! error TS2729: Property 'm3' is used before its initialization.
|
||||
!!! related TS2728 tests/cases/conformance/classes/propertyMemberDeclarations/assignParameterPropertyToPropertyDeclarationESNext.ts:10:5: 'm3' is declared here.
|
||||
m1() {
|
||||
this.foo // ok
|
||||
}
|
||||
m3 = function() { }
|
||||
constructor(public foo: string) {}
|
||||
quim = this.baz // should error
|
||||
~~~
|
||||
!!! error TS2729: Property 'baz' is used before its initialization.
|
||||
!!! related TS2728 tests/cases/conformance/classes/propertyMemberDeclarations/assignParameterPropertyToPropertyDeclarationESNext.ts:10:5: 'baz' is declared here.
|
||||
!!! related TS2728 tests/cases/conformance/classes/propertyMemberDeclarations/assignParameterPropertyToPropertyDeclarationESNext.ts:13:5: 'baz' is declared here.
|
||||
baz = this.foo; // should error
|
||||
~~~
|
||||
!!! error TS2729: Property 'foo' is used before its initialization.
|
||||
!!! related TS2728 tests/cases/conformance/classes/propertyMemberDeclarations/assignParameterPropertyToPropertyDeclarationESNext.ts:8:17: 'foo' is declared here.
|
||||
!!! related TS2728 tests/cases/conformance/classes/propertyMemberDeclarations/assignParameterPropertyToPropertyDeclarationESNext.ts:11:17: 'foo' is declared here.
|
||||
quid = this.baz // ok
|
||||
m2() {
|
||||
this.foo // ok
|
||||
|
||||
@@ -3,9 +3,12 @@ class C {
|
||||
qux = this.bar // should error
|
||||
bar = this.foo // should error
|
||||
quiz = this.bar // ok
|
||||
quench = this.m1() // ok
|
||||
quanch = this.m3() // should error
|
||||
m1() {
|
||||
this.foo // ok
|
||||
}
|
||||
m3 = function() { }
|
||||
constructor(public foo: string) {}
|
||||
quim = this.baz // should error
|
||||
baz = this.foo; // should error
|
||||
@@ -45,9 +48,12 @@ class C {
|
||||
qux = this.bar; // should error
|
||||
bar = this.foo; // should error
|
||||
quiz = this.bar; // ok
|
||||
quench = this.m1(); // ok
|
||||
quanch = this.m3(); // should error
|
||||
m1() {
|
||||
this.foo; // ok
|
||||
}
|
||||
m3 = function () { };
|
||||
constructor(foo) {
|
||||
this.foo = foo;
|
||||
}
|
||||
|
||||
+64
-49
@@ -10,9 +10,9 @@ class C {
|
||||
|
||||
bar = this.foo // should error
|
||||
>bar : Symbol(C.bar, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 1, 18))
|
||||
>this.foo : Symbol(C.foo, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 7, 16))
|
||||
>this.foo : Symbol(C.foo, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 10, 16))
|
||||
>this : Symbol(C, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 0, 0))
|
||||
>foo : Symbol(C.foo, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 7, 16))
|
||||
>foo : Symbol(C.foo, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 10, 16))
|
||||
|
||||
quiz = this.bar // ok
|
||||
>quiz : Symbol(C.quiz, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 2, 18))
|
||||
@@ -20,105 +20,120 @@ class C {
|
||||
>this : Symbol(C, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 0, 0))
|
||||
>bar : Symbol(C.bar, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 1, 18))
|
||||
|
||||
quench = this.m1() // ok
|
||||
>quench : Symbol(C.quench, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 3, 19))
|
||||
>this.m1 : Symbol(C.m1, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 5, 22))
|
||||
>this : Symbol(C, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 0, 0))
|
||||
>m1 : Symbol(C.m1, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 5, 22))
|
||||
|
||||
quanch = this.m3() // should error
|
||||
>quanch : Symbol(C.quanch, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 4, 22))
|
||||
>this.m3 : Symbol(C.m3, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 8, 5))
|
||||
>this : Symbol(C, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 0, 0))
|
||||
>m3 : Symbol(C.m3, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 8, 5))
|
||||
|
||||
m1() {
|
||||
>m1 : Symbol(C.m1, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 3, 19))
|
||||
>m1 : Symbol(C.m1, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 5, 22))
|
||||
|
||||
this.foo // ok
|
||||
>this.foo : Symbol(C.foo, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 7, 16))
|
||||
>this.foo : Symbol(C.foo, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 10, 16))
|
||||
>this : Symbol(C, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 0, 0))
|
||||
>foo : Symbol(C.foo, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 7, 16))
|
||||
>foo : Symbol(C.foo, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 10, 16))
|
||||
}
|
||||
m3 = function() { }
|
||||
>m3 : Symbol(C.m3, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 8, 5))
|
||||
|
||||
constructor(public foo: string) {}
|
||||
>foo : Symbol(C.foo, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 7, 16))
|
||||
>foo : Symbol(C.foo, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 10, 16))
|
||||
|
||||
quim = this.baz // should error
|
||||
>quim : Symbol(C.quim, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 7, 38))
|
||||
>this.baz : Symbol(C.baz, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 8, 19))
|
||||
>quim : Symbol(C.quim, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 10, 38))
|
||||
>this.baz : Symbol(C.baz, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 11, 19))
|
||||
>this : Symbol(C, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 0, 0))
|
||||
>baz : Symbol(C.baz, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 8, 19))
|
||||
>baz : Symbol(C.baz, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 11, 19))
|
||||
|
||||
baz = this.foo; // should error
|
||||
>baz : Symbol(C.baz, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 8, 19))
|
||||
>this.foo : Symbol(C.foo, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 7, 16))
|
||||
>baz : Symbol(C.baz, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 11, 19))
|
||||
>this.foo : Symbol(C.foo, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 10, 16))
|
||||
>this : Symbol(C, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 0, 0))
|
||||
>foo : Symbol(C.foo, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 7, 16))
|
||||
>foo : Symbol(C.foo, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 10, 16))
|
||||
|
||||
quid = this.baz // ok
|
||||
>quid : Symbol(C.quid, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 9, 19))
|
||||
>this.baz : Symbol(C.baz, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 8, 19))
|
||||
>quid : Symbol(C.quid, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 12, 19))
|
||||
>this.baz : Symbol(C.baz, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 11, 19))
|
||||
>this : Symbol(C, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 0, 0))
|
||||
>baz : Symbol(C.baz, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 8, 19))
|
||||
>baz : Symbol(C.baz, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 11, 19))
|
||||
|
||||
m2() {
|
||||
>m2 : Symbol(C.m2, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 10, 19))
|
||||
>m2 : Symbol(C.m2, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 13, 19))
|
||||
|
||||
this.foo // ok
|
||||
>this.foo : Symbol(C.foo, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 7, 16))
|
||||
>this.foo : Symbol(C.foo, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 10, 16))
|
||||
>this : Symbol(C, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 0, 0))
|
||||
>foo : Symbol(C.foo, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 7, 16))
|
||||
>foo : Symbol(C.foo, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 10, 16))
|
||||
}
|
||||
}
|
||||
|
||||
class D extends C {
|
||||
>D : Symbol(D, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 14, 1))
|
||||
>D : Symbol(D, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 17, 1))
|
||||
>C : Symbol(C, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 0, 0))
|
||||
|
||||
quill = this.foo // ok
|
||||
>quill : Symbol(D.quill, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 16, 19))
|
||||
>this.foo : Symbol(C.foo, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 7, 16))
|
||||
>this : Symbol(D, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 14, 1))
|
||||
>foo : Symbol(C.foo, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 7, 16))
|
||||
>quill : Symbol(D.quill, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 19, 19))
|
||||
>this.foo : Symbol(C.foo, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 10, 16))
|
||||
>this : Symbol(D, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 17, 1))
|
||||
>foo : Symbol(C.foo, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 10, 16))
|
||||
}
|
||||
|
||||
class E {
|
||||
>E : Symbol(E, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 18, 1))
|
||||
>E : Symbol(E, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 21, 1))
|
||||
|
||||
bar = () => this.foo1 + this.foo2; // both ok
|
||||
>bar : Symbol(E.bar, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 20, 9))
|
||||
>this.foo1 : Symbol(E.foo1, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 21, 38))
|
||||
>this : Symbol(E, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 18, 1))
|
||||
>foo1 : Symbol(E.foo1, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 21, 38))
|
||||
>this.foo2 : Symbol(E.foo2, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 23, 16))
|
||||
>this : Symbol(E, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 18, 1))
|
||||
>foo2 : Symbol(E.foo2, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 23, 16))
|
||||
>bar : Symbol(E.bar, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 23, 9))
|
||||
>this.foo1 : Symbol(E.foo1, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 24, 38))
|
||||
>this : Symbol(E, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 21, 1))
|
||||
>foo1 : Symbol(E.foo1, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 24, 38))
|
||||
>this.foo2 : Symbol(E.foo2, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 26, 16))
|
||||
>this : Symbol(E, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 21, 1))
|
||||
>foo2 : Symbol(E.foo2, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 26, 16))
|
||||
|
||||
foo1 = '';
|
||||
>foo1 : Symbol(E.foo1, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 21, 38))
|
||||
>foo1 : Symbol(E.foo1, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 24, 38))
|
||||
|
||||
constructor(public foo2: string) {}
|
||||
>foo2 : Symbol(E.foo2, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 23, 16))
|
||||
>foo2 : Symbol(E.foo2, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 26, 16))
|
||||
}
|
||||
|
||||
class F {
|
||||
>F : Symbol(F, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 24, 1))
|
||||
>F : Symbol(F, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 27, 1))
|
||||
|
||||
Inner = class extends F {
|
||||
>Inner : Symbol(F.Inner, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 26, 9))
|
||||
>F : Symbol(F, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 24, 1))
|
||||
>Inner : Symbol(F.Inner, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 29, 9))
|
||||
>F : Symbol(F, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 27, 1))
|
||||
|
||||
p2 = this.p1
|
||||
>p2 : Symbol((Anonymous class).p2, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 27, 29))
|
||||
>this.p1 : Symbol(F.p1, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 29, 5))
|
||||
>this : Symbol((Anonymous class), Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 27, 11))
|
||||
>p1 : Symbol(F.p1, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 29, 5))
|
||||
>p2 : Symbol((Anonymous class).p2, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 30, 29))
|
||||
>this.p1 : Symbol(F.p1, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 32, 5))
|
||||
>this : Symbol((Anonymous class), Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 30, 11))
|
||||
>p1 : Symbol(F.p1, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 32, 5))
|
||||
}
|
||||
p1 = 0
|
||||
>p1 : Symbol(F.p1, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 29, 5))
|
||||
>p1 : Symbol(F.p1, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 32, 5))
|
||||
}
|
||||
class G {
|
||||
>G : Symbol(G, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 31, 1))
|
||||
>G : Symbol(G, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 34, 1))
|
||||
|
||||
Inner = class extends G {
|
||||
>Inner : Symbol(G.Inner, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 32, 9))
|
||||
>G : Symbol(G, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 31, 1))
|
||||
>Inner : Symbol(G.Inner, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 35, 9))
|
||||
>G : Symbol(G, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 34, 1))
|
||||
|
||||
p2 = this.p1
|
||||
>p2 : Symbol((Anonymous class).p2, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 33, 29))
|
||||
>this.p1 : Symbol(G.p1, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 36, 16))
|
||||
>this : Symbol((Anonymous class), Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 33, 11))
|
||||
>p1 : Symbol(G.p1, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 36, 16))
|
||||
>p2 : Symbol((Anonymous class).p2, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 36, 29))
|
||||
>this.p1 : Symbol(G.p1, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 39, 16))
|
||||
>this : Symbol((Anonymous class), Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 36, 11))
|
||||
>p1 : Symbol(G.p1, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 39, 16))
|
||||
}
|
||||
constructor(public p1: number) {}
|
||||
>p1 : Symbol(G.p1, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 36, 16))
|
||||
>p1 : Symbol(G.p1, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 39, 16))
|
||||
}
|
||||
|
||||
|
||||
@@ -20,6 +20,20 @@ class C {
|
||||
>this : this
|
||||
>bar : string
|
||||
|
||||
quench = this.m1() // ok
|
||||
>quench : void
|
||||
>this.m1() : void
|
||||
>this.m1 : () => void
|
||||
>this : this
|
||||
>m1 : () => void
|
||||
|
||||
quanch = this.m3() // should error
|
||||
>quanch : void
|
||||
>this.m3() : void
|
||||
>this.m3 : () => void
|
||||
>this : this
|
||||
>m3 : () => void
|
||||
|
||||
m1() {
|
||||
>m1 : () => void
|
||||
|
||||
@@ -28,6 +42,10 @@ class C {
|
||||
>this : this
|
||||
>foo : string
|
||||
}
|
||||
m3 = function() { }
|
||||
>m3 : () => void
|
||||
>function() { } : () => void
|
||||
|
||||
constructor(public foo: string) {}
|
||||
>foo : string
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction3_es2017.ts(1,20): error TS2372: Parameter 'await' cannot be referenced in its initializer.
|
||||
tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction3_es2017.ts(1,20): error TS2372: Parameter 'await' cannot reference itself.
|
||||
|
||||
|
||||
==== tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction3_es2017.ts (1 errors) ====
|
||||
function f(await = await) {
|
||||
~~~~~
|
||||
!!! error TS2372: Parameter 'await' cannot be referenced in its initializer.
|
||||
!!! error TS2372: Parameter 'await' cannot reference itself.
|
||||
}
|
||||
@@ -1,8 +1,8 @@
|
||||
tests/cases/conformance/async/es5/asyncArrowFunction/asyncArrowFunction3_es5.ts(1,20): error TS2372: Parameter 'await' cannot be referenced in its initializer.
|
||||
tests/cases/conformance/async/es5/asyncArrowFunction/asyncArrowFunction3_es5.ts(1,20): error TS2372: Parameter 'await' cannot reference itself.
|
||||
|
||||
|
||||
==== tests/cases/conformance/async/es5/asyncArrowFunction/asyncArrowFunction3_es5.ts (1 errors) ====
|
||||
function f(await = await) {
|
||||
~~~~~
|
||||
!!! error TS2372: Parameter 'await' cannot be referenced in its initializer.
|
||||
!!! error TS2372: Parameter 'await' cannot reference itself.
|
||||
}
|
||||
@@ -1,8 +1,8 @@
|
||||
tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction3_es6.ts(1,20): error TS2372: Parameter 'await' cannot be referenced in its initializer.
|
||||
tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction3_es6.ts(1,20): error TS2372: Parameter 'await' cannot reference itself.
|
||||
|
||||
|
||||
==== tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction3_es6.ts (1 errors) ====
|
||||
function f(await = await) {
|
||||
~~~~~
|
||||
!!! error TS2372: Parameter 'await' cannot be referenced in its initializer.
|
||||
!!! error TS2372: Parameter 'await' cannot reference itself.
|
||||
}
|
||||
@@ -1,8 +1,8 @@
|
||||
tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration3_es2017.ts(1,20): error TS2372: Parameter 'await' cannot be referenced in its initializer.
|
||||
tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration3_es2017.ts(1,20): error TS2372: Parameter 'await' cannot reference itself.
|
||||
|
||||
|
||||
==== tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration3_es2017.ts (1 errors) ====
|
||||
function f(await = await) {
|
||||
~~~~~
|
||||
!!! error TS2372: Parameter 'await' cannot be referenced in its initializer.
|
||||
!!! error TS2372: Parameter 'await' cannot reference itself.
|
||||
}
|
||||
@@ -1,8 +1,8 @@
|
||||
tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclaration3_es5.ts(1,20): error TS2372: Parameter 'await' cannot be referenced in its initializer.
|
||||
tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclaration3_es5.ts(1,20): error TS2372: Parameter 'await' cannot reference itself.
|
||||
|
||||
|
||||
==== tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclaration3_es5.ts (1 errors) ====
|
||||
function f(await = await) {
|
||||
~~~~~
|
||||
!!! error TS2372: Parameter 'await' cannot be referenced in its initializer.
|
||||
!!! error TS2372: Parameter 'await' cannot reference itself.
|
||||
}
|
||||
@@ -1,8 +1,8 @@
|
||||
tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration3_es6.ts(1,20): error TS2372: Parameter 'await' cannot be referenced in its initializer.
|
||||
tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration3_es6.ts(1,20): error TS2372: Parameter 'await' cannot reference itself.
|
||||
|
||||
|
||||
==== tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration3_es6.ts (1 errors) ====
|
||||
function f(await = await) {
|
||||
~~~~~
|
||||
!!! error TS2372: Parameter 'await' cannot be referenced in its initializer.
|
||||
!!! error TS2372: Parameter 'await' cannot reference itself.
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
tests/cases/compiler/capturedParametersInInitializers1.ts(18,20): error TS2373: Initializer of parameter 'y' cannot reference identifier 'z' declared after it.
|
||||
tests/cases/compiler/capturedParametersInInitializers1.ts(22,26): error TS2373: Initializer of parameter 'y' cannot reference identifier 'z' declared after it.
|
||||
tests/cases/compiler/capturedParametersInInitializers1.ts(38,21): error TS2373: Initializer of parameter 'y' cannot reference identifier 'z' declared after it.
|
||||
tests/cases/compiler/capturedParametersInInitializers1.ts(18,20): error TS2373: Parameter 'y' cannot reference identifier 'z' declared after it.
|
||||
tests/cases/compiler/capturedParametersInInitializers1.ts(22,26): error TS2373: Parameter 'y' cannot reference identifier 'z' declared after it.
|
||||
tests/cases/compiler/capturedParametersInInitializers1.ts(38,21): error TS2373: Parameter 'y' cannot reference identifier 'z' declared after it.
|
||||
|
||||
|
||||
==== tests/cases/compiler/capturedParametersInInitializers1.ts (3 errors) ====
|
||||
@@ -23,13 +23,13 @@ tests/cases/compiler/capturedParametersInInitializers1.ts(38,21): error TS2373:
|
||||
// error - used before declaration
|
||||
function foo4(y = {z}, z = 1) {
|
||||
~
|
||||
!!! error TS2373: Initializer of parameter 'y' cannot reference identifier 'z' declared after it.
|
||||
!!! error TS2373: Parameter 'y' cannot reference identifier 'z' declared after it.
|
||||
}
|
||||
|
||||
// error - used before declaration, IIFEs are inlined
|
||||
function foo5(y = (() => z)(), z = 1) {
|
||||
~
|
||||
!!! error TS2373: Initializer of parameter 'y' cannot reference identifier 'z' declared after it.
|
||||
!!! error TS2373: Parameter 'y' cannot reference identifier 'z' declared after it.
|
||||
}
|
||||
|
||||
// ok - IIFE inside another function
|
||||
@@ -47,6 +47,6 @@ tests/cases/compiler/capturedParametersInInitializers1.ts(38,21): error TS2373:
|
||||
// error - used as computed name of method
|
||||
function foo9(y = {[z]() { return z; }}, z = 1) {
|
||||
~
|
||||
!!! error TS2373: Initializer of parameter 'y' cannot reference identifier 'z' declared after it.
|
||||
!!! error TS2373: Parameter 'y' cannot reference identifier 'z' declared after it.
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
tests/cases/compiler/capturedParametersInInitializers2.ts(3,20): error TS2373: Initializer of parameter 'y' cannot reference identifier 'x' declared after it.
|
||||
tests/cases/compiler/capturedParametersInInitializers2.ts(4,14): error TS2373: Initializer of parameter 'y' cannot reference identifier 'x' declared after it.
|
||||
tests/cases/compiler/capturedParametersInInitializers2.ts(6,10): error TS2373: Initializer of parameter 'y' cannot reference identifier 'z' declared after it.
|
||||
tests/cases/compiler/capturedParametersInInitializers2.ts(3,20): error TS2373: Parameter 'y' cannot reference identifier 'x' declared after it.
|
||||
tests/cases/compiler/capturedParametersInInitializers2.ts(4,14): error TS2373: Parameter 'y' cannot reference identifier 'x' declared after it.
|
||||
tests/cases/compiler/capturedParametersInInitializers2.ts(6,10): error TS2373: Parameter 'y' cannot reference identifier 'z' declared after it.
|
||||
tests/cases/compiler/capturedParametersInInitializers2.ts(13,26): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type.
|
||||
tests/cases/compiler/capturedParametersInInitializers2.ts(13,27): error TS2373: Initializer of parameter 'y' cannot reference identifier 'x' declared after it.
|
||||
tests/cases/compiler/capturedParametersInInitializers2.ts(13,27): error TS2373: Parameter 'y' cannot reference identifier 'x' declared after it.
|
||||
|
||||
|
||||
==== tests/cases/compiler/capturedParametersInInitializers2.ts (5 errors) ====
|
||||
@@ -10,14 +10,14 @@ tests/cases/compiler/capturedParametersInInitializers2.ts(13,27): error TS2373:
|
||||
y = class {
|
||||
static c = x;
|
||||
~
|
||||
!!! error TS2373: Initializer of parameter 'y' cannot reference identifier 'x' declared after it.
|
||||
!!! error TS2373: Parameter 'y' cannot reference identifier 'x' declared after it.
|
||||
get [x]() {return x;}
|
||||
~
|
||||
!!! error TS2373: Initializer of parameter 'y' cannot reference identifier 'x' declared after it.
|
||||
!!! error TS2373: Parameter 'y' cannot reference identifier 'x' declared after it.
|
||||
constructor() { x; }
|
||||
[z]() { return z; }
|
||||
~
|
||||
!!! error TS2373: Initializer of parameter 'y' cannot reference identifier 'z' declared after it.
|
||||
!!! error TS2373: Parameter 'y' cannot reference identifier 'z' declared after it.
|
||||
},
|
||||
x = 1,
|
||||
z = 2
|
||||
@@ -28,5 +28,5 @@ tests/cases/compiler/capturedParametersInInitializers2.ts(13,27): error TS2373:
|
||||
~~~
|
||||
!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type.
|
||||
~
|
||||
!!! error TS2373: Initializer of parameter 'y' cannot reference identifier 'x' declared after it.
|
||||
!!! error TS2373: Parameter 'y' cannot reference identifier 'x' declared after it.
|
||||
}
|
||||
@@ -16,6 +16,7 @@ function foo2(y = class {[x] = x}, x = 1) {
|
||||
|
||||
//// [capturedParametersInInitializers2.js]
|
||||
function foo(y, x, z) {
|
||||
var _a;
|
||||
if (y === void 0) { y = (_a = /** @class */ (function () {
|
||||
function class_1() {
|
||||
x;
|
||||
@@ -32,10 +33,10 @@ function foo(y, x, z) {
|
||||
_a); }
|
||||
if (x === void 0) { x = 1; }
|
||||
if (z === void 0) { z = 2; }
|
||||
var _a;
|
||||
y.c;
|
||||
}
|
||||
function foo2(y, x) {
|
||||
var _a, _b;
|
||||
if (y === void 0) { y = (_b = /** @class */ (function () {
|
||||
function class_2() {
|
||||
this[_a] = x;
|
||||
@@ -45,5 +46,4 @@ function foo2(y, x) {
|
||||
_a = x,
|
||||
_b); }
|
||||
if (x === void 0) { x = 1; }
|
||||
var _a, _b;
|
||||
}
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
tests/cases/compiler/circularOptionalityRemoval.ts(2,14): error TS2502: 'x' is referenced directly or indirectly in its own type annotation.
|
||||
tests/cases/compiler/circularOptionalityRemoval.ts(2,38): error TS2372: Parameter 'x' cannot be referenced in its initializer.
|
||||
tests/cases/compiler/circularOptionalityRemoval.ts(2,38): error TS2372: Parameter 'x' cannot reference itself.
|
||||
tests/cases/compiler/circularOptionalityRemoval.ts(2,38): error TS2532: Object is possibly 'undefined'.
|
||||
tests/cases/compiler/circularOptionalityRemoval.ts(2,46): error TS2372: Parameter 'x' cannot be referenced in its initializer.
|
||||
tests/cases/compiler/circularOptionalityRemoval.ts(2,46): error TS2372: Parameter 'x' cannot reference itself.
|
||||
tests/cases/compiler/circularOptionalityRemoval.ts(5,14): error TS1015: Parameter cannot have question mark and initializer.
|
||||
tests/cases/compiler/circularOptionalityRemoval.ts(5,14): error TS2502: 'x' is referenced directly or indirectly in its own type annotation.
|
||||
tests/cases/compiler/circularOptionalityRemoval.ts(5,27): error TS2304: Cannot find name 'someCondition'.
|
||||
tests/cases/compiler/circularOptionalityRemoval.ts(5,54): error TS2372: Parameter 'x' cannot be referenced in its initializer.
|
||||
tests/cases/compiler/circularOptionalityRemoval.ts(5,54): error TS2372: Parameter 'x' cannot reference itself.
|
||||
|
||||
|
||||
==== tests/cases/compiler/circularOptionalityRemoval.ts (8 errors) ====
|
||||
@@ -14,11 +14,11 @@ tests/cases/compiler/circularOptionalityRemoval.ts(5,54): error TS2372: Paramete
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2502: 'x' is referenced directly or indirectly in its own type annotation.
|
||||
~
|
||||
!!! error TS2372: Parameter 'x' cannot be referenced in its initializer.
|
||||
!!! error TS2372: Parameter 'x' cannot reference itself.
|
||||
~
|
||||
!!! error TS2532: Object is possibly 'undefined'.
|
||||
~
|
||||
!!! error TS2372: Parameter 'x' cannot be referenced in its initializer.
|
||||
!!! error TS2372: Parameter 'x' cannot reference itself.
|
||||
|
||||
// Report from user
|
||||
function fn2(x?: string = someCondition ? 'value1' : x) { }
|
||||
@@ -29,4 +29,4 @@ tests/cases/compiler/circularOptionalityRemoval.ts(5,54): error TS2372: Paramete
|
||||
~~~~~~~~~~~~~
|
||||
!!! error TS2304: Cannot find name 'someCondition'.
|
||||
~
|
||||
!!! error TS2372: Parameter 'x' cannot be referenced in its initializer.
|
||||
!!! error TS2372: Parameter 'x' cannot reference itself.
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
//// [classWithStaticFieldInParameterBindingPattern.ts]
|
||||
// https://github.com/microsoft/TypeScript/issues/36295
|
||||
(({ [class { static x = 1 }.x]: b = "" }) => {})();
|
||||
|
||||
//// [classWithStaticFieldInParameterBindingPattern.js]
|
||||
// https://github.com/microsoft/TypeScript/issues/36295
|
||||
((_a) => { var _b; var { [(_b = class {
|
||||
},
|
||||
_b.x = 1,
|
||||
_b).x]: b = "" } = _a; })();
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
//// [classWithStaticFieldInParameterBindingPattern.ts]
|
||||
// https://github.com/microsoft/TypeScript/issues/36295
|
||||
(({ [class { static x = 1 }.x]: b = "" }) => {})();
|
||||
|
||||
//// [classWithStaticFieldInParameterBindingPattern.js]
|
||||
// https://github.com/microsoft/TypeScript/issues/36295
|
||||
(function (_a) {
|
||||
var _b;
|
||||
var _c = (_b = /** @class */ (function () {
|
||||
function class_1() {
|
||||
}
|
||||
return class_1;
|
||||
}()),
|
||||
_b.x = 1,
|
||||
_b).x, _d = _a[_c], b = _d === void 0 ? "" : _d;
|
||||
})();
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
//// [classWithStaticFieldInParameterBindingPattern.ts]
|
||||
// https://github.com/microsoft/TypeScript/issues/36295
|
||||
(({ [class { static x = 1 }.x]: b = "" }) => {})();
|
||||
|
||||
//// [classWithStaticFieldInParameterBindingPattern.js]
|
||||
// https://github.com/microsoft/TypeScript/issues/36295
|
||||
((_a) => { var _b; var { [(_b = class {
|
||||
},
|
||||
_b.x = 1,
|
||||
_b).x]: b = "" } = _a; })();
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
tests/cases/conformance/classes/classExpressions/classWithStaticFieldInParameterBindingPattern.2.ts(3,20): error TS2373: Parameter '{ [class extends C { static x = 1 }.x]: b = "" }' cannot reference identifier 'C' declared after it.
|
||||
tests/cases/conformance/classes/classExpressions/classWithStaticFieldInParameterBindingPattern.2.ts(6,57): error TS2373: Parameter 'd' cannot reference identifier 'x' declared after it.
|
||||
|
||||
|
||||
==== tests/cases/conformance/classes/classExpressions/classWithStaticFieldInParameterBindingPattern.2.ts (2 errors) ====
|
||||
// https://github.com/microsoft/TypeScript/issues/36295
|
||||
class C {}
|
||||
(({ [class extends C { static x = 1 }.x]: b = "" }) => { var C; })();
|
||||
~
|
||||
!!! error TS2373: Parameter '{ [class extends C { static x = 1 }.x]: b = "" }' cannot reference identifier 'C' declared after it.
|
||||
|
||||
const x = "";
|
||||
(({ [class extends C { static x = 1 }.x]: b = "" }, d = x) => { var x; })();
|
||||
~
|
||||
!!! error TS2373: Parameter 'd' cannot reference identifier 'x' declared after it.
|
||||
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
tests/cases/conformance/classes/classExpressions/classWithStaticFieldInParameterBindingPattern.2.ts(3,20): error TS2373: Parameter '{ [class extends C { static x = 1 }.x]: b = "" }' cannot reference identifier 'C' declared after it.
|
||||
tests/cases/conformance/classes/classExpressions/classWithStaticFieldInParameterBindingPattern.2.ts(6,57): error TS2373: Parameter 'd' cannot reference identifier 'x' declared after it.
|
||||
|
||||
|
||||
==== tests/cases/conformance/classes/classExpressions/classWithStaticFieldInParameterBindingPattern.2.ts (2 errors) ====
|
||||
// https://github.com/microsoft/TypeScript/issues/36295
|
||||
class C {}
|
||||
(({ [class extends C { static x = 1 }.x]: b = "" }) => { var C; })();
|
||||
~
|
||||
!!! error TS2373: Parameter '{ [class extends C { static x = 1 }.x]: b = "" }' cannot reference identifier 'C' declared after it.
|
||||
|
||||
const x = "";
|
||||
(({ [class extends C { static x = 1 }.x]: b = "" }, d = x) => { var x; })();
|
||||
~
|
||||
!!! error TS2373: Parameter 'd' cannot reference identifier 'x' declared after it.
|
||||
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
tests/cases/conformance/classes/classExpressions/classWithStaticFieldInParameterBindingPattern.2.ts(3,20): error TS2373: Parameter '{ [class extends C { static x = 1 }.x]: b = "" }' cannot reference identifier 'C' declared after it.
|
||||
tests/cases/conformance/classes/classExpressions/classWithStaticFieldInParameterBindingPattern.2.ts(6,57): error TS2373: Parameter 'd' cannot reference identifier 'x' declared after it.
|
||||
|
||||
|
||||
==== tests/cases/conformance/classes/classExpressions/classWithStaticFieldInParameterBindingPattern.2.ts (2 errors) ====
|
||||
// https://github.com/microsoft/TypeScript/issues/36295
|
||||
class C {}
|
||||
(({ [class extends C { static x = 1 }.x]: b = "" }) => { var C; })();
|
||||
~
|
||||
!!! error TS2373: Parameter '{ [class extends C { static x = 1 }.x]: b = "" }' cannot reference identifier 'C' declared after it.
|
||||
|
||||
const x = "";
|
||||
(({ [class extends C { static x = 1 }.x]: b = "" }, d = x) => { var x; })();
|
||||
~
|
||||
!!! error TS2373: Parameter 'd' cannot reference identifier 'x' declared after it.
|
||||
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
//// [classWithStaticFieldInParameterInitializer.ts]
|
||||
// https://github.com/microsoft/TypeScript/issues/36295
|
||||
((b = class { static x = 1 }) => {})();
|
||||
|
||||
//// [classWithStaticFieldInParameterInitializer.js]
|
||||
// https://github.com/microsoft/TypeScript/issues/36295
|
||||
((b) => { var _a; if (b === void 0) { b = (_a = class {
|
||||
},
|
||||
_a.x = 1,
|
||||
_a); } })();
|
||||
@@ -0,0 +1,16 @@
|
||||
//// [classWithStaticFieldInParameterInitializer.ts]
|
||||
// https://github.com/microsoft/TypeScript/issues/36295
|
||||
((b = class { static x = 1 }) => {})();
|
||||
|
||||
//// [classWithStaticFieldInParameterInitializer.js]
|
||||
// https://github.com/microsoft/TypeScript/issues/36295
|
||||
(function (b) {
|
||||
var _a;
|
||||
if (b === void 0) { b = (_a = /** @class */ (function () {
|
||||
function class_1() {
|
||||
}
|
||||
return class_1;
|
||||
}()),
|
||||
_a.x = 1,
|
||||
_a); }
|
||||
})();
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
//// [classWithStaticFieldInParameterInitializer.ts]
|
||||
// https://github.com/microsoft/TypeScript/issues/36295
|
||||
((b = class { static x = 1 }) => {})();
|
||||
|
||||
//// [classWithStaticFieldInParameterInitializer.js]
|
||||
// https://github.com/microsoft/TypeScript/issues/36295
|
||||
((b) => { var _a; if (b === void 0) { b = (_a = class {
|
||||
},
|
||||
_a.x = 1,
|
||||
_a); } })();
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
tests/cases/conformance/classes/classExpressions/classWithStaticFieldInParameterInitializer.2.ts(3,21): error TS2373: Parameter 'b' cannot reference identifier 'C' declared after it.
|
||||
tests/cases/conformance/classes/classExpressions/classWithStaticFieldInParameterInitializer.2.ts(6,45): error TS2373: Parameter 'd' cannot reference identifier 'x' declared after it.
|
||||
|
||||
|
||||
==== tests/cases/conformance/classes/classExpressions/classWithStaticFieldInParameterInitializer.2.ts (2 errors) ====
|
||||
// https://github.com/microsoft/TypeScript/issues/36295
|
||||
class C {}
|
||||
((b = class extends C { static x = 1 }) => { var C; })();
|
||||
~
|
||||
!!! error TS2373: Parameter 'b' cannot reference identifier 'C' declared after it.
|
||||
|
||||
const x = "";
|
||||
((b = class extends C { static x = 1 }, d = x) => { var x; })();
|
||||
~
|
||||
!!! error TS2373: Parameter 'd' cannot reference identifier 'x' declared after it.
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
tests/cases/conformance/classes/classExpressions/classWithStaticFieldInParameterInitializer.2.ts(3,21): error TS2373: Parameter 'b' cannot reference identifier 'C' declared after it.
|
||||
tests/cases/conformance/classes/classExpressions/classWithStaticFieldInParameterInitializer.2.ts(6,45): error TS2373: Parameter 'd' cannot reference identifier 'x' declared after it.
|
||||
|
||||
|
||||
==== tests/cases/conformance/classes/classExpressions/classWithStaticFieldInParameterInitializer.2.ts (2 errors) ====
|
||||
// https://github.com/microsoft/TypeScript/issues/36295
|
||||
class C {}
|
||||
((b = class extends C { static x = 1 }) => { var C; })();
|
||||
~
|
||||
!!! error TS2373: Parameter 'b' cannot reference identifier 'C' declared after it.
|
||||
|
||||
const x = "";
|
||||
((b = class extends C { static x = 1 }, d = x) => { var x; })();
|
||||
~
|
||||
!!! error TS2373: Parameter 'd' cannot reference identifier 'x' declared after it.
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
tests/cases/conformance/classes/classExpressions/classWithStaticFieldInParameterInitializer.2.ts(3,21): error TS2373: Parameter 'b' cannot reference identifier 'C' declared after it.
|
||||
tests/cases/conformance/classes/classExpressions/classWithStaticFieldInParameterInitializer.2.ts(6,45): error TS2373: Parameter 'd' cannot reference identifier 'x' declared after it.
|
||||
|
||||
|
||||
==== tests/cases/conformance/classes/classExpressions/classWithStaticFieldInParameterInitializer.2.ts (2 errors) ====
|
||||
// https://github.com/microsoft/TypeScript/issues/36295
|
||||
class C {}
|
||||
((b = class extends C { static x = 1 }) => { var C; })();
|
||||
~
|
||||
!!! error TS2373: Parameter 'b' cannot reference identifier 'C' declared after it.
|
||||
|
||||
const x = "";
|
||||
((b = class extends C { static x = 1 }, d = x) => { var x; })();
|
||||
~
|
||||
!!! error TS2373: Parameter 'd' cannot reference identifier 'x' declared after it.
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
tests/cases/compiler/contextualTypeForInitalizedVariablesFiltersUndefined.ts(7,9): error TS2339: Property 's' does not exist on type '{ s: string; } | undefined'.
|
||||
tests/cases/compiler/contextualTypeForInitalizedVariablesFiltersUndefined.ts(8,16): error TS2339: Property 's' does not exist on type '{ s: string; } | undefined'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/contextualTypeForInitalizedVariablesFiltersUndefined.ts (2 errors) ====
|
||||
const fInferred = ({ a = 0 } = {}) => a;
|
||||
// const fInferred: ({ a }?: { a?: number; }) => number
|
||||
|
||||
const fAnnotated: typeof fInferred = ({ a = 0 } = {}) => a;
|
||||
|
||||
declare var t: { s: string } | undefined;
|
||||
const { s } = t;
|
||||
~
|
||||
!!! error TS2339: Property 's' does not exist on type '{ s: string; } | undefined'.
|
||||
function fst({ s } = t) { }
|
||||
~
|
||||
!!! error TS2339: Property 's' does not exist on type '{ s: string; } | undefined'.
|
||||
|
||||
@@ -2,7 +2,12 @@
|
||||
const fInferred = ({ a = 0 } = {}) => a;
|
||||
// const fInferred: ({ a }?: { a?: number; }) => number
|
||||
|
||||
const fAnnotated: typeof fInferred = ({ a = 0 } = {}) => a;
|
||||
const fAnnotated: typeof fInferred = ({ a = 0 } = {}) => a;
|
||||
|
||||
declare var t: { s: string } | undefined;
|
||||
const { s } = t;
|
||||
function fst({ s } = t) { }
|
||||
|
||||
|
||||
//// [contextualTypeForInitalizedVariablesFiltersUndefined.js]
|
||||
"use strict";
|
||||
@@ -15,3 +20,7 @@ var fAnnotated = function (_a) {
|
||||
var _b = (_a === void 0 ? {} : _a).a, a = _b === void 0 ? 0 : _b;
|
||||
return a;
|
||||
};
|
||||
var s = t.s;
|
||||
function fst(_a) {
|
||||
var s = (_a === void 0 ? t : _a).s;
|
||||
}
|
||||
|
||||
+13
@@ -12,3 +12,16 @@ const fAnnotated: typeof fInferred = ({ a = 0 } = {}) => a;
|
||||
>a : Symbol(a, Decl(contextualTypeForInitalizedVariablesFiltersUndefined.ts, 3, 39))
|
||||
>a : Symbol(a, Decl(contextualTypeForInitalizedVariablesFiltersUndefined.ts, 3, 39))
|
||||
|
||||
declare var t: { s: string } | undefined;
|
||||
>t : Symbol(t, Decl(contextualTypeForInitalizedVariablesFiltersUndefined.ts, 5, 11))
|
||||
>s : Symbol(s, Decl(contextualTypeForInitalizedVariablesFiltersUndefined.ts, 5, 16))
|
||||
|
||||
const { s } = t;
|
||||
>s : Symbol(s, Decl(contextualTypeForInitalizedVariablesFiltersUndefined.ts, 6, 7))
|
||||
>t : Symbol(t, Decl(contextualTypeForInitalizedVariablesFiltersUndefined.ts, 5, 11))
|
||||
|
||||
function fst({ s } = t) { }
|
||||
>fst : Symbol(fst, Decl(contextualTypeForInitalizedVariablesFiltersUndefined.ts, 6, 16))
|
||||
>s : Symbol(s, Decl(contextualTypeForInitalizedVariablesFiltersUndefined.ts, 7, 14))
|
||||
>t : Symbol(t, Decl(contextualTypeForInitalizedVariablesFiltersUndefined.ts, 5, 11))
|
||||
|
||||
|
||||
@@ -18,3 +18,16 @@ const fAnnotated: typeof fInferred = ({ a = 0 } = {}) => a;
|
||||
>{} : {}
|
||||
>a : number
|
||||
|
||||
declare var t: { s: string } | undefined;
|
||||
>t : { s: string; } | undefined
|
||||
>s : string
|
||||
|
||||
const { s } = t;
|
||||
>s : any
|
||||
>t : { s: string; } | undefined
|
||||
|
||||
function fst({ s } = t) { }
|
||||
>fst : ({ s }?: { s: string; } | undefined) => void
|
||||
>s : any
|
||||
>t : { s: string; } | undefined
|
||||
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
tests/cases/conformance/controlFlow/controlFlowDeleteOperator.ts(10,12): error TS2790: The operand of a 'delete' operator must be optional.
|
||||
tests/cases/conformance/controlFlow/controlFlowDeleteOperator.ts(14,12): error TS2703: The operand of a 'delete' operator must be a property reference.
|
||||
|
||||
|
||||
==== tests/cases/conformance/controlFlow/controlFlowDeleteOperator.ts (1 errors) ====
|
||||
==== tests/cases/conformance/controlFlow/controlFlowDeleteOperator.ts (2 errors) ====
|
||||
function f() {
|
||||
let x: { a?: number | string, b: number | string } = { b: 1 };
|
||||
x.a;
|
||||
@@ -12,6 +13,8 @@ tests/cases/conformance/controlFlow/controlFlowDeleteOperator.ts(14,12): error T
|
||||
x.b;
|
||||
delete x.a;
|
||||
delete x.b;
|
||||
~~~
|
||||
!!! error TS2790: The operand of a 'delete' operator must be optional.
|
||||
x.a;
|
||||
x.b;
|
||||
x;
|
||||
|
||||
@@ -1,17 +0,0 @@
|
||||
// ==ORIGINAL==
|
||||
|
||||
function /*[#|*/f/*|]*/():Promise<void> {
|
||||
return fetch('https://typescriptlang.org').then(result => { console.log(result); }, rejection => { console.log("rejected:", rejection); });
|
||||
}
|
||||
|
||||
// ==ASYNC FUNCTION::Convert to async function==
|
||||
|
||||
async function f():Promise<void> {
|
||||
try {
|
||||
const result = await fetch('https://typescriptlang.org');
|
||||
console.log(result);
|
||||
}
|
||||
catch (rejection) {
|
||||
console.log("rejected:", rejection);
|
||||
}
|
||||
}
|
||||
-17
@@ -1,17 +0,0 @@
|
||||
// ==ORIGINAL==
|
||||
|
||||
function /*[#|*/f/*|]*/():Promise<void> {
|
||||
return fetch('https://typescriptlang.org').then(result => console.log(result), rejection => console.log("rejected:", rejection));
|
||||
}
|
||||
|
||||
// ==ASYNC FUNCTION::Convert to async function==
|
||||
|
||||
async function f():Promise<void> {
|
||||
try {
|
||||
const result = await fetch('https://typescriptlang.org');
|
||||
return console.log(result);
|
||||
}
|
||||
catch (rejection) {
|
||||
return console.log("rejected:", rejection);
|
||||
}
|
||||
}
|
||||
@@ -1,29 +0,0 @@
|
||||
// ==ORIGINAL==
|
||||
|
||||
function /*[#|*/f/*|]*/():Promise<void> {
|
||||
return fetch('https://typescriptlang.org').then(res, rej);
|
||||
}
|
||||
function res(result){
|
||||
console.log(result);
|
||||
}
|
||||
function rej(err){
|
||||
console.log(err);
|
||||
}
|
||||
|
||||
// ==ASYNC FUNCTION::Convert to async function==
|
||||
|
||||
async function f():Promise<void> {
|
||||
try {
|
||||
const result = await fetch('https://typescriptlang.org');
|
||||
return res(result);
|
||||
}
|
||||
catch (err) {
|
||||
return rej(err);
|
||||
}
|
||||
}
|
||||
function res(result){
|
||||
console.log(result);
|
||||
}
|
||||
function rej(err){
|
||||
console.log(err);
|
||||
}
|
||||
-17
@@ -1,17 +0,0 @@
|
||||
// ==ORIGINAL==
|
||||
|
||||
function /*[#|*/f/*|]*/() {
|
||||
return Promise.resolve().then(() => 1, () => "a");
|
||||
}
|
||||
|
||||
// ==ASYNC FUNCTION::Convert to async function==
|
||||
|
||||
async function f() {
|
||||
try {
|
||||
await Promise.resolve();
|
||||
return 1;
|
||||
}
|
||||
catch (e) {
|
||||
return "a";
|
||||
}
|
||||
}
|
||||
-17
@@ -1,17 +0,0 @@
|
||||
// ==ORIGINAL==
|
||||
|
||||
function /*[#|*/f/*|]*/() {
|
||||
return Promise.resolve().then(() => 1, () => "a");
|
||||
}
|
||||
|
||||
// ==ASYNC FUNCTION::Convert to async function==
|
||||
|
||||
async function f() {
|
||||
try {
|
||||
await Promise.resolve();
|
||||
return 1;
|
||||
}
|
||||
catch (e) {
|
||||
return "a";
|
||||
}
|
||||
}
|
||||
+82
@@ -0,0 +1,82 @@
|
||||
//// [tests/cases/compiler/declarationEmitExportAssignedNamespaceNoTripleSlashTypesReference.ts] ////
|
||||
|
||||
//// [index.d.ts]
|
||||
export = React;
|
||||
|
||||
declare namespace React {
|
||||
export type Component<T = any, U = {}, V = {}> = { x: T, y: U, z: V };
|
||||
export interface DOMAttributes<T> { }
|
||||
}
|
||||
//// [index.d.ts]
|
||||
import {
|
||||
Component
|
||||
} from 'react'
|
||||
export {};
|
||||
|
||||
declare module 'react' {
|
||||
interface DOMAttributes<T> {
|
||||
css?: any
|
||||
}
|
||||
}
|
||||
|
||||
//// [get-comp.ts]
|
||||
import {Component} from 'react';
|
||||
|
||||
export function getComp(): Component {
|
||||
return {} as any as Component
|
||||
}
|
||||
//// [inferred-comp-export.ts]
|
||||
import { getComp } from "./get-comp";
|
||||
|
||||
// this shouldn't need any triple-slash references - it should have a direct import to `react` and that's it
|
||||
// This issue (#35343) _only_ reproduces in the test harness when the file in question is in a subfolder
|
||||
export const obj = {
|
||||
comp: getComp()
|
||||
}
|
||||
//// [some-other-file.ts]
|
||||
export * from '@emotion/core';
|
||||
|
||||
|
||||
//// [get-comp.js]
|
||||
"use strict";
|
||||
exports.__esModule = true;
|
||||
exports.getComp = void 0;
|
||||
function getComp() {
|
||||
return {};
|
||||
}
|
||||
exports.getComp = getComp;
|
||||
//// [inferred-comp-export.js]
|
||||
"use strict";
|
||||
exports.__esModule = true;
|
||||
exports.obj = void 0;
|
||||
var get_comp_1 = require("./get-comp");
|
||||
// this shouldn't need any triple-slash references - it should have a direct import to `react` and that's it
|
||||
// This issue (#35343) _only_ reproduces in the test harness when the file in question is in a subfolder
|
||||
exports.obj = {
|
||||
comp: get_comp_1.getComp()
|
||||
};
|
||||
//// [some-other-file.js]
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
||||
for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p);
|
||||
}
|
||||
exports.__esModule = true;
|
||||
__exportStar(require("@emotion/core"), exports);
|
||||
|
||||
|
||||
//// [get-comp.d.ts]
|
||||
import { Component } from 'react';
|
||||
export declare function getComp(): Component;
|
||||
//// [inferred-comp-export.d.ts]
|
||||
export declare const obj: {
|
||||
comp: import("react").Component<any, {}, {}>;
|
||||
};
|
||||
//// [some-other-file.d.ts]
|
||||
export * from '@emotion/core';
|
||||
+71
@@ -0,0 +1,71 @@
|
||||
=== tests/cases/compiler/node_modules/@types/react/index.d.ts ===
|
||||
export = React;
|
||||
>React : Symbol(React, Decl(index.d.ts, 0, 15), Decl(index.d.ts, 3, 10))
|
||||
|
||||
declare namespace React {
|
||||
>React : Symbol(React, Decl(index.d.ts, 0, 15), Decl(index.d.ts, 3, 10))
|
||||
|
||||
export type Component<T = any, U = {}, V = {}> = { x: T, y: U, z: V };
|
||||
>Component : Symbol(Component, Decl(index.d.ts, 2, 25))
|
||||
>T : Symbol(T, Decl(index.d.ts, 3, 26))
|
||||
>U : Symbol(U, Decl(index.d.ts, 3, 34))
|
||||
>V : Symbol(V, Decl(index.d.ts, 3, 42))
|
||||
>x : Symbol(x, Decl(index.d.ts, 3, 54))
|
||||
>T : Symbol(T, Decl(index.d.ts, 3, 26))
|
||||
>y : Symbol(y, Decl(index.d.ts, 3, 60))
|
||||
>U : Symbol(U, Decl(index.d.ts, 3, 34))
|
||||
>z : Symbol(z, Decl(index.d.ts, 3, 66))
|
||||
>V : Symbol(V, Decl(index.d.ts, 3, 42))
|
||||
|
||||
export interface DOMAttributes<T> { }
|
||||
>DOMAttributes : Symbol(DOMAttributes, Decl(index.d.ts, 3, 74), Decl(index.d.ts, 5, 24))
|
||||
>T : Symbol(T, Decl(index.d.ts, 4, 35), Decl(index.d.ts, 6, 28))
|
||||
}
|
||||
=== tests/cases/compiler/node_modules/@emotion/core/index.d.ts ===
|
||||
import {
|
||||
Component
|
||||
>Component : Symbol(Component, Decl(index.d.ts, 0, 8))
|
||||
|
||||
} from 'react'
|
||||
export {};
|
||||
|
||||
declare module 'react' {
|
||||
>'react' : Symbol(React, Decl(index.d.ts, 0, 15), Decl(index.d.ts, 3, 10))
|
||||
|
||||
interface DOMAttributes<T> {
|
||||
>DOMAttributes : Symbol(DOMAttributes, Decl(index.d.ts, 3, 74), Decl(index.d.ts, 5, 24))
|
||||
>T : Symbol(T, Decl(index.d.ts, 4, 35), Decl(index.d.ts, 6, 28))
|
||||
|
||||
css?: any
|
||||
>css : Symbol(DOMAttributes.css, Decl(index.d.ts, 6, 32))
|
||||
}
|
||||
}
|
||||
|
||||
=== tests/cases/compiler/src/get-comp.ts ===
|
||||
import {Component} from 'react';
|
||||
>Component : Symbol(Component, Decl(get-comp.ts, 0, 8))
|
||||
|
||||
export function getComp(): Component {
|
||||
>getComp : Symbol(getComp, Decl(get-comp.ts, 0, 32))
|
||||
>Component : Symbol(Component, Decl(get-comp.ts, 0, 8))
|
||||
|
||||
return {} as any as Component
|
||||
>Component : Symbol(Component, Decl(get-comp.ts, 0, 8))
|
||||
}
|
||||
=== tests/cases/compiler/src/inferred-comp-export.ts ===
|
||||
import { getComp } from "./get-comp";
|
||||
>getComp : Symbol(getComp, Decl(inferred-comp-export.ts, 0, 8))
|
||||
|
||||
// this shouldn't need any triple-slash references - it should have a direct import to `react` and that's it
|
||||
// This issue (#35343) _only_ reproduces in the test harness when the file in question is in a subfolder
|
||||
export const obj = {
|
||||
>obj : Symbol(obj, Decl(inferred-comp-export.ts, 4, 12))
|
||||
|
||||
comp: getComp()
|
||||
>comp : Symbol(comp, Decl(inferred-comp-export.ts, 4, 20))
|
||||
>getComp : Symbol(getComp, Decl(inferred-comp-export.ts, 0, 8))
|
||||
}
|
||||
=== tests/cases/compiler/src/some-other-file.ts ===
|
||||
export * from '@emotion/core';
|
||||
No type information for this code.
|
||||
No type information for this code.
|
||||
+61
@@ -0,0 +1,61 @@
|
||||
=== tests/cases/compiler/node_modules/@types/react/index.d.ts ===
|
||||
export = React;
|
||||
>React : any
|
||||
|
||||
declare namespace React {
|
||||
export type Component<T = any, U = {}, V = {}> = { x: T, y: U, z: V };
|
||||
>Component : Component<T, U, V>
|
||||
>x : T
|
||||
>y : U
|
||||
>z : V
|
||||
|
||||
export interface DOMAttributes<T> { }
|
||||
}
|
||||
=== tests/cases/compiler/node_modules/@emotion/core/index.d.ts ===
|
||||
import {
|
||||
Component
|
||||
>Component : any
|
||||
|
||||
} from 'react'
|
||||
export {};
|
||||
|
||||
declare module 'react' {
|
||||
>'react' : error
|
||||
|
||||
interface DOMAttributes<T> {
|
||||
css?: any
|
||||
>css : any
|
||||
}
|
||||
}
|
||||
|
||||
=== tests/cases/compiler/src/get-comp.ts ===
|
||||
import {Component} from 'react';
|
||||
>Component : any
|
||||
|
||||
export function getComp(): Component {
|
||||
>getComp : () => Component
|
||||
|
||||
return {} as any as Component
|
||||
>{} as any as Component : Component<any, {}, {}>
|
||||
>{} as any : any
|
||||
>{} : {}
|
||||
}
|
||||
=== tests/cases/compiler/src/inferred-comp-export.ts ===
|
||||
import { getComp } from "./get-comp";
|
||||
>getComp : () => import("tests/cases/compiler/node_modules/@types/react/index").Component<any, {}, {}>
|
||||
|
||||
// this shouldn't need any triple-slash references - it should have a direct import to `react` and that's it
|
||||
// This issue (#35343) _only_ reproduces in the test harness when the file in question is in a subfolder
|
||||
export const obj = {
|
||||
>obj : { comp: import("tests/cases/compiler/node_modules/@types/react/index").Component<any, {}, {}>; }
|
||||
>{ comp: getComp()} : { comp: import("tests/cases/compiler/node_modules/@types/react/index").Component<any, {}, {}>; }
|
||||
|
||||
comp: getComp()
|
||||
>comp : import("tests/cases/compiler/node_modules/@types/react/index").Component<any, {}, {}>
|
||||
>getComp() : import("tests/cases/compiler/node_modules/@types/react/index").Component<any, {}, {}>
|
||||
>getComp : () => import("tests/cases/compiler/node_modules/@types/react/index").Component<any, {}, {}>
|
||||
}
|
||||
=== tests/cases/compiler/src/some-other-file.ts ===
|
||||
export * from '@emotion/core';
|
||||
No type information for this code.
|
||||
No type information for this code.
|
||||
+2
-2
@@ -38,13 +38,13 @@ export const updateIfChanged = <T>(t: T) => {
|
||||
>newU : U
|
||||
|
||||
return Object.assign(
|
||||
>Object.assign( <K extends Key<U>>(key: K) => reduce<Value<K, U>>(u[key as keyof U] as Value<K, U>, (v: Value<K, U>) => { return update(Object.assign(Array.isArray(u) ? [] : {}, u, { [key]: v })); }), { map: (updater: (u: U) => U) => set(updater(u)), set }) : (<K extends keyof U>(key: K) => (<K extends keyof U[K]>(key: K) => (<K extends keyof U[K][K]>(key: K) => (<K extends keyof U[K][K][K]>(key: K) => (<K extends keyof U[K][K][K][K]>(key: K) => (<K extends keyof U[K][K][K][K][K]>(key: K) => (<K extends keyof U[K][K][K][K][K][K]>(key: K) => (<K extends keyof U[K][K][K][K][K][K][K]>(key: K) => (<K extends keyof U[K][K][K][K][K][K][K][K]>(key: K) => (<K extends keyof U[K][K][K][K][K][K][K][K][K]>(key: K) => (<K extends keyof U[K][K][K][K][K][K][K][K][K][K]>(key: K) => any & { map: (updater: (u: U[K][K][K][K][K][K][K][K][K][K][K]) => U[K][K][K][K][K][K][K][K][K][K][K]) => T; set: (newU: U[K][K][K][K][K][K][K][K][K][K][K]) => T; }) & { map: (updater: (u: U[K][K][K][K][K][K][K][K][K][K]) => U[K][K][K][K][K][K][K][K][K][K]) => T; set: (newU: U[K][K][K][K][K][K][K][K][K][K]) => T; }) & { map: (updater: (u: U[K][K][K][K][K][K][K][K][K]) => U[K][K][K][K][K][K][K][K][K]) => T; set: (newU: U[K][K][K][K][K][K][K][K][K]) => T; }) & { map: (updater: (u: U[K][K][K][K][K][K][K][K]) => U[K][K][K][K][K][K][K][K]) => T; set: (newU: U[K][K][K][K][K][K][K][K]) => T; }) & { map: (updater: (u: U[K][K][K][K][K][K][K]) => U[K][K][K][K][K][K][K]) => T; set: (newU: U[K][K][K][K][K][K][K]) => T; }) & { map: (updater: (u: U[K][K][K][K][K][K]) => U[K][K][K][K][K][K]) => T; set: (newU: U[K][K][K][K][K][K]) => T; }) & { map: (updater: (u: U[K][K][K][K][K]) => U[K][K][K][K][K]) => T; set: (newU: U[K][K][K][K][K]) => T; }) & { map: (updater: (u: U[K][K][K][K]) => U[K][K][K][K]) => T; set: (newU: U[K][K][K][K]) => T; }) & { map: (updater: (u: U[K][K][K]) => U[K][K][K]) => T; set: (newU: U[K][K][K]) => T; }) & { map: (updater: (u: U[K][K]) => U[K][K]) => T; set: (newU: U[K][K]) => T; }) & { map: (updater: (u: U[K]) => U[K]) => T; set: (newU: U[K]) => T; }) & { map: (updater: (u: U) => U) => T; set: (newU: U) => T; }
|
||||
>Object.assign( <K extends Key<U>>(key: K) => reduce<Value<K, U>>(u[key as keyof U] as Value<K, U>, (v: Value<K, U>) => { return update(Object.assign(Array.isArray(u) ? [] : {}, u, { [key]: v })); }), { map: (updater: (u: U) => U) => set(updater(u)), set }) : (<K extends keyof U>(key: K) => (<K extends keyof U[K]>(key: K) => (<K extends keyof U[K][K]>(key: K) => (<K extends keyof U[K][K][K]>(key: K) => (<K extends keyof U[K][K][K][K]>(key: K) => (<K extends keyof U[K][K][K][K][K]>(key: K) => (<K extends keyof U[K][K][K][K][K][K]>(key: K) => (<K extends keyof U[K][K][K][K][K][K][K]>(key: K) => (<K extends keyof U[K][K][K][K][K][K][K][K]>(key: K) => (<K extends keyof U[K][K][K][K][K][K][K][K][K]>(key: K) => (<K extends keyof U[K][K][K][K][K][K][K][K][K][K]>(key: K) => any & { map: (updater: (u: U[K][K][K][K][K][K][K][K][K][K][K]) => U) => T; set: (newU: U[K][K][K][K][K][K][K][K][K][K][K]) => T; }) & { map: (updater: (u: U[K][K][K][K][K][K][K][K][K][K]) => U) => T; set: (newU: U[K][K][K][K][K][K][K][K][K][K]) => T; }) & { map: (updater: (u: U[K][K][K][K][K][K][K][K][K]) => U) => T; set: (newU: U[K][K][K][K][K][K][K][K][K]) => T; }) & { map: (updater: (u: U[K][K][K][K][K][K][K][K]) => U) => T; set: (newU: U[K][K][K][K][K][K][K][K]) => T; }) & { map: (updater: (u: U[K][K][K][K][K][K][K]) => U) => T; set: (newU: U[K][K][K][K][K][K][K]) => T; }) & { map: (updater: (u: U[K][K][K][K][K][K]) => U) => T; set: (newU: U[K][K][K][K][K][K]) => T; }) & { map: (updater: (u: U[K][K][K][K][K]) => U) => T; set: (newU: U[K][K][K][K][K]) => T; }) & { map: (updater: (u: U[K][K][K][K]) => U) => T; set: (newU: U[K][K][K][K]) => T; }) & { map: (updater: (u: U[K][K][K]) => U) => T; set: (newU: U[K][K][K]) => T; }) & { map: (updater: (u: U[K][K]) => U) => T; set: (newU: U[K][K]) => T; }) & { map: (updater: (u: U[K]) => U) => T; set: (newU: U[K]) => T; }) & { map: (updater: (u: U) => U) => T; set: (newU: U) => T; }
|
||||
>Object.assign : { <T, U>(target: T, source: U): T & U; <T, U, V>(target: T, source1: U, source2: V): T & U & V; <T, U, V, W>(target: T, source1: U, source2: V, source3: W): T & U & V & W; (target: object, ...sources: any[]): any; }
|
||||
>Object : ObjectConstructor
|
||||
>assign : { <T, U>(target: T, source: U): T & U; <T, U, V>(target: T, source1: U, source2: V): T & U & V; <T, U, V, W>(target: T, source1: U, source2: V, source3: W): T & U & V & W; (target: object, ...sources: any[]): any; }
|
||||
|
||||
<K extends Key<U>>(key: K) =>
|
||||
><K extends Key<U>>(key: K) => reduce<Value<K, U>>(u[key as keyof U] as Value<K, U>, (v: Value<K, U>) => { return update(Object.assign(Array.isArray(u) ? [] : {}, u, { [key]: v })); }) : <K extends keyof U>(key: K) => (<K extends keyof U[K]>(key: K) => (<K extends keyof U[K][K]>(key: K) => (<K extends keyof U[K][K][K]>(key: K) => (<K extends keyof U[K][K][K][K]>(key: K) => (<K extends keyof U[K][K][K][K][K]>(key: K) => (<K extends keyof U[K][K][K][K][K][K]>(key: K) => (<K extends keyof U[K][K][K][K][K][K][K]>(key: K) => (<K extends keyof U[K][K][K][K][K][K][K][K]>(key: K) => (<K extends keyof U[K][K][K][K][K][K][K][K][K]>(key: K) => (<K extends keyof U[K][K][K][K][K][K][K][K][K][K]>(key: K) => any & { map: (updater: (u: U[K][K][K][K][K][K][K][K][K][K][K]) => U[K][K][K][K][K][K][K][K][K][K][K]) => T; set: (newU: U[K][K][K][K][K][K][K][K][K][K][K]) => T; }) & { map: (updater: (u: U[K][K][K][K][K][K][K][K][K][K]) => U[K][K][K][K][K][K][K][K][K][K]) => T; set: (newU: U[K][K][K][K][K][K][K][K][K][K]) => T; }) & { map: (updater: (u: U[K][K][K][K][K][K][K][K][K]) => U[K][K][K][K][K][K][K][K][K]) => T; set: (newU: U[K][K][K][K][K][K][K][K][K]) => T; }) & { map: (updater: (u: U[K][K][K][K][K][K][K][K]) => U[K][K][K][K][K][K][K][K]) => T; set: (newU: U[K][K][K][K][K][K][K][K]) => T; }) & { map: (updater: (u: U[K][K][K][K][K][K][K]) => U[K][K][K][K][K][K][K]) => T; set: (newU: U[K][K][K][K][K][K][K]) => T; }) & { map: (updater: (u: U[K][K][K][K][K][K]) => U[K][K][K][K][K][K]) => T; set: (newU: U[K][K][K][K][K][K]) => T; }) & { map: (updater: (u: U[K][K][K][K][K]) => U[K][K][K][K][K]) => T; set: (newU: U[K][K][K][K][K]) => T; }) & { map: (updater: (u: U[K][K][K][K]) => U[K][K][K][K]) => T; set: (newU: U[K][K][K][K]) => T; }) & { map: (updater: (u: U[K][K][K]) => U[K][K][K]) => T; set: (newU: U[K][K][K]) => T; }) & { map: (updater: (u: U[K][K]) => U[K][K]) => T; set: (newU: U[K][K]) => T; }) & { map: (updater: (u: U[K]) => U[K]) => T; set: (newU: U[K]) => T; }
|
||||
><K extends Key<U>>(key: K) => reduce<Value<K, U>>(u[key as keyof U] as Value<K, U>, (v: Value<K, U>) => { return update(Object.assign(Array.isArray(u) ? [] : {}, u, { [key]: v })); }) : <K extends keyof U>(key: K) => (<K extends keyof U[K]>(key: K) => (<K extends keyof U[K][K]>(key: K) => (<K extends keyof U[K][K][K]>(key: K) => (<K extends keyof U[K][K][K][K]>(key: K) => (<K extends keyof U[K][K][K][K][K]>(key: K) => (<K extends keyof U[K][K][K][K][K][K]>(key: K) => (<K extends keyof U[K][K][K][K][K][K][K]>(key: K) => (<K extends keyof U[K][K][K][K][K][K][K][K]>(key: K) => (<K extends keyof U[K][K][K][K][K][K][K][K][K]>(key: K) => (<K extends keyof U[K][K][K][K][K][K][K][K][K][K]>(key: K) => any & { map: (updater: (u: U[K][K][K][K][K][K][K][K][K][K][K]) => U) => T; set: (newU: U[K][K][K][K][K][K][K][K][K][K][K]) => T; }) & { map: (updater: (u: U[K][K][K][K][K][K][K][K][K][K]) => U) => T; set: (newU: U[K][K][K][K][K][K][K][K][K][K]) => T; }) & { map: (updater: (u: U[K][K][K][K][K][K][K][K][K]) => U) => T; set: (newU: U[K][K][K][K][K][K][K][K][K]) => T; }) & { map: (updater: (u: U[K][K][K][K][K][K][K][K]) => U) => T; set: (newU: U[K][K][K][K][K][K][K][K]) => T; }) & { map: (updater: (u: U[K][K][K][K][K][K][K]) => U) => T; set: (newU: U[K][K][K][K][K][K][K]) => T; }) & { map: (updater: (u: U[K][K][K][K][K][K]) => U) => T; set: (newU: U[K][K][K][K][K][K]) => T; }) & { map: (updater: (u: U[K][K][K][K][K]) => U) => T; set: (newU: U[K][K][K][K][K]) => T; }) & { map: (updater: (u: U[K][K][K][K]) => U) => T; set: (newU: U[K][K][K][K]) => T; }) & { map: (updater: (u: U[K][K][K]) => U) => T; set: (newU: U[K][K][K]) => T; }) & { map: (updater: (u: U[K][K]) => U) => T; set: (newU: U[K][K]) => T; }) & { map: (updater: (u: U[K]) => U) => T; set: (newU: U[K]) => T; }
|
||||
>key : K
|
||||
|
||||
reduce<Value<K, U>>(u[key as keyof U] as Value<K, U>, (v: Value<K, U>) => {
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
tests/cases/conformance/expressions/optionalChaining/delete/deleteChain.ts(2,8): error TS2790: The operand of a 'delete' operator must be optional.
|
||||
tests/cases/conformance/expressions/optionalChaining/delete/deleteChain.ts(3,9): error TS2790: The operand of a 'delete' operator must be optional.
|
||||
tests/cases/conformance/expressions/optionalChaining/delete/deleteChain.ts(6,8): error TS2790: The operand of a 'delete' operator must be optional.
|
||||
tests/cases/conformance/expressions/optionalChaining/delete/deleteChain.ts(7,9): error TS2790: The operand of a 'delete' operator must be optional.
|
||||
tests/cases/conformance/expressions/optionalChaining/delete/deleteChain.ts(10,8): error TS2790: The operand of a 'delete' operator must be optional.
|
||||
tests/cases/conformance/expressions/optionalChaining/delete/deleteChain.ts(11,9): error TS2790: The operand of a 'delete' operator must be optional.
|
||||
tests/cases/conformance/expressions/optionalChaining/delete/deleteChain.ts(14,8): error TS2790: The operand of a 'delete' operator must be optional.
|
||||
tests/cases/conformance/expressions/optionalChaining/delete/deleteChain.ts(15,8): error TS2790: The operand of a 'delete' operator must be optional.
|
||||
tests/cases/conformance/expressions/optionalChaining/delete/deleteChain.ts(16,9): error TS2790: The operand of a 'delete' operator must be optional.
|
||||
tests/cases/conformance/expressions/optionalChaining/delete/deleteChain.ts(19,8): error TS2790: The operand of a 'delete' operator must be optional.
|
||||
tests/cases/conformance/expressions/optionalChaining/delete/deleteChain.ts(20,9): error TS2790: The operand of a 'delete' operator must be optional.
|
||||
tests/cases/conformance/expressions/optionalChaining/delete/deleteChain.ts(23,8): error TS2790: The operand of a 'delete' operator must be optional.
|
||||
tests/cases/conformance/expressions/optionalChaining/delete/deleteChain.ts(24,9): error TS2790: The operand of a 'delete' operator must be optional.
|
||||
|
||||
|
||||
==== tests/cases/conformance/expressions/optionalChaining/delete/deleteChain.ts (13 errors) ====
|
||||
declare const o1: undefined | { b: string };
|
||||
delete o1?.b;
|
||||
~~~~~
|
||||
!!! error TS2790: The operand of a 'delete' operator must be optional.
|
||||
delete (o1?.b);
|
||||
~~~~~
|
||||
!!! error TS2790: The operand of a 'delete' operator must be optional.
|
||||
|
||||
declare const o2: undefined | { b: { c: string } };
|
||||
delete o2?.b.c;
|
||||
~~~~~~~
|
||||
!!! error TS2790: The operand of a 'delete' operator must be optional.
|
||||
delete (o2?.b.c);
|
||||
~~~~~~~
|
||||
!!! error TS2790: The operand of a 'delete' operator must be optional.
|
||||
|
||||
declare const o3: { b: undefined | { c: string } };
|
||||
delete o3.b?.c;
|
||||
~~~~~~~
|
||||
!!! error TS2790: The operand of a 'delete' operator must be optional.
|
||||
delete (o3.b?.c);
|
||||
~~~~~~~
|
||||
!!! error TS2790: The operand of a 'delete' operator must be optional.
|
||||
|
||||
declare const o4: { b?: { c: { d?: { e: string } } } };
|
||||
delete o4.b?.c.d?.e;
|
||||
~~~~~~~~~~~~
|
||||
!!! error TS2790: The operand of a 'delete' operator must be optional.
|
||||
delete (o4.b?.c.d)?.e;
|
||||
~~~~~~~~~~~~~~
|
||||
!!! error TS2790: The operand of a 'delete' operator must be optional.
|
||||
delete (o4.b?.c.d?.e);
|
||||
~~~~~~~~~~~~
|
||||
!!! error TS2790: The operand of a 'delete' operator must be optional.
|
||||
|
||||
declare const o5: { b?(): { c: { d?: { e: string } } } };
|
||||
delete o5.b?.().c.d?.e;
|
||||
~~~~~~~~~~~~~~~
|
||||
!!! error TS2790: The operand of a 'delete' operator must be optional.
|
||||
delete (o5.b?.().c.d?.e);
|
||||
~~~~~~~~~~~~~~~
|
||||
!!! error TS2790: The operand of a 'delete' operator must be optional.
|
||||
|
||||
declare const o6: { b?: { c: { d?: { e: string } } } };
|
||||
delete o6.b?.['c'].d?.['e'];
|
||||
~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2790: The operand of a 'delete' operator must be optional.
|
||||
delete (o6.b?.['c'].d?.['e']);
|
||||
~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2790: The operand of a 'delete' operator must be optional.
|
||||
@@ -0,0 +1,46 @@
|
||||
tests/cases/compiler/deleteExpressionMustBeOptional.ts(34,10): error TS2339: Property 'j' does not exist on type 'Foo'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/deleteExpressionMustBeOptional.ts (1 errors) ====
|
||||
interface Foo {
|
||||
a: number
|
||||
b: number | undefined
|
||||
c: number | null
|
||||
d?: number
|
||||
e: number | undefined | null
|
||||
f?: number | undefined | null
|
||||
g: unknown
|
||||
h: any
|
||||
i: never
|
||||
}
|
||||
|
||||
interface AA {
|
||||
[s: string]: number
|
||||
}
|
||||
|
||||
type BB = {
|
||||
[P in keyof any]: number
|
||||
}
|
||||
|
||||
declare const f: Foo
|
||||
declare const a: AA
|
||||
declare const b: BB
|
||||
|
||||
delete f.a
|
||||
delete f.b
|
||||
delete f.c
|
||||
delete f.d
|
||||
delete f.e
|
||||
delete f.f
|
||||
delete f.g
|
||||
delete f.h
|
||||
delete f.i
|
||||
delete f.j
|
||||
~
|
||||
!!! error TS2339: Property 'j' does not exist on type 'Foo'.
|
||||
|
||||
delete a.a
|
||||
delete a.b
|
||||
|
||||
delete b.a
|
||||
delete b.b
|
||||
@@ -0,0 +1,57 @@
|
||||
//// [deleteExpressionMustBeOptional.ts]
|
||||
interface Foo {
|
||||
a: number
|
||||
b: number | undefined
|
||||
c: number | null
|
||||
d?: number
|
||||
e: number | undefined | null
|
||||
f?: number | undefined | null
|
||||
g: unknown
|
||||
h: any
|
||||
i: never
|
||||
}
|
||||
|
||||
interface AA {
|
||||
[s: string]: number
|
||||
}
|
||||
|
||||
type BB = {
|
||||
[P in keyof any]: number
|
||||
}
|
||||
|
||||
declare const f: Foo
|
||||
declare const a: AA
|
||||
declare const b: BB
|
||||
|
||||
delete f.a
|
||||
delete f.b
|
||||
delete f.c
|
||||
delete f.d
|
||||
delete f.e
|
||||
delete f.f
|
||||
delete f.g
|
||||
delete f.h
|
||||
delete f.i
|
||||
delete f.j
|
||||
|
||||
delete a.a
|
||||
delete a.b
|
||||
|
||||
delete b.a
|
||||
delete b.b
|
||||
|
||||
//// [deleteExpressionMustBeOptional.js]
|
||||
delete f.a;
|
||||
delete f.b;
|
||||
delete f.c;
|
||||
delete f.d;
|
||||
delete f.e;
|
||||
delete f.f;
|
||||
delete f.g;
|
||||
delete f.h;
|
||||
delete f.i;
|
||||
delete f.j;
|
||||
delete a.a;
|
||||
delete a.b;
|
||||
delete b.a;
|
||||
delete b.b;
|
||||
@@ -0,0 +1,118 @@
|
||||
=== tests/cases/compiler/deleteExpressionMustBeOptional.ts ===
|
||||
interface Foo {
|
||||
>Foo : Symbol(Foo, Decl(deleteExpressionMustBeOptional.ts, 0, 0))
|
||||
|
||||
a: number
|
||||
>a : Symbol(Foo.a, Decl(deleteExpressionMustBeOptional.ts, 0, 15))
|
||||
|
||||
b: number | undefined
|
||||
>b : Symbol(Foo.b, Decl(deleteExpressionMustBeOptional.ts, 1, 13))
|
||||
|
||||
c: number | null
|
||||
>c : Symbol(Foo.c, Decl(deleteExpressionMustBeOptional.ts, 2, 25))
|
||||
|
||||
d?: number
|
||||
>d : Symbol(Foo.d, Decl(deleteExpressionMustBeOptional.ts, 3, 20))
|
||||
|
||||
e: number | undefined | null
|
||||
>e : Symbol(Foo.e, Decl(deleteExpressionMustBeOptional.ts, 4, 14))
|
||||
|
||||
f?: number | undefined | null
|
||||
>f : Symbol(Foo.f, Decl(deleteExpressionMustBeOptional.ts, 5, 32))
|
||||
|
||||
g: unknown
|
||||
>g : Symbol(Foo.g, Decl(deleteExpressionMustBeOptional.ts, 6, 33))
|
||||
|
||||
h: any
|
||||
>h : Symbol(Foo.h, Decl(deleteExpressionMustBeOptional.ts, 7, 14))
|
||||
|
||||
i: never
|
||||
>i : Symbol(Foo.i, Decl(deleteExpressionMustBeOptional.ts, 8, 10))
|
||||
}
|
||||
|
||||
interface AA {
|
||||
>AA : Symbol(AA, Decl(deleteExpressionMustBeOptional.ts, 10, 1))
|
||||
|
||||
[s: string]: number
|
||||
>s : Symbol(s, Decl(deleteExpressionMustBeOptional.ts, 13, 5))
|
||||
}
|
||||
|
||||
type BB = {
|
||||
>BB : Symbol(BB, Decl(deleteExpressionMustBeOptional.ts, 14, 1))
|
||||
|
||||
[P in keyof any]: number
|
||||
>P : Symbol(P, Decl(deleteExpressionMustBeOptional.ts, 17, 5))
|
||||
}
|
||||
|
||||
declare const f: Foo
|
||||
>f : Symbol(f, Decl(deleteExpressionMustBeOptional.ts, 20, 13))
|
||||
>Foo : Symbol(Foo, Decl(deleteExpressionMustBeOptional.ts, 0, 0))
|
||||
|
||||
declare const a: AA
|
||||
>a : Symbol(a, Decl(deleteExpressionMustBeOptional.ts, 21, 13))
|
||||
>AA : Symbol(AA, Decl(deleteExpressionMustBeOptional.ts, 10, 1))
|
||||
|
||||
declare const b: BB
|
||||
>b : Symbol(b, Decl(deleteExpressionMustBeOptional.ts, 22, 13))
|
||||
>BB : Symbol(BB, Decl(deleteExpressionMustBeOptional.ts, 14, 1))
|
||||
|
||||
delete f.a
|
||||
>f.a : Symbol(Foo.a, Decl(deleteExpressionMustBeOptional.ts, 0, 15))
|
||||
>f : Symbol(f, Decl(deleteExpressionMustBeOptional.ts, 20, 13))
|
||||
>a : Symbol(Foo.a, Decl(deleteExpressionMustBeOptional.ts, 0, 15))
|
||||
|
||||
delete f.b
|
||||
>f.b : Symbol(Foo.b, Decl(deleteExpressionMustBeOptional.ts, 1, 13))
|
||||
>f : Symbol(f, Decl(deleteExpressionMustBeOptional.ts, 20, 13))
|
||||
>b : Symbol(Foo.b, Decl(deleteExpressionMustBeOptional.ts, 1, 13))
|
||||
|
||||
delete f.c
|
||||
>f.c : Symbol(Foo.c, Decl(deleteExpressionMustBeOptional.ts, 2, 25))
|
||||
>f : Symbol(f, Decl(deleteExpressionMustBeOptional.ts, 20, 13))
|
||||
>c : Symbol(Foo.c, Decl(deleteExpressionMustBeOptional.ts, 2, 25))
|
||||
|
||||
delete f.d
|
||||
>f.d : Symbol(Foo.d, Decl(deleteExpressionMustBeOptional.ts, 3, 20))
|
||||
>f : Symbol(f, Decl(deleteExpressionMustBeOptional.ts, 20, 13))
|
||||
>d : Symbol(Foo.d, Decl(deleteExpressionMustBeOptional.ts, 3, 20))
|
||||
|
||||
delete f.e
|
||||
>f.e : Symbol(Foo.e, Decl(deleteExpressionMustBeOptional.ts, 4, 14))
|
||||
>f : Symbol(f, Decl(deleteExpressionMustBeOptional.ts, 20, 13))
|
||||
>e : Symbol(Foo.e, Decl(deleteExpressionMustBeOptional.ts, 4, 14))
|
||||
|
||||
delete f.f
|
||||
>f.f : Symbol(Foo.f, Decl(deleteExpressionMustBeOptional.ts, 5, 32))
|
||||
>f : Symbol(f, Decl(deleteExpressionMustBeOptional.ts, 20, 13))
|
||||
>f : Symbol(Foo.f, Decl(deleteExpressionMustBeOptional.ts, 5, 32))
|
||||
|
||||
delete f.g
|
||||
>f.g : Symbol(Foo.g, Decl(deleteExpressionMustBeOptional.ts, 6, 33))
|
||||
>f : Symbol(f, Decl(deleteExpressionMustBeOptional.ts, 20, 13))
|
||||
>g : Symbol(Foo.g, Decl(deleteExpressionMustBeOptional.ts, 6, 33))
|
||||
|
||||
delete f.h
|
||||
>f.h : Symbol(Foo.h, Decl(deleteExpressionMustBeOptional.ts, 7, 14))
|
||||
>f : Symbol(f, Decl(deleteExpressionMustBeOptional.ts, 20, 13))
|
||||
>h : Symbol(Foo.h, Decl(deleteExpressionMustBeOptional.ts, 7, 14))
|
||||
|
||||
delete f.i
|
||||
>f.i : Symbol(Foo.i, Decl(deleteExpressionMustBeOptional.ts, 8, 10))
|
||||
>f : Symbol(f, Decl(deleteExpressionMustBeOptional.ts, 20, 13))
|
||||
>i : Symbol(Foo.i, Decl(deleteExpressionMustBeOptional.ts, 8, 10))
|
||||
|
||||
delete f.j
|
||||
>f : Symbol(f, Decl(deleteExpressionMustBeOptional.ts, 20, 13))
|
||||
|
||||
delete a.a
|
||||
>a : Symbol(a, Decl(deleteExpressionMustBeOptional.ts, 21, 13))
|
||||
|
||||
delete a.b
|
||||
>a : Symbol(a, Decl(deleteExpressionMustBeOptional.ts, 21, 13))
|
||||
|
||||
delete b.a
|
||||
>b : Symbol(b, Decl(deleteExpressionMustBeOptional.ts, 22, 13))
|
||||
|
||||
delete b.b
|
||||
>b : Symbol(b, Decl(deleteExpressionMustBeOptional.ts, 22, 13))
|
||||
|
||||
@@ -0,0 +1,137 @@
|
||||
=== tests/cases/compiler/deleteExpressionMustBeOptional.ts ===
|
||||
interface Foo {
|
||||
a: number
|
||||
>a : number
|
||||
|
||||
b: number | undefined
|
||||
>b : number
|
||||
|
||||
c: number | null
|
||||
>c : number
|
||||
>null : null
|
||||
|
||||
d?: number
|
||||
>d : number
|
||||
|
||||
e: number | undefined | null
|
||||
>e : number
|
||||
>null : null
|
||||
|
||||
f?: number | undefined | null
|
||||
>f : number
|
||||
>null : null
|
||||
|
||||
g: unknown
|
||||
>g : unknown
|
||||
|
||||
h: any
|
||||
>h : any
|
||||
|
||||
i: never
|
||||
>i : never
|
||||
}
|
||||
|
||||
interface AA {
|
||||
[s: string]: number
|
||||
>s : string
|
||||
}
|
||||
|
||||
type BB = {
|
||||
>BB : BB
|
||||
|
||||
[P in keyof any]: number
|
||||
}
|
||||
|
||||
declare const f: Foo
|
||||
>f : Foo
|
||||
|
||||
declare const a: AA
|
||||
>a : AA
|
||||
|
||||
declare const b: BB
|
||||
>b : BB
|
||||
|
||||
delete f.a
|
||||
>delete f.a : boolean
|
||||
>f.a : number
|
||||
>f : Foo
|
||||
>a : number
|
||||
|
||||
delete f.b
|
||||
>delete f.b : boolean
|
||||
>f.b : number
|
||||
>f : Foo
|
||||
>b : number
|
||||
|
||||
delete f.c
|
||||
>delete f.c : boolean
|
||||
>f.c : number
|
||||
>f : Foo
|
||||
>c : number
|
||||
|
||||
delete f.d
|
||||
>delete f.d : boolean
|
||||
>f.d : number
|
||||
>f : Foo
|
||||
>d : number
|
||||
|
||||
delete f.e
|
||||
>delete f.e : boolean
|
||||
>f.e : number
|
||||
>f : Foo
|
||||
>e : number
|
||||
|
||||
delete f.f
|
||||
>delete f.f : boolean
|
||||
>f.f : number
|
||||
>f : Foo
|
||||
>f : number
|
||||
|
||||
delete f.g
|
||||
>delete f.g : boolean
|
||||
>f.g : unknown
|
||||
>f : Foo
|
||||
>g : unknown
|
||||
|
||||
delete f.h
|
||||
>delete f.h : boolean
|
||||
>f.h : any
|
||||
>f : Foo
|
||||
>h : any
|
||||
|
||||
delete f.i
|
||||
>delete f.i : boolean
|
||||
>f.i : never
|
||||
>f : Foo
|
||||
>i : never
|
||||
|
||||
delete f.j
|
||||
>delete f.j : boolean
|
||||
>f.j : any
|
||||
>f : Foo
|
||||
>j : any
|
||||
|
||||
delete a.a
|
||||
>delete a.a : boolean
|
||||
>a.a : number
|
||||
>a : AA
|
||||
>a : number
|
||||
|
||||
delete a.b
|
||||
>delete a.b : boolean
|
||||
>a.b : number
|
||||
>a : AA
|
||||
>b : number
|
||||
|
||||
delete b.a
|
||||
>delete b.a : boolean
|
||||
>b.a : number
|
||||
>b : BB
|
||||
>a : number
|
||||
|
||||
delete b.b
|
||||
>delete b.b : boolean
|
||||
>b.b : number
|
||||
>b : BB
|
||||
>b : number
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
tests/cases/compiler/deleteExpressionMustBeOptional.ts(25,8): error TS2790: The operand of a 'delete' operator must be optional.
|
||||
tests/cases/compiler/deleteExpressionMustBeOptional.ts(27,8): error TS2790: The operand of a 'delete' operator must be optional.
|
||||
tests/cases/compiler/deleteExpressionMustBeOptional.ts(34,10): error TS2339: Property 'j' does not exist on type 'Foo'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/deleteExpressionMustBeOptional.ts (3 errors) ====
|
||||
interface Foo {
|
||||
a: number
|
||||
b: number | undefined
|
||||
c: number | null
|
||||
d?: number
|
||||
e: number | undefined | null
|
||||
f?: number | undefined | null
|
||||
g: unknown
|
||||
h: any
|
||||
i: never
|
||||
}
|
||||
|
||||
interface AA {
|
||||
[s: string]: number
|
||||
}
|
||||
|
||||
type BB = {
|
||||
[P in keyof any]: number
|
||||
}
|
||||
|
||||
declare const f: Foo
|
||||
declare const a: AA
|
||||
declare const b: BB
|
||||
|
||||
delete f.a
|
||||
~~~
|
||||
!!! error TS2790: The operand of a 'delete' operator must be optional.
|
||||
delete f.b
|
||||
delete f.c
|
||||
~~~
|
||||
!!! error TS2790: The operand of a 'delete' operator must be optional.
|
||||
delete f.d
|
||||
delete f.e
|
||||
delete f.f
|
||||
delete f.g
|
||||
delete f.h
|
||||
delete f.i
|
||||
delete f.j
|
||||
~
|
||||
!!! error TS2339: Property 'j' does not exist on type 'Foo'.
|
||||
|
||||
delete a.a
|
||||
delete a.b
|
||||
|
||||
delete b.a
|
||||
delete b.b
|
||||
@@ -0,0 +1,58 @@
|
||||
//// [deleteExpressionMustBeOptional.ts]
|
||||
interface Foo {
|
||||
a: number
|
||||
b: number | undefined
|
||||
c: number | null
|
||||
d?: number
|
||||
e: number | undefined | null
|
||||
f?: number | undefined | null
|
||||
g: unknown
|
||||
h: any
|
||||
i: never
|
||||
}
|
||||
|
||||
interface AA {
|
||||
[s: string]: number
|
||||
}
|
||||
|
||||
type BB = {
|
||||
[P in keyof any]: number
|
||||
}
|
||||
|
||||
declare const f: Foo
|
||||
declare const a: AA
|
||||
declare const b: BB
|
||||
|
||||
delete f.a
|
||||
delete f.b
|
||||
delete f.c
|
||||
delete f.d
|
||||
delete f.e
|
||||
delete f.f
|
||||
delete f.g
|
||||
delete f.h
|
||||
delete f.i
|
||||
delete f.j
|
||||
|
||||
delete a.a
|
||||
delete a.b
|
||||
|
||||
delete b.a
|
||||
delete b.b
|
||||
|
||||
//// [deleteExpressionMustBeOptional.js]
|
||||
"use strict";
|
||||
delete f.a;
|
||||
delete f.b;
|
||||
delete f.c;
|
||||
delete f.d;
|
||||
delete f.e;
|
||||
delete f.f;
|
||||
delete f.g;
|
||||
delete f.h;
|
||||
delete f.i;
|
||||
delete f.j;
|
||||
delete a.a;
|
||||
delete a.b;
|
||||
delete b.a;
|
||||
delete b.b;
|
||||
@@ -0,0 +1,118 @@
|
||||
=== tests/cases/compiler/deleteExpressionMustBeOptional.ts ===
|
||||
interface Foo {
|
||||
>Foo : Symbol(Foo, Decl(deleteExpressionMustBeOptional.ts, 0, 0))
|
||||
|
||||
a: number
|
||||
>a : Symbol(Foo.a, Decl(deleteExpressionMustBeOptional.ts, 0, 15))
|
||||
|
||||
b: number | undefined
|
||||
>b : Symbol(Foo.b, Decl(deleteExpressionMustBeOptional.ts, 1, 13))
|
||||
|
||||
c: number | null
|
||||
>c : Symbol(Foo.c, Decl(deleteExpressionMustBeOptional.ts, 2, 25))
|
||||
|
||||
d?: number
|
||||
>d : Symbol(Foo.d, Decl(deleteExpressionMustBeOptional.ts, 3, 20))
|
||||
|
||||
e: number | undefined | null
|
||||
>e : Symbol(Foo.e, Decl(deleteExpressionMustBeOptional.ts, 4, 14))
|
||||
|
||||
f?: number | undefined | null
|
||||
>f : Symbol(Foo.f, Decl(deleteExpressionMustBeOptional.ts, 5, 32))
|
||||
|
||||
g: unknown
|
||||
>g : Symbol(Foo.g, Decl(deleteExpressionMustBeOptional.ts, 6, 33))
|
||||
|
||||
h: any
|
||||
>h : Symbol(Foo.h, Decl(deleteExpressionMustBeOptional.ts, 7, 14))
|
||||
|
||||
i: never
|
||||
>i : Symbol(Foo.i, Decl(deleteExpressionMustBeOptional.ts, 8, 10))
|
||||
}
|
||||
|
||||
interface AA {
|
||||
>AA : Symbol(AA, Decl(deleteExpressionMustBeOptional.ts, 10, 1))
|
||||
|
||||
[s: string]: number
|
||||
>s : Symbol(s, Decl(deleteExpressionMustBeOptional.ts, 13, 5))
|
||||
}
|
||||
|
||||
type BB = {
|
||||
>BB : Symbol(BB, Decl(deleteExpressionMustBeOptional.ts, 14, 1))
|
||||
|
||||
[P in keyof any]: number
|
||||
>P : Symbol(P, Decl(deleteExpressionMustBeOptional.ts, 17, 5))
|
||||
}
|
||||
|
||||
declare const f: Foo
|
||||
>f : Symbol(f, Decl(deleteExpressionMustBeOptional.ts, 20, 13))
|
||||
>Foo : Symbol(Foo, Decl(deleteExpressionMustBeOptional.ts, 0, 0))
|
||||
|
||||
declare const a: AA
|
||||
>a : Symbol(a, Decl(deleteExpressionMustBeOptional.ts, 21, 13))
|
||||
>AA : Symbol(AA, Decl(deleteExpressionMustBeOptional.ts, 10, 1))
|
||||
|
||||
declare const b: BB
|
||||
>b : Symbol(b, Decl(deleteExpressionMustBeOptional.ts, 22, 13))
|
||||
>BB : Symbol(BB, Decl(deleteExpressionMustBeOptional.ts, 14, 1))
|
||||
|
||||
delete f.a
|
||||
>f.a : Symbol(Foo.a, Decl(deleteExpressionMustBeOptional.ts, 0, 15))
|
||||
>f : Symbol(f, Decl(deleteExpressionMustBeOptional.ts, 20, 13))
|
||||
>a : Symbol(Foo.a, Decl(deleteExpressionMustBeOptional.ts, 0, 15))
|
||||
|
||||
delete f.b
|
||||
>f.b : Symbol(Foo.b, Decl(deleteExpressionMustBeOptional.ts, 1, 13))
|
||||
>f : Symbol(f, Decl(deleteExpressionMustBeOptional.ts, 20, 13))
|
||||
>b : Symbol(Foo.b, Decl(deleteExpressionMustBeOptional.ts, 1, 13))
|
||||
|
||||
delete f.c
|
||||
>f.c : Symbol(Foo.c, Decl(deleteExpressionMustBeOptional.ts, 2, 25))
|
||||
>f : Symbol(f, Decl(deleteExpressionMustBeOptional.ts, 20, 13))
|
||||
>c : Symbol(Foo.c, Decl(deleteExpressionMustBeOptional.ts, 2, 25))
|
||||
|
||||
delete f.d
|
||||
>f.d : Symbol(Foo.d, Decl(deleteExpressionMustBeOptional.ts, 3, 20))
|
||||
>f : Symbol(f, Decl(deleteExpressionMustBeOptional.ts, 20, 13))
|
||||
>d : Symbol(Foo.d, Decl(deleteExpressionMustBeOptional.ts, 3, 20))
|
||||
|
||||
delete f.e
|
||||
>f.e : Symbol(Foo.e, Decl(deleteExpressionMustBeOptional.ts, 4, 14))
|
||||
>f : Symbol(f, Decl(deleteExpressionMustBeOptional.ts, 20, 13))
|
||||
>e : Symbol(Foo.e, Decl(deleteExpressionMustBeOptional.ts, 4, 14))
|
||||
|
||||
delete f.f
|
||||
>f.f : Symbol(Foo.f, Decl(deleteExpressionMustBeOptional.ts, 5, 32))
|
||||
>f : Symbol(f, Decl(deleteExpressionMustBeOptional.ts, 20, 13))
|
||||
>f : Symbol(Foo.f, Decl(deleteExpressionMustBeOptional.ts, 5, 32))
|
||||
|
||||
delete f.g
|
||||
>f.g : Symbol(Foo.g, Decl(deleteExpressionMustBeOptional.ts, 6, 33))
|
||||
>f : Symbol(f, Decl(deleteExpressionMustBeOptional.ts, 20, 13))
|
||||
>g : Symbol(Foo.g, Decl(deleteExpressionMustBeOptional.ts, 6, 33))
|
||||
|
||||
delete f.h
|
||||
>f.h : Symbol(Foo.h, Decl(deleteExpressionMustBeOptional.ts, 7, 14))
|
||||
>f : Symbol(f, Decl(deleteExpressionMustBeOptional.ts, 20, 13))
|
||||
>h : Symbol(Foo.h, Decl(deleteExpressionMustBeOptional.ts, 7, 14))
|
||||
|
||||
delete f.i
|
||||
>f.i : Symbol(Foo.i, Decl(deleteExpressionMustBeOptional.ts, 8, 10))
|
||||
>f : Symbol(f, Decl(deleteExpressionMustBeOptional.ts, 20, 13))
|
||||
>i : Symbol(Foo.i, Decl(deleteExpressionMustBeOptional.ts, 8, 10))
|
||||
|
||||
delete f.j
|
||||
>f : Symbol(f, Decl(deleteExpressionMustBeOptional.ts, 20, 13))
|
||||
|
||||
delete a.a
|
||||
>a : Symbol(a, Decl(deleteExpressionMustBeOptional.ts, 21, 13))
|
||||
|
||||
delete a.b
|
||||
>a : Symbol(a, Decl(deleteExpressionMustBeOptional.ts, 21, 13))
|
||||
|
||||
delete b.a
|
||||
>b : Symbol(b, Decl(deleteExpressionMustBeOptional.ts, 22, 13))
|
||||
|
||||
delete b.b
|
||||
>b : Symbol(b, Decl(deleteExpressionMustBeOptional.ts, 22, 13))
|
||||
|
||||
@@ -0,0 +1,137 @@
|
||||
=== tests/cases/compiler/deleteExpressionMustBeOptional.ts ===
|
||||
interface Foo {
|
||||
a: number
|
||||
>a : number
|
||||
|
||||
b: number | undefined
|
||||
>b : number | undefined
|
||||
|
||||
c: number | null
|
||||
>c : number | null
|
||||
>null : null
|
||||
|
||||
d?: number
|
||||
>d : number | undefined
|
||||
|
||||
e: number | undefined | null
|
||||
>e : number | null | undefined
|
||||
>null : null
|
||||
|
||||
f?: number | undefined | null
|
||||
>f : number | null | undefined
|
||||
>null : null
|
||||
|
||||
g: unknown
|
||||
>g : unknown
|
||||
|
||||
h: any
|
||||
>h : any
|
||||
|
||||
i: never
|
||||
>i : never
|
||||
}
|
||||
|
||||
interface AA {
|
||||
[s: string]: number
|
||||
>s : string
|
||||
}
|
||||
|
||||
type BB = {
|
||||
>BB : BB
|
||||
|
||||
[P in keyof any]: number
|
||||
}
|
||||
|
||||
declare const f: Foo
|
||||
>f : Foo
|
||||
|
||||
declare const a: AA
|
||||
>a : AA
|
||||
|
||||
declare const b: BB
|
||||
>b : BB
|
||||
|
||||
delete f.a
|
||||
>delete f.a : boolean
|
||||
>f.a : number
|
||||
>f : Foo
|
||||
>a : number
|
||||
|
||||
delete f.b
|
||||
>delete f.b : boolean
|
||||
>f.b : number | undefined
|
||||
>f : Foo
|
||||
>b : number | undefined
|
||||
|
||||
delete f.c
|
||||
>delete f.c : boolean
|
||||
>f.c : number | null
|
||||
>f : Foo
|
||||
>c : number | null
|
||||
|
||||
delete f.d
|
||||
>delete f.d : boolean
|
||||
>f.d : number | undefined
|
||||
>f : Foo
|
||||
>d : number | undefined
|
||||
|
||||
delete f.e
|
||||
>delete f.e : boolean
|
||||
>f.e : number | null | undefined
|
||||
>f : Foo
|
||||
>e : number | null | undefined
|
||||
|
||||
delete f.f
|
||||
>delete f.f : boolean
|
||||
>f.f : number | null | undefined
|
||||
>f : Foo
|
||||
>f : number | null | undefined
|
||||
|
||||
delete f.g
|
||||
>delete f.g : boolean
|
||||
>f.g : unknown
|
||||
>f : Foo
|
||||
>g : unknown
|
||||
|
||||
delete f.h
|
||||
>delete f.h : boolean
|
||||
>f.h : any
|
||||
>f : Foo
|
||||
>h : any
|
||||
|
||||
delete f.i
|
||||
>delete f.i : boolean
|
||||
>f.i : never
|
||||
>f : Foo
|
||||
>i : never
|
||||
|
||||
delete f.j
|
||||
>delete f.j : boolean
|
||||
>f.j : any
|
||||
>f : Foo
|
||||
>j : any
|
||||
|
||||
delete a.a
|
||||
>delete a.a : boolean
|
||||
>a.a : number
|
||||
>a : AA
|
||||
>a : number
|
||||
|
||||
delete a.b
|
||||
>delete a.b : boolean
|
||||
>a.b : number
|
||||
>a : AA
|
||||
>b : number
|
||||
|
||||
delete b.a
|
||||
>delete b.a : boolean
|
||||
>b.a : number
|
||||
>b : BB
|
||||
>a : number
|
||||
|
||||
delete b.b
|
||||
>delete b.b : boolean
|
||||
>b.b : number
|
||||
>b : BB
|
||||
>b : number
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user