Merge branch 'master' into object-spread

This commit is contained in:
Nathan Shively-Sanders
2016-11-07 11:02:49 -08:00
63 changed files with 1680 additions and 430 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

@@ -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);

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);
@@ -4762,6 +4762,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;
@@ -6908,6 +6917,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);
@@ -11632,6 +11662,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) {
@@ -11651,17 +11696,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;
@@ -16453,6 +16488,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);
}

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

@@ -2893,6 +2893,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
@@ -3154,5 +3162,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

@@ -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

@@ -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

@@ -2107,6 +2107,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;
}
@@ -2301,6 +2302,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[];
@@ -2720,7 +2723,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
@@ -3069,6 +3072,7 @@ namespace ts {
moduleResolution?: ModuleResolutionKind;
newLine?: NewLineKind;
noEmit?: boolean;
/*@internal*/noEmitOverwritenFiles?: boolean;
noEmitHelpers?: boolean;
noEmitOnError?: boolean;
noErrorTruncation?: boolean;

View File

@@ -557,6 +557,7 @@ namespace ts {
return undefined;
}
aggregateTransformFlags(node);
const visited = visitor(node);
if (visited === node) {
return node;
@@ -625,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) {

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

@@ -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

@@ -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

@@ -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

@@ -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")
}
}