Merge branch 'object-spread' into object-rest

This commit is contained in:
Nathan Shively-Sanders 2016-11-07 11:10:29 -08:00
commit 609cd0016b
86 changed files with 1936 additions and 592 deletions

View file

@ -76,7 +76,7 @@
"travis-fold": "latest",
"ts-node": "latest",
"tsd": "latest",
"tslint": "next",
"tslint": "4.0.0-dev.0",
"typescript": "next"
},
"scripts": {

View file

@ -1138,8 +1138,8 @@ namespace ts {
}
else if (node.kind === SyntaxKind.ArrayLiteralExpression) {
for (const e of (<ArrayLiteralExpression>node).elements) {
if (e.kind === SyntaxKind.SpreadExpression) {
bindAssignmentTargetFlow((<SpreadExpression>e).expression);
if (e.kind === SyntaxKind.SpreadElement) {
bindAssignmentTargetFlow((<SpreadElement>e).expression);
}
else {
bindDestructuringTargetFlow(e);
@ -1154,8 +1154,8 @@ namespace ts {
else if (p.kind === SyntaxKind.ShorthandPropertyAssignment) {
bindAssignmentTargetFlow((<ShorthandPropertyAssignment>p).name);
}
else if (p.kind === SyntaxKind.SpreadElementExpression) {
bindAssignmentTargetFlow((<SpreadElementExpression>p).expression);
else if (p.kind === SyntaxKind.SpreadAssignment) {
bindAssignmentTargetFlow((<SpreadAssignment>p).expression);
}
}
}
@ -1237,9 +1237,11 @@ namespace ts {
const postExpressionLabel = createBranchLabel();
bindCondition(node.condition, trueLabel, falseLabel);
currentFlow = finishFlowLabel(trueLabel);
bind(node.questionToken);
bind(node.whenTrue);
addAntecedent(postExpressionLabel, currentFlow);
currentFlow = finishFlowLabel(falseLabel);
bind(node.colonToken);
bind(node.whenFalse);
addAntecedent(postExpressionLabel, currentFlow);
currentFlow = finishFlowLabel(postExpressionLabel);
@ -1932,7 +1934,7 @@ namespace ts {
case SyntaxKind.EnumMember:
return bindPropertyOrMethodOrAccessor(<Declaration>node, SymbolFlags.EnumMember, SymbolFlags.EnumMemberExcludes);
case SyntaxKind.SpreadElementExpression:
case SyntaxKind.SpreadAssignment:
case SyntaxKind.JsxSpreadAttribute:
let root = container;
let hasRest = false;
@ -3174,9 +3176,9 @@ namespace ts {
}
break;
case SyntaxKind.SpreadExpression:
case SyntaxKind.SpreadElementExpression:
// This node is ES2015 or ES next syntax, but is handled by a containing node.
case SyntaxKind.SpreadElement:
case SyntaxKind.SpreadAssignment:
// This node is ES6 or ES next syntax, but is handled by a containing node.
transformFlags |= TransformFlags.ContainsSpreadExpression;
break;

View file

@ -107,7 +107,12 @@ namespace ts {
getJsxElementAttributesType,
getJsxIntrinsicTagNames,
isOptionalParameter
isOptionalParameter,
tryFindAmbientModuleWithoutAugmentations: moduleName => {
// we deliberately exclude augmentations
// since we are only interested in declarations of the module itself
return tryFindAmbientModule(moduleName, /*withAugmentations*/ false);
}
};
const tupleTypes: GenericType[] = [];
@ -1370,16 +1375,11 @@ namespace ts {
return;
}
const isRelative = isExternalModuleNameRelative(moduleName);
const quotedName = '"' + moduleName + '"';
if (!isRelative) {
const symbol = getSymbol(globals, quotedName, SymbolFlags.ValueModule);
if (symbol) {
// merged symbol is module declaration symbol combined with all augmentations
return getMergedSymbol(symbol);
}
const ambientModule = tryFindAmbientModule(moduleName, /*withAugmentations*/ true);
if (ambientModule) {
return ambientModule;
}
const isRelative = isExternalModuleNameRelative(moduleName);
const resolvedModule = getResolvedModule(getSourceFileOfNode(location), moduleReference);
const resolutionDiagnostic = resolvedModule && getResolutionDiagnostic(compilerOptions, resolvedModule);
const sourceFile = resolvedModule && !resolutionDiagnostic && host.getSourceFile(resolvedModule.resolvedFileName);
@ -4617,7 +4617,7 @@ namespace ts {
result.valueDeclaration = declarations[0];
}
result.isReadonly = isReadonly;
result.type = containingType.flags & TypeFlags.Intersection ? getIntersectionType(propTypes) : getUnionType(propTypes);
result.type = containingType.flags & TypeFlags.Union ? getUnionType(propTypes) : getIntersectionType(propTypes);
return result;
}
@ -4782,6 +4782,15 @@ namespace ts {
}
}
function tryFindAmbientModule(moduleName: string, withAugmentations: boolean) {
if (isExternalModuleNameRelative(moduleName)) {
return undefined;
}
const symbol = getSymbol(globals, `"${moduleName}"`, SymbolFlags.ValueModule);
// merged symbol is module declaration symbol combined with all augmentations
return symbol && withAugmentations ? getMergedSymbol(symbol) : symbol;
}
function isOptionalParameter(node: ParameterDeclaration) {
if (hasQuestionToken(node) || isJSDocOptionalParameter(node)) {
return true;
@ -5900,12 +5909,15 @@ namespace ts {
}
/**
* Since the source of spread types are object literals and type literals, which are not binary,
* Since the source of spread types are object literals, which are not binary,
* this function should be called in a left folding style, with left = previous result of getSpreadType
* and right = the new element to be spread.
*/
function getSpreadType(left: Type, right: Type, symbol: Symbol): ResolvedType {
Debug.assert(!!(left.flags & TypeFlags.Object) && !!(right.flags & TypeFlags.Object), "Only object types may be spread.");
function getSpreadType(left: Type, right: Type, symbol: Symbol): ResolvedType | IntrinsicType {
Debug.assert(!!(left.flags & (TypeFlags.Object | TypeFlags.Any)) && !!(right.flags & (TypeFlags.Object | TypeFlags.Any)), "Only object types may be spread.");
if (left.flags & TypeFlags.Any || right.flags & TypeFlags.Any) {
return anyType;
}
const members = createMap<Symbol>();
const skippedPrivateMembers = createMap<boolean>();
let stringIndexInfo: IndexInfo;
@ -6925,6 +6937,27 @@ namespace ts {
}
}
if (target.flags & TypeFlags.TypeParameter) {
// Given a type parameter K with a constraint keyof T, a type S is
// assignable to K if S is assignable to keyof T.
const constraint = getConstraintOfTypeParameter(<TypeParameter>target);
if (constraint && constraint.flags & TypeFlags.Index) {
if (result = isRelatedTo(source, constraint, reportErrors)) {
return result;
}
}
}
else if (target.flags & TypeFlags.Index) {
// Given a type parameter T with a constraint C, a type S is assignable to
// keyof T if S is assignable to keyof C.
const constraint = getConstraintOfTypeParameter((<IndexType>target).type);
if (constraint) {
if (result = isRelatedTo(source, getIndexType(constraint), reportErrors)) {
return result;
}
}
}
if (source.flags & TypeFlags.TypeParameter) {
let constraint = getConstraintOfTypeParameter(<TypeParameter>source);
@ -8657,7 +8690,7 @@ namespace ts {
return getTypeOfDestructuredArrayElement(getAssignedType(node), indexOf(node.elements, element));
}
function getAssignedTypeOfSpreadExpression(node: SpreadExpression): Type {
function getAssignedTypeOfSpreadExpression(node: SpreadElement): Type {
return getTypeOfDestructuredSpreadExpression(getAssignedType(<ArrayLiteralExpression>node.parent));
}
@ -8682,8 +8715,8 @@ namespace ts {
return undefinedType;
case SyntaxKind.ArrayLiteralExpression:
return getAssignedTypeOfArrayLiteralElement(<ArrayLiteralExpression>parent, node);
case SyntaxKind.SpreadExpression:
return getAssignedTypeOfSpreadExpression(<SpreadExpression>parent);
case SyntaxKind.SpreadElement:
return getAssignedTypeOfSpreadExpression(<SpreadElement>parent);
case SyntaxKind.PropertyAssignment:
return getAssignedTypeOfPropertyAssignment(<PropertyAssignment>parent);
case SyntaxKind.ShorthandPropertyAssignment:
@ -10714,7 +10747,7 @@ namespace ts {
return mapper && mapper.context;
}
function checkSpreadExpression(node: SpreadExpression, contextualMapper?: TypeMapper): Type {
function checkSpreadExpression(node: SpreadElement, contextualMapper?: TypeMapper): Type {
// It is usually not safe to call checkExpressionCached if we can be contextually typing.
// You can tell that we are contextually typing because of the contextualMapper parameter.
// While it is true that a spread element can have a contextual type, it does not do anything
@ -10736,7 +10769,7 @@ namespace ts {
const elementTypes: Type[] = [];
const inDestructuringPattern = isAssignmentTarget(node);
for (const e of elements) {
if (inDestructuringPattern && e.kind === SyntaxKind.SpreadExpression) {
if (inDestructuringPattern && e.kind === SyntaxKind.SpreadElement) {
// Given the following situation:
// var c: {};
// [...c] = ["", 0];
@ -10749,7 +10782,7 @@ namespace ts {
// get the contextual element type from it. So we do something similar to
// getContextualTypeForElementExpression, which will crucially not error
// if there is no index type / iterated type.
const restArrayType = checkExpression((<SpreadExpression>e).expression, contextualMapper);
const restArrayType = checkExpression((<SpreadElement>e).expression, contextualMapper);
const restElementType = getIndexTypeOfType(restArrayType, IndexKind.Number) ||
(languageVersion >= ScriptTarget.ES2015 ? getElementTypeOfIterable(restArrayType, /*errorNode*/ undefined) : undefined);
if (restElementType) {
@ -10760,7 +10793,7 @@ namespace ts {
const type = checkExpressionForMutableLocation(e, contextualMapper);
elementTypes.push(type);
}
hasSpreadElement = hasSpreadElement || e.kind === SyntaxKind.SpreadExpression;
hasSpreadElement = hasSpreadElement || e.kind === SyntaxKind.SpreadElement;
}
if (!hasSpreadElement) {
// If array literal is actually a destructuring pattern, mark it as an implied type. We do this such
@ -10944,7 +10977,7 @@ namespace ts {
prop.target = member;
member = prop;
}
else if (memberDecl.kind === SyntaxKind.SpreadElementExpression) {
else if (memberDecl.kind === SyntaxKind.SpreadAssignment) {
if (propertiesArray.length > 0) {
spread = getSpreadType(spread, createObjectLiteralType(), node.symbol);
propertiesArray = [];
@ -10953,8 +10986,8 @@ namespace ts {
hasComputedNumberProperty = false;
typeFlags = 0;
}
const type = checkExpression((memberDecl as SpreadElementExpression).expression);
if (!(type.flags & TypeFlags.Object)) {
const type = checkExpression((memberDecl as SpreadAssignment).expression);
if (!(type.flags & (TypeFlags.Object | TypeFlags.Any))) {
error(memberDecl, Diagnostics.Spread_types_may_only_be_created_from_object_types);
return unknownType;
}
@ -11649,6 +11682,21 @@ namespace ts {
diagnostics.add(createDiagnosticForNodeFromMessageChain(propNode, errorInfo));
}
function markPropertyAsReferenced(prop: Symbol) {
if (prop &&
noUnusedIdentifiers &&
(prop.flags & SymbolFlags.ClassMember) &&
prop.valueDeclaration && (getModifierFlags(prop.valueDeclaration) & ModifierFlags.Private)) {
if (prop.flags & SymbolFlags.Instantiated) {
getSymbolLinks(prop).target.isReferenced = true;
}
else {
prop.isReferenced = true;
}
}
}
function checkPropertyAccessExpressionOrQualifiedName(node: PropertyAccessExpression | QualifiedName, left: Expression | QualifiedName, right: Identifier) {
const type = checkNonNullExpression(left);
if (isTypeAny(type) || type === silentNeverType) {
@ -11668,17 +11716,7 @@ namespace ts {
return unknownType;
}
if (noUnusedIdentifiers &&
(prop.flags & SymbolFlags.ClassMember) &&
prop.valueDeclaration && (getModifierFlags(prop.valueDeclaration) & ModifierFlags.Private)) {
if (prop.flags & SymbolFlags.Instantiated) {
getSymbolLinks(prop).target.isReferenced = true;
}
else {
prop.isReferenced = true;
}
}
markPropertyAsReferenced(prop);
getNodeLinks(node).resolvedSymbol = prop;
@ -11922,7 +11960,7 @@ namespace ts {
function getSpreadArgumentIndex(args: Expression[]): number {
for (let i = 0; i < args.length; i++) {
const arg = args[i];
if (arg && arg.kind === SyntaxKind.SpreadExpression) {
if (arg && arg.kind === SyntaxKind.SpreadElement) {
return i;
}
}
@ -13888,7 +13926,7 @@ namespace ts {
error(name, Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(objectLiteralType), declarationNameToString(name));
}
}
else if (property.kind !== SyntaxKind.SpreadElementExpression) {
else if (property.kind !== SyntaxKind.SpreadAssignment) {
error(property, Diagnostics.Property_assignment_expected);
}
}
@ -13910,7 +13948,7 @@ namespace ts {
const elements = node.elements;
const element = elements[elementIndex];
if (element.kind !== SyntaxKind.OmittedExpression) {
if (element.kind !== SyntaxKind.SpreadExpression) {
if (element.kind !== SyntaxKind.SpreadElement) {
const propName = "" + elementIndex;
const type = isTypeAny(sourceType)
? sourceType
@ -13937,7 +13975,7 @@ namespace ts {
error(element, Diagnostics.A_rest_element_must_be_last_in_a_destructuring_pattern);
}
else {
const restExpression = (<SpreadExpression>element).expression;
const restExpression = (<SpreadElement>element).expression;
if (restExpression.kind === SyntaxKind.BinaryExpression && (<BinaryExpression>restExpression).operatorToken.kind === SyntaxKind.EqualsToken) {
error((<BinaryExpression>restExpression).operatorToken, Diagnostics.A_rest_element_cannot_have_an_initializer);
}
@ -14570,8 +14608,8 @@ namespace ts {
return checkBinaryExpression(<BinaryExpression>node, contextualMapper);
case SyntaxKind.ConditionalExpression:
return checkConditionalExpression(<ConditionalExpression>node, contextualMapper);
case SyntaxKind.SpreadExpression:
return checkSpreadExpression(<SpreadExpression>node, contextualMapper);
case SyntaxKind.SpreadElement:
return checkSpreadExpression(<SpreadElement>node, contextualMapper);
case SyntaxKind.OmittedExpression:
return undefinedWideningType;
case SyntaxKind.YieldExpression:
@ -16470,6 +16508,7 @@ namespace ts {
const parentType = getTypeForBindingElementParent(parent);
const name = node.propertyName || <Identifier>node.name;
const property = getPropertyOfType(parentType, getTextOfPropertyName(name));
markPropertyAsReferenced(property);
if (parent.initializer && property && getParentOfSymbol(property)) {
checkClassPropertyAccess(parent, parent.initializer, parentType, property);
}
@ -20528,7 +20567,7 @@ namespace ts {
const GetOrSetAccessor = GetAccessor | SetAccessor;
for (const prop of node.properties) {
if (prop.kind === SyntaxKind.SpreadElementExpression) {
if (prop.kind === SyntaxKind.SpreadAssignment) {
continue;
}
const name = prop.name;

View file

@ -265,6 +265,7 @@ namespace ts {
"es2015": ScriptTarget.ES2015,
"es2016": ScriptTarget.ES2016,
"es2017": ScriptTarget.ES2017,
"esnext": ScriptTarget.ESNext,
}),
description: Diagnostics.Specify_ECMAScript_target_version_Colon_ES3_default_ES5_or_ES2015,
paramType: Diagnostics.VERSION,

View file

@ -1127,6 +1127,18 @@ namespace ts {
};
}
export function createCompilerDiagnosticFromMessageChain(chain: DiagnosticMessageChain): Diagnostic {
return {
file: undefined,
start: undefined,
length: undefined,
code: chain.code,
category: chain.category,
messageText: chain.next ? chain : chain.messageText
};
}
export function chainDiagnosticMessages(details: DiagnosticMessageChain, message: DiagnosticMessage, ...args: any[]): DiagnosticMessageChain;
export function chainDiagnosticMessages(details: DiagnosticMessageChain, message: DiagnosticMessage): DiagnosticMessageChain {
let text = getLocaleSpecificMessage(message);

View file

@ -2897,6 +2897,14 @@
"category": "Error",
"code": 6143
},
"Module '{0}' was resolved as locally declared ambient module in file '{1}'.": {
"category": "Message",
"code": 6144
},
"Module '{0}' was resolved as ambient module declared in '{1}' since this file was not modified.": {
"category": "Message",
"code": 6145
},
"Variable '{0}' implicitly has an '{1}' type.": {
"category": "Error",
"code": 7005
@ -3158,5 +3166,9 @@
"Implement inherited abstract class": {
"category": "Message",
"code": 90007
},
"Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig": {
"category": "Error",
"code": 90009
}
}

View file

@ -741,6 +741,8 @@ const _super = (function (geti, seti) {
return emitPropertyAssignment(<PropertyAssignment>node);
case SyntaxKind.ShorthandPropertyAssignment:
return emitShorthandPropertyAssignment(<ShorthandPropertyAssignment>node);
case SyntaxKind.SpreadAssignment:
return emitSpreadAssignment(node as SpreadAssignment);
// Enum
case SyntaxKind.EnumMember:
@ -831,8 +833,8 @@ const _super = (function (geti, seti) {
return emitTemplateExpression(<TemplateExpression>node);
case SyntaxKind.YieldExpression:
return emitYieldExpression(<YieldExpression>node);
case SyntaxKind.SpreadExpression:
return emitSpreadExpression(<SpreadExpression>node);
case SyntaxKind.SpreadElement:
return emitSpreadExpression(<SpreadElement>node);
case SyntaxKind.ClassExpression:
return emitClassExpression(<ClassExpression>node);
case SyntaxKind.OmittedExpression:
@ -1383,7 +1385,7 @@ const _super = (function (geti, seti) {
emitExpressionWithPrefix(" ", node.expression);
}
function emitSpreadExpression(node: SpreadExpression) {
function emitSpreadExpression(node: SpreadElement) {
write("...");
emitExpression(node.expression);
}
@ -2111,6 +2113,13 @@ const _super = (function (geti, seti) {
}
}
function emitSpreadAssignment(node: SpreadAssignment) {
if (node.expression) {
write("...");
emitExpression(node.expression);
}
}
//
// Enum
//
@ -2214,7 +2223,10 @@ const _super = (function (geti, seti) {
helpersEmitted = true;
}
if (compilerOptions.jsx !== JsxEmit.Preserve && !assignEmitted && (node.flags & NodeFlags.HasSpreadAttribute)) {
if ((languageVersion < ScriptTarget.ESNext || currentSourceFile.scriptKind === ScriptKind.JSX || currentSourceFile.scriptKind === ScriptKind.TSX) &&
compilerOptions.jsx !== JsxEmit.Preserve &&
!assignEmitted &&
node.flags & NodeFlags.HasSpreadAttribute) {
writeLines(assignHelper);
assignEmitted = true;
}

View file

@ -692,12 +692,12 @@ namespace ts {
}
export function createSpread(expression: Expression, location?: TextRange) {
const node = <SpreadExpression>createNode(SyntaxKind.SpreadExpression, location);
const node = <SpreadElement>createNode(SyntaxKind.SpreadElement, location);
node.expression = parenthesizeExpressionForList(expression);
return node;
}
export function updateSpread(node: SpreadExpression, expression: Expression) {
export function updateSpread(node: SpreadElement, expression: Expression) {
if (node.expression !== expression) {
return updateNode(createSpread(expression, node), node);
}
@ -1399,14 +1399,27 @@ namespace ts {
return node;
}
export function updateShorthandPropertyAssignment(node: ShorthandPropertyAssignment, name: Identifier, objectAssignmentInitializer: Expression) {
export function createSpreadAssignment(expression: Expression, location?: TextRange) {
const node = <SpreadAssignment>createNode(SyntaxKind.SpreadAssignment, location);
node.expression = expression !== undefined ? parenthesizeExpressionForList(expression) : undefined;
return node;
}
export function updateShorthandPropertyAssignment(node: ShorthandPropertyAssignment, name: Identifier, objectAssignmentInitializer: Expression) {
if (node.name !== name || node.objectAssignmentInitializer !== objectAssignmentInitializer) {
return updateNode(createShorthandPropertyAssignment(name, objectAssignmentInitializer, node), node);
}
return node;
}
// Top-level nodes
export function updateSpreadAssignment(node: SpreadAssignment, expression: Expression) {
if (node.expression !== expression) {
return updateNode(createSpreadAssignment(expression, node), node);
}
return node;
}
// Top-level nodes
export function updateSourceFileNode(node: SourceFile, statements: Statement[]) {
if (node.statements !== statements) {

View file

@ -2,12 +2,15 @@
/// <reference path="diagnosticInformationMap.generated.ts" />
namespace ts {
function trace(host: ModuleResolutionHost, message: DiagnosticMessage, ...args: any[]): void;
function trace(host: ModuleResolutionHost): void {
/* @internal */
export function trace(host: ModuleResolutionHost, message: DiagnosticMessage, ...args: any[]): void;
export function trace(host: ModuleResolutionHost): void {
host.trace(formatMessage.apply(undefined, arguments));
}
function isTraceEnabled(compilerOptions: CompilerOptions, host: ModuleResolutionHost): boolean {
/* @internal */
export function isTraceEnabled(compilerOptions: CompilerOptions, host: ModuleResolutionHost): boolean {
return compilerOptions.traceResolution && host.trace !== undefined;
}

View file

@ -74,8 +74,8 @@ namespace ts {
visitNode(cbNode, (<ShorthandPropertyAssignment>node).questionToken) ||
visitNode(cbNode, (<ShorthandPropertyAssignment>node).equalsToken) ||
visitNode(cbNode, (<ShorthandPropertyAssignment>node).objectAssignmentInitializer);
case SyntaxKind.SpreadElementExpression:
return visitNode(cbNode, (<SpreadElementExpression>node).expression);
case SyntaxKind.SpreadAssignment:
return visitNode(cbNode, (<SpreadAssignment>node).expression);
case SyntaxKind.Parameter:
case SyntaxKind.PropertyDeclaration:
case SyntaxKind.PropertySignature:
@ -199,8 +199,8 @@ namespace ts {
visitNode(cbNode, (<ConditionalExpression>node).whenTrue) ||
visitNode(cbNode, (<ConditionalExpression>node).colonToken) ||
visitNode(cbNode, (<ConditionalExpression>node).whenFalse);
case SyntaxKind.SpreadExpression:
return visitNode(cbNode, (<SpreadExpression>node).expression);
case SyntaxKind.SpreadElement:
return visitNode(cbNode, (<SpreadElement>node).expression);
case SyntaxKind.Block:
case SyntaxKind.ModuleBlock:
return visitNodes(cbNodes, (<Block>node).statements);
@ -4130,15 +4130,15 @@ namespace ts {
return finishNode(node);
}
function parseSpreadExpression(): Expression {
const node = <SpreadExpression>createNode(SyntaxKind.SpreadExpression);
function parseSpreadElement(): Expression {
const node = <SpreadElement>createNode(SyntaxKind.SpreadElement);
parseExpected(SyntaxKind.DotDotDotToken);
node.expression = parseAssignmentExpressionOrHigher();
return finishNode(node);
}
function parseArgumentOrArrayLiteralElement(): Expression {
return token() === SyntaxKind.DotDotDotToken ? parseSpreadExpression() :
return token() === SyntaxKind.DotDotDotToken ? parseSpreadElement() :
token() === SyntaxKind.CommaToken ? <Expression>createNode(SyntaxKind.OmittedExpression) :
parseAssignmentExpressionOrHigher();
}
@ -4173,7 +4173,7 @@ namespace ts {
const fullStart = scanner.getStartPos();
const dotDotDotToken = parseOptionalToken(SyntaxKind.DotDotDotToken);
if (dotDotDotToken) {
const spreadElement = <SpreadElementExpression>createNode(SyntaxKind.SpreadElementExpression, fullStart);
const spreadElement = <SpreadAssignment>createNode(SyntaxKind.SpreadAssignment, fullStart);
spreadElement.expression = parseAssignmentExpressionOrHigher();
return addJSDocComment(finishNode(spreadElement));
}

View file

@ -239,11 +239,11 @@ namespace ts {
const { line, character } = getLineAndCharacterOfPosition(diagnostic.file, diagnostic.start);
const fileName = diagnostic.file.fileName;
const relativeFileName = convertToRelativePath(fileName, host.getCurrentDirectory(), fileName => host.getCanonicalFileName(fileName));
output += `${ relativeFileName }(${ line + 1 },${ character + 1 }): `;
output += `${relativeFileName}(${line + 1},${character + 1}): `;
}
const category = DiagnosticCategory[diagnostic.category].toLowerCase();
output += `${ category } TS${ diagnostic.code }: ${ flattenDiagnosticMessageText(diagnostic.messageText, host.getNewLine()) }${ host.getNewLine() }`;
output += `${category} TS${diagnostic.code}: ${flattenDiagnosticMessageText(diagnostic.messageText, host.getNewLine())}${host.getNewLine()}`;
}
return output;
}
@ -462,6 +462,130 @@ namespace ts {
return classifiableNames;
}
interface OldProgramState {
program: Program;
file: SourceFile;
modifiedFilePaths: Path[];
}
function resolveModuleNamesReusingOldState(moduleNames: string[], containingFile: string, file: SourceFile, oldProgramState?: OldProgramState) {
if (!oldProgramState && !file.ambientModuleNames.length) {
// if old program state is not supplied and file does not contain locally defined ambient modules
// then the best we can do is fallback to the default logic
return resolveModuleNamesWorker(moduleNames, containingFile);
}
// at this point we know that either
// - file has local declarations for ambient modules
// OR
// - old program state is available
// OR
// - both of items above
// With this it is possible that we can tell how some module names from the initial list will be resolved
// without doing actual resolution (in particular if some name was resolved to ambient module).
// Such names should be excluded from the list of module names that will be provided to `resolveModuleNamesWorker`
// since we don't want to resolve them again.
// this is a list of modules for which we cannot predict resolution so they should be actually resolved
let unknownModuleNames: string[];
// this is a list of combined results assembles from predicted and resolved results.
// Order in this list matches the order in the original list of module names `moduleNames` which is important
// so later we can split results to resolutions of modules and resolutions of module augmentations.
let result: ResolvedModuleFull[];
// a transient placeholder that is used to mark predicted resolution in the result list
const predictedToResolveToAmbientModuleMarker: ResolvedModuleFull = <any>{};
for (let i = 0; i < moduleNames.length; i++) {
const moduleName = moduleNames[i];
// module name is known to be resolved to ambient module if
// - module name is contained in the list of ambient modules that are locally declared in the file
// - in the old program module name was resolved to ambient module whose declaration is in non-modified file
// (so the same module declaration will land in the new program)
let isKnownToResolveToAmbientModule = false;
if (contains(file.ambientModuleNames, moduleName)) {
isKnownToResolveToAmbientModule = true;
if (isTraceEnabled(options, host)) {
trace(host, Diagnostics.Module_0_was_resolved_as_locally_declared_ambient_module_in_file_1, moduleName, containingFile);
}
}
else {
isKnownToResolveToAmbientModule = checkModuleNameResolvedToAmbientModuleInNonModifiedFile(moduleName, oldProgramState);
}
if (isKnownToResolveToAmbientModule) {
if (!unknownModuleNames) {
// found a first module name for which result can be prediced
// this means that this module name should not be passed to `resolveModuleNamesWorker`.
// We'll use a separate list for module names that are definitely unknown.
result = new Array(moduleNames.length);
// copy all module names that appear before the current one in the list
// since they are known to be unknown
unknownModuleNames = moduleNames.slice(0, i);
}
// mark prediced resolution in the result list
result[i] = predictedToResolveToAmbientModuleMarker;
}
else if (unknownModuleNames) {
// found unknown module name and we are already using separate list for those - add it to the list
unknownModuleNames.push(moduleName);
}
}
if (!unknownModuleNames) {
// we've looked throught the list but have not seen any predicted resolution
// use default logic
return resolveModuleNamesWorker(moduleNames, containingFile);
}
const resolutions = unknownModuleNames.length
? resolveModuleNamesWorker(unknownModuleNames, containingFile)
: emptyArray;
// combine results of resolutions and predicted results
let j = 0;
for (let i = 0; i < result.length; i++) {
if (result[i] == predictedToResolveToAmbientModuleMarker) {
result[i] = undefined;
}
else {
result[i] = resolutions[j];
j++;
}
}
Debug.assert(j === resolutions.length);
return result;
function checkModuleNameResolvedToAmbientModuleInNonModifiedFile(moduleName: string, oldProgramState?: OldProgramState): boolean {
if (!oldProgramState) {
return false;
}
const resolutionToFile = getResolvedModule(oldProgramState.file, moduleName);
if (resolutionToFile) {
// module used to be resolved to file - ignore it
return false;
}
const ambientModule = oldProgram.getTypeChecker().tryFindAmbientModuleWithoutAugmentations(moduleName);
if (!(ambientModule && ambientModule.declarations)) {
return false;
}
// at least one of declarations should come from non-modified source file
const firstUnmodifiedFile = forEach(ambientModule.declarations, d => {
const f = getSourceFileOfNode(d);
return !contains(oldProgramState.modifiedFilePaths, f.path) && f;
});
if (!firstUnmodifiedFile) {
return false;
}
if (isTraceEnabled(options, host)) {
trace(host, Diagnostics.Module_0_was_resolved_as_ambient_module_declared_in_1_since_this_file_was_not_modified, moduleName, firstUnmodifiedFile.fileName);
}
return true;
}
}
function tryReuseStructureFromOldProgram(): boolean {
if (!oldProgram) {
return false;
@ -489,7 +613,7 @@ namespace ts {
// check if program source files has changed in the way that can affect structure of the program
const newSourceFiles: SourceFile[] = [];
const filePaths: Path[] = [];
const modifiedSourceFiles: SourceFile[] = [];
const modifiedSourceFiles: { oldFile: SourceFile, newFile: SourceFile }[] = [];
for (const oldSourceFile of oldProgram.getSourceFiles()) {
let newSourceFile = host.getSourceFileByPath
@ -532,29 +656,8 @@ namespace ts {
return false;
}
const newSourceFilePath = getNormalizedAbsolutePath(newSourceFile.fileName, currentDirectory);
if (resolveModuleNamesWorker) {
const moduleNames = map(concatenate(newSourceFile.imports, newSourceFile.moduleAugmentations), getTextOfLiteral);
const resolutions = resolveModuleNamesWorker(moduleNames, newSourceFilePath);
// ensure that module resolution results are still correct
const resolutionsChanged = hasChangesInResolutions(moduleNames, resolutions, oldSourceFile.resolvedModules, moduleResolutionIsEqualTo);
if (resolutionsChanged) {
return false;
}
}
if (resolveTypeReferenceDirectiveNamesWorker) {
const typesReferenceDirectives = map(newSourceFile.typeReferenceDirectives, x => x.fileName);
const resolutions = resolveTypeReferenceDirectiveNamesWorker(typesReferenceDirectives, newSourceFilePath);
// ensure that types resolutions are still correct
const resolutionsChanged = hasChangesInResolutions(typesReferenceDirectives, resolutions, oldSourceFile.resolvedTypeReferenceDirectiveNames, typeDirectiveIsEqualTo);
if (resolutionsChanged) {
return false;
}
}
// pass the cache of module/types resolutions from the old source file
newSourceFile.resolvedModules = oldSourceFile.resolvedModules;
newSourceFile.resolvedTypeReferenceDirectiveNames = oldSourceFile.resolvedTypeReferenceDirectiveNames;
modifiedSourceFiles.push(newSourceFile);
// tentatively approve the file
modifiedSourceFiles.push({ oldFile: oldSourceFile, newFile: newSourceFile });
}
else {
// file has no changes - use it as is
@ -565,6 +668,33 @@ namespace ts {
newSourceFiles.push(newSourceFile);
}
const modifiedFilePaths = modifiedSourceFiles.map(f => f.newFile.path);
// try to verify results of module resolution
for (const { oldFile: oldSourceFile, newFile: newSourceFile } of modifiedSourceFiles) {
const newSourceFilePath = getNormalizedAbsolutePath(newSourceFile.fileName, currentDirectory);
if (resolveModuleNamesWorker) {
const moduleNames = map(concatenate(newSourceFile.imports, newSourceFile.moduleAugmentations), getTextOfLiteral);
const resolutions = resolveModuleNamesReusingOldState(moduleNames, newSourceFilePath, newSourceFile, { file: oldSourceFile, program: oldProgram, modifiedFilePaths });
// ensure that module resolution results are still correct
const resolutionsChanged = hasChangesInResolutions(moduleNames, resolutions, oldSourceFile.resolvedModules, moduleResolutionIsEqualTo);
if (resolutionsChanged) {
return false;
}
}
if (resolveTypeReferenceDirectiveNamesWorker) {
const typesReferenceDirectives = map(newSourceFile.typeReferenceDirectives, x => x.fileName);
const resolutions = resolveTypeReferenceDirectiveNamesWorker(typesReferenceDirectives, newSourceFilePath);
// ensure that types resolutions are still correct
const resolutionsChanged = hasChangesInResolutions(typesReferenceDirectives, resolutions, oldSourceFile.resolvedTypeReferenceDirectiveNames, typeDirectiveIsEqualTo);
if (resolutionsChanged) {
return false;
}
}
// pass the cache of module/types resolutions from the old source file
newSourceFile.resolvedModules = oldSourceFile.resolvedModules;
newSourceFile.resolvedTypeReferenceDirectiveNames = oldSourceFile.resolvedTypeReferenceDirectiveNames;
}
// update fileName -> file mapping
for (let i = 0, len = newSourceFiles.length; i < len; i++) {
filesByName.set(filePaths[i], newSourceFiles[i]);
@ -574,7 +704,7 @@ namespace ts {
fileProcessingDiagnostics = oldProgram.getFileProcessingDiagnostics();
for (const modifiedFile of modifiedSourceFiles) {
fileProcessingDiagnostics.reattachFileDiagnostics(modifiedFile);
fileProcessingDiagnostics.reattachFileDiagnostics(modifiedFile.newFile);
}
resolvedTypeReferenceDirectives = oldProgram.getResolvedTypeReferenceDirectives();
oldProgram.structureIsReused = true;
@ -994,9 +1124,11 @@ namespace ts {
const isJavaScriptFile = isSourceFileJavaScript(file);
const isExternalModuleFile = isExternalModule(file);
const isDtsFile = isDeclarationFile(file);
let imports: LiteralExpression[];
let moduleAugmentations: LiteralExpression[];
let ambientModules: string[];
// If we are importing helpers, we need to add a synthetic reference to resolve the
// helpers library.
@ -1018,6 +1150,7 @@ namespace ts {
file.imports = imports || emptyArray;
file.moduleAugmentations = moduleAugmentations || emptyArray;
file.ambientModuleNames = ambientModules || emptyArray;
return;
@ -1053,6 +1186,10 @@ namespace ts {
(moduleAugmentations || (moduleAugmentations = [])).push(moduleName);
}
else if (!inAmbientModule) {
if (isDtsFile) {
// for global .d.ts files record name of ambient module
(ambientModules || (ambientModules = [])).push(moduleName.text);
}
// An AmbientExternalModuleDeclaration declares an external module.
// This type of declaration is permitted only in the global module.
// The StringLiteral must specify a top - level external module name.
@ -1298,7 +1435,7 @@ namespace ts {
if (file.imports.length || file.moduleAugmentations.length) {
file.resolvedModules = createMap<ResolvedModuleFull>();
const moduleNames = map(concatenate(file.imports, file.moduleAugmentations), getTextOfLiteral);
const resolutions = resolveModuleNamesWorker(moduleNames, getNormalizedAbsolutePath(file.fileName, currentDirectory));
const resolutions = resolveModuleNamesReusingOldState(moduleNames, getNormalizedAbsolutePath(file.fileName, currentDirectory), file);
Debug.assert(resolutions.length === moduleNames.length);
for (let i = 0; i < moduleNames.length; i++) {
const resolution = resolutions[i];
@ -1548,13 +1685,24 @@ namespace ts {
const emitFilePath = toPath(emitFileName, currentDirectory, getCanonicalFileName);
// Report error if the output overwrites input file
if (filesByName.contains(emitFilePath)) {
createEmitBlockingDiagnostics(emitFileName, Diagnostics.Cannot_write_file_0_because_it_would_overwrite_input_file);
if (options.noEmitOverwritenFiles && !options.out && !options.outDir && !options.outFile) {
blockEmittingOfFile(emitFileName);
}
else {
let chain: DiagnosticMessageChain;
if (!options.configFilePath) {
// The program is from either an inferred project or an external project
chain = chainDiagnosticMessages(/*details*/ undefined, Diagnostics.Adding_a_tsconfig_json_file_will_help_organize_projects_that_contain_both_TypeScript_and_JavaScript_files_Learn_more_at_https_Colon_Slash_Slashaka_ms_Slashtsconfig);
}
chain = chainDiagnosticMessages(chain, Diagnostics.Cannot_write_file_0_because_it_would_overwrite_input_file, emitFileName);
blockEmittingOfFile(emitFileName, createCompilerDiagnosticFromMessageChain(chain));
}
}
// Report error if multiple files write into same file
if (emitFilesSeen.contains(emitFilePath)) {
// Already seen the same emit file - report error
createEmitBlockingDiagnostics(emitFileName, Diagnostics.Cannot_write_file_0_because_it_would_be_overwritten_by_multiple_input_files);
blockEmittingOfFile(emitFileName, createCompilerDiagnostic(Diagnostics.Cannot_write_file_0_because_it_would_be_overwritten_by_multiple_input_files, emitFileName));
}
else {
emitFilesSeen.set(emitFilePath, true);
@ -1563,9 +1711,11 @@ namespace ts {
}
}
function createEmitBlockingDiagnostics(emitFileName: string, message: DiagnosticMessage) {
function blockEmittingOfFile(emitFileName: string, diag?: Diagnostic) {
hasEmitBlockingDiagnostics.set(toPath(emitFileName, currentDirectory, getCanonicalFileName), true);
programDiagnostics.add(createCompilerDiagnostic(message, emitFileName));
if (diag) {
programDiagnostics.add(diag);
}
}
}

View file

@ -117,7 +117,10 @@ namespace ts {
transformers.push(transformJsx);
}
transformers.push(transformESNext);
if (languageVersion < ScriptTarget.ESNext) {
transformers.push(transformESNext);
}
if (languageVersion < ScriptTarget.ES2017) {
transformers.push(transformES2017);
}

View file

@ -325,13 +325,13 @@ namespace ts {
emitDestructuringAssignment(bindingTarget, createDestructuringPropertyAccess(value, propName), p);
}
}
else if (i === properties.length - 1 && p.kind === SyntaxKind.SpreadElementExpression) {
Debug.assert((p as SpreadElementExpression).expression.kind === SyntaxKind.Identifier);
else if (i === properties.length - 1 && p.kind === SyntaxKind.SpreadAssignment) {
Debug.assert((p as SpreadAssignment).expression.kind === SyntaxKind.Identifier);
if (es2015.length) {
emitRestAssignment(es2015, value, location, target);
es2015 = [];
}
const propName = (p as SpreadElementExpression).expression as Identifier;
const propName = (p as SpreadAssignment).expression as Identifier;
const restCall = createRestCall(value, target.properties, p => p.name, target);
emitDestructuringAssignment(propName, restCall, p);
}
@ -356,11 +356,11 @@ namespace ts {
const e = elements[i];
if (e.kind !== SyntaxKind.OmittedExpression) {
// Assignment for target = value.propName should highligh whole property, hence use e as source map node
if (e.kind !== SyntaxKind.SpreadExpression) {
if (e.kind !== SyntaxKind.SpreadElement) {
emitDestructuringAssignment(e, createElementAccess(value, createLiteral(i)), e);
}
else if (i === numElements - 1) {
emitDestructuringAssignment((<SpreadExpression>e).expression, createArraySlice(value, i), e);
emitDestructuringAssignment((<SpreadElement>e).expression, createArraySlice(value, i), e);
}
}
}

View file

@ -2400,7 +2400,7 @@ namespace ts {
*
* @param node A SpreadExpression node.
*/
function visitExpressionOfSpread(node: SpreadExpression) {
function visitExpressionOfSpread(node: SpreadElement) {
return visitNode(node.expression, visitor, isExpression);
}
@ -2776,11 +2776,11 @@ namespace ts {
}
const callArgument = singleOrUndefined((<CallExpression>statementExpression).arguments);
if (!callArgument || !nodeIsSynthesized(callArgument) || callArgument.kind !== SyntaxKind.SpreadExpression) {
if (!callArgument || !nodeIsSynthesized(callArgument) || callArgument.kind !== SyntaxKind.SpreadElement) {
return false;
}
const expression = (<SpreadExpression>callArgument).expression;
const expression = (<SpreadElement>callArgument).expression;
return isIdentifier(expression) && expression === parameter.name;
}
}

View file

@ -58,12 +58,12 @@ namespace ts {
let chunkObject: (ShorthandPropertyAssignment | PropertyAssignment)[];
const objects: Expression[] = [];
for (const e of elements) {
if (e.kind === SyntaxKind.SpreadElementExpression) {
if (e.kind === SyntaxKind.SpreadAssignment) {
if (chunkObject) {
objects.push(createObjectLiteral(chunkObject));
chunkObject = undefined;
}
const target = (e as SpreadElementExpression).expression;
const target = (e as SpreadAssignment).expression;
objects.push(visitNode(target, visitor, isExpression));
}
else {

View file

@ -246,7 +246,7 @@ namespace ts {
ConditionalExpression,
TemplateExpression,
YieldExpression,
SpreadExpression,
SpreadElement,
ClassExpression,
OmittedExpression,
ExpressionWithTypeArguments,
@ -320,7 +320,7 @@ namespace ts {
// Property assignments
PropertyAssignment,
ShorthandPropertyAssignment,
SpreadElementExpression,
SpreadAssignment,
// Enum
EnumMember,
@ -663,7 +663,6 @@ namespace ts {
initializer?: Expression; // Optional initializer
}
// @kind(SyntaxKind.PropertyDeclaration)
export interface PropertyDeclaration extends ClassElement {
kind: SyntaxKind.PropertyDeclaration;
questionToken?: QuestionToken; // Present for use with reporting a grammar error
@ -677,7 +676,7 @@ namespace ts {
name?: PropertyName;
}
export type ObjectLiteralElementLike = PropertyAssignment | ShorthandPropertyAssignment | MethodDeclaration | AccessorDeclaration | SpreadElementExpression;
export type ObjectLiteralElementLike = PropertyAssignment | ShorthandPropertyAssignment | MethodDeclaration | AccessorDeclaration | SpreadAssignment;
export interface PropertyAssignment extends ObjectLiteralElement {
kind: SyntaxKind.PropertyAssignment;
@ -696,8 +695,8 @@ namespace ts {
objectAssignmentInitializer?: Expression;
}
export interface SpreadElementExpression extends ObjectLiteralElement {
kind: SyntaxKind.SpreadElementExpression;
export interface SpreadAssignment extends ObjectLiteralElement {
kind: SyntaxKind.SpreadAssignment;
expression: Expression;
}
@ -1286,9 +1285,8 @@ namespace ts {
multiLine?: boolean;
}
// @kind(SyntaxKind.SpreadExpression)
export interface SpreadExpression extends Expression {
kind: SyntaxKind.SpreadExpression;
export interface SpreadElement extends Expression {
kind: SyntaxKind.SpreadElement;
expression: Expression;
}
@ -2110,6 +2108,7 @@ namespace ts {
/* @internal */ imports: LiteralExpression[];
/* @internal */ moduleAugmentations: LiteralExpression[];
/* @internal */ patternAmbientModules?: PatternAmbientModule[];
/* @internal */ ambientModuleNames: string[];
// The synthesized identifier for an imported external helpers module.
/* @internal */ externalHelpersModuleName?: Identifier;
}
@ -2304,6 +2303,8 @@ namespace ts {
isOptionalParameter(node: ParameterDeclaration): boolean;
getAmbientModules(): Symbol[];
/* @internal */ tryFindAmbientModuleWithoutAugmentations(moduleName: string): Symbol;
// Should not be called directly. Should only be accessed through the Program instance.
/* @internal */ getDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): Diagnostic[];
/* @internal */ getGlobalDiagnostics(): Diagnostic[];
@ -2723,7 +2724,7 @@ namespace ts {
EnumLike = Enum | EnumLiteral,
UnionOrIntersection = Union | Intersection,
StructuredType = Object | Union | Intersection,
StructuredOrTypeParameter = StructuredType | TypeParameter,
StructuredOrTypeParameter = StructuredType | TypeParameter | Index,
// 'Narrowable' types are types where narrowing actually narrows.
// This *should* be every type other than null, undefined, void, and never
@ -3072,6 +3073,7 @@ namespace ts {
moduleResolution?: ModuleResolutionKind;
newLine?: NewLineKind;
noEmit?: boolean;
/*@internal*/noEmitOverwritenFiles?: boolean;
noEmitHelpers?: boolean;
noEmitOnError?: boolean;
noErrorTruncation?: boolean;
@ -3174,7 +3176,8 @@ namespace ts {
ES2015 = 2,
ES2016 = 3,
ES2017 = 4,
Latest = ES2017,
ESNext = 5,
Latest = ESNext,
}
export const enum LanguageVariant {

View file

@ -1195,7 +1195,7 @@ namespace ts {
case SyntaxKind.PostfixUnaryExpression:
case SyntaxKind.BinaryExpression:
case SyntaxKind.ConditionalExpression:
case SyntaxKind.SpreadExpression:
case SyntaxKind.SpreadElement:
case SyntaxKind.TemplateExpression:
case SyntaxKind.NoSubstitutionTemplateLiteral:
case SyntaxKind.OmittedExpression:
@ -1657,7 +1657,7 @@ namespace ts {
return (<ForInStatement | ForOfStatement>parent).initializer === node ? AssignmentKind.Definite : AssignmentKind.None;
case SyntaxKind.ParenthesizedExpression:
case SyntaxKind.ArrayLiteralExpression:
case SyntaxKind.SpreadExpression:
case SyntaxKind.SpreadElement:
node = parent;
break;
case SyntaxKind.ShorthandPropertyAssignment:
@ -2242,7 +2242,7 @@ namespace ts {
case SyntaxKind.YieldExpression:
return 2;
case SyntaxKind.SpreadExpression:
case SyntaxKind.SpreadElement:
return 1;
default:
@ -3878,7 +3878,7 @@ namespace ts {
const kind = node.kind;
return kind === SyntaxKind.PropertyAssignment
|| kind === SyntaxKind.ShorthandPropertyAssignment
|| kind === SyntaxKind.SpreadElementExpression
|| kind === SyntaxKind.SpreadAssignment
|| kind === SyntaxKind.MethodDeclaration
|| kind === SyntaxKind.GetAccessor
|| kind === SyntaxKind.SetAccessor
@ -3966,8 +3966,8 @@ namespace ts {
|| kind === SyntaxKind.NoSubstitutionTemplateLiteral;
}
export function isSpreadExpression(node: Node): node is SpreadExpression {
return node.kind === SyntaxKind.SpreadExpression;
export function isSpreadExpression(node: Node): node is SpreadElement {
return node.kind === SyntaxKind.SpreadElement;
}
export function isExpressionWithTypeArguments(node: Node): node is ExpressionWithTypeArguments {
@ -4025,7 +4025,7 @@ namespace ts {
|| kind === SyntaxKind.YieldExpression
|| kind === SyntaxKind.ArrowFunction
|| kind === SyntaxKind.BinaryExpression
|| kind === SyntaxKind.SpreadExpression
|| kind === SyntaxKind.SpreadElement
|| kind === SyntaxKind.AsExpression
|| kind === SyntaxKind.OmittedExpression
|| isUnaryExpressionKind(kind);

View file

@ -267,9 +267,9 @@ namespace ts {
case SyntaxKind.VoidExpression:
case SyntaxKind.AwaitExpression:
case SyntaxKind.YieldExpression:
case SyntaxKind.SpreadExpression:
case SyntaxKind.SpreadElement:
case SyntaxKind.NonNullExpression:
result = reduceNode((<ParenthesizedExpression | DeleteExpression | TypeOfExpression | VoidExpression | AwaitExpression | YieldExpression | SpreadExpression | NonNullExpression>node).expression, f, result);
result = reduceNode((<ParenthesizedExpression | DeleteExpression | TypeOfExpression | VoidExpression | AwaitExpression | YieldExpression | SpreadElement | NonNullExpression>node).expression, f, result);
break;
case SyntaxKind.PrefixUnaryExpression:
@ -510,6 +510,10 @@ namespace ts {
result = reduceNode((<ShorthandPropertyAssignment>node).objectAssignmentInitializer, f, result);
break;
case SyntaxKind.SpreadAssignment:
result = reduceNode((node as SpreadAssignment).expression, f, result);
break;
// Top-level nodes
case SyntaxKind.SourceFile:
result = reduceLeft((<SourceFile>node).statements, f, result);
@ -553,6 +557,7 @@ namespace ts {
return undefined;
}
aggregateTransformFlags(node);
const visited = visitor(node);
if (visited === node) {
return node;
@ -621,6 +626,7 @@ namespace ts {
// Visit each original node.
for (let i = 0; i < count; i++) {
const node = nodes[i + start];
aggregateTransformFlags(node);
const visited = node !== undefined ? visitor(node) : undefined;
if (updated !== undefined || visited === undefined || visited !== node) {
if (updated === undefined) {
@ -870,9 +876,9 @@ namespace ts {
return updateYield(<YieldExpression>node,
visitNode((<YieldExpression>node).expression, visitor, isExpression));
case SyntaxKind.SpreadExpression:
return updateSpread(<SpreadExpression>node,
visitNode((<SpreadExpression>node).expression, visitor, isExpression));
case SyntaxKind.SpreadElement:
return updateSpread(<SpreadElement>node,
visitNode((<SpreadElement>node).expression, visitor, isExpression));
case SyntaxKind.ClassExpression:
return updateClassExpression(<ClassExpression>node,
@ -1125,7 +1131,11 @@ namespace ts {
visitNode((<ShorthandPropertyAssignment>node).name, visitor, isIdentifier),
visitNode((<ShorthandPropertyAssignment>node).objectAssignmentInitializer, visitor, isExpression));
// Top-level nodes
case SyntaxKind.SpreadAssignment:
return updateSpreadAssignment(node as SpreadAssignment,
visitNode((node as SpreadAssignment).expression, visitor, isExpression));
// Top-level nodes
case SyntaxKind.SourceFile:
context.startLexicalEnvironment();
return updateSourceFileNode(<SourceFile>node,

View file

@ -1253,7 +1253,18 @@ namespace FourSlash {
resultString += "Diagnostics:" + Harness.IO.newLine();
const diagnostics = ts.getPreEmitDiagnostics(this.languageService.getProgram());
for (const diagnostic of diagnostics) {
resultString += " " + diagnostic.messageText + Harness.IO.newLine();
if (typeof diagnostic.messageText !== "string") {
let chainedMessage = <ts.DiagnosticMessageChain>diagnostic.messageText;
let indentation = " ";
while (chainedMessage) {
resultString += indentation + chainedMessage.messageText + Harness.IO.newLine();
chainedMessage = chainedMessage.next;
indentation = indentation + " ";
}
}
else {
resultString += " " + diagnostic.messageText + Harness.IO.newLine();
}
}
}

View file

@ -165,7 +165,7 @@ namespace ts {
start: undefined,
length: undefined,
}, {
messageText: "Argument for '--target' option must be: 'es3', 'es5', 'es6', 'es2015', 'es2016', 'es2017'",
messageText: "Argument for '--target' option must be: 'es3', 'es5', 'es6', 'es2015', 'es2016', 'es2017', 'esnext'",
category: ts.Diagnostics.Argument_for_0_option_must_be_Colon_1.category,
code: ts.Diagnostics.Argument_for_0_option_must_be_Colon_1.code,

View file

@ -176,7 +176,7 @@ namespace ts {
file: undefined,
start: 0,
length: 0,
messageText: "Argument for '--target' option must be: 'es3', 'es5', 'es6', 'es2015', 'es2016', 'es2017'",
messageText: "Argument for '--target' option must be: 'es3', 'es5', 'es6', 'es2015', 'es2016', 'es2017', 'esnext'",
code: Diagnostics.Argument_for_0_option_must_be_Colon_1.code,
category: Diagnostics.Argument_for_0_option_must_be_Colon_1.category
}]

View file

@ -1065,5 +1065,69 @@ import b = require("./moduleB");
assert.equal(diagnostics2.length, 1, "expected one diagnostic");
assert.equal(diagnostics1[0].messageText, diagnostics2[0].messageText, "expected one diagnostic");
});
it ("Modules in the same .d.ts file are preferred to external files", () => {
const f = {
name: "/a/b/c/c/app.d.ts",
content: `
declare module "fs" {
export interface Stat { id: number }
}
declare module "fs-client" {
import { Stat } from "fs";
export function foo(): Stat;
}`
};
const file = createSourceFile(f.name, f.content, ScriptTarget.ES2015);
const compilerHost: CompilerHost = {
fileExists : fileName => fileName === file.fileName,
getSourceFile: fileName => fileName === file.fileName ? file : undefined,
getDefaultLibFileName: () => "lib.d.ts",
writeFile: notImplemented,
getCurrentDirectory: () => "/",
getDirectories: () => [],
getCanonicalFileName: f => f.toLowerCase(),
getNewLine: () => "\r\n",
useCaseSensitiveFileNames: () => false,
readFile: fileName => fileName === file.fileName ? file.text : undefined,
resolveModuleNames() {
assert(false, "resolveModuleNames should not be called");
return undefined;
}
};
createProgram([f.name], {}, compilerHost);
});
it ("Modules in .ts file are not checked in the same file", () => {
const f = {
name: "/a/b/c/c/app.ts",
content: `
declare module "fs" {
export interface Stat { id: number }
}
declare module "fs-client" {
import { Stat } from "fs";
export function foo(): Stat;
}`
};
const file = createSourceFile(f.name, f.content, ScriptTarget.ES2015);
const compilerHost: CompilerHost = {
fileExists : fileName => fileName === file.fileName,
getSourceFile: fileName => fileName === file.fileName ? file : undefined,
getDefaultLibFileName: () => "lib.d.ts",
writeFile: notImplemented,
getCurrentDirectory: () => "/",
getDirectories: () => [],
getCanonicalFileName: f => f.toLowerCase(),
getNewLine: () => "\r\n",
useCaseSensitiveFileNames: () => false,
readFile: fileName => fileName === file.fileName ? file.text : undefined,
resolveModuleNames(moduleNames: string[], _containingFile: string) {
assert.deepEqual(moduleNames, ["fs"]);
return [undefined];
}
};
createProgram([f.name], {}, compilerHost);
});
});
}

View file

@ -22,6 +22,11 @@ namespace ts {
interface ProgramWithSourceTexts extends Program {
sourceTexts?: NamedSourceText[];
host: TestCompilerHost;
}
interface TestCompilerHost extends CompilerHost {
getTrace(): string[];
}
class SourceText implements IScriptSnapshot {
@ -101,10 +106,21 @@ namespace ts {
return file;
}
function createTestCompilerHost(texts: NamedSourceText[], target: ScriptTarget): CompilerHost {
const files = arrayToMap(texts, t => t.name, t => createSourceFileWithText(t.name, t.text, target));
function createTestCompilerHost(texts: NamedSourceText[], target: ScriptTarget, oldProgram?: ProgramWithSourceTexts): TestCompilerHost {
const files = arrayToMap(texts, t => t.name, t => {
if (oldProgram) {
const oldFile = <SourceFileWithText>oldProgram.getSourceFile(t.name);
if (oldFile && oldFile.sourceText.getVersion() === t.text.getVersion()) {
return oldFile;
}
}
return createSourceFileWithText(t.name, t.text, target);
});
const trace: string[] = [];
return {
trace: s => trace.push(s),
getTrace: () => trace,
getSourceFile(fileName): SourceFile {
return files[fileName];
},
@ -130,23 +146,25 @@ namespace ts {
fileExists: fileName => fileName in files,
readFile: fileName => {
return fileName in files ? files[fileName].text : undefined;
}
},
};
}
function newProgram(texts: NamedSourceText[], rootNames: string[], options: CompilerOptions): Program {
function newProgram(texts: NamedSourceText[], rootNames: string[], options: CompilerOptions): ProgramWithSourceTexts {
const host = createTestCompilerHost(texts, options.target);
const program = <ProgramWithSourceTexts>createProgram(rootNames, options, host);
program.sourceTexts = texts;
program.host = host;
return program;
}
function updateProgram(oldProgram: Program, rootNames: string[], options: CompilerOptions, updater: (files: NamedSourceText[]) => void) {
function updateProgram(oldProgram: ProgramWithSourceTexts, rootNames: string[], options: CompilerOptions, updater: (files: NamedSourceText[]) => void) {
const texts: NamedSourceText[] = (<ProgramWithSourceTexts>oldProgram).sourceTexts.slice(0);
updater(texts);
const host = createTestCompilerHost(texts, options.target);
const host = createTestCompilerHost(texts, options.target, oldProgram);
const program = <ProgramWithSourceTexts>createProgram(rootNames, options, host, oldProgram);
program.sourceTexts = texts;
program.host = host;
return program;
}
@ -355,6 +373,112 @@ namespace ts {
assert.isTrue(!program_3.structureIsReused);
checkResolvedTypeDirectivesCache(program_1, "/a.ts", createMap({ "typedefs": { resolvedFileName: "/types/typedefs/index.d.ts", primary: true } }));
});
it("can reuse ambient module declarations from non-modified files", () => {
const files = [
{ name: "/a/b/app.ts", text: SourceText.New("", "import * as fs from 'fs'", "") },
{ name: "/a/b/node.d.ts", text: SourceText.New("", "", "declare module 'fs' {}") }
];
const options = { target: ScriptTarget.ES2015, traceResolution: true };
const program = newProgram(files, files.map(f => f.name), options);
assert.deepEqual(program.host.getTrace(),
[
"======== Resolving module 'fs' from '/a/b/app.ts'. ========",
"Module resolution kind is not specified, using 'Classic'.",
"File '/a/b/fs.ts' does not exist.",
"File '/a/b/fs.tsx' does not exist.",
"File '/a/b/fs.d.ts' does not exist.",
"File '/a/fs.ts' does not exist.",
"File '/a/fs.tsx' does not exist.",
"File '/a/fs.d.ts' does not exist.",
"File '/fs.ts' does not exist.",
"File '/fs.tsx' does not exist.",
"File '/fs.d.ts' does not exist.",
"File '/a/b/node_modules/@types/fs.ts' does not exist.",
"File '/a/b/node_modules/@types/fs.tsx' does not exist.",
"File '/a/b/node_modules/@types/fs.d.ts' does not exist.",
"File '/a/b/node_modules/@types/fs/package.json' does not exist.",
"File '/a/b/node_modules/@types/fs/index.ts' does not exist.",
"File '/a/b/node_modules/@types/fs/index.tsx' does not exist.",
"File '/a/b/node_modules/@types/fs/index.d.ts' does not exist.",
"File '/a/node_modules/@types/fs.ts' does not exist.",
"File '/a/node_modules/@types/fs.tsx' does not exist.",
"File '/a/node_modules/@types/fs.d.ts' does not exist.",
"File '/a/node_modules/@types/fs/package.json' does not exist.",
"File '/a/node_modules/@types/fs/index.ts' does not exist.",
"File '/a/node_modules/@types/fs/index.tsx' does not exist.",
"File '/a/node_modules/@types/fs/index.d.ts' does not exist.",
"File '/node_modules/@types/fs.ts' does not exist.",
"File '/node_modules/@types/fs.tsx' does not exist.",
"File '/node_modules/@types/fs.d.ts' does not exist.",
"File '/node_modules/@types/fs/package.json' does not exist.",
"File '/node_modules/@types/fs/index.ts' does not exist.",
"File '/node_modules/@types/fs/index.tsx' does not exist.",
"File '/node_modules/@types/fs/index.d.ts' does not exist.",
"File '/a/b/fs.js' does not exist.",
"File '/a/b/fs.jsx' does not exist.",
"File '/a/fs.js' does not exist.",
"File '/a/fs.jsx' does not exist.",
"File '/fs.js' does not exist.",
"File '/fs.jsx' does not exist.",
"======== Module name 'fs' was not resolved. ========",
], "should look for 'fs'");
const program_2 = updateProgram(program, program.getRootFileNames(), options, f => {
f[0].text = f[0].text.updateProgram("var x = 1;");
});
assert.deepEqual(program_2.host.getTrace(), [
"Module 'fs' was resolved as ambient module declared in '/a/b/node.d.ts' since this file was not modified."
], "should reuse 'fs' since node.d.ts was not changed");
const program_3 = updateProgram(program_2, program_2.getRootFileNames(), options, f => {
f[0].text = f[0].text.updateProgram("var y = 1;");
f[1].text = f[1].text.updateProgram("declare var process: any");
});
assert.deepEqual(program_3.host.getTrace(),
[
"======== Resolving module 'fs' from '/a/b/app.ts'. ========",
"Module resolution kind is not specified, using 'Classic'.",
"File '/a/b/fs.ts' does not exist.",
"File '/a/b/fs.tsx' does not exist.",
"File '/a/b/fs.d.ts' does not exist.",
"File '/a/fs.ts' does not exist.",
"File '/a/fs.tsx' does not exist.",
"File '/a/fs.d.ts' does not exist.",
"File '/fs.ts' does not exist.",
"File '/fs.tsx' does not exist.",
"File '/fs.d.ts' does not exist.",
"File '/a/b/node_modules/@types/fs.ts' does not exist.",
"File '/a/b/node_modules/@types/fs.tsx' does not exist.",
"File '/a/b/node_modules/@types/fs.d.ts' does not exist.",
"File '/a/b/node_modules/@types/fs/package.json' does not exist.",
"File '/a/b/node_modules/@types/fs/index.ts' does not exist.",
"File '/a/b/node_modules/@types/fs/index.tsx' does not exist.",
"File '/a/b/node_modules/@types/fs/index.d.ts' does not exist.",
"File '/a/node_modules/@types/fs.ts' does not exist.",
"File '/a/node_modules/@types/fs.tsx' does not exist.",
"File '/a/node_modules/@types/fs.d.ts' does not exist.",
"File '/a/node_modules/@types/fs/package.json' does not exist.",
"File '/a/node_modules/@types/fs/index.ts' does not exist.",
"File '/a/node_modules/@types/fs/index.tsx' does not exist.",
"File '/a/node_modules/@types/fs/index.d.ts' does not exist.",
"File '/node_modules/@types/fs.ts' does not exist.",
"File '/node_modules/@types/fs.tsx' does not exist.",
"File '/node_modules/@types/fs.d.ts' does not exist.",
"File '/node_modules/@types/fs/package.json' does not exist.",
"File '/node_modules/@types/fs/index.ts' does not exist.",
"File '/node_modules/@types/fs/index.tsx' does not exist.",
"File '/node_modules/@types/fs/index.d.ts' does not exist.",
"File '/a/b/fs.js' does not exist.",
"File '/a/b/fs.jsx' does not exist.",
"File '/a/fs.js' does not exist.",
"File '/a/fs.jsx' does not exist.",
"File '/fs.js' does not exist.",
"File '/fs.jsx' does not exist.",
"======== Module name 'fs' was not resolved. ========",
], "should look for 'fs' again since node.d.ts was changed");
});
});
describe("host is optional", () => {

View file

@ -2505,4 +2505,28 @@ namespace ts.projectSystem {
checkProjectActualFiles(projectService.inferredProjects[0], [f.path]);
});
});
describe("No overwrite emit error", () => {
it("for inferred project", () => {
const f1 = {
path: "/a/b/f1.js",
content: "function test1() { }"
};
const host = createServerHost([f1, libFile]);
const session = createSession(host);
openFilesForSession([f1], session);
const projectService = session.getProjectService();
checkNumberOfProjects(projectService, { inferredProjects: 1 });
const projectName = projectService.inferredProjects[0].getProjectName();
const diags = session.executeCommand(<server.protocol.CompilerOptionsDiagnosticsRequest>{
type: "request",
command: server.CommandNames.CompilerOptionsDiagnosticsFull,
seq: 2,
arguments: { projectFileName: projectName }
}).response;
assert.isTrue(diags.length === 0);
});
});
}

View file

@ -161,6 +161,10 @@ namespace ts.server {
this.compilerOptions.allowNonTsExtensions = true;
}
if (this.projectKind === ProjectKind.Inferred) {
this.compilerOptions.noEmitOverwritenFiles = true;
}
if (languageServiceEnabled) {
this.enableLanguageService();
}

View file

@ -264,7 +264,7 @@ namespace ts.BreakpointResolver {
// a or ...c or d: x from
// [a, b, ...c] or { a, b } or { d: x } from destructuring pattern
if ((node.kind === SyntaxKind.Identifier ||
node.kind == SyntaxKind.SpreadExpression ||
node.kind == SyntaxKind.SpreadElement ||
node.kind === SyntaxKind.PropertyAssignment ||
node.kind === SyntaxKind.ShorthandPropertyAssignment) &&
isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent)) {

View file

@ -472,6 +472,7 @@ namespace ts {
public imports: LiteralExpression[];
public moduleAugmentations: LiteralExpression[];
private namedDeclarations: Map<Declaration[]>;
public ambientModuleNames: string[];
constructor(kind: SyntaxKind, pos: number, end: number) {
super(kind, pos, end);

View file

@ -530,8 +530,8 @@ namespace ts {
case SyntaxKind.DeleteExpression:
case SyntaxKind.VoidExpression:
case SyntaxKind.YieldExpression:
case SyntaxKind.SpreadExpression:
const unaryWordExpression = n as (TypeOfExpression | DeleteExpression | VoidExpression | YieldExpression | SpreadExpression);
case SyntaxKind.SpreadElement:
const unaryWordExpression = n as (TypeOfExpression | DeleteExpression | VoidExpression | YieldExpression | SpreadElement);
return isCompletedNode(unaryWordExpression.expression, sourceFile);
case SyntaxKind.TaggedTemplateExpression:

View file

@ -1,6 +1,6 @@
//// [callWithSpread.ts]
interface X {
foo(x: number, y: number, ...z: string[]);
foo(x: number, y: number, ...z: string[]): X;
}
function foo(x: number, y: number, ...z: string[]) {
@ -19,10 +19,18 @@ obj.foo(1, 2, "abc");
obj.foo(1, 2, ...a);
obj.foo(1, 2, ...a, "abc");
obj.foo(1, 2, ...a).foo(1, 2, "abc");
obj.foo(1, 2, ...a).foo(1, 2, ...a);
obj.foo(1, 2, ...a).foo(1, 2, ...a, "abc");
(obj.foo)(1, 2, "abc");
(obj.foo)(1, 2, ...a);
(obj.foo)(1, 2, ...a, "abc");
((obj.foo)(1, 2, ...a).foo)(1, 2, "abc");
((obj.foo)(1, 2, ...a).foo)(1, 2, ...a);
((obj.foo)(1, 2, ...a).foo)(1, 2, ...a, "abc");
xa[1].foo(1, 2, "abc");
xa[1].foo(1, 2, ...a);
xa[1].foo(1, 2, ...a, "abc");
@ -72,13 +80,19 @@ foo.apply(void 0, [1, 2].concat(a, ["abc"]));
obj.foo(1, 2, "abc");
obj.foo.apply(obj, [1, 2].concat(a));
obj.foo.apply(obj, [1, 2].concat(a, ["abc"]));
obj.foo.apply(obj, [1, 2].concat(a)).foo(1, 2, "abc");
(_a = obj.foo.apply(obj, [1, 2].concat(a))).foo.apply(_a, [1, 2].concat(a));
(_b = obj.foo.apply(obj, [1, 2].concat(a))).foo.apply(_b, [1, 2].concat(a, ["abc"]));
(obj.foo)(1, 2, "abc");
obj.foo.apply(obj, [1, 2].concat(a));
obj.foo.apply(obj, [1, 2].concat(a, ["abc"]));
(obj.foo.apply(obj, [1, 2].concat(a)).foo)(1, 2, "abc");
(_c = obj.foo.apply(obj, [1, 2].concat(a))).foo.apply(_c, [1, 2].concat(a));
(_d = obj.foo.apply(obj, [1, 2].concat(a))).foo.apply(_d, [1, 2].concat(a, ["abc"]));
xa[1].foo(1, 2, "abc");
(_a = xa[1]).foo.apply(_a, [1, 2].concat(a));
(_b = xa[1]).foo.apply(_b, [1, 2].concat(a, ["abc"]));
(_c = xa[1]).foo.apply(_c, [1, 2, "abc"]);
(_e = xa[1]).foo.apply(_e, [1, 2].concat(a));
(_f = xa[1]).foo.apply(_f, [1, 2].concat(a, ["abc"]));
(_g = xa[1]).foo.apply(_g, [1, 2, "abc"]);
var C = (function () {
function C(x, y) {
var z = [];
@ -109,4 +123,4 @@ var D = (function (_super) {
};
return D;
}(C));
var _a, _b, _c;
var _a, _b, _c, _d, _e, _f, _g;

View file

@ -2,11 +2,12 @@
interface X {
>X : Symbol(X, Decl(callWithSpread.ts, 0, 0))
foo(x: number, y: number, ...z: string[]);
foo(x: number, y: number, ...z: string[]): X;
>foo : Symbol(X.foo, Decl(callWithSpread.ts, 0, 13))
>x : Symbol(x, Decl(callWithSpread.ts, 1, 8))
>y : Symbol(y, Decl(callWithSpread.ts, 1, 18))
>z : Symbol(z, Decl(callWithSpread.ts, 1, 29))
>X : Symbol(X, Decl(callWithSpread.ts, 0, 0))
}
function foo(x: number, y: number, ...z: string[]) {
@ -58,6 +59,32 @@ obj.foo(1, 2, ...a, "abc");
>foo : Symbol(X.foo, Decl(callWithSpread.ts, 0, 13))
>a : Symbol(a, Decl(callWithSpread.ts, 7, 3))
obj.foo(1, 2, ...a).foo(1, 2, "abc");
>obj.foo(1, 2, ...a).foo : Symbol(X.foo, Decl(callWithSpread.ts, 0, 13))
>obj.foo : Symbol(X.foo, Decl(callWithSpread.ts, 0, 13))
>obj : Symbol(obj, Decl(callWithSpread.ts, 9, 3))
>foo : Symbol(X.foo, Decl(callWithSpread.ts, 0, 13))
>a : Symbol(a, Decl(callWithSpread.ts, 7, 3))
>foo : Symbol(X.foo, Decl(callWithSpread.ts, 0, 13))
obj.foo(1, 2, ...a).foo(1, 2, ...a);
>obj.foo(1, 2, ...a).foo : Symbol(X.foo, Decl(callWithSpread.ts, 0, 13))
>obj.foo : Symbol(X.foo, Decl(callWithSpread.ts, 0, 13))
>obj : Symbol(obj, Decl(callWithSpread.ts, 9, 3))
>foo : Symbol(X.foo, Decl(callWithSpread.ts, 0, 13))
>a : Symbol(a, Decl(callWithSpread.ts, 7, 3))
>foo : Symbol(X.foo, Decl(callWithSpread.ts, 0, 13))
>a : Symbol(a, Decl(callWithSpread.ts, 7, 3))
obj.foo(1, 2, ...a).foo(1, 2, ...a, "abc");
>obj.foo(1, 2, ...a).foo : Symbol(X.foo, Decl(callWithSpread.ts, 0, 13))
>obj.foo : Symbol(X.foo, Decl(callWithSpread.ts, 0, 13))
>obj : Symbol(obj, Decl(callWithSpread.ts, 9, 3))
>foo : Symbol(X.foo, Decl(callWithSpread.ts, 0, 13))
>a : Symbol(a, Decl(callWithSpread.ts, 7, 3))
>foo : Symbol(X.foo, Decl(callWithSpread.ts, 0, 13))
>a : Symbol(a, Decl(callWithSpread.ts, 7, 3))
(obj.foo)(1, 2, "abc");
>obj.foo : Symbol(X.foo, Decl(callWithSpread.ts, 0, 13))
>obj : Symbol(obj, Decl(callWithSpread.ts, 9, 3))
@ -75,6 +102,32 @@ obj.foo(1, 2, ...a, "abc");
>foo : Symbol(X.foo, Decl(callWithSpread.ts, 0, 13))
>a : Symbol(a, Decl(callWithSpread.ts, 7, 3))
((obj.foo)(1, 2, ...a).foo)(1, 2, "abc");
>(obj.foo)(1, 2, ...a).foo : Symbol(X.foo, Decl(callWithSpread.ts, 0, 13))
>obj.foo : Symbol(X.foo, Decl(callWithSpread.ts, 0, 13))
>obj : Symbol(obj, Decl(callWithSpread.ts, 9, 3))
>foo : Symbol(X.foo, Decl(callWithSpread.ts, 0, 13))
>a : Symbol(a, Decl(callWithSpread.ts, 7, 3))
>foo : Symbol(X.foo, Decl(callWithSpread.ts, 0, 13))
((obj.foo)(1, 2, ...a).foo)(1, 2, ...a);
>(obj.foo)(1, 2, ...a).foo : Symbol(X.foo, Decl(callWithSpread.ts, 0, 13))
>obj.foo : Symbol(X.foo, Decl(callWithSpread.ts, 0, 13))
>obj : Symbol(obj, Decl(callWithSpread.ts, 9, 3))
>foo : Symbol(X.foo, Decl(callWithSpread.ts, 0, 13))
>a : Symbol(a, Decl(callWithSpread.ts, 7, 3))
>foo : Symbol(X.foo, Decl(callWithSpread.ts, 0, 13))
>a : Symbol(a, Decl(callWithSpread.ts, 7, 3))
((obj.foo)(1, 2, ...a).foo)(1, 2, ...a, "abc");
>(obj.foo)(1, 2, ...a).foo : Symbol(X.foo, Decl(callWithSpread.ts, 0, 13))
>obj.foo : Symbol(X.foo, Decl(callWithSpread.ts, 0, 13))
>obj : Symbol(obj, Decl(callWithSpread.ts, 9, 3))
>foo : Symbol(X.foo, Decl(callWithSpread.ts, 0, 13))
>a : Symbol(a, Decl(callWithSpread.ts, 7, 3))
>foo : Symbol(X.foo, Decl(callWithSpread.ts, 0, 13))
>a : Symbol(a, Decl(callWithSpread.ts, 7, 3))
xa[1].foo(1, 2, "abc");
>xa[1].foo : Symbol(X.foo, Decl(callWithSpread.ts, 0, 13))
>xa : Symbol(xa, Decl(callWithSpread.ts, 10, 3))
@ -99,60 +152,60 @@ xa[1].foo(1, 2, ...a, "abc");
>foo : Symbol(X.foo, Decl(callWithSpread.ts, 0, 13))
class C {
>C : Symbol(C, Decl(callWithSpread.ts, 28, 40))
>C : Symbol(C, Decl(callWithSpread.ts, 36, 40))
constructor(x: number, y: number, ...z: string[]) {
>x : Symbol(x, Decl(callWithSpread.ts, 31, 16))
>y : Symbol(y, Decl(callWithSpread.ts, 31, 26))
>z : Symbol(z, Decl(callWithSpread.ts, 31, 37))
>x : Symbol(x, Decl(callWithSpread.ts, 39, 16))
>y : Symbol(y, Decl(callWithSpread.ts, 39, 26))
>z : Symbol(z, Decl(callWithSpread.ts, 39, 37))
this.foo(x, y);
>this.foo : Symbol(C.foo, Decl(callWithSpread.ts, 34, 5))
>this : Symbol(C, Decl(callWithSpread.ts, 28, 40))
>foo : Symbol(C.foo, Decl(callWithSpread.ts, 34, 5))
>x : Symbol(x, Decl(callWithSpread.ts, 31, 16))
>y : Symbol(y, Decl(callWithSpread.ts, 31, 26))
>this.foo : Symbol(C.foo, Decl(callWithSpread.ts, 42, 5))
>this : Symbol(C, Decl(callWithSpread.ts, 36, 40))
>foo : Symbol(C.foo, Decl(callWithSpread.ts, 42, 5))
>x : Symbol(x, Decl(callWithSpread.ts, 39, 16))
>y : Symbol(y, Decl(callWithSpread.ts, 39, 26))
this.foo(x, y, ...z);
>this.foo : Symbol(C.foo, Decl(callWithSpread.ts, 34, 5))
>this : Symbol(C, Decl(callWithSpread.ts, 28, 40))
>foo : Symbol(C.foo, Decl(callWithSpread.ts, 34, 5))
>x : Symbol(x, Decl(callWithSpread.ts, 31, 16))
>y : Symbol(y, Decl(callWithSpread.ts, 31, 26))
>z : Symbol(z, Decl(callWithSpread.ts, 31, 37))
>this.foo : Symbol(C.foo, Decl(callWithSpread.ts, 42, 5))
>this : Symbol(C, Decl(callWithSpread.ts, 36, 40))
>foo : Symbol(C.foo, Decl(callWithSpread.ts, 42, 5))
>x : Symbol(x, Decl(callWithSpread.ts, 39, 16))
>y : Symbol(y, Decl(callWithSpread.ts, 39, 26))
>z : Symbol(z, Decl(callWithSpread.ts, 39, 37))
}
foo(x: number, y: number, ...z: string[]) {
>foo : Symbol(C.foo, Decl(callWithSpread.ts, 34, 5))
>x : Symbol(x, Decl(callWithSpread.ts, 35, 8))
>y : Symbol(y, Decl(callWithSpread.ts, 35, 18))
>z : Symbol(z, Decl(callWithSpread.ts, 35, 29))
>foo : Symbol(C.foo, Decl(callWithSpread.ts, 42, 5))
>x : Symbol(x, Decl(callWithSpread.ts, 43, 8))
>y : Symbol(y, Decl(callWithSpread.ts, 43, 18))
>z : Symbol(z, Decl(callWithSpread.ts, 43, 29))
}
}
class D extends C {
>D : Symbol(D, Decl(callWithSpread.ts, 37, 1))
>C : Symbol(C, Decl(callWithSpread.ts, 28, 40))
>D : Symbol(D, Decl(callWithSpread.ts, 45, 1))
>C : Symbol(C, Decl(callWithSpread.ts, 36, 40))
constructor() {
super(1, 2);
>super : Symbol(C, Decl(callWithSpread.ts, 28, 40))
>super : Symbol(C, Decl(callWithSpread.ts, 36, 40))
super(1, 2, ...a);
>super : Symbol(C, Decl(callWithSpread.ts, 28, 40))
>super : Symbol(C, Decl(callWithSpread.ts, 36, 40))
>a : Symbol(a, Decl(callWithSpread.ts, 7, 3))
}
foo() {
>foo : Symbol(D.foo, Decl(callWithSpread.ts, 43, 5))
>foo : Symbol(D.foo, Decl(callWithSpread.ts, 51, 5))
super.foo(1, 2);
>super.foo : Symbol(C.foo, Decl(callWithSpread.ts, 34, 5))
>super : Symbol(C, Decl(callWithSpread.ts, 28, 40))
>foo : Symbol(C.foo, Decl(callWithSpread.ts, 34, 5))
>super.foo : Symbol(C.foo, Decl(callWithSpread.ts, 42, 5))
>super : Symbol(C, Decl(callWithSpread.ts, 36, 40))
>foo : Symbol(C.foo, Decl(callWithSpread.ts, 42, 5))
super.foo(1, 2, ...a);
>super.foo : Symbol(C.foo, Decl(callWithSpread.ts, 34, 5))
>super : Symbol(C, Decl(callWithSpread.ts, 28, 40))
>foo : Symbol(C.foo, Decl(callWithSpread.ts, 34, 5))
>super.foo : Symbol(C.foo, Decl(callWithSpread.ts, 42, 5))
>super : Symbol(C, Decl(callWithSpread.ts, 36, 40))
>foo : Symbol(C.foo, Decl(callWithSpread.ts, 42, 5))
>a : Symbol(a, Decl(callWithSpread.ts, 7, 3))
}
}

View file

@ -2,11 +2,12 @@
interface X {
>X : X
foo(x: number, y: number, ...z: string[]);
>foo : (x: number, y: number, ...z: string[]) => any
foo(x: number, y: number, ...z: string[]): X;
>foo : (x: number, y: number, ...z: string[]) => X
>x : number
>y : number
>z : string[]
>X : X
}
function foo(x: number, y: number, ...z: string[]) {
@ -55,29 +56,80 @@ foo(1, 2, ...a, "abc");
>"abc" : "abc"
obj.foo(1, 2, "abc");
>obj.foo(1, 2, "abc") : any
>obj.foo : (x: number, y: number, ...z: string[]) => any
>obj.foo(1, 2, "abc") : X
>obj.foo : (x: number, y: number, ...z: string[]) => X
>obj : X
>foo : (x: number, y: number, ...z: string[]) => any
>foo : (x: number, y: number, ...z: string[]) => X
>1 : 1
>2 : 2
>"abc" : "abc"
obj.foo(1, 2, ...a);
>obj.foo(1, 2, ...a) : any
>obj.foo : (x: number, y: number, ...z: string[]) => any
>obj.foo(1, 2, ...a) : X
>obj.foo : (x: number, y: number, ...z: string[]) => X
>obj : X
>foo : (x: number, y: number, ...z: string[]) => any
>foo : (x: number, y: number, ...z: string[]) => X
>1 : 1
>2 : 2
>...a : string
>a : string[]
obj.foo(1, 2, ...a, "abc");
>obj.foo(1, 2, ...a, "abc") : any
>obj.foo : (x: number, y: number, ...z: string[]) => any
>obj.foo(1, 2, ...a, "abc") : X
>obj.foo : (x: number, y: number, ...z: string[]) => X
>obj : X
>foo : (x: number, y: number, ...z: string[]) => any
>foo : (x: number, y: number, ...z: string[]) => X
>1 : 1
>2 : 2
>...a : string
>a : string[]
>"abc" : "abc"
obj.foo(1, 2, ...a).foo(1, 2, "abc");
>obj.foo(1, 2, ...a).foo(1, 2, "abc") : X
>obj.foo(1, 2, ...a).foo : (x: number, y: number, ...z: string[]) => X
>obj.foo(1, 2, ...a) : X
>obj.foo : (x: number, y: number, ...z: string[]) => X
>obj : X
>foo : (x: number, y: number, ...z: string[]) => X
>1 : 1
>2 : 2
>...a : string
>a : string[]
>foo : (x: number, y: number, ...z: string[]) => X
>1 : 1
>2 : 2
>"abc" : "abc"
obj.foo(1, 2, ...a).foo(1, 2, ...a);
>obj.foo(1, 2, ...a).foo(1, 2, ...a) : X
>obj.foo(1, 2, ...a).foo : (x: number, y: number, ...z: string[]) => X
>obj.foo(1, 2, ...a) : X
>obj.foo : (x: number, y: number, ...z: string[]) => X
>obj : X
>foo : (x: number, y: number, ...z: string[]) => X
>1 : 1
>2 : 2
>...a : string
>a : string[]
>foo : (x: number, y: number, ...z: string[]) => X
>1 : 1
>2 : 2
>...a : string
>a : string[]
obj.foo(1, 2, ...a).foo(1, 2, ...a, "abc");
>obj.foo(1, 2, ...a).foo(1, 2, ...a, "abc") : X
>obj.foo(1, 2, ...a).foo : (x: number, y: number, ...z: string[]) => X
>obj.foo(1, 2, ...a) : X
>obj.foo : (x: number, y: number, ...z: string[]) => X
>obj : X
>foo : (x: number, y: number, ...z: string[]) => X
>1 : 1
>2 : 2
>...a : string
>a : string[]
>foo : (x: number, y: number, ...z: string[]) => X
>1 : 1
>2 : 2
>...a : string
@ -85,32 +137,89 @@ obj.foo(1, 2, ...a, "abc");
>"abc" : "abc"
(obj.foo)(1, 2, "abc");
>(obj.foo)(1, 2, "abc") : any
>(obj.foo) : (x: number, y: number, ...z: string[]) => any
>obj.foo : (x: number, y: number, ...z: string[]) => any
>(obj.foo)(1, 2, "abc") : X
>(obj.foo) : (x: number, y: number, ...z: string[]) => X
>obj.foo : (x: number, y: number, ...z: string[]) => X
>obj : X
>foo : (x: number, y: number, ...z: string[]) => any
>foo : (x: number, y: number, ...z: string[]) => X
>1 : 1
>2 : 2
>"abc" : "abc"
(obj.foo)(1, 2, ...a);
>(obj.foo)(1, 2, ...a) : any
>(obj.foo) : (x: number, y: number, ...z: string[]) => any
>obj.foo : (x: number, y: number, ...z: string[]) => any
>(obj.foo)(1, 2, ...a) : X
>(obj.foo) : (x: number, y: number, ...z: string[]) => X
>obj.foo : (x: number, y: number, ...z: string[]) => X
>obj : X
>foo : (x: number, y: number, ...z: string[]) => any
>foo : (x: number, y: number, ...z: string[]) => X
>1 : 1
>2 : 2
>...a : string
>a : string[]
(obj.foo)(1, 2, ...a, "abc");
>(obj.foo)(1, 2, ...a, "abc") : any
>(obj.foo) : (x: number, y: number, ...z: string[]) => any
>obj.foo : (x: number, y: number, ...z: string[]) => any
>(obj.foo)(1, 2, ...a, "abc") : X
>(obj.foo) : (x: number, y: number, ...z: string[]) => X
>obj.foo : (x: number, y: number, ...z: string[]) => X
>obj : X
>foo : (x: number, y: number, ...z: string[]) => any
>foo : (x: number, y: number, ...z: string[]) => X
>1 : 1
>2 : 2
>...a : string
>a : string[]
>"abc" : "abc"
((obj.foo)(1, 2, ...a).foo)(1, 2, "abc");
>((obj.foo)(1, 2, ...a).foo)(1, 2, "abc") : X
>((obj.foo)(1, 2, ...a).foo) : (x: number, y: number, ...z: string[]) => X
>(obj.foo)(1, 2, ...a).foo : (x: number, y: number, ...z: string[]) => X
>(obj.foo)(1, 2, ...a) : X
>(obj.foo) : (x: number, y: number, ...z: string[]) => X
>obj.foo : (x: number, y: number, ...z: string[]) => X
>obj : X
>foo : (x: number, y: number, ...z: string[]) => X
>1 : 1
>2 : 2
>...a : string
>a : string[]
>foo : (x: number, y: number, ...z: string[]) => X
>1 : 1
>2 : 2
>"abc" : "abc"
((obj.foo)(1, 2, ...a).foo)(1, 2, ...a);
>((obj.foo)(1, 2, ...a).foo)(1, 2, ...a) : X
>((obj.foo)(1, 2, ...a).foo) : (x: number, y: number, ...z: string[]) => X
>(obj.foo)(1, 2, ...a).foo : (x: number, y: number, ...z: string[]) => X
>(obj.foo)(1, 2, ...a) : X
>(obj.foo) : (x: number, y: number, ...z: string[]) => X
>obj.foo : (x: number, y: number, ...z: string[]) => X
>obj : X
>foo : (x: number, y: number, ...z: string[]) => X
>1 : 1
>2 : 2
>...a : string
>a : string[]
>foo : (x: number, y: number, ...z: string[]) => X
>1 : 1
>2 : 2
>...a : string
>a : string[]
((obj.foo)(1, 2, ...a).foo)(1, 2, ...a, "abc");
>((obj.foo)(1, 2, ...a).foo)(1, 2, ...a, "abc") : X
>((obj.foo)(1, 2, ...a).foo) : (x: number, y: number, ...z: string[]) => X
>(obj.foo)(1, 2, ...a).foo : (x: number, y: number, ...z: string[]) => X
>(obj.foo)(1, 2, ...a) : X
>(obj.foo) : (x: number, y: number, ...z: string[]) => X
>obj.foo : (x: number, y: number, ...z: string[]) => X
>obj : X
>foo : (x: number, y: number, ...z: string[]) => X
>1 : 1
>2 : 2
>...a : string
>a : string[]
>foo : (x: number, y: number, ...z: string[]) => X
>1 : 1
>2 : 2
>...a : string
@ -118,35 +227,35 @@ obj.foo(1, 2, ...a, "abc");
>"abc" : "abc"
xa[1].foo(1, 2, "abc");
>xa[1].foo(1, 2, "abc") : any
>xa[1].foo : (x: number, y: number, ...z: string[]) => any
>xa[1].foo(1, 2, "abc") : X
>xa[1].foo : (x: number, y: number, ...z: string[]) => X
>xa[1] : X
>xa : X[]
>1 : 1
>foo : (x: number, y: number, ...z: string[]) => any
>foo : (x: number, y: number, ...z: string[]) => X
>1 : 1
>2 : 2
>"abc" : "abc"
xa[1].foo(1, 2, ...a);
>xa[1].foo(1, 2, ...a) : any
>xa[1].foo : (x: number, y: number, ...z: string[]) => any
>xa[1].foo(1, 2, ...a) : X
>xa[1].foo : (x: number, y: number, ...z: string[]) => X
>xa[1] : X
>xa : X[]
>1 : 1
>foo : (x: number, y: number, ...z: string[]) => any
>foo : (x: number, y: number, ...z: string[]) => X
>1 : 1
>2 : 2
>...a : string
>a : string[]
xa[1].foo(1, 2, ...a, "abc");
>xa[1].foo(1, 2, ...a, "abc") : any
>xa[1].foo : (x: number, y: number, ...z: string[]) => any
>xa[1].foo(1, 2, ...a, "abc") : X
>xa[1].foo : (x: number, y: number, ...z: string[]) => X
>xa[1] : X
>xa : X[]
>1 : 1
>foo : (x: number, y: number, ...z: string[]) => any
>foo : (x: number, y: number, ...z: string[]) => X
>1 : 1
>2 : 2
>...a : string
@ -158,11 +267,11 @@ xa[1].foo(1, 2, ...a, "abc");
>(<Function>xa[1].foo) : Function
><Function>xa[1].foo : Function
>Function : Function
>xa[1].foo : (x: number, y: number, ...z: string[]) => any
>xa[1].foo : (x: number, y: number, ...z: string[]) => X
>xa[1] : X
>xa : X[]
>1 : 1
>foo : (x: number, y: number, ...z: string[]) => any
>foo : (x: number, y: number, ...z: string[]) => X
>...[1, 2, "abc"] : string | number
>[1, 2, "abc"] : (string | number)[]
>1 : 1

View file

@ -1,6 +1,7 @@
EmitSkipped: true
Diagnostics:
Cannot write file '/tests/cases/fourslash/b.js' because it would overwrite input file.
Cannot write file '/tests/cases/fourslash/b.js' because it would overwrite input file.
Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig
EmitSkipped: false
FileName : /tests/cases/fourslash/a.js

View file

@ -1,7 +1,9 @@
error TS5055: Cannot write file 'tests/cases/compiler/a.d.ts' because it would overwrite input file.
Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig
!!! error TS5055: Cannot write file 'tests/cases/compiler/a.d.ts' because it would overwrite input file.
!!! error TS5055: Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig
==== tests/cases/compiler/a.d.ts (0 errors) ====
declare class c {

View file

@ -1,7 +1,9 @@
error TS5055: Cannot write file 'tests/cases/compiler/out.d.ts' because it would overwrite input file.
Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig
!!! error TS5055: Cannot write file 'tests/cases/compiler/out.d.ts' because it would overwrite input file.
!!! error TS5055: Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig
==== tests/cases/compiler/out.d.ts (0 errors) ====
declare class c {

View file

@ -1,7 +1,9 @@
error TS5055: Cannot write file 'tests/cases/conformance/salsa/myFile01.js' because it would overwrite input file.
Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig
!!! error TS5055: Cannot write file 'tests/cases/conformance/salsa/myFile01.js' because it would overwrite input file.
!!! error TS5055: Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig
==== tests/cases/conformance/salsa/myFile01.js (0 errors) ====
export default "hello";

View file

@ -1,7 +1,9 @@
error TS5055: Cannot write file 'tests/cases/conformance/salsa/myFile02.js' because it would overwrite input file.
Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig
!!! error TS5055: Cannot write file 'tests/cases/conformance/salsa/myFile02.js' because it would overwrite input file.
!!! error TS5055: Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig
==== tests/cases/conformance/salsa/myFile02.js (0 errors) ====
export default "hello";

View file

@ -1,8 +1,10 @@
error TS5055: Cannot write file 'tests/cases/compiler/a.js' because it would overwrite input file.
Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig
tests/cases/compiler/a.js(1,1): error TS8009: 'declare' can only be used in a .ts file.
!!! error TS5055: Cannot write file 'tests/cases/compiler/a.js' because it would overwrite input file.
!!! error TS5055: Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig
==== tests/cases/compiler/a.js (1 errors) ====
declare var v;
~~~~~~~

View file

@ -1,8 +1,10 @@
error TS5055: Cannot write file 'tests/cases/compiler/a.js' because it would overwrite input file.
Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig
error TS5056: Cannot write file 'tests/cases/compiler/a.js' because it would be overwritten by multiple input files.
!!! error TS5055: Cannot write file 'tests/cases/compiler/a.js' because it would overwrite input file.
!!! error TS5055: Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig
!!! error TS5056: Cannot write file 'tests/cases/compiler/a.js' because it would be overwritten by multiple input files.
==== tests/cases/compiler/a.ts (0 errors) ====
class c {

View file

@ -1,8 +1,10 @@
error TS5055: Cannot write file 'tests/cases/compiler/a.js' because it would overwrite input file.
Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig
tests/cases/compiler/a.js(1,6): error TS8015: 'enum declarations' can only be used in a .ts file.
!!! error TS5055: Cannot write file 'tests/cases/compiler/a.js' because it would overwrite input file.
!!! error TS5055: Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig
==== tests/cases/compiler/a.js (1 errors) ====
enum E { }
~

View file

@ -1,9 +1,11 @@
error TS5053: Option 'allowJs' cannot be specified with option 'declaration'.
error TS5055: Cannot write file 'tests/cases/compiler/c.js' because it would overwrite input file.
Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig
!!! error TS5053: Option 'allowJs' cannot be specified with option 'declaration'.
!!! error TS5055: Cannot write file 'tests/cases/compiler/c.js' because it would overwrite input file.
!!! error TS5055: Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig
==== tests/cases/compiler/a.ts (0 errors) ====
class c {
}

View file

@ -1,8 +1,10 @@
error TS5055: Cannot write file 'tests/cases/compiler/a.js' because it would overwrite input file.
Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig
tests/cases/compiler/a.js(1,1): error TS8003: 'export=' can only be used in a .ts file.
!!! error TS5055: Cannot write file 'tests/cases/compiler/a.js' because it would overwrite input file.
!!! error TS5055: Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig
==== tests/cases/compiler/a.js (1 errors) ====
export = b;
~~~~~~~~~~~

View file

@ -1,8 +1,10 @@
error TS5055: Cannot write file 'tests/cases/compiler/a.js' because it would overwrite input file.
Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig
tests/cases/compiler/a.js(1,9): error TS8005: 'implements clauses' can only be used in a .ts file.
!!! error TS5055: Cannot write file 'tests/cases/compiler/a.js' because it would overwrite input file.
!!! error TS5055: Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig
==== tests/cases/compiler/a.js (1 errors) ====
class C implements D { }
~~~~~~~~~~~~

View file

@ -1,8 +1,10 @@
error TS5055: Cannot write file 'tests/cases/compiler/a.js' because it would overwrite input file.
Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig
tests/cases/compiler/a.js(1,1): error TS8002: 'import ... =' can only be used in a .ts file.
!!! error TS5055: Cannot write file 'tests/cases/compiler/a.js' because it would overwrite input file.
!!! error TS5055: Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig
==== tests/cases/compiler/a.js (1 errors) ====
import a = b;
~~~~~~~~~~~~~

View file

@ -1,8 +1,10 @@
error TS5055: Cannot write file 'tests/cases/compiler/a.js' because it would overwrite input file.
Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig
tests/cases/compiler/a.js(1,11): error TS8006: 'interface declarations' can only be used in a .ts file.
!!! error TS5055: Cannot write file 'tests/cases/compiler/a.js' because it would overwrite input file.
!!! error TS5055: Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig
==== tests/cases/compiler/a.js (1 errors) ====
interface I { }
~

View file

@ -1,8 +1,10 @@
error TS5055: Cannot write file 'tests/cases/compiler/a.js' because it would overwrite input file.
Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig
tests/cases/compiler/a.js(1,8): error TS8007: 'module declarations' can only be used in a .ts file.
!!! error TS5055: Cannot write file 'tests/cases/compiler/a.js' because it would overwrite input file.
!!! error TS5055: Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig
==== tests/cases/compiler/a.js (1 errors) ====
module M { }
~

View file

@ -1,7 +1,9 @@
error TS5055: Cannot write file 'tests/cases/compiler/c.js' because it would overwrite input file.
Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig
!!! error TS5055: Cannot write file 'tests/cases/compiler/c.js' because it would overwrite input file.
!!! error TS5055: Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig
==== tests/cases/compiler/a.ts (0 errors) ====
class c {
}

View file

@ -1,8 +1,10 @@
error TS5055: Cannot write file 'tests/cases/compiler/a.js' because it would overwrite input file.
Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig
tests/cases/compiler/a.js(1,13): error TS8009: '?' can only be used in a .ts file.
!!! error TS5055: Cannot write file 'tests/cases/compiler/a.js' because it would overwrite input file.
!!! error TS5055: Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig
==== tests/cases/compiler/a.js (1 errors) ====
function F(p?) { }
~

View file

@ -1,8 +1,10 @@
error TS5055: Cannot write file 'tests/cases/compiler/a.js' because it would overwrite input file.
Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig
tests/cases/compiler/a.js(2,5): error TS8009: 'public' can only be used in a .ts file.
!!! error TS5055: Cannot write file 'tests/cases/compiler/a.js' because it would overwrite input file.
!!! error TS5055: Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig
==== tests/cases/compiler/a.js (1 errors) ====
class C {
public foo() {

View file

@ -1,8 +1,10 @@
error TS5055: Cannot write file 'tests/cases/compiler/a.js' because it would overwrite input file.
Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig
tests/cases/compiler/a.js(1,23): error TS8012: 'parameter modifiers' can only be used in a .ts file.
!!! error TS5055: Cannot write file 'tests/cases/compiler/a.js' because it would overwrite input file.
!!! error TS5055: Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig
==== tests/cases/compiler/a.js (1 errors) ====
class C { constructor(public x) { }}
~~~~~~

View file

@ -1,8 +1,10 @@
error TS5055: Cannot write file 'tests/cases/compiler/a.js' because it would overwrite input file.
Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig
tests/cases/compiler/a.js(1,15): error TS8010: 'types' can only be used in a .ts file.
!!! error TS5055: Cannot write file 'tests/cases/compiler/a.js' because it would overwrite input file.
!!! error TS5055: Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig
==== tests/cases/compiler/a.js (1 errors) ====
function F(): number { }
~~~~~~

View file

@ -1,7 +1,9 @@
error TS5055: Cannot write file 'tests/cases/compiler/a.js' because it would overwrite input file.
Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig
!!! error TS5055: Cannot write file 'tests/cases/compiler/a.js' because it would overwrite input file.
!!! error TS5055: Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig
==== tests/cases/compiler/a.js (0 errors) ====
/**
* @type {number}

View file

@ -1,8 +1,10 @@
error TS5055: Cannot write file 'tests/cases/compiler/a.js' because it would overwrite input file.
Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig
tests/cases/compiler/a.js(1,6): error TS8008: 'type aliases' can only be used in a .ts file.
!!! error TS5055: Cannot write file 'tests/cases/compiler/a.js' because it would overwrite input file.
!!! error TS5055: Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig
==== tests/cases/compiler/a.js (1 errors) ====
type a = b;
~

View file

@ -1,8 +1,10 @@
error TS5055: Cannot write file 'tests/cases/compiler/a.js' because it would overwrite input file.
Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig
tests/cases/compiler/a.js(1,5): error TS8011: 'type arguments' can only be used in a .ts file.
!!! error TS5055: Cannot write file 'tests/cases/compiler/a.js' because it would overwrite input file.
!!! error TS5055: Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig
==== tests/cases/compiler/a.js (1 errors) ====
Foo<number>();
~~~~~~

View file

@ -1,9 +1,11 @@
error TS5055: Cannot write file 'tests/cases/compiler/a.js' because it would overwrite input file.
Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig
tests/cases/compiler/a.js(1,10): error TS17008: JSX element 'string' has no corresponding closing tag.
tests/cases/compiler/a.js(1,27): error TS1005: '</' expected.
!!! error TS5055: Cannot write file 'tests/cases/compiler/a.js' because it would overwrite input file.
!!! error TS5055: Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig
==== tests/cases/compiler/a.js (2 errors) ====
var v = <string>undefined;
~~~~~~

View file

@ -1,8 +1,10 @@
error TS5055: Cannot write file 'tests/cases/compiler/a.js' because it would overwrite input file.
Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig
tests/cases/compiler/a.js(1,15): error TS8010: 'types' can only be used in a .ts file.
!!! error TS5055: Cannot write file 'tests/cases/compiler/a.js' because it would overwrite input file.
!!! error TS5055: Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig
==== tests/cases/compiler/a.js (1 errors) ====
function F(a: number) { }
~~~~~~

View file

@ -1,8 +1,10 @@
error TS5055: Cannot write file 'tests/cases/compiler/a.js' because it would overwrite input file.
Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig
tests/cases/compiler/a.js(1,9): error TS8004: 'type parameter declarations' can only be used in a .ts file.
!!! error TS5055: Cannot write file 'tests/cases/compiler/a.js' because it would overwrite input file.
!!! error TS5055: Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig
==== tests/cases/compiler/a.js (1 errors) ====
class C<T> { }
~

View file

@ -1,8 +1,10 @@
error TS5055: Cannot write file 'tests/cases/compiler/a.js' because it would overwrite input file.
Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig
tests/cases/compiler/a.js(1,12): error TS8004: 'type parameter declarations' can only be used in a .ts file.
!!! error TS5055: Cannot write file 'tests/cases/compiler/a.js' because it would overwrite input file.
!!! error TS5055: Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig
==== tests/cases/compiler/a.js (1 errors) ====
function F<T>() { }
~

View file

@ -1,8 +1,10 @@
error TS5055: Cannot write file 'tests/cases/compiler/a.js' because it would overwrite input file.
Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig
tests/cases/compiler/a.js(1,8): error TS8010: 'types' can only be used in a .ts file.
!!! error TS5055: Cannot write file 'tests/cases/compiler/a.js' because it would overwrite input file.
!!! error TS5055: Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig
==== tests/cases/compiler/a.js (1 errors) ====
var v: () => number;
~~~~~~~~~~~~

View file

@ -1,7 +1,9 @@
error TS5055: Cannot write file 'tests/cases/compiler/a.d.ts' because it would overwrite input file.
Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig
!!! error TS5055: Cannot write file 'tests/cases/compiler/a.d.ts' because it would overwrite input file.
!!! error TS5055: Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig
==== tests/cases/compiler/a.ts (0 errors) ====
class c {
}

View file

@ -1,8 +1,10 @@
error TS5055: Cannot write file 'tests/cases/compiler/a.js' because it would overwrite input file.
Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig
error TS5056: Cannot write file 'tests/cases/compiler/a.js' because it would be overwritten by multiple input files.
!!! error TS5055: Cannot write file 'tests/cases/compiler/a.js' because it would overwrite input file.
!!! error TS5055: Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig
!!! error TS5056: Cannot write file 'tests/cases/compiler/a.js' because it would be overwritten by multiple input files.
==== tests/cases/compiler/a.ts (0 errors) ====
class c {

View file

@ -1,8 +1,10 @@
error TS5055: Cannot write file 'tests/cases/compiler/b.js' because it would overwrite input file.
Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig
error TS6054: File 'tests/cases/compiler/b.js.map' has unsupported extension. The only supported extensions are '.ts', '.tsx', '.d.ts', '.js', '.jsx'.
!!! error TS5055: Cannot write file 'tests/cases/compiler/b.js' because it would overwrite input file.
!!! error TS5055: Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig
!!! error TS6054: File 'tests/cases/compiler/b.js.map' has unsupported extension. The only supported extensions are '.ts', '.tsx', '.d.ts', '.js', '.jsx'.
==== tests/cases/compiler/a.ts (0 errors) ====

View file

@ -1,8 +1,10 @@
error TS5055: Cannot write file 'tests/cases/compiler/b.js' because it would overwrite input file.
Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig
error TS6054: File 'tests/cases/compiler/b.js.map' has unsupported extension. The only supported extensions are '.ts', '.tsx', '.d.ts', '.js', '.jsx'.
!!! error TS5055: Cannot write file 'tests/cases/compiler/b.js' because it would overwrite input file.
!!! error TS5055: Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig
!!! error TS6054: File 'tests/cases/compiler/b.js.map' has unsupported extension. The only supported extensions are '.ts', '.tsx', '.d.ts', '.js', '.jsx'.
==== tests/cases/compiler/a.ts (0 errors) ====

View file

@ -1,7 +1,9 @@
error TS5055: Cannot write file 'tests/cases/compiler/b.d.ts' because it would overwrite input file.
Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig
!!! error TS5055: Cannot write file 'tests/cases/compiler/b.d.ts' because it would overwrite input file.
!!! error TS5055: Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig
==== tests/cases/compiler/a.ts (0 errors) ====
class c {
}

View file

@ -1,7 +1,9 @@
error TS5055: Cannot write file 'tests/cases/compiler/b.js' because it would overwrite input file.
Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig
!!! error TS5055: Cannot write file 'tests/cases/compiler/b.js' because it would overwrite input file.
!!! error TS5055: Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig
==== tests/cases/compiler/a.ts (0 errors) ====
class c {
}

View file

@ -1,7 +1,9 @@
error TS5055: Cannot write file 'tests/cases/compiler/b.js' because it would overwrite input file.
Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig
!!! error TS5055: Cannot write file 'tests/cases/compiler/b.js' because it would overwrite input file.
!!! error TS5055: Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig
==== tests/cases/compiler/a.ts (0 errors) ====
class c {
}

View file

@ -7,6 +7,10 @@ class Shape {
visible: boolean;
}
class TaggedShape extends Shape {
tag: string;
}
class Item {
name: string;
price: number;
@ -149,6 +153,17 @@ function f32<K extends "width" | "height">(key: K) {
return shape[key]; // Shape[K]
}
function f33<S extends Shape, K extends keyof S>(shape: S, key: K) {
let name = getProperty(shape, "name");
let prop = getProperty(shape, key);
return prop;
}
function f34(ts: TaggedShape) {
let tag1 = f33(ts, "tag");
let tag2 = getProperty(ts, "tag");
}
class C {
public x: string;
protected y: string;
@ -164,14 +179,58 @@ function f40(c: C) {
let x: X = c["x"];
let y: Y = c["y"];
let z: Z = c["z"];
}
// Repros from #12011
class Base {
get<K extends keyof this>(prop: K) {
return this[prop];
}
set<K extends keyof this>(prop: K, value: this[K]) {
this[prop] = value;
}
}
class Person extends Base {
parts: number;
constructor(parts: number) {
super();
this.set("parts", parts);
}
getParts() {
return this.get("parts")
}
}
class OtherPerson {
parts: number;
constructor(parts: number) {
setProperty(this, "parts", parts);
}
getParts() {
return getProperty(this, "parts")
}
}
//// [keyofAndIndexedAccess.js]
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
var Shape = (function () {
function Shape() {
}
return Shape;
}());
var TaggedShape = (function (_super) {
__extends(TaggedShape, _super);
function TaggedShape() {
return _super.apply(this, arguments) || this;
}
return TaggedShape;
}(Shape));
var Item = (function () {
function Item() {
}
@ -249,6 +308,15 @@ function f32(key) {
var shape = { name: "foo", width: 5, height: 10, visible: true };
return shape[key]; // Shape[K]
}
function f33(shape, key) {
var name = getProperty(shape, "name");
var prop = getProperty(shape, key);
return prop;
}
function f34(ts) {
var tag1 = f33(ts, "tag");
var tag2 = getProperty(ts, "tag");
}
var C = (function () {
function C() {
}
@ -261,6 +329,39 @@ function f40(c) {
var y = c["y"];
var z = c["z"];
}
// Repros from #12011
var Base = (function () {
function Base() {
}
Base.prototype.get = function (prop) {
return this[prop];
};
Base.prototype.set = function (prop, value) {
this[prop] = value;
};
return Base;
}());
var Person = (function (_super) {
__extends(Person, _super);
function Person(parts) {
var _this = _super.call(this) || this;
_this.set("parts", parts);
return _this;
}
Person.prototype.getParts = function () {
return this.get("parts");
};
return Person;
}(Base));
var OtherPerson = (function () {
function OtherPerson(parts) {
setProperty(this, "parts", parts);
}
OtherPerson.prototype.getParts = function () {
return getProperty(this, "parts");
};
return OtherPerson;
}());
//// [keyofAndIndexedAccess.d.ts]
@ -270,6 +371,9 @@ declare class Shape {
height: number;
visible: boolean;
}
declare class TaggedShape extends Shape {
tag: string;
}
declare class Item {
name: string;
price: number;
@ -342,9 +446,25 @@ declare function pluck<T, K extends keyof T>(array: T[], key: K): T[K][];
declare function f30(shapes: Shape[]): void;
declare function f31<K extends keyof Shape>(key: K): Shape[K];
declare function f32<K extends "width" | "height">(key: K): Shape[K];
declare function f33<S extends Shape, K extends keyof S>(shape: S, key: K): S[K];
declare function f34(ts: TaggedShape): void;
declare class C {
x: string;
protected y: string;
private z;
}
declare function f40(c: C): void;
declare class Base {
get<K extends keyof this>(prop: K): this[K];
set<K extends keyof this>(prop: K, value: this[K]): void;
}
declare class Person extends Base {
parts: number;
constructor(parts: number);
getParts(): number;
}
declare class OtherPerson {
parts: number;
constructor(parts: number);
getParts(): number;
}

View file

@ -16,562 +16,694 @@ class Shape {
>visible : Symbol(Shape.visible, Decl(keyofAndIndexedAccess.ts, 4, 19))
}
class TaggedShape extends Shape {
>TaggedShape : Symbol(TaggedShape, Decl(keyofAndIndexedAccess.ts, 6, 1))
>Shape : Symbol(Shape, Decl(keyofAndIndexedAccess.ts, 0, 0))
tag: string;
>tag : Symbol(TaggedShape.tag, Decl(keyofAndIndexedAccess.ts, 8, 33))
}
class Item {
>Item : Symbol(Item, Decl(keyofAndIndexedAccess.ts, 6, 1))
>Item : Symbol(Item, Decl(keyofAndIndexedAccess.ts, 10, 1))
name: string;
>name : Symbol(Item.name, Decl(keyofAndIndexedAccess.ts, 8, 12))
>name : Symbol(Item.name, Decl(keyofAndIndexedAccess.ts, 12, 12))
price: number;
>price : Symbol(Item.price, Decl(keyofAndIndexedAccess.ts, 9, 17))
>price : Symbol(Item.price, Decl(keyofAndIndexedAccess.ts, 13, 17))
}
class Options {
>Options : Symbol(Options, Decl(keyofAndIndexedAccess.ts, 11, 1))
>Options : Symbol(Options, Decl(keyofAndIndexedAccess.ts, 15, 1))
visible: "yes" | "no";
>visible : Symbol(Options.visible, Decl(keyofAndIndexedAccess.ts, 13, 15))
>visible : Symbol(Options.visible, Decl(keyofAndIndexedAccess.ts, 17, 15))
}
type Dictionary<T> = { [x: string]: T };
>Dictionary : Symbol(Dictionary, Decl(keyofAndIndexedAccess.ts, 15, 1))
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 17, 16))
>x : Symbol(x, Decl(keyofAndIndexedAccess.ts, 17, 24))
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 17, 16))
>Dictionary : Symbol(Dictionary, Decl(keyofAndIndexedAccess.ts, 19, 1))
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 21, 16))
>x : Symbol(x, Decl(keyofAndIndexedAccess.ts, 21, 24))
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 21, 16))
const enum E { A, B, C }
>E : Symbol(E, Decl(keyofAndIndexedAccess.ts, 17, 40))
>A : Symbol(E.A, Decl(keyofAndIndexedAccess.ts, 19, 14))
>B : Symbol(E.B, Decl(keyofAndIndexedAccess.ts, 19, 17))
>C : Symbol(E.C, Decl(keyofAndIndexedAccess.ts, 19, 20))
>E : Symbol(E, Decl(keyofAndIndexedAccess.ts, 21, 40))
>A : Symbol(E.A, Decl(keyofAndIndexedAccess.ts, 23, 14))
>B : Symbol(E.B, Decl(keyofAndIndexedAccess.ts, 23, 17))
>C : Symbol(E.C, Decl(keyofAndIndexedAccess.ts, 23, 20))
type K00 = keyof any; // string | number
>K00 : Symbol(K00, Decl(keyofAndIndexedAccess.ts, 19, 24))
>K00 : Symbol(K00, Decl(keyofAndIndexedAccess.ts, 23, 24))
type K01 = keyof string; // number | "toString" | "charAt" | ...
>K01 : Symbol(K01, Decl(keyofAndIndexedAccess.ts, 21, 21))
>K01 : Symbol(K01, Decl(keyofAndIndexedAccess.ts, 25, 21))
type K02 = keyof number; // "toString" | "toFixed" | "toExponential" | ...
>K02 : Symbol(K02, Decl(keyofAndIndexedAccess.ts, 22, 24))
>K02 : Symbol(K02, Decl(keyofAndIndexedAccess.ts, 26, 24))
type K03 = keyof boolean; // "valueOf"
>K03 : Symbol(K03, Decl(keyofAndIndexedAccess.ts, 23, 24))
>K03 : Symbol(K03, Decl(keyofAndIndexedAccess.ts, 27, 24))
type K04 = keyof void; // never
>K04 : Symbol(K04, Decl(keyofAndIndexedAccess.ts, 24, 25))
>K04 : Symbol(K04, Decl(keyofAndIndexedAccess.ts, 28, 25))
type K05 = keyof undefined; // never
>K05 : Symbol(K05, Decl(keyofAndIndexedAccess.ts, 25, 22))
>K05 : Symbol(K05, Decl(keyofAndIndexedAccess.ts, 29, 22))
type K06 = keyof null; // never
>K06 : Symbol(K06, Decl(keyofAndIndexedAccess.ts, 26, 27))
>K06 : Symbol(K06, Decl(keyofAndIndexedAccess.ts, 30, 27))
type K07 = keyof never; // never
>K07 : Symbol(K07, Decl(keyofAndIndexedAccess.ts, 27, 22))
>K07 : Symbol(K07, Decl(keyofAndIndexedAccess.ts, 31, 22))
type K10 = keyof Shape; // "name" | "width" | "height" | "visible"
>K10 : Symbol(K10, Decl(keyofAndIndexedAccess.ts, 28, 23))
>K10 : Symbol(K10, Decl(keyofAndIndexedAccess.ts, 32, 23))
>Shape : Symbol(Shape, Decl(keyofAndIndexedAccess.ts, 0, 0))
type K11 = keyof Shape[]; // number | "length" | "toString" | ...
>K11 : Symbol(K11, Decl(keyofAndIndexedAccess.ts, 30, 23))
>K11 : Symbol(K11, Decl(keyofAndIndexedAccess.ts, 34, 23))
>Shape : Symbol(Shape, Decl(keyofAndIndexedAccess.ts, 0, 0))
type K12 = keyof Dictionary<Shape>; // string | number
>K12 : Symbol(K12, Decl(keyofAndIndexedAccess.ts, 31, 25))
>Dictionary : Symbol(Dictionary, Decl(keyofAndIndexedAccess.ts, 15, 1))
>K12 : Symbol(K12, Decl(keyofAndIndexedAccess.ts, 35, 25))
>Dictionary : Symbol(Dictionary, Decl(keyofAndIndexedAccess.ts, 19, 1))
>Shape : Symbol(Shape, Decl(keyofAndIndexedAccess.ts, 0, 0))
type K13 = keyof {}; // never
>K13 : Symbol(K13, Decl(keyofAndIndexedAccess.ts, 32, 35))
>K13 : Symbol(K13, Decl(keyofAndIndexedAccess.ts, 36, 35))
type K14 = keyof Object; // "constructor" | "toString" | ...
>K14 : Symbol(K14, Decl(keyofAndIndexedAccess.ts, 33, 20))
>K14 : Symbol(K14, Decl(keyofAndIndexedAccess.ts, 37, 20))
>Object : Symbol(Object, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
type K15 = keyof E; // "toString" | "toFixed" | "toExponential" | ...
>K15 : Symbol(K15, Decl(keyofAndIndexedAccess.ts, 34, 24))
>E : Symbol(E, Decl(keyofAndIndexedAccess.ts, 17, 40))
>K15 : Symbol(K15, Decl(keyofAndIndexedAccess.ts, 38, 24))
>E : Symbol(E, Decl(keyofAndIndexedAccess.ts, 21, 40))
type K16 = keyof [string, number]; // number | "0" | "1" | "length" | "toString" | ...
>K16 : Symbol(K16, Decl(keyofAndIndexedAccess.ts, 35, 19))
>K16 : Symbol(K16, Decl(keyofAndIndexedAccess.ts, 39, 19))
type K17 = keyof (Shape | Item); // "name"
>K17 : Symbol(K17, Decl(keyofAndIndexedAccess.ts, 36, 34))
>K17 : Symbol(K17, Decl(keyofAndIndexedAccess.ts, 40, 34))
>Shape : Symbol(Shape, Decl(keyofAndIndexedAccess.ts, 0, 0))
>Item : Symbol(Item, Decl(keyofAndIndexedAccess.ts, 6, 1))
>Item : Symbol(Item, Decl(keyofAndIndexedAccess.ts, 10, 1))
type K18 = keyof (Shape & Item); // "name" | "width" | "height" | "visible" | "price"
>K18 : Symbol(K18, Decl(keyofAndIndexedAccess.ts, 37, 32))
>K18 : Symbol(K18, Decl(keyofAndIndexedAccess.ts, 41, 32))
>Shape : Symbol(Shape, Decl(keyofAndIndexedAccess.ts, 0, 0))
>Item : Symbol(Item, Decl(keyofAndIndexedAccess.ts, 6, 1))
>Item : Symbol(Item, Decl(keyofAndIndexedAccess.ts, 10, 1))
type KeyOf<T> = keyof T;
>KeyOf : Symbol(KeyOf, Decl(keyofAndIndexedAccess.ts, 38, 32))
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 40, 11))
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 40, 11))
>KeyOf : Symbol(KeyOf, Decl(keyofAndIndexedAccess.ts, 42, 32))
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 44, 11))
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 44, 11))
type K20 = KeyOf<Shape>; // "name" | "width" | "height" | "visible"
>K20 : Symbol(K20, Decl(keyofAndIndexedAccess.ts, 40, 24))
>KeyOf : Symbol(KeyOf, Decl(keyofAndIndexedAccess.ts, 38, 32))
>K20 : Symbol(K20, Decl(keyofAndIndexedAccess.ts, 44, 24))
>KeyOf : Symbol(KeyOf, Decl(keyofAndIndexedAccess.ts, 42, 32))
>Shape : Symbol(Shape, Decl(keyofAndIndexedAccess.ts, 0, 0))
type K21 = KeyOf<Dictionary<Shape>>; // string | number
>K21 : Symbol(K21, Decl(keyofAndIndexedAccess.ts, 42, 24))
>KeyOf : Symbol(KeyOf, Decl(keyofAndIndexedAccess.ts, 38, 32))
>Dictionary : Symbol(Dictionary, Decl(keyofAndIndexedAccess.ts, 15, 1))
>K21 : Symbol(K21, Decl(keyofAndIndexedAccess.ts, 46, 24))
>KeyOf : Symbol(KeyOf, Decl(keyofAndIndexedAccess.ts, 42, 32))
>Dictionary : Symbol(Dictionary, Decl(keyofAndIndexedAccess.ts, 19, 1))
>Shape : Symbol(Shape, Decl(keyofAndIndexedAccess.ts, 0, 0))
type NAME = "name";
>NAME : Symbol(NAME, Decl(keyofAndIndexedAccess.ts, 43, 36))
>NAME : Symbol(NAME, Decl(keyofAndIndexedAccess.ts, 47, 36))
type WIDTH_OR_HEIGHT = "width" | "height";
>WIDTH_OR_HEIGHT : Symbol(WIDTH_OR_HEIGHT, Decl(keyofAndIndexedAccess.ts, 45, 19))
>WIDTH_OR_HEIGHT : Symbol(WIDTH_OR_HEIGHT, Decl(keyofAndIndexedAccess.ts, 49, 19))
type Q10 = Shape["name"]; // string
>Q10 : Symbol(Q10, Decl(keyofAndIndexedAccess.ts, 46, 42))
>Q10 : Symbol(Q10, Decl(keyofAndIndexedAccess.ts, 50, 42))
>Shape : Symbol(Shape, Decl(keyofAndIndexedAccess.ts, 0, 0))
type Q11 = Shape["width" | "height"]; // number
>Q11 : Symbol(Q11, Decl(keyofAndIndexedAccess.ts, 48, 25))
>Q11 : Symbol(Q11, Decl(keyofAndIndexedAccess.ts, 52, 25))
>Shape : Symbol(Shape, Decl(keyofAndIndexedAccess.ts, 0, 0))
type Q12 = Shape["name" | "visible"]; // string | boolean
>Q12 : Symbol(Q12, Decl(keyofAndIndexedAccess.ts, 49, 37))
>Q12 : Symbol(Q12, Decl(keyofAndIndexedAccess.ts, 53, 37))
>Shape : Symbol(Shape, Decl(keyofAndIndexedAccess.ts, 0, 0))
type Q20 = Shape[NAME]; // string
>Q20 : Symbol(Q20, Decl(keyofAndIndexedAccess.ts, 50, 37))
>Q20 : Symbol(Q20, Decl(keyofAndIndexedAccess.ts, 54, 37))
>Shape : Symbol(Shape, Decl(keyofAndIndexedAccess.ts, 0, 0))
>NAME : Symbol(NAME, Decl(keyofAndIndexedAccess.ts, 43, 36))
>NAME : Symbol(NAME, Decl(keyofAndIndexedAccess.ts, 47, 36))
type Q21 = Shape[WIDTH_OR_HEIGHT]; // number
>Q21 : Symbol(Q21, Decl(keyofAndIndexedAccess.ts, 52, 23))
>Q21 : Symbol(Q21, Decl(keyofAndIndexedAccess.ts, 56, 23))
>Shape : Symbol(Shape, Decl(keyofAndIndexedAccess.ts, 0, 0))
>WIDTH_OR_HEIGHT : Symbol(WIDTH_OR_HEIGHT, Decl(keyofAndIndexedAccess.ts, 45, 19))
>WIDTH_OR_HEIGHT : Symbol(WIDTH_OR_HEIGHT, Decl(keyofAndIndexedAccess.ts, 49, 19))
type Q30 = [string, number][0]; // string
>Q30 : Symbol(Q30, Decl(keyofAndIndexedAccess.ts, 53, 34))
>Q30 : Symbol(Q30, Decl(keyofAndIndexedAccess.ts, 57, 34))
type Q31 = [string, number][1]; // number
>Q31 : Symbol(Q31, Decl(keyofAndIndexedAccess.ts, 55, 31))
>Q31 : Symbol(Q31, Decl(keyofAndIndexedAccess.ts, 59, 31))
type Q32 = [string, number][2]; // string | number
>Q32 : Symbol(Q32, Decl(keyofAndIndexedAccess.ts, 56, 31))
>Q32 : Symbol(Q32, Decl(keyofAndIndexedAccess.ts, 60, 31))
type Q33 = [string, number][E.A]; // string
>Q33 : Symbol(Q33, Decl(keyofAndIndexedAccess.ts, 57, 31))
>E : Symbol(E, Decl(keyofAndIndexedAccess.ts, 17, 40))
>A : Symbol(E.A, Decl(keyofAndIndexedAccess.ts, 19, 14))
>Q33 : Symbol(Q33, Decl(keyofAndIndexedAccess.ts, 61, 31))
>E : Symbol(E, Decl(keyofAndIndexedAccess.ts, 21, 40))
>A : Symbol(E.A, Decl(keyofAndIndexedAccess.ts, 23, 14))
type Q34 = [string, number][E.B]; // number
>Q34 : Symbol(Q34, Decl(keyofAndIndexedAccess.ts, 58, 33))
>E : Symbol(E, Decl(keyofAndIndexedAccess.ts, 17, 40))
>B : Symbol(E.B, Decl(keyofAndIndexedAccess.ts, 19, 17))
>Q34 : Symbol(Q34, Decl(keyofAndIndexedAccess.ts, 62, 33))
>E : Symbol(E, Decl(keyofAndIndexedAccess.ts, 21, 40))
>B : Symbol(E.B, Decl(keyofAndIndexedAccess.ts, 23, 17))
type Q35 = [string, number][E.C]; // string | number
>Q35 : Symbol(Q35, Decl(keyofAndIndexedAccess.ts, 59, 33))
>E : Symbol(E, Decl(keyofAndIndexedAccess.ts, 17, 40))
>C : Symbol(E.C, Decl(keyofAndIndexedAccess.ts, 19, 20))
>Q35 : Symbol(Q35, Decl(keyofAndIndexedAccess.ts, 63, 33))
>E : Symbol(E, Decl(keyofAndIndexedAccess.ts, 21, 40))
>C : Symbol(E.C, Decl(keyofAndIndexedAccess.ts, 23, 20))
type Q36 = [string, number]["0"]; // string
>Q36 : Symbol(Q36, Decl(keyofAndIndexedAccess.ts, 60, 33))
>Q36 : Symbol(Q36, Decl(keyofAndIndexedAccess.ts, 64, 33))
type Q37 = [string, number]["1"]; // string
>Q37 : Symbol(Q37, Decl(keyofAndIndexedAccess.ts, 61, 33))
>Q37 : Symbol(Q37, Decl(keyofAndIndexedAccess.ts, 65, 33))
type Q40 = (Shape | Options)["visible"]; // boolean | "yes" | "no"
>Q40 : Symbol(Q40, Decl(keyofAndIndexedAccess.ts, 62, 33))
>Q40 : Symbol(Q40, Decl(keyofAndIndexedAccess.ts, 66, 33))
>Shape : Symbol(Shape, Decl(keyofAndIndexedAccess.ts, 0, 0))
>Options : Symbol(Options, Decl(keyofAndIndexedAccess.ts, 11, 1))
>Options : Symbol(Options, Decl(keyofAndIndexedAccess.ts, 15, 1))
type Q41 = (Shape & Options)["visible"]; // true & "yes" | true & "no" | false & "yes" | false & "no"
>Q41 : Symbol(Q41, Decl(keyofAndIndexedAccess.ts, 64, 40))
>Q41 : Symbol(Q41, Decl(keyofAndIndexedAccess.ts, 68, 40))
>Shape : Symbol(Shape, Decl(keyofAndIndexedAccess.ts, 0, 0))
>Options : Symbol(Options, Decl(keyofAndIndexedAccess.ts, 11, 1))
>Options : Symbol(Options, Decl(keyofAndIndexedAccess.ts, 15, 1))
type Q50 = Dictionary<Shape>["howdy"]; // Shape
>Q50 : Symbol(Q50, Decl(keyofAndIndexedAccess.ts, 65, 40))
>Dictionary : Symbol(Dictionary, Decl(keyofAndIndexedAccess.ts, 15, 1))
>Q50 : Symbol(Q50, Decl(keyofAndIndexedAccess.ts, 69, 40))
>Dictionary : Symbol(Dictionary, Decl(keyofAndIndexedAccess.ts, 19, 1))
>Shape : Symbol(Shape, Decl(keyofAndIndexedAccess.ts, 0, 0))
type Q51 = Dictionary<Shape>[123]; // Shape
>Q51 : Symbol(Q51, Decl(keyofAndIndexedAccess.ts, 67, 38))
>Dictionary : Symbol(Dictionary, Decl(keyofAndIndexedAccess.ts, 15, 1))
>Q51 : Symbol(Q51, Decl(keyofAndIndexedAccess.ts, 71, 38))
>Dictionary : Symbol(Dictionary, Decl(keyofAndIndexedAccess.ts, 19, 1))
>Shape : Symbol(Shape, Decl(keyofAndIndexedAccess.ts, 0, 0))
type Q52 = Dictionary<Shape>[E.B]; // Shape
>Q52 : Symbol(Q52, Decl(keyofAndIndexedAccess.ts, 68, 34))
>Dictionary : Symbol(Dictionary, Decl(keyofAndIndexedAccess.ts, 15, 1))
>Q52 : Symbol(Q52, Decl(keyofAndIndexedAccess.ts, 72, 34))
>Dictionary : Symbol(Dictionary, Decl(keyofAndIndexedAccess.ts, 19, 1))
>Shape : Symbol(Shape, Decl(keyofAndIndexedAccess.ts, 0, 0))
>E : Symbol(E, Decl(keyofAndIndexedAccess.ts, 17, 40))
>B : Symbol(E.B, Decl(keyofAndIndexedAccess.ts, 19, 17))
>E : Symbol(E, Decl(keyofAndIndexedAccess.ts, 21, 40))
>B : Symbol(E.B, Decl(keyofAndIndexedAccess.ts, 23, 17))
declare let cond: boolean;
>cond : Symbol(cond, Decl(keyofAndIndexedAccess.ts, 71, 11))
>cond : Symbol(cond, Decl(keyofAndIndexedAccess.ts, 75, 11))
function getProperty<T, K extends keyof T>(obj: T, key: K) {
>getProperty : Symbol(getProperty, Decl(keyofAndIndexedAccess.ts, 71, 26))
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 73, 21))
>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 73, 23))
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 73, 21))
>obj : Symbol(obj, Decl(keyofAndIndexedAccess.ts, 73, 43))
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 73, 21))
>key : Symbol(key, Decl(keyofAndIndexedAccess.ts, 73, 50))
>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 73, 23))
>getProperty : Symbol(getProperty, Decl(keyofAndIndexedAccess.ts, 75, 26))
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 77, 21))
>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 77, 23))
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 77, 21))
>obj : Symbol(obj, Decl(keyofAndIndexedAccess.ts, 77, 43))
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 77, 21))
>key : Symbol(key, Decl(keyofAndIndexedAccess.ts, 77, 50))
>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 77, 23))
return obj[key];
>obj : Symbol(obj, Decl(keyofAndIndexedAccess.ts, 73, 43))
>key : Symbol(key, Decl(keyofAndIndexedAccess.ts, 73, 50))
>obj : Symbol(obj, Decl(keyofAndIndexedAccess.ts, 77, 43))
>key : Symbol(key, Decl(keyofAndIndexedAccess.ts, 77, 50))
}
function setProperty<T, K extends keyof T>(obj: T, key: K, value: T[K]) {
>setProperty : Symbol(setProperty, Decl(keyofAndIndexedAccess.ts, 75, 1))
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 77, 21))
>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 77, 23))
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 77, 21))
>obj : Symbol(obj, Decl(keyofAndIndexedAccess.ts, 77, 43))
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 77, 21))
>key : Symbol(key, Decl(keyofAndIndexedAccess.ts, 77, 50))
>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 77, 23))
>value : Symbol(value, Decl(keyofAndIndexedAccess.ts, 77, 58))
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 77, 21))
>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 77, 23))
>setProperty : Symbol(setProperty, Decl(keyofAndIndexedAccess.ts, 79, 1))
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 81, 21))
>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 81, 23))
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 81, 21))
>obj : Symbol(obj, Decl(keyofAndIndexedAccess.ts, 81, 43))
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 81, 21))
>key : Symbol(key, Decl(keyofAndIndexedAccess.ts, 81, 50))
>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 81, 23))
>value : Symbol(value, Decl(keyofAndIndexedAccess.ts, 81, 58))
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 81, 21))
>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 81, 23))
obj[key] = value;
>obj : Symbol(obj, Decl(keyofAndIndexedAccess.ts, 77, 43))
>key : Symbol(key, Decl(keyofAndIndexedAccess.ts, 77, 50))
>value : Symbol(value, Decl(keyofAndIndexedAccess.ts, 77, 58))
>obj : Symbol(obj, Decl(keyofAndIndexedAccess.ts, 81, 43))
>key : Symbol(key, Decl(keyofAndIndexedAccess.ts, 81, 50))
>value : Symbol(value, Decl(keyofAndIndexedAccess.ts, 81, 58))
}
function f10(shape: Shape) {
>f10 : Symbol(f10, Decl(keyofAndIndexedAccess.ts, 79, 1))
>shape : Symbol(shape, Decl(keyofAndIndexedAccess.ts, 81, 13))
>f10 : Symbol(f10, Decl(keyofAndIndexedAccess.ts, 83, 1))
>shape : Symbol(shape, Decl(keyofAndIndexedAccess.ts, 85, 13))
>Shape : Symbol(Shape, Decl(keyofAndIndexedAccess.ts, 0, 0))
let name = getProperty(shape, "name"); // string
>name : Symbol(name, Decl(keyofAndIndexedAccess.ts, 82, 7))
>getProperty : Symbol(getProperty, Decl(keyofAndIndexedAccess.ts, 71, 26))
>shape : Symbol(shape, Decl(keyofAndIndexedAccess.ts, 81, 13))
>name : Symbol(name, Decl(keyofAndIndexedAccess.ts, 86, 7))
>getProperty : Symbol(getProperty, Decl(keyofAndIndexedAccess.ts, 75, 26))
>shape : Symbol(shape, Decl(keyofAndIndexedAccess.ts, 85, 13))
let widthOrHeight = getProperty(shape, cond ? "width" : "height"); // number
>widthOrHeight : Symbol(widthOrHeight, Decl(keyofAndIndexedAccess.ts, 83, 7))
>getProperty : Symbol(getProperty, Decl(keyofAndIndexedAccess.ts, 71, 26))
>shape : Symbol(shape, Decl(keyofAndIndexedAccess.ts, 81, 13))
>cond : Symbol(cond, Decl(keyofAndIndexedAccess.ts, 71, 11))
>widthOrHeight : Symbol(widthOrHeight, Decl(keyofAndIndexedAccess.ts, 87, 7))
>getProperty : Symbol(getProperty, Decl(keyofAndIndexedAccess.ts, 75, 26))
>shape : Symbol(shape, Decl(keyofAndIndexedAccess.ts, 85, 13))
>cond : Symbol(cond, Decl(keyofAndIndexedAccess.ts, 75, 11))
let nameOrVisible = getProperty(shape, cond ? "name" : "visible"); // string | boolean
>nameOrVisible : Symbol(nameOrVisible, Decl(keyofAndIndexedAccess.ts, 84, 7))
>getProperty : Symbol(getProperty, Decl(keyofAndIndexedAccess.ts, 71, 26))
>shape : Symbol(shape, Decl(keyofAndIndexedAccess.ts, 81, 13))
>cond : Symbol(cond, Decl(keyofAndIndexedAccess.ts, 71, 11))
>nameOrVisible : Symbol(nameOrVisible, Decl(keyofAndIndexedAccess.ts, 88, 7))
>getProperty : Symbol(getProperty, Decl(keyofAndIndexedAccess.ts, 75, 26))
>shape : Symbol(shape, Decl(keyofAndIndexedAccess.ts, 85, 13))
>cond : Symbol(cond, Decl(keyofAndIndexedAccess.ts, 75, 11))
setProperty(shape, "name", "rectangle");
>setProperty : Symbol(setProperty, Decl(keyofAndIndexedAccess.ts, 75, 1))
>shape : Symbol(shape, Decl(keyofAndIndexedAccess.ts, 81, 13))
>setProperty : Symbol(setProperty, Decl(keyofAndIndexedAccess.ts, 79, 1))
>shape : Symbol(shape, Decl(keyofAndIndexedAccess.ts, 85, 13))
setProperty(shape, cond ? "width" : "height", 10);
>setProperty : Symbol(setProperty, Decl(keyofAndIndexedAccess.ts, 75, 1))
>shape : Symbol(shape, Decl(keyofAndIndexedAccess.ts, 81, 13))
>cond : Symbol(cond, Decl(keyofAndIndexedAccess.ts, 71, 11))
>setProperty : Symbol(setProperty, Decl(keyofAndIndexedAccess.ts, 79, 1))
>shape : Symbol(shape, Decl(keyofAndIndexedAccess.ts, 85, 13))
>cond : Symbol(cond, Decl(keyofAndIndexedAccess.ts, 75, 11))
setProperty(shape, cond ? "name" : "visible", true); // Technically not safe
>setProperty : Symbol(setProperty, Decl(keyofAndIndexedAccess.ts, 75, 1))
>shape : Symbol(shape, Decl(keyofAndIndexedAccess.ts, 81, 13))
>cond : Symbol(cond, Decl(keyofAndIndexedAccess.ts, 71, 11))
>setProperty : Symbol(setProperty, Decl(keyofAndIndexedAccess.ts, 79, 1))
>shape : Symbol(shape, Decl(keyofAndIndexedAccess.ts, 85, 13))
>cond : Symbol(cond, Decl(keyofAndIndexedAccess.ts, 75, 11))
}
function f11(a: Shape[]) {
>f11 : Symbol(f11, Decl(keyofAndIndexedAccess.ts, 88, 1))
>a : Symbol(a, Decl(keyofAndIndexedAccess.ts, 90, 13))
>f11 : Symbol(f11, Decl(keyofAndIndexedAccess.ts, 92, 1))
>a : Symbol(a, Decl(keyofAndIndexedAccess.ts, 94, 13))
>Shape : Symbol(Shape, Decl(keyofAndIndexedAccess.ts, 0, 0))
let len = getProperty(a, "length"); // number
>len : Symbol(len, Decl(keyofAndIndexedAccess.ts, 91, 7))
>getProperty : Symbol(getProperty, Decl(keyofAndIndexedAccess.ts, 71, 26))
>a : Symbol(a, Decl(keyofAndIndexedAccess.ts, 90, 13))
>len : Symbol(len, Decl(keyofAndIndexedAccess.ts, 95, 7))
>getProperty : Symbol(getProperty, Decl(keyofAndIndexedAccess.ts, 75, 26))
>a : Symbol(a, Decl(keyofAndIndexedAccess.ts, 94, 13))
let shape = getProperty(a, 1000); // Shape
>shape : Symbol(shape, Decl(keyofAndIndexedAccess.ts, 92, 7))
>getProperty : Symbol(getProperty, Decl(keyofAndIndexedAccess.ts, 71, 26))
>a : Symbol(a, Decl(keyofAndIndexedAccess.ts, 90, 13))
>shape : Symbol(shape, Decl(keyofAndIndexedAccess.ts, 96, 7))
>getProperty : Symbol(getProperty, Decl(keyofAndIndexedAccess.ts, 75, 26))
>a : Symbol(a, Decl(keyofAndIndexedAccess.ts, 94, 13))
setProperty(a, 1000, getProperty(a, 1001));
>setProperty : Symbol(setProperty, Decl(keyofAndIndexedAccess.ts, 75, 1))
>a : Symbol(a, Decl(keyofAndIndexedAccess.ts, 90, 13))
>getProperty : Symbol(getProperty, Decl(keyofAndIndexedAccess.ts, 71, 26))
>a : Symbol(a, Decl(keyofAndIndexedAccess.ts, 90, 13))
>setProperty : Symbol(setProperty, Decl(keyofAndIndexedAccess.ts, 79, 1))
>a : Symbol(a, Decl(keyofAndIndexedAccess.ts, 94, 13))
>getProperty : Symbol(getProperty, Decl(keyofAndIndexedAccess.ts, 75, 26))
>a : Symbol(a, Decl(keyofAndIndexedAccess.ts, 94, 13))
}
function f12(t: [Shape, boolean]) {
>f12 : Symbol(f12, Decl(keyofAndIndexedAccess.ts, 94, 1))
>t : Symbol(t, Decl(keyofAndIndexedAccess.ts, 96, 13))
>f12 : Symbol(f12, Decl(keyofAndIndexedAccess.ts, 98, 1))
>t : Symbol(t, Decl(keyofAndIndexedAccess.ts, 100, 13))
>Shape : Symbol(Shape, Decl(keyofAndIndexedAccess.ts, 0, 0))
let len = getProperty(t, "length");
>len : Symbol(len, Decl(keyofAndIndexedAccess.ts, 97, 7))
>getProperty : Symbol(getProperty, Decl(keyofAndIndexedAccess.ts, 71, 26))
>t : Symbol(t, Decl(keyofAndIndexedAccess.ts, 96, 13))
>len : Symbol(len, Decl(keyofAndIndexedAccess.ts, 101, 7))
>getProperty : Symbol(getProperty, Decl(keyofAndIndexedAccess.ts, 75, 26))
>t : Symbol(t, Decl(keyofAndIndexedAccess.ts, 100, 13))
let s1 = getProperty(t, 0); // Shape
>s1 : Symbol(s1, Decl(keyofAndIndexedAccess.ts, 98, 7))
>getProperty : Symbol(getProperty, Decl(keyofAndIndexedAccess.ts, 71, 26))
>t : Symbol(t, Decl(keyofAndIndexedAccess.ts, 96, 13))
>s1 : Symbol(s1, Decl(keyofAndIndexedAccess.ts, 102, 7))
>getProperty : Symbol(getProperty, Decl(keyofAndIndexedAccess.ts, 75, 26))
>t : Symbol(t, Decl(keyofAndIndexedAccess.ts, 100, 13))
let s2 = getProperty(t, "0"); // Shape
>s2 : Symbol(s2, Decl(keyofAndIndexedAccess.ts, 99, 7))
>getProperty : Symbol(getProperty, Decl(keyofAndIndexedAccess.ts, 71, 26))
>t : Symbol(t, Decl(keyofAndIndexedAccess.ts, 96, 13))
>s2 : Symbol(s2, Decl(keyofAndIndexedAccess.ts, 103, 7))
>getProperty : Symbol(getProperty, Decl(keyofAndIndexedAccess.ts, 75, 26))
>t : Symbol(t, Decl(keyofAndIndexedAccess.ts, 100, 13))
let b1 = getProperty(t, 1); // boolean
>b1 : Symbol(b1, Decl(keyofAndIndexedAccess.ts, 100, 7))
>getProperty : Symbol(getProperty, Decl(keyofAndIndexedAccess.ts, 71, 26))
>t : Symbol(t, Decl(keyofAndIndexedAccess.ts, 96, 13))
>b1 : Symbol(b1, Decl(keyofAndIndexedAccess.ts, 104, 7))
>getProperty : Symbol(getProperty, Decl(keyofAndIndexedAccess.ts, 75, 26))
>t : Symbol(t, Decl(keyofAndIndexedAccess.ts, 100, 13))
let b2 = getProperty(t, "1"); // boolean
>b2 : Symbol(b2, Decl(keyofAndIndexedAccess.ts, 101, 7))
>getProperty : Symbol(getProperty, Decl(keyofAndIndexedAccess.ts, 71, 26))
>t : Symbol(t, Decl(keyofAndIndexedAccess.ts, 96, 13))
>b2 : Symbol(b2, Decl(keyofAndIndexedAccess.ts, 105, 7))
>getProperty : Symbol(getProperty, Decl(keyofAndIndexedAccess.ts, 75, 26))
>t : Symbol(t, Decl(keyofAndIndexedAccess.ts, 100, 13))
let x1 = getProperty(t, 2); // Shape | boolean
>x1 : Symbol(x1, Decl(keyofAndIndexedAccess.ts, 102, 7))
>getProperty : Symbol(getProperty, Decl(keyofAndIndexedAccess.ts, 71, 26))
>t : Symbol(t, Decl(keyofAndIndexedAccess.ts, 96, 13))
>x1 : Symbol(x1, Decl(keyofAndIndexedAccess.ts, 106, 7))
>getProperty : Symbol(getProperty, Decl(keyofAndIndexedAccess.ts, 75, 26))
>t : Symbol(t, Decl(keyofAndIndexedAccess.ts, 100, 13))
}
function f13(foo: any, bar: any) {
>f13 : Symbol(f13, Decl(keyofAndIndexedAccess.ts, 103, 1))
>foo : Symbol(foo, Decl(keyofAndIndexedAccess.ts, 105, 13))
>bar : Symbol(bar, Decl(keyofAndIndexedAccess.ts, 105, 22))
>f13 : Symbol(f13, Decl(keyofAndIndexedAccess.ts, 107, 1))
>foo : Symbol(foo, Decl(keyofAndIndexedAccess.ts, 109, 13))
>bar : Symbol(bar, Decl(keyofAndIndexedAccess.ts, 109, 22))
let x = getProperty(foo, "x"); // any
>x : Symbol(x, Decl(keyofAndIndexedAccess.ts, 106, 7))
>getProperty : Symbol(getProperty, Decl(keyofAndIndexedAccess.ts, 71, 26))
>foo : Symbol(foo, Decl(keyofAndIndexedAccess.ts, 105, 13))
>x : Symbol(x, Decl(keyofAndIndexedAccess.ts, 110, 7))
>getProperty : Symbol(getProperty, Decl(keyofAndIndexedAccess.ts, 75, 26))
>foo : Symbol(foo, Decl(keyofAndIndexedAccess.ts, 109, 13))
let y = getProperty(foo, 100); // any
>y : Symbol(y, Decl(keyofAndIndexedAccess.ts, 107, 7))
>getProperty : Symbol(getProperty, Decl(keyofAndIndexedAccess.ts, 71, 26))
>foo : Symbol(foo, Decl(keyofAndIndexedAccess.ts, 105, 13))
>y : Symbol(y, Decl(keyofAndIndexedAccess.ts, 111, 7))
>getProperty : Symbol(getProperty, Decl(keyofAndIndexedAccess.ts, 75, 26))
>foo : Symbol(foo, Decl(keyofAndIndexedAccess.ts, 109, 13))
let z = getProperty(foo, bar); // any
>z : Symbol(z, Decl(keyofAndIndexedAccess.ts, 108, 7))
>getProperty : Symbol(getProperty, Decl(keyofAndIndexedAccess.ts, 71, 26))
>foo : Symbol(foo, Decl(keyofAndIndexedAccess.ts, 105, 13))
>bar : Symbol(bar, Decl(keyofAndIndexedAccess.ts, 105, 22))
>z : Symbol(z, Decl(keyofAndIndexedAccess.ts, 112, 7))
>getProperty : Symbol(getProperty, Decl(keyofAndIndexedAccess.ts, 75, 26))
>foo : Symbol(foo, Decl(keyofAndIndexedAccess.ts, 109, 13))
>bar : Symbol(bar, Decl(keyofAndIndexedAccess.ts, 109, 22))
}
class Component<PropType> {
>Component : Symbol(Component, Decl(keyofAndIndexedAccess.ts, 109, 1))
>PropType : Symbol(PropType, Decl(keyofAndIndexedAccess.ts, 111, 16))
>Component : Symbol(Component, Decl(keyofAndIndexedAccess.ts, 113, 1))
>PropType : Symbol(PropType, Decl(keyofAndIndexedAccess.ts, 115, 16))
props: PropType;
>props : Symbol(Component.props, Decl(keyofAndIndexedAccess.ts, 111, 27))
>PropType : Symbol(PropType, Decl(keyofAndIndexedAccess.ts, 111, 16))
>props : Symbol(Component.props, Decl(keyofAndIndexedAccess.ts, 115, 27))
>PropType : Symbol(PropType, Decl(keyofAndIndexedAccess.ts, 115, 16))
getProperty<K extends keyof PropType>(key: K) {
>getProperty : Symbol(Component.getProperty, Decl(keyofAndIndexedAccess.ts, 112, 20))
>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 113, 16))
>PropType : Symbol(PropType, Decl(keyofAndIndexedAccess.ts, 111, 16))
>key : Symbol(key, Decl(keyofAndIndexedAccess.ts, 113, 42))
>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 113, 16))
>getProperty : Symbol(Component.getProperty, Decl(keyofAndIndexedAccess.ts, 116, 20))
>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 117, 16))
>PropType : Symbol(PropType, Decl(keyofAndIndexedAccess.ts, 115, 16))
>key : Symbol(key, Decl(keyofAndIndexedAccess.ts, 117, 42))
>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 117, 16))
return this.props[key];
>this.props : Symbol(Component.props, Decl(keyofAndIndexedAccess.ts, 111, 27))
>this : Symbol(Component, Decl(keyofAndIndexedAccess.ts, 109, 1))
>props : Symbol(Component.props, Decl(keyofAndIndexedAccess.ts, 111, 27))
>key : Symbol(key, Decl(keyofAndIndexedAccess.ts, 113, 42))
>this.props : Symbol(Component.props, Decl(keyofAndIndexedAccess.ts, 115, 27))
>this : Symbol(Component, Decl(keyofAndIndexedAccess.ts, 113, 1))
>props : Symbol(Component.props, Decl(keyofAndIndexedAccess.ts, 115, 27))
>key : Symbol(key, Decl(keyofAndIndexedAccess.ts, 117, 42))
}
setProperty<K extends keyof PropType>(key: K, value: PropType[K]) {
>setProperty : Symbol(Component.setProperty, Decl(keyofAndIndexedAccess.ts, 115, 5))
>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 116, 16))
>PropType : Symbol(PropType, Decl(keyofAndIndexedAccess.ts, 111, 16))
>key : Symbol(key, Decl(keyofAndIndexedAccess.ts, 116, 42))
>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 116, 16))
>value : Symbol(value, Decl(keyofAndIndexedAccess.ts, 116, 49))
>PropType : Symbol(PropType, Decl(keyofAndIndexedAccess.ts, 111, 16))
>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 116, 16))
>setProperty : Symbol(Component.setProperty, Decl(keyofAndIndexedAccess.ts, 119, 5))
>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 120, 16))
>PropType : Symbol(PropType, Decl(keyofAndIndexedAccess.ts, 115, 16))
>key : Symbol(key, Decl(keyofAndIndexedAccess.ts, 120, 42))
>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 120, 16))
>value : Symbol(value, Decl(keyofAndIndexedAccess.ts, 120, 49))
>PropType : Symbol(PropType, Decl(keyofAndIndexedAccess.ts, 115, 16))
>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 120, 16))
this.props[key] = value;
>this.props : Symbol(Component.props, Decl(keyofAndIndexedAccess.ts, 111, 27))
>this : Symbol(Component, Decl(keyofAndIndexedAccess.ts, 109, 1))
>props : Symbol(Component.props, Decl(keyofAndIndexedAccess.ts, 111, 27))
>key : Symbol(key, Decl(keyofAndIndexedAccess.ts, 116, 42))
>value : Symbol(value, Decl(keyofAndIndexedAccess.ts, 116, 49))
>this.props : Symbol(Component.props, Decl(keyofAndIndexedAccess.ts, 115, 27))
>this : Symbol(Component, Decl(keyofAndIndexedAccess.ts, 113, 1))
>props : Symbol(Component.props, Decl(keyofAndIndexedAccess.ts, 115, 27))
>key : Symbol(key, Decl(keyofAndIndexedAccess.ts, 120, 42))
>value : Symbol(value, Decl(keyofAndIndexedAccess.ts, 120, 49))
}
}
function f20(component: Component<Shape>) {
>f20 : Symbol(f20, Decl(keyofAndIndexedAccess.ts, 119, 1))
>component : Symbol(component, Decl(keyofAndIndexedAccess.ts, 121, 13))
>Component : Symbol(Component, Decl(keyofAndIndexedAccess.ts, 109, 1))
>f20 : Symbol(f20, Decl(keyofAndIndexedAccess.ts, 123, 1))
>component : Symbol(component, Decl(keyofAndIndexedAccess.ts, 125, 13))
>Component : Symbol(Component, Decl(keyofAndIndexedAccess.ts, 113, 1))
>Shape : Symbol(Shape, Decl(keyofAndIndexedAccess.ts, 0, 0))
let name = component.getProperty("name"); // string
>name : Symbol(name, Decl(keyofAndIndexedAccess.ts, 122, 7))
>component.getProperty : Symbol(Component.getProperty, Decl(keyofAndIndexedAccess.ts, 112, 20))
>component : Symbol(component, Decl(keyofAndIndexedAccess.ts, 121, 13))
>getProperty : Symbol(Component.getProperty, Decl(keyofAndIndexedAccess.ts, 112, 20))
>name : Symbol(name, Decl(keyofAndIndexedAccess.ts, 126, 7))
>component.getProperty : Symbol(Component.getProperty, Decl(keyofAndIndexedAccess.ts, 116, 20))
>component : Symbol(component, Decl(keyofAndIndexedAccess.ts, 125, 13))
>getProperty : Symbol(Component.getProperty, Decl(keyofAndIndexedAccess.ts, 116, 20))
let widthOrHeight = component.getProperty(cond ? "width" : "height"); // number
>widthOrHeight : Symbol(widthOrHeight, Decl(keyofAndIndexedAccess.ts, 123, 7))
>component.getProperty : Symbol(Component.getProperty, Decl(keyofAndIndexedAccess.ts, 112, 20))
>component : Symbol(component, Decl(keyofAndIndexedAccess.ts, 121, 13))
>getProperty : Symbol(Component.getProperty, Decl(keyofAndIndexedAccess.ts, 112, 20))
>cond : Symbol(cond, Decl(keyofAndIndexedAccess.ts, 71, 11))
>widthOrHeight : Symbol(widthOrHeight, Decl(keyofAndIndexedAccess.ts, 127, 7))
>component.getProperty : Symbol(Component.getProperty, Decl(keyofAndIndexedAccess.ts, 116, 20))
>component : Symbol(component, Decl(keyofAndIndexedAccess.ts, 125, 13))
>getProperty : Symbol(Component.getProperty, Decl(keyofAndIndexedAccess.ts, 116, 20))
>cond : Symbol(cond, Decl(keyofAndIndexedAccess.ts, 75, 11))
let nameOrVisible = component.getProperty(cond ? "name" : "visible"); // string | boolean
>nameOrVisible : Symbol(nameOrVisible, Decl(keyofAndIndexedAccess.ts, 124, 7))
>component.getProperty : Symbol(Component.getProperty, Decl(keyofAndIndexedAccess.ts, 112, 20))
>component : Symbol(component, Decl(keyofAndIndexedAccess.ts, 121, 13))
>getProperty : Symbol(Component.getProperty, Decl(keyofAndIndexedAccess.ts, 112, 20))
>cond : Symbol(cond, Decl(keyofAndIndexedAccess.ts, 71, 11))
>nameOrVisible : Symbol(nameOrVisible, Decl(keyofAndIndexedAccess.ts, 128, 7))
>component.getProperty : Symbol(Component.getProperty, Decl(keyofAndIndexedAccess.ts, 116, 20))
>component : Symbol(component, Decl(keyofAndIndexedAccess.ts, 125, 13))
>getProperty : Symbol(Component.getProperty, Decl(keyofAndIndexedAccess.ts, 116, 20))
>cond : Symbol(cond, Decl(keyofAndIndexedAccess.ts, 75, 11))
component.setProperty("name", "rectangle");
>component.setProperty : Symbol(Component.setProperty, Decl(keyofAndIndexedAccess.ts, 115, 5))
>component : Symbol(component, Decl(keyofAndIndexedAccess.ts, 121, 13))
>setProperty : Symbol(Component.setProperty, Decl(keyofAndIndexedAccess.ts, 115, 5))
>component.setProperty : Symbol(Component.setProperty, Decl(keyofAndIndexedAccess.ts, 119, 5))
>component : Symbol(component, Decl(keyofAndIndexedAccess.ts, 125, 13))
>setProperty : Symbol(Component.setProperty, Decl(keyofAndIndexedAccess.ts, 119, 5))
component.setProperty(cond ? "width" : "height", 10)
>component.setProperty : Symbol(Component.setProperty, Decl(keyofAndIndexedAccess.ts, 115, 5))
>component : Symbol(component, Decl(keyofAndIndexedAccess.ts, 121, 13))
>setProperty : Symbol(Component.setProperty, Decl(keyofAndIndexedAccess.ts, 115, 5))
>cond : Symbol(cond, Decl(keyofAndIndexedAccess.ts, 71, 11))
>component.setProperty : Symbol(Component.setProperty, Decl(keyofAndIndexedAccess.ts, 119, 5))
>component : Symbol(component, Decl(keyofAndIndexedAccess.ts, 125, 13))
>setProperty : Symbol(Component.setProperty, Decl(keyofAndIndexedAccess.ts, 119, 5))
>cond : Symbol(cond, Decl(keyofAndIndexedAccess.ts, 75, 11))
component.setProperty(cond ? "name" : "visible", true); // Technically not safe
>component.setProperty : Symbol(Component.setProperty, Decl(keyofAndIndexedAccess.ts, 115, 5))
>component : Symbol(component, Decl(keyofAndIndexedAccess.ts, 121, 13))
>setProperty : Symbol(Component.setProperty, Decl(keyofAndIndexedAccess.ts, 115, 5))
>cond : Symbol(cond, Decl(keyofAndIndexedAccess.ts, 71, 11))
>component.setProperty : Symbol(Component.setProperty, Decl(keyofAndIndexedAccess.ts, 119, 5))
>component : Symbol(component, Decl(keyofAndIndexedAccess.ts, 125, 13))
>setProperty : Symbol(Component.setProperty, Decl(keyofAndIndexedAccess.ts, 119, 5))
>cond : Symbol(cond, Decl(keyofAndIndexedAccess.ts, 75, 11))
}
function pluck<T, K extends keyof T>(array: T[], key: K) {
>pluck : Symbol(pluck, Decl(keyofAndIndexedAccess.ts, 128, 1))
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 130, 15))
>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 130, 17))
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 130, 15))
>array : Symbol(array, Decl(keyofAndIndexedAccess.ts, 130, 37))
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 130, 15))
>key : Symbol(key, Decl(keyofAndIndexedAccess.ts, 130, 48))
>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 130, 17))
>pluck : Symbol(pluck, Decl(keyofAndIndexedAccess.ts, 132, 1))
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 134, 15))
>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 134, 17))
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 134, 15))
>array : Symbol(array, Decl(keyofAndIndexedAccess.ts, 134, 37))
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 134, 15))
>key : Symbol(key, Decl(keyofAndIndexedAccess.ts, 134, 48))
>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 134, 17))
return array.map(x => x[key]);
>array.map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
>array : Symbol(array, Decl(keyofAndIndexedAccess.ts, 130, 37))
>array : Symbol(array, Decl(keyofAndIndexedAccess.ts, 134, 37))
>map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
>x : Symbol(x, Decl(keyofAndIndexedAccess.ts, 131, 21))
>x : Symbol(x, Decl(keyofAndIndexedAccess.ts, 131, 21))
>key : Symbol(key, Decl(keyofAndIndexedAccess.ts, 130, 48))
>x : Symbol(x, Decl(keyofAndIndexedAccess.ts, 135, 21))
>x : Symbol(x, Decl(keyofAndIndexedAccess.ts, 135, 21))
>key : Symbol(key, Decl(keyofAndIndexedAccess.ts, 134, 48))
}
function f30(shapes: Shape[]) {
>f30 : Symbol(f30, Decl(keyofAndIndexedAccess.ts, 132, 1))
>shapes : Symbol(shapes, Decl(keyofAndIndexedAccess.ts, 134, 13))
>f30 : Symbol(f30, Decl(keyofAndIndexedAccess.ts, 136, 1))
>shapes : Symbol(shapes, Decl(keyofAndIndexedAccess.ts, 138, 13))
>Shape : Symbol(Shape, Decl(keyofAndIndexedAccess.ts, 0, 0))
let names = pluck(shapes, "name"); // string[]
>names : Symbol(names, Decl(keyofAndIndexedAccess.ts, 135, 7))
>pluck : Symbol(pluck, Decl(keyofAndIndexedAccess.ts, 128, 1))
>shapes : Symbol(shapes, Decl(keyofAndIndexedAccess.ts, 134, 13))
>names : Symbol(names, Decl(keyofAndIndexedAccess.ts, 139, 7))
>pluck : Symbol(pluck, Decl(keyofAndIndexedAccess.ts, 132, 1))
>shapes : Symbol(shapes, Decl(keyofAndIndexedAccess.ts, 138, 13))
let widths = pluck(shapes, "width"); // number[]
>widths : Symbol(widths, Decl(keyofAndIndexedAccess.ts, 136, 7))
>pluck : Symbol(pluck, Decl(keyofAndIndexedAccess.ts, 128, 1))
>shapes : Symbol(shapes, Decl(keyofAndIndexedAccess.ts, 134, 13))
>widths : Symbol(widths, Decl(keyofAndIndexedAccess.ts, 140, 7))
>pluck : Symbol(pluck, Decl(keyofAndIndexedAccess.ts, 132, 1))
>shapes : Symbol(shapes, Decl(keyofAndIndexedAccess.ts, 138, 13))
let nameOrVisibles = pluck(shapes, cond ? "name" : "visible"); // (string | boolean)[]
>nameOrVisibles : Symbol(nameOrVisibles, Decl(keyofAndIndexedAccess.ts, 137, 7))
>pluck : Symbol(pluck, Decl(keyofAndIndexedAccess.ts, 128, 1))
>shapes : Symbol(shapes, Decl(keyofAndIndexedAccess.ts, 134, 13))
>cond : Symbol(cond, Decl(keyofAndIndexedAccess.ts, 71, 11))
>nameOrVisibles : Symbol(nameOrVisibles, Decl(keyofAndIndexedAccess.ts, 141, 7))
>pluck : Symbol(pluck, Decl(keyofAndIndexedAccess.ts, 132, 1))
>shapes : Symbol(shapes, Decl(keyofAndIndexedAccess.ts, 138, 13))
>cond : Symbol(cond, Decl(keyofAndIndexedAccess.ts, 75, 11))
}
function f31<K extends keyof Shape>(key: K) {
>f31 : Symbol(f31, Decl(keyofAndIndexedAccess.ts, 138, 1))
>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 140, 13))
>f31 : Symbol(f31, Decl(keyofAndIndexedAccess.ts, 142, 1))
>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 144, 13))
>Shape : Symbol(Shape, Decl(keyofAndIndexedAccess.ts, 0, 0))
>key : Symbol(key, Decl(keyofAndIndexedAccess.ts, 140, 36))
>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 140, 13))
>key : Symbol(key, Decl(keyofAndIndexedAccess.ts, 144, 36))
>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 144, 13))
const shape: Shape = { name: "foo", width: 5, height: 10, visible: true };
>shape : Symbol(shape, Decl(keyofAndIndexedAccess.ts, 141, 9))
>shape : Symbol(shape, Decl(keyofAndIndexedAccess.ts, 145, 9))
>Shape : Symbol(Shape, Decl(keyofAndIndexedAccess.ts, 0, 0))
>name : Symbol(name, Decl(keyofAndIndexedAccess.ts, 141, 26))
>width : Symbol(width, Decl(keyofAndIndexedAccess.ts, 141, 39))
>height : Symbol(height, Decl(keyofAndIndexedAccess.ts, 141, 49))
>visible : Symbol(visible, Decl(keyofAndIndexedAccess.ts, 141, 61))
>name : Symbol(name, Decl(keyofAndIndexedAccess.ts, 145, 26))
>width : Symbol(width, Decl(keyofAndIndexedAccess.ts, 145, 39))
>height : Symbol(height, Decl(keyofAndIndexedAccess.ts, 145, 49))
>visible : Symbol(visible, Decl(keyofAndIndexedAccess.ts, 145, 61))
return shape[key]; // Shape[K]
>shape : Symbol(shape, Decl(keyofAndIndexedAccess.ts, 141, 9))
>key : Symbol(key, Decl(keyofAndIndexedAccess.ts, 140, 36))
>shape : Symbol(shape, Decl(keyofAndIndexedAccess.ts, 145, 9))
>key : Symbol(key, Decl(keyofAndIndexedAccess.ts, 144, 36))
}
function f32<K extends "width" | "height">(key: K) {
>f32 : Symbol(f32, Decl(keyofAndIndexedAccess.ts, 143, 1))
>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 145, 13))
>key : Symbol(key, Decl(keyofAndIndexedAccess.ts, 145, 43))
>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 145, 13))
>f32 : Symbol(f32, Decl(keyofAndIndexedAccess.ts, 147, 1))
>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 149, 13))
>key : Symbol(key, Decl(keyofAndIndexedAccess.ts, 149, 43))
>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 149, 13))
const shape: Shape = { name: "foo", width: 5, height: 10, visible: true };
>shape : Symbol(shape, Decl(keyofAndIndexedAccess.ts, 146, 9))
>shape : Symbol(shape, Decl(keyofAndIndexedAccess.ts, 150, 9))
>Shape : Symbol(Shape, Decl(keyofAndIndexedAccess.ts, 0, 0))
>name : Symbol(name, Decl(keyofAndIndexedAccess.ts, 146, 26))
>width : Symbol(width, Decl(keyofAndIndexedAccess.ts, 146, 39))
>height : Symbol(height, Decl(keyofAndIndexedAccess.ts, 146, 49))
>visible : Symbol(visible, Decl(keyofAndIndexedAccess.ts, 146, 61))
>name : Symbol(name, Decl(keyofAndIndexedAccess.ts, 150, 26))
>width : Symbol(width, Decl(keyofAndIndexedAccess.ts, 150, 39))
>height : Symbol(height, Decl(keyofAndIndexedAccess.ts, 150, 49))
>visible : Symbol(visible, Decl(keyofAndIndexedAccess.ts, 150, 61))
return shape[key]; // Shape[K]
>shape : Symbol(shape, Decl(keyofAndIndexedAccess.ts, 146, 9))
>key : Symbol(key, Decl(keyofAndIndexedAccess.ts, 145, 43))
>shape : Symbol(shape, Decl(keyofAndIndexedAccess.ts, 150, 9))
>key : Symbol(key, Decl(keyofAndIndexedAccess.ts, 149, 43))
}
function f33<S extends Shape, K extends keyof S>(shape: S, key: K) {
>f33 : Symbol(f33, Decl(keyofAndIndexedAccess.ts, 152, 1))
>S : Symbol(S, Decl(keyofAndIndexedAccess.ts, 154, 13))
>Shape : Symbol(Shape, Decl(keyofAndIndexedAccess.ts, 0, 0))
>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 154, 29))
>S : Symbol(S, Decl(keyofAndIndexedAccess.ts, 154, 13))
>shape : Symbol(shape, Decl(keyofAndIndexedAccess.ts, 154, 49))
>S : Symbol(S, Decl(keyofAndIndexedAccess.ts, 154, 13))
>key : Symbol(key, Decl(keyofAndIndexedAccess.ts, 154, 58))
>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 154, 29))
let name = getProperty(shape, "name");
>name : Symbol(name, Decl(keyofAndIndexedAccess.ts, 155, 7))
>getProperty : Symbol(getProperty, Decl(keyofAndIndexedAccess.ts, 75, 26))
>shape : Symbol(shape, Decl(keyofAndIndexedAccess.ts, 154, 49))
let prop = getProperty(shape, key);
>prop : Symbol(prop, Decl(keyofAndIndexedAccess.ts, 156, 7))
>getProperty : Symbol(getProperty, Decl(keyofAndIndexedAccess.ts, 75, 26))
>shape : Symbol(shape, Decl(keyofAndIndexedAccess.ts, 154, 49))
>key : Symbol(key, Decl(keyofAndIndexedAccess.ts, 154, 58))
return prop;
>prop : Symbol(prop, Decl(keyofAndIndexedAccess.ts, 156, 7))
}
function f34(ts: TaggedShape) {
>f34 : Symbol(f34, Decl(keyofAndIndexedAccess.ts, 158, 1))
>ts : Symbol(ts, Decl(keyofAndIndexedAccess.ts, 160, 13))
>TaggedShape : Symbol(TaggedShape, Decl(keyofAndIndexedAccess.ts, 6, 1))
let tag1 = f33(ts, "tag");
>tag1 : Symbol(tag1, Decl(keyofAndIndexedAccess.ts, 161, 7))
>f33 : Symbol(f33, Decl(keyofAndIndexedAccess.ts, 152, 1))
>ts : Symbol(ts, Decl(keyofAndIndexedAccess.ts, 160, 13))
let tag2 = getProperty(ts, "tag");
>tag2 : Symbol(tag2, Decl(keyofAndIndexedAccess.ts, 162, 7))
>getProperty : Symbol(getProperty, Decl(keyofAndIndexedAccess.ts, 75, 26))
>ts : Symbol(ts, Decl(keyofAndIndexedAccess.ts, 160, 13))
}
class C {
>C : Symbol(C, Decl(keyofAndIndexedAccess.ts, 148, 1))
>C : Symbol(C, Decl(keyofAndIndexedAccess.ts, 163, 1))
public x: string;
>x : Symbol(C.x, Decl(keyofAndIndexedAccess.ts, 150, 9))
>x : Symbol(C.x, Decl(keyofAndIndexedAccess.ts, 165, 9))
protected y: string;
>y : Symbol(C.y, Decl(keyofAndIndexedAccess.ts, 151, 21))
>y : Symbol(C.y, Decl(keyofAndIndexedAccess.ts, 166, 21))
private z: string;
>z : Symbol(C.z, Decl(keyofAndIndexedAccess.ts, 152, 24))
>z : Symbol(C.z, Decl(keyofAndIndexedAccess.ts, 167, 24))
}
// Indexed access expressions have always permitted access to private and protected members.
// For consistency we also permit such access in indexed access types.
function f40(c: C) {
>f40 : Symbol(f40, Decl(keyofAndIndexedAccess.ts, 154, 1))
>c : Symbol(c, Decl(keyofAndIndexedAccess.ts, 158, 13))
>C : Symbol(C, Decl(keyofAndIndexedAccess.ts, 148, 1))
>f40 : Symbol(f40, Decl(keyofAndIndexedAccess.ts, 169, 1))
>c : Symbol(c, Decl(keyofAndIndexedAccess.ts, 173, 13))
>C : Symbol(C, Decl(keyofAndIndexedAccess.ts, 163, 1))
type X = C["x"];
>X : Symbol(X, Decl(keyofAndIndexedAccess.ts, 158, 20))
>C : Symbol(C, Decl(keyofAndIndexedAccess.ts, 148, 1))
>X : Symbol(X, Decl(keyofAndIndexedAccess.ts, 173, 20))
>C : Symbol(C, Decl(keyofAndIndexedAccess.ts, 163, 1))
type Y = C["y"];
>Y : Symbol(Y, Decl(keyofAndIndexedAccess.ts, 159, 20))
>C : Symbol(C, Decl(keyofAndIndexedAccess.ts, 148, 1))
>Y : Symbol(Y, Decl(keyofAndIndexedAccess.ts, 174, 20))
>C : Symbol(C, Decl(keyofAndIndexedAccess.ts, 163, 1))
type Z = C["z"];
>Z : Symbol(Z, Decl(keyofAndIndexedAccess.ts, 160, 20))
>C : Symbol(C, Decl(keyofAndIndexedAccess.ts, 148, 1))
>Z : Symbol(Z, Decl(keyofAndIndexedAccess.ts, 175, 20))
>C : Symbol(C, Decl(keyofAndIndexedAccess.ts, 163, 1))
let x: X = c["x"];
>x : Symbol(x, Decl(keyofAndIndexedAccess.ts, 162, 7))
>X : Symbol(X, Decl(keyofAndIndexedAccess.ts, 158, 20))
>c : Symbol(c, Decl(keyofAndIndexedAccess.ts, 158, 13))
>"x" : Symbol(C.x, Decl(keyofAndIndexedAccess.ts, 150, 9))
>x : Symbol(x, Decl(keyofAndIndexedAccess.ts, 177, 7))
>X : Symbol(X, Decl(keyofAndIndexedAccess.ts, 173, 20))
>c : Symbol(c, Decl(keyofAndIndexedAccess.ts, 173, 13))
>"x" : Symbol(C.x, Decl(keyofAndIndexedAccess.ts, 165, 9))
let y: Y = c["y"];
>y : Symbol(y, Decl(keyofAndIndexedAccess.ts, 163, 7))
>Y : Symbol(Y, Decl(keyofAndIndexedAccess.ts, 159, 20))
>c : Symbol(c, Decl(keyofAndIndexedAccess.ts, 158, 13))
>"y" : Symbol(C.y, Decl(keyofAndIndexedAccess.ts, 151, 21))
>y : Symbol(y, Decl(keyofAndIndexedAccess.ts, 178, 7))
>Y : Symbol(Y, Decl(keyofAndIndexedAccess.ts, 174, 20))
>c : Symbol(c, Decl(keyofAndIndexedAccess.ts, 173, 13))
>"y" : Symbol(C.y, Decl(keyofAndIndexedAccess.ts, 166, 21))
let z: Z = c["z"];
>z : Symbol(z, Decl(keyofAndIndexedAccess.ts, 164, 7))
>Z : Symbol(Z, Decl(keyofAndIndexedAccess.ts, 160, 20))
>c : Symbol(c, Decl(keyofAndIndexedAccess.ts, 158, 13))
>"z" : Symbol(C.z, Decl(keyofAndIndexedAccess.ts, 152, 24))
>z : Symbol(z, Decl(keyofAndIndexedAccess.ts, 179, 7))
>Z : Symbol(Z, Decl(keyofAndIndexedAccess.ts, 175, 20))
>c : Symbol(c, Decl(keyofAndIndexedAccess.ts, 173, 13))
>"z" : Symbol(C.z, Decl(keyofAndIndexedAccess.ts, 167, 24))
}
// Repros from #12011
class Base {
>Base : Symbol(Base, Decl(keyofAndIndexedAccess.ts, 180, 1))
get<K extends keyof this>(prop: K) {
>get : Symbol(Base.get, Decl(keyofAndIndexedAccess.ts, 184, 12))
>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 185, 8))
>prop : Symbol(prop, Decl(keyofAndIndexedAccess.ts, 185, 30))
>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 185, 8))
return this[prop];
>this : Symbol(Base, Decl(keyofAndIndexedAccess.ts, 180, 1))
>prop : Symbol(prop, Decl(keyofAndIndexedAccess.ts, 185, 30))
}
set<K extends keyof this>(prop: K, value: this[K]) {
>set : Symbol(Base.set, Decl(keyofAndIndexedAccess.ts, 187, 5))
>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 188, 8))
>prop : Symbol(prop, Decl(keyofAndIndexedAccess.ts, 188, 30))
>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 188, 8))
>value : Symbol(value, Decl(keyofAndIndexedAccess.ts, 188, 38))
>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 188, 8))
this[prop] = value;
>this : Symbol(Base, Decl(keyofAndIndexedAccess.ts, 180, 1))
>prop : Symbol(prop, Decl(keyofAndIndexedAccess.ts, 188, 30))
>value : Symbol(value, Decl(keyofAndIndexedAccess.ts, 188, 38))
}
}
class Person extends Base {
>Person : Symbol(Person, Decl(keyofAndIndexedAccess.ts, 191, 1))
>Base : Symbol(Base, Decl(keyofAndIndexedAccess.ts, 180, 1))
parts: number;
>parts : Symbol(Person.parts, Decl(keyofAndIndexedAccess.ts, 193, 27))
constructor(parts: number) {
>parts : Symbol(parts, Decl(keyofAndIndexedAccess.ts, 195, 16))
super();
>super : Symbol(Base, Decl(keyofAndIndexedAccess.ts, 180, 1))
this.set("parts", parts);
>this.set : Symbol(Base.set, Decl(keyofAndIndexedAccess.ts, 187, 5))
>this : Symbol(Person, Decl(keyofAndIndexedAccess.ts, 191, 1))
>set : Symbol(Base.set, Decl(keyofAndIndexedAccess.ts, 187, 5))
>parts : Symbol(parts, Decl(keyofAndIndexedAccess.ts, 195, 16))
}
getParts() {
>getParts : Symbol(Person.getParts, Decl(keyofAndIndexedAccess.ts, 198, 5))
return this.get("parts")
>this.get : Symbol(Base.get, Decl(keyofAndIndexedAccess.ts, 184, 12))
>this : Symbol(Person, Decl(keyofAndIndexedAccess.ts, 191, 1))
>get : Symbol(Base.get, Decl(keyofAndIndexedAccess.ts, 184, 12))
}
}
class OtherPerson {
>OtherPerson : Symbol(OtherPerson, Decl(keyofAndIndexedAccess.ts, 202, 1))
parts: number;
>parts : Symbol(OtherPerson.parts, Decl(keyofAndIndexedAccess.ts, 204, 19))
constructor(parts: number) {
>parts : Symbol(parts, Decl(keyofAndIndexedAccess.ts, 206, 16))
setProperty(this, "parts", parts);
>setProperty : Symbol(setProperty, Decl(keyofAndIndexedAccess.ts, 79, 1))
>this : Symbol(OtherPerson, Decl(keyofAndIndexedAccess.ts, 202, 1))
>parts : Symbol(parts, Decl(keyofAndIndexedAccess.ts, 206, 16))
}
getParts() {
>getParts : Symbol(OtherPerson.getParts, Decl(keyofAndIndexedAccess.ts, 208, 5))
return getProperty(this, "parts")
>getProperty : Symbol(getProperty, Decl(keyofAndIndexedAccess.ts, 75, 26))
>this : Symbol(OtherPerson, Decl(keyofAndIndexedAccess.ts, 202, 1))
}
}

View file

@ -16,6 +16,14 @@ class Shape {
>visible : boolean
}
class TaggedShape extends Shape {
>TaggedShape : TaggedShape
>Shape : Shape
tag: string;
>tag : string
}
class Item {
>Item : Item
@ -626,6 +634,55 @@ function f32<K extends "width" | "height">(key: K) {
>key : K
}
function f33<S extends Shape, K extends keyof S>(shape: S, key: K) {
>f33 : <S extends Shape, K extends keyof S>(shape: S, key: K) => S[K]
>S : S
>Shape : Shape
>K : K
>S : S
>shape : S
>S : S
>key : K
>K : K
let name = getProperty(shape, "name");
>name : string
>getProperty(shape, "name") : string
>getProperty : <T, K extends keyof T>(obj: T, key: K) => T[K]
>shape : S
>"name" : "name"
let prop = getProperty(shape, key);
>prop : S[K]
>getProperty(shape, key) : S[K]
>getProperty : <T, K extends keyof T>(obj: T, key: K) => T[K]
>shape : S
>key : K
return prop;
>prop : S[K]
}
function f34(ts: TaggedShape) {
>f34 : (ts: TaggedShape) => void
>ts : TaggedShape
>TaggedShape : TaggedShape
let tag1 = f33(ts, "tag");
>tag1 : string
>f33(ts, "tag") : string
>f33 : <S extends Shape, K extends keyof S>(shape: S, key: K) => S[K]
>ts : TaggedShape
>"tag" : "tag"
let tag2 = getProperty(ts, "tag");
>tag2 : string
>getProperty(ts, "tag") : string
>getProperty : <T, K extends keyof T>(obj: T, key: K) => T[K]
>ts : TaggedShape
>"tag" : "tag"
}
class C {
>C : C
@ -679,3 +736,97 @@ function f40(c: C) {
>c : C
>"z" : "z"
}
// Repros from #12011
class Base {
>Base : Base
get<K extends keyof this>(prop: K) {
>get : <K extends keyof this>(prop: K) => this[K]
>K : K
>prop : K
>K : K
return this[prop];
>this[prop] : this[K]
>this : this
>prop : K
}
set<K extends keyof this>(prop: K, value: this[K]) {
>set : <K extends keyof this>(prop: K, value: this[K]) => void
>K : K
>prop : K
>K : K
>value : this[K]
>K : K
this[prop] = value;
>this[prop] = value : this[K]
>this[prop] : this[K]
>this : this
>prop : K
>value : this[K]
}
}
class Person extends Base {
>Person : Person
>Base : Base
parts: number;
>parts : number
constructor(parts: number) {
>parts : number
super();
>super() : void
>super : typeof Base
this.set("parts", parts);
>this.set("parts", parts) : void
>this.set : <K extends keyof this>(prop: K, value: this[K]) => void
>this : this
>set : <K extends keyof this>(prop: K, value: this[K]) => void
>"parts" : "parts"
>parts : number
}
getParts() {
>getParts : () => number
return this.get("parts")
>this.get("parts") : number
>this.get : <K extends keyof this>(prop: K) => this[K]
>this : this
>get : <K extends keyof this>(prop: K) => this[K]
>"parts" : "parts"
}
}
class OtherPerson {
>OtherPerson : OtherPerson
parts: number;
>parts : number
constructor(parts: number) {
>parts : number
setProperty(this, "parts", parts);
>setProperty(this, "parts", parts) : void
>setProperty : <T, K extends keyof T>(obj: T, key: K, value: T[K]) => void
>this : this
>"parts" : "parts"
>parts : number
}
getParts() {
>getParts : () => number
return getProperty(this, "parts")
>getProperty(this, "parts") : number
>getProperty : <T, K extends keyof T>(obj: T, key: K) => T[K]
>this : this
>"parts" : "parts"
}
}

View file

@ -38,6 +38,10 @@ getter.a = 12;
// functions result in { }
let spreadFunc = { ...(function () { }) };
// any results in any
let anything: any;
let spreadAny = { ...anything };
// methods are not enumerable
class C { p = 1; m() { } }
let c: C = new C()
@ -109,6 +113,9 @@ var getter = __assign({}, op, { c: 7 });
getter.a = 12;
// functions result in { }
var spreadFunc = __assign({}, (function () { }));
// any results in any
var anything;
var spreadAny = __assign({}, anything);
// methods are not enumerable
var C = (function () {
function C() {

View file

@ -154,123 +154,130 @@ getter.a = 12;
let spreadFunc = { ...(function () { }) };
>spreadFunc : Symbol(spreadFunc, Decl(objectSpread.ts, 37, 3))
// any results in any
let anything: any;
>anything : Symbol(anything, Decl(objectSpread.ts, 40, 3))
let spreadAny = { ...anything };
>spreadAny : Symbol(spreadAny, Decl(objectSpread.ts, 41, 3))
// methods are not enumerable
class C { p = 1; m() { } }
>C : Symbol(C, Decl(objectSpread.ts, 37, 42))
>p : Symbol(C.p, Decl(objectSpread.ts, 40, 9))
>m : Symbol(C.m, Decl(objectSpread.ts, 40, 16))
>C : Symbol(C, Decl(objectSpread.ts, 41, 32))
>p : Symbol(C.p, Decl(objectSpread.ts, 44, 9))
>m : Symbol(C.m, Decl(objectSpread.ts, 44, 16))
let c: C = new C()
>c : Symbol(c, Decl(objectSpread.ts, 41, 3))
>C : Symbol(C, Decl(objectSpread.ts, 37, 42))
>C : Symbol(C, Decl(objectSpread.ts, 37, 42))
>c : Symbol(c, Decl(objectSpread.ts, 45, 3))
>C : Symbol(C, Decl(objectSpread.ts, 41, 32))
>C : Symbol(C, Decl(objectSpread.ts, 41, 32))
let spreadC: { p: number } = { ...c }
>spreadC : Symbol(spreadC, Decl(objectSpread.ts, 42, 3))
>p : Symbol(p, Decl(objectSpread.ts, 42, 14))
>spreadC : Symbol(spreadC, Decl(objectSpread.ts, 46, 3))
>p : Symbol(p, Decl(objectSpread.ts, 46, 14))
// own methods are enumerable
let cplus: { p: number, plus(): void } = { ...c, plus() { return this.p + 1; } };
>cplus : Symbol(cplus, Decl(objectSpread.ts, 45, 3))
>p : Symbol(p, Decl(objectSpread.ts, 45, 12))
>plus : Symbol(plus, Decl(objectSpread.ts, 45, 23))
>plus : Symbol(plus, Decl(objectSpread.ts, 45, 48))
>cplus : Symbol(cplus, Decl(objectSpread.ts, 49, 3))
>p : Symbol(p, Decl(objectSpread.ts, 49, 12))
>plus : Symbol(plus, Decl(objectSpread.ts, 49, 23))
>plus : Symbol(plus, Decl(objectSpread.ts, 49, 48))
cplus.plus();
>cplus.plus : Symbol(plus, Decl(objectSpread.ts, 45, 23))
>cplus : Symbol(cplus, Decl(objectSpread.ts, 45, 3))
>plus : Symbol(plus, Decl(objectSpread.ts, 45, 23))
>cplus.plus : Symbol(plus, Decl(objectSpread.ts, 49, 23))
>cplus : Symbol(cplus, Decl(objectSpread.ts, 49, 3))
>plus : Symbol(plus, Decl(objectSpread.ts, 49, 23))
// new field's type conflicting with existing field is OK
let changeTypeAfter: { a: string, b: string } =
>changeTypeAfter : Symbol(changeTypeAfter, Decl(objectSpread.ts, 49, 3))
>a : Symbol(a, Decl(objectSpread.ts, 49, 22))
>b : Symbol(b, Decl(objectSpread.ts, 49, 33))
>changeTypeAfter : Symbol(changeTypeAfter, Decl(objectSpread.ts, 53, 3))
>a : Symbol(a, Decl(objectSpread.ts, 53, 22))
>b : Symbol(b, Decl(objectSpread.ts, 53, 33))
{ ...o, a: 'wrong type?' }
>a : Symbol(a, Decl(objectSpread.ts, 50, 11))
>a : Symbol(a, Decl(objectSpread.ts, 54, 11))
let changeTypeBefore: { a: number, b: string } =
>changeTypeBefore : Symbol(changeTypeBefore, Decl(objectSpread.ts, 51, 3))
>a : Symbol(a, Decl(objectSpread.ts, 51, 23))
>b : Symbol(b, Decl(objectSpread.ts, 51, 34))
>changeTypeBefore : Symbol(changeTypeBefore, Decl(objectSpread.ts, 55, 3))
>a : Symbol(a, Decl(objectSpread.ts, 55, 23))
>b : Symbol(b, Decl(objectSpread.ts, 55, 34))
{ a: 'wrong type?', ...o };
>a : Symbol(a, Decl(objectSpread.ts, 52, 5))
>a : Symbol(a, Decl(objectSpread.ts, 56, 5))
let changeTypeBoth: { a: string, b: number } =
>changeTypeBoth : Symbol(changeTypeBoth, Decl(objectSpread.ts, 53, 3))
>a : Symbol(a, Decl(objectSpread.ts, 53, 21))
>b : Symbol(b, Decl(objectSpread.ts, 53, 32))
>changeTypeBoth : Symbol(changeTypeBoth, Decl(objectSpread.ts, 57, 3))
>a : Symbol(a, Decl(objectSpread.ts, 57, 21))
>b : Symbol(b, Decl(objectSpread.ts, 57, 32))
{ ...o, ...swap };
// optional
let definiteBoolean: { sn: boolean };
>definiteBoolean : Symbol(definiteBoolean, Decl(objectSpread.ts, 57, 3))
>sn : Symbol(sn, Decl(objectSpread.ts, 57, 22))
>definiteBoolean : Symbol(definiteBoolean, Decl(objectSpread.ts, 61, 3))
>sn : Symbol(sn, Decl(objectSpread.ts, 61, 22))
let definiteString: { sn: string };
>definiteString : Symbol(definiteString, Decl(objectSpread.ts, 58, 3))
>sn : Symbol(sn, Decl(objectSpread.ts, 58, 21))
>definiteString : Symbol(definiteString, Decl(objectSpread.ts, 62, 3))
>sn : Symbol(sn, Decl(objectSpread.ts, 62, 21))
let optionalString: { sn?: string };
>optionalString : Symbol(optionalString, Decl(objectSpread.ts, 59, 3))
>sn : Symbol(sn, Decl(objectSpread.ts, 59, 21))
>optionalString : Symbol(optionalString, Decl(objectSpread.ts, 63, 3))
>sn : Symbol(sn, Decl(objectSpread.ts, 63, 21))
let optionalNumber: { sn?: number };
>optionalNumber : Symbol(optionalNumber, Decl(objectSpread.ts, 60, 3))
>sn : Symbol(sn, Decl(objectSpread.ts, 60, 21))
>optionalNumber : Symbol(optionalNumber, Decl(objectSpread.ts, 64, 3))
>sn : Symbol(sn, Decl(objectSpread.ts, 64, 21))
let optionalUnionStops: { sn: string | number | boolean } = { ...definiteBoolean, ...definiteString, ...optionalNumber };
>optionalUnionStops : Symbol(optionalUnionStops, Decl(objectSpread.ts, 61, 3))
>sn : Symbol(sn, Decl(objectSpread.ts, 61, 25))
>optionalUnionStops : Symbol(optionalUnionStops, Decl(objectSpread.ts, 65, 3))
>sn : Symbol(sn, Decl(objectSpread.ts, 65, 25))
let optionalUnionDuplicates: { sn: string | number } = { ...definiteBoolean, ...definiteString, ...optionalString, ...optionalNumber };
>optionalUnionDuplicates : Symbol(optionalUnionDuplicates, Decl(objectSpread.ts, 62, 3))
>sn : Symbol(sn, Decl(objectSpread.ts, 62, 30))
>optionalUnionDuplicates : Symbol(optionalUnionDuplicates, Decl(objectSpread.ts, 66, 3))
>sn : Symbol(sn, Decl(objectSpread.ts, 66, 30))
let allOptional: { sn?: string | number } = { ...optionalString, ...optionalNumber };
>allOptional : Symbol(allOptional, Decl(objectSpread.ts, 63, 3))
>sn : Symbol(sn, Decl(objectSpread.ts, 63, 18))
>allOptional : Symbol(allOptional, Decl(objectSpread.ts, 67, 3))
>sn : Symbol(sn, Decl(objectSpread.ts, 67, 18))
// computed property
let computedFirst: { a: number, b: string, "before everything": number } =
>computedFirst : Symbol(computedFirst, Decl(objectSpread.ts, 66, 3))
>a : Symbol(a, Decl(objectSpread.ts, 66, 20))
>b : Symbol(b, Decl(objectSpread.ts, 66, 31))
{ ['before everything']: 12, ...o, b: 'yes' }
>'before everything' : Symbol(['before everything'], Decl(objectSpread.ts, 67, 5))
>b : Symbol(b, Decl(objectSpread.ts, 67, 38))
let computedMiddle: { a: number, b: string, c: boolean, "in the middle": number } =
>computedMiddle : Symbol(computedMiddle, Decl(objectSpread.ts, 68, 3))
>a : Symbol(a, Decl(objectSpread.ts, 68, 21))
>b : Symbol(b, Decl(objectSpread.ts, 68, 32))
>c : Symbol(c, Decl(objectSpread.ts, 68, 43))
{ ...o, ['in the middle']: 13, b: 'maybe?', ...o2 }
>'in the middle' : Symbol(['in the middle'], Decl(objectSpread.ts, 69, 11))
>b : Symbol(b, Decl(objectSpread.ts, 69, 34))
let computedAfter: { a: number, b: string, "at the end": number } =
>computedAfter : Symbol(computedAfter, Decl(objectSpread.ts, 70, 3))
>computedFirst : Symbol(computedFirst, Decl(objectSpread.ts, 70, 3))
>a : Symbol(a, Decl(objectSpread.ts, 70, 20))
>b : Symbol(b, Decl(objectSpread.ts, 70, 31))
{ ['before everything']: 12, ...o, b: 'yes' }
>'before everything' : Symbol(['before everything'], Decl(objectSpread.ts, 71, 5))
>b : Symbol(b, Decl(objectSpread.ts, 71, 38))
let computedMiddle: { a: number, b: string, c: boolean, "in the middle": number } =
>computedMiddle : Symbol(computedMiddle, Decl(objectSpread.ts, 72, 3))
>a : Symbol(a, Decl(objectSpread.ts, 72, 21))
>b : Symbol(b, Decl(objectSpread.ts, 72, 32))
>c : Symbol(c, Decl(objectSpread.ts, 72, 43))
{ ...o, ['in the middle']: 13, b: 'maybe?', ...o2 }
>'in the middle' : Symbol(['in the middle'], Decl(objectSpread.ts, 73, 11))
>b : Symbol(b, Decl(objectSpread.ts, 73, 34))
let computedAfter: { a: number, b: string, "at the end": number } =
>computedAfter : Symbol(computedAfter, Decl(objectSpread.ts, 74, 3))
>a : Symbol(a, Decl(objectSpread.ts, 74, 20))
>b : Symbol(b, Decl(objectSpread.ts, 74, 31))
{ ...o, b: 'yeah', ['at the end']: 14 }
>b : Symbol(b, Decl(objectSpread.ts, 71, 11))
>'at the end' : Symbol(['at the end'], Decl(objectSpread.ts, 71, 22))
>b : Symbol(b, Decl(objectSpread.ts, 75, 11))
>'at the end' : Symbol(['at the end'], Decl(objectSpread.ts, 75, 22))
// shortcut syntax
let a = 12;
>a : Symbol(a, Decl(objectSpread.ts, 73, 3))
>a : Symbol(a, Decl(objectSpread.ts, 77, 3))
let shortCutted: { a: number, b: string } = { ...o, a }
>shortCutted : Symbol(shortCutted, Decl(objectSpread.ts, 74, 3))
>a : Symbol(a, Decl(objectSpread.ts, 74, 18))
>b : Symbol(b, Decl(objectSpread.ts, 74, 29))
>a : Symbol(a, Decl(objectSpread.ts, 74, 51))
>shortCutted : Symbol(shortCutted, Decl(objectSpread.ts, 78, 3))
>a : Symbol(a, Decl(objectSpread.ts, 78, 18))
>b : Symbol(b, Decl(objectSpread.ts, 78, 29))
>a : Symbol(a, Decl(objectSpread.ts, 78, 51))

View file

@ -230,6 +230,15 @@ let spreadFunc = { ...(function () { }) };
>(function () { }) : () => void
>function () { } : () => void
// any results in any
let anything: any;
>anything : any
let spreadAny = { ...anything };
>spreadAny : any
>{ ...anything } : any
>anything : any
// methods are not enumerable
class C { p = 1; m() { } }
>C : C

View file

@ -123,7 +123,7 @@ spreadStr.charAt(1); // error, no methods either
var spreadFunc = __assign({}, function () { });
spreadFunc(); // error, no call signature
// write-only properties get skipped
var setterOnly = __assign({ set b(bad: number) { } });
var setterOnly = __assign({ set b(bad) { } });
setterOnly.b = 12; // error, 'b' does not exist
// methods are skipped because they aren't enumerable
var C = (function () {

View file

@ -1,22 +1,17 @@
tests/cases/conformance/types/spread/objectSpreadNegativeParse.ts(1,12): error TS2698: Spread types may only be created from object types.
tests/cases/conformance/types/spread/objectSpreadNegativeParse.ts(1,15): error TS2304: Cannot find name 'o'.
tests/cases/conformance/types/spread/objectSpreadNegativeParse.ts(1,18): error TS1109: Expression expected.
tests/cases/conformance/types/spread/objectSpreadNegativeParse.ts(2,12): error TS2698: Spread types may only be created from object types.
tests/cases/conformance/types/spread/objectSpreadNegativeParse.ts(2,15): error TS1109: Expression expected.
tests/cases/conformance/types/spread/objectSpreadNegativeParse.ts(2,16): error TS2304: Cannot find name 'o'.
tests/cases/conformance/types/spread/objectSpreadNegativeParse.ts(3,12): error TS2698: Spread types may only be created from object types.
tests/cases/conformance/types/spread/objectSpreadNegativeParse.ts(3,15): error TS2304: Cannot find name 'matchMedia'.
tests/cases/conformance/types/spread/objectSpreadNegativeParse.ts(3,28): error TS1005: ',' expected.
tests/cases/conformance/types/spread/objectSpreadNegativeParse.ts(3,31): error TS1128: Declaration or statement expected.
tests/cases/conformance/types/spread/objectSpreadNegativeParse.ts(4,13): error TS2698: Spread types may only be created from object types.
tests/cases/conformance/types/spread/objectSpreadNegativeParse.ts(4,16): error TS2304: Cannot find name 'get'.
tests/cases/conformance/types/spread/objectSpreadNegativeParse.ts(4,20): error TS1005: ',' expected.
==== tests/cases/conformance/types/spread/objectSpreadNegativeParse.ts (13 errors) ====
==== tests/cases/conformance/types/spread/objectSpreadNegativeParse.ts (10 errors) ====
let o7 = { ...o? };
~~~~~
!!! error TS2698: Spread types may only be created from object types.
~
!!! error TS2304: Cannot find name 'o'.
~
@ -29,8 +24,6 @@ tests/cases/conformance/types/spread/objectSpreadNegativeParse.ts(4,20): error T
~
!!! error TS2304: Cannot find name 'o'.
let o9 = { ...matchMedia() { }};
~~~~~~~~~~~~~~~
!!! error TS2698: Spread types may only be created from object types.
~~~~~~~~~~
!!! error TS2304: Cannot find name 'matchMedia'.
~
@ -38,8 +31,6 @@ tests/cases/conformance/types/spread/objectSpreadNegativeParse.ts(4,20): error T
~
!!! error TS1128: Declaration or statement expected.
let o10 = { ...get x() { return 12; }};
~~~~~~
!!! error TS2698: Spread types may only be created from object types.
~~~
!!! error TS2304: Cannot find name 'get'.
~

View file

@ -0,0 +1,8 @@
//// [objectSpreadNoTransform.ts]
const y = { a: 'yes', b: 'no' };
const o = { x: 1, ...y };
//// [objectSpreadNoTransform.js]
const y = { a: 'yes', b: 'no' };
const o = { x: 1, ...y };

View file

@ -0,0 +1,10 @@
=== tests/cases/conformance/types/spread/objectSpreadNoTransform.ts ===
const y = { a: 'yes', b: 'no' };
>y : Symbol(y, Decl(objectSpreadNoTransform.ts, 0, 5))
>a : Symbol(a, Decl(objectSpreadNoTransform.ts, 0, 11))
>b : Symbol(b, Decl(objectSpreadNoTransform.ts, 0, 21))
const o = { x: 1, ...y };
>o : Symbol(o, Decl(objectSpreadNoTransform.ts, 1, 5))
>x : Symbol(x, Decl(objectSpreadNoTransform.ts, 1, 11))

View file

@ -0,0 +1,16 @@
=== tests/cases/conformance/types/spread/objectSpreadNoTransform.ts ===
const y = { a: 'yes', b: 'no' };
>y : { a: string; b: string; }
>{ a: 'yes', b: 'no' } : { a: string; b: string; }
>a : string
>'yes' : "yes"
>b : string
>'no' : "no"
const o = { x: 1, ...y };
>o : { a: string; b: string; x: number; }
>{ x: 1, ...y } : { a: string; b: string; x: number; }
>x : number
>1 : 1
>y : any

View file

@ -1,9 +1,11 @@
error TS5053: Option 'allowJs' cannot be specified with option 'declaration'.
error TS5055: Cannot write file 'SameNameDTsNotSpecifiedWithAllowJs/a.js' because it would overwrite input file.
Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig
!!! error TS5053: Option 'allowJs' cannot be specified with option 'declaration'.
!!! error TS5055: Cannot write file 'SameNameDTsNotSpecifiedWithAllowJs/a.js' because it would overwrite input file.
!!! error TS5055: Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig
==== SameNameDTsNotSpecifiedWithAllowJs/a.d.ts (0 errors) ====
declare var a: number;
==== SameNameDTsNotSpecifiedWithAllowJs/a.js (0 errors) ====

View file

@ -1,9 +1,11 @@
error TS5053: Option 'allowJs' cannot be specified with option 'declaration'.
error TS5055: Cannot write file 'SameNameDTsNotSpecifiedWithAllowJs/a.js' because it would overwrite input file.
Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig
!!! error TS5053: Option 'allowJs' cannot be specified with option 'declaration'.
!!! error TS5055: Cannot write file 'SameNameDTsNotSpecifiedWithAllowJs/a.js' because it would overwrite input file.
!!! error TS5055: Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig
==== SameNameDTsNotSpecifiedWithAllowJs/a.d.ts (0 errors) ====
declare var a: number;
==== SameNameDTsNotSpecifiedWithAllowJs/a.js (0 errors) ====

View file

@ -0,0 +1,25 @@
//// [unusedLocalProperty.ts]
declare var console: { log(msg: any): void; }
class Animal {
constructor(private species: string) {
}
printSpecies() {
let { species } = this;
console.log(species);
}
}
//// [unusedLocalProperty.js]
var Animal = (function () {
function Animal(species) {
this.species = species;
}
Animal.prototype.printSpecies = function () {
var species = this.species;
console.log(species);
};
return Animal;
}());

View file

@ -0,0 +1,29 @@
=== tests/cases/compiler/unusedLocalProperty.ts ===
declare var console: { log(msg: any): void; }
>console : Symbol(console, Decl(unusedLocalProperty.ts, 0, 11))
>log : Symbol(log, Decl(unusedLocalProperty.ts, 0, 22))
>msg : Symbol(msg, Decl(unusedLocalProperty.ts, 0, 27))
class Animal {
>Animal : Symbol(Animal, Decl(unusedLocalProperty.ts, 0, 45))
constructor(private species: string) {
>species : Symbol(Animal.species, Decl(unusedLocalProperty.ts, 2, 16))
}
printSpecies() {
>printSpecies : Symbol(Animal.printSpecies, Decl(unusedLocalProperty.ts, 3, 5))
let { species } = this;
>species : Symbol(species, Decl(unusedLocalProperty.ts, 6, 13))
>this : Symbol(Animal, Decl(unusedLocalProperty.ts, 0, 45))
console.log(species);
>console.log : Symbol(log, Decl(unusedLocalProperty.ts, 0, 22))
>console : Symbol(console, Decl(unusedLocalProperty.ts, 0, 11))
>log : Symbol(log, Decl(unusedLocalProperty.ts, 0, 22))
>species : Symbol(species, Decl(unusedLocalProperty.ts, 6, 13))
}
}

View file

@ -0,0 +1,30 @@
=== tests/cases/compiler/unusedLocalProperty.ts ===
declare var console: { log(msg: any): void; }
>console : { log(msg: any): void; }
>log : (msg: any) => void
>msg : any
class Animal {
>Animal : Animal
constructor(private species: string) {
>species : string
}
printSpecies() {
>printSpecies : () => void
let { species } = this;
>species : string
>this : this
console.log(species);
>console.log(species) : void
>console.log : (msg: any) => void
>console : { log(msg: any): void; }
>log : (msg: any) => void
>species : string
}
}

View file

@ -0,0 +1,12 @@
//@noUnusedLocals:true
declare var console: { log(msg: any): void; }
class Animal {
constructor(private species: string) {
}
printSpecies() {
let { species } = this;
console.log(species);
}
}

View file

@ -1,5 +1,5 @@
interface X {
foo(x: number, y: number, ...z: string[]);
foo(x: number, y: number, ...z: string[]): X;
}
function foo(x: number, y: number, ...z: string[]) {
@ -18,10 +18,18 @@ obj.foo(1, 2, "abc");
obj.foo(1, 2, ...a);
obj.foo(1, 2, ...a, "abc");
obj.foo(1, 2, ...a).foo(1, 2, "abc");
obj.foo(1, 2, ...a).foo(1, 2, ...a);
obj.foo(1, 2, ...a).foo(1, 2, ...a, "abc");
(obj.foo)(1, 2, "abc");
(obj.foo)(1, 2, ...a);
(obj.foo)(1, 2, ...a, "abc");
((obj.foo)(1, 2, ...a).foo)(1, 2, "abc");
((obj.foo)(1, 2, ...a).foo)(1, 2, ...a);
((obj.foo)(1, 2, ...a).foo)(1, 2, ...a, "abc");
xa[1].foo(1, 2, "abc");
xa[1].foo(1, 2, ...a);
xa[1].foo(1, 2, ...a, "abc");

View file

@ -7,6 +7,10 @@ class Shape {
visible: boolean;
}
class TaggedShape extends Shape {
tag: string;
}
class Item {
name: string;
price: number;
@ -149,6 +153,17 @@ function f32<K extends "width" | "height">(key: K) {
return shape[key]; // Shape[K]
}
function f33<S extends Shape, K extends keyof S>(shape: S, key: K) {
let name = getProperty(shape, "name");
let prop = getProperty(shape, key);
return prop;
}
function f34(ts: TaggedShape) {
let tag1 = f33(ts, "tag");
let tag2 = getProperty(ts, "tag");
}
class C {
public x: string;
protected y: string;
@ -164,4 +179,36 @@ function f40(c: C) {
let x: X = c["x"];
let y: Y = c["y"];
let z: Z = c["z"];
}
// Repros from #12011
class Base {
get<K extends keyof this>(prop: K) {
return this[prop];
}
set<K extends keyof this>(prop: K, value: this[K]) {
this[prop] = value;
}
}
class Person extends Base {
parts: number;
constructor(parts: number) {
super();
this.set("parts", parts);
}
getParts() {
return this.get("parts")
}
}
class OtherPerson {
parts: number;
constructor(parts: number) {
setProperty(this, "parts", parts);
}
getParts() {
return getProperty(this, "parts")
}
}

View file

@ -38,6 +38,10 @@ getter.a = 12;
// functions result in { }
let spreadFunc = { ...(function () { }) };
// any results in any
let anything: any;
let spreadAny = { ...anything };
// methods are not enumerable
class C { p = 1; m() { } }
let c: C = new C()

View file

@ -0,0 +1,3 @@
// @target: esnext
const y = { a: 'yes', b: 'no' };
const o = { x: 1, ...y };