mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Merge branch 'master' into release-3.4
This commit is contained in:
+21
-4
@@ -388,7 +388,7 @@ namespace ts {
|
||||
const intersectionTypes = createMap<IntersectionType>();
|
||||
const literalTypes = createMap<LiteralType>();
|
||||
const indexedAccessTypes = createMap<IndexedAccessType>();
|
||||
const conditionalTypes = createMap<Type>();
|
||||
const conditionalTypes = createMap<Type | undefined>();
|
||||
const evolvingArrayTypes: EvolvingArrayType[] = [];
|
||||
const undefinedProperties = createMap<Symbol>() as UnderscoreEscapedMap<Symbol>;
|
||||
|
||||
@@ -10138,11 +10138,24 @@ namespace ts {
|
||||
const trueType = instantiateType(root.trueType, mapper);
|
||||
const falseType = instantiateType(root.falseType, mapper);
|
||||
const instantiationId = `${root.isDistributive ? "d" : ""}${getTypeId(checkType)}>${getTypeId(extendsType)}?${getTypeId(trueType)}:${getTypeId(falseType)}`;
|
||||
const result = conditionalTypes.get(instantiationId);
|
||||
if (result) {
|
||||
return result;
|
||||
if (conditionalTypes.has(instantiationId)) {
|
||||
const result = conditionalTypes.get(instantiationId);
|
||||
if (result !== undefined) {
|
||||
return result;
|
||||
}
|
||||
// Somehow the conditional type depends on itself - usually via `infer` types in the `extends` clause
|
||||
// paired with a (potentially deferred) circularly constrained type.
|
||||
// The conditional _must_ be deferred.
|
||||
const deferred = getDeferredConditionalType(root, mapper, /*combinedMapper*/ undefined, checkType, extendsType, trueType, falseType);
|
||||
conditionalTypes.set(instantiationId, deferred);
|
||||
return deferred;
|
||||
}
|
||||
conditionalTypes.set(instantiationId, undefined);
|
||||
const newResult = getConditionalTypeWorker(root, mapper, checkType, extendsType, trueType, falseType);
|
||||
const cachedRecursiveResult = conditionalTypes.get(instantiationId);
|
||||
if (cachedRecursiveResult) {
|
||||
return cachedRecursiveResult;
|
||||
}
|
||||
conditionalTypes.set(instantiationId, newResult);
|
||||
return newResult;
|
||||
}
|
||||
@@ -10206,6 +10219,10 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
// Return a deferred type for a check that is neither definitely true nor definitely false
|
||||
return getDeferredConditionalType(root, mapper, combinedMapper, checkType, extendsType, trueType, falseType);
|
||||
}
|
||||
|
||||
function getDeferredConditionalType(root: ConditionalRoot, mapper: TypeMapper | undefined, combinedMapper: TypeMapper | undefined, checkType: Type, extendsType: Type, trueType: Type, falseType: Type) {
|
||||
const erasedCheckType = getActualTypeVariable(checkType);
|
||||
const result = <ConditionalType>createType(TypeFlags.Conditional);
|
||||
result.root = root;
|
||||
|
||||
@@ -131,6 +131,81 @@ namespace ts {
|
||||
return Extension.Js;
|
||||
}
|
||||
|
||||
function rootDirOfOptions(configFile: ParsedCommandLine) {
|
||||
return configFile.options.rootDir || getDirectoryPath(Debug.assertDefined(configFile.options.configFilePath));
|
||||
}
|
||||
|
||||
/* @internal */
|
||||
export function getOutputDeclarationFileName(inputFileName: string, configFile: ParsedCommandLine, ignoreCase: boolean) {
|
||||
Debug.assert(!fileExtensionIs(inputFileName, Extension.Dts) && hasTSFileExtension(inputFileName));
|
||||
const relativePath = getRelativePathFromDirectory(rootDirOfOptions(configFile), inputFileName, ignoreCase);
|
||||
const outputPath = resolvePath(configFile.options.declarationDir || configFile.options.outDir || getDirectoryPath(Debug.assertDefined(configFile.options.configFilePath)), relativePath);
|
||||
return changeExtension(outputPath, Extension.Dts);
|
||||
}
|
||||
|
||||
function getOutputJSFileName(inputFileName: string, configFile: ParsedCommandLine, ignoreCase: boolean) {
|
||||
const relativePath = getRelativePathFromDirectory(rootDirOfOptions(configFile), inputFileName, ignoreCase);
|
||||
const outputPath = resolvePath(configFile.options.outDir || getDirectoryPath(Debug.assertDefined(configFile.options.configFilePath)), relativePath);
|
||||
const isJsonFile = fileExtensionIs(inputFileName, Extension.Json);
|
||||
const outputFileName = changeExtension(outputPath, isJsonFile ?
|
||||
Extension.Json :
|
||||
fileExtensionIs(inputFileName, Extension.Tsx) && configFile.options.jsx === JsxEmit.Preserve ?
|
||||
Extension.Jsx :
|
||||
Extension.Js);
|
||||
return !isJsonFile || comparePaths(inputFileName, outputFileName, Debug.assertDefined(configFile.options.configFilePath), ignoreCase) !== Comparison.EqualTo ?
|
||||
outputFileName :
|
||||
undefined;
|
||||
}
|
||||
|
||||
/*@internal*/
|
||||
export function getAllProjectOutputs(configFile: ParsedCommandLine, ignoreCase: boolean): ReadonlyArray<string> {
|
||||
let outputs: string[] | undefined;
|
||||
const addOutput = (path: string | undefined) => path && (outputs || (outputs = [])).push(path);
|
||||
if (configFile.options.outFile || configFile.options.out) {
|
||||
const { jsFilePath, sourceMapFilePath, declarationFilePath, declarationMapPath, buildInfoPath } = getOutputPathsForBundle(configFile.options, /*forceDtsPaths*/ false);
|
||||
addOutput(jsFilePath);
|
||||
addOutput(sourceMapFilePath);
|
||||
addOutput(declarationFilePath);
|
||||
addOutput(declarationMapPath);
|
||||
addOutput(buildInfoPath);
|
||||
}
|
||||
else {
|
||||
for (const inputFileName of configFile.fileNames) {
|
||||
if (fileExtensionIs(inputFileName, Extension.Dts)) continue;
|
||||
const js = getOutputJSFileName(inputFileName, configFile, ignoreCase);
|
||||
addOutput(js);
|
||||
if (fileExtensionIs(inputFileName, Extension.Json)) continue;
|
||||
if (configFile.options.sourceMap) {
|
||||
addOutput(`${js}.map`);
|
||||
}
|
||||
if (getEmitDeclarations(configFile.options) && hasTSFileExtension(inputFileName)) {
|
||||
const dts = getOutputDeclarationFileName(inputFileName, configFile, ignoreCase);
|
||||
addOutput(dts);
|
||||
if (configFile.options.declarationMap) {
|
||||
addOutput(`${dts}.map`);
|
||||
}
|
||||
}
|
||||
}
|
||||
addOutput(getOutputPathForBuildInfo(configFile.options));
|
||||
}
|
||||
return outputs || emptyArray;
|
||||
}
|
||||
|
||||
/*@internal*/
|
||||
export function getFirstProjectOutput(configFile: ParsedCommandLine, ignoreCase: boolean): string {
|
||||
if (configFile.options.outFile || configFile.options.out) {
|
||||
const { jsFilePath } = getOutputPathsForBundle(configFile.options, /*forceDtsPaths*/ false);
|
||||
return Debug.assertDefined(jsFilePath, `project ${configFile.options.configFilePath} expected to have at least one output`);
|
||||
}
|
||||
|
||||
for (const inputFileName of configFile.fileNames) {
|
||||
if (fileExtensionIs(inputFileName, Extension.Dts)) continue;
|
||||
const jsFilePath = getOutputJSFileName(inputFileName, configFile, ignoreCase);
|
||||
if (jsFilePath) return jsFilePath;
|
||||
}
|
||||
return Debug.fail(`project ${configFile.options.configFilePath} expected to have at least one output`);
|
||||
}
|
||||
|
||||
/*@internal*/
|
||||
// targetSourceFile is when users only want one file in entire project to be emitted. This is used in compileOnSave feature
|
||||
export function emitFiles(resolver: EmitResolver, host: EmitHost, targetSourceFile: SourceFile | undefined, emitOnlyDtsFiles?: boolean, transformers?: TransformerFactory<Bundle | SourceFile>[], declarationTransformers?: TransformerFactory<Bundle | SourceFile>[], onlyBuildInfo?: boolean): EmitResult {
|
||||
|
||||
@@ -833,7 +833,7 @@ namespace ts {
|
||||
else if (getEmitModuleKind(parsedRef.commandLine.options) === ModuleKind.None) {
|
||||
for (const fileName of parsedRef.commandLine.fileNames) {
|
||||
if (!fileExtensionIs(fileName, Extension.Dts) && hasTSFileExtension(fileName)) {
|
||||
processSourceFile(getOutputDeclarationFileName(fileName, parsedRef.commandLine), /*isDefaultLib*/ false, /*ignoreNoDefaultLib*/ false, /*packageId*/ undefined);
|
||||
processSourceFile(getOutputDeclarationFileName(fileName, parsedRef.commandLine, !host.useCaseSensitiveFileNames()), /*isDefaultLib*/ false, /*ignoreNoDefaultLib*/ false, /*packageId*/ undefined);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2378,7 +2378,7 @@ namespace ts {
|
||||
const out = referencedProject.commandLine.options.outFile || referencedProject.commandLine.options.out;
|
||||
return out ?
|
||||
changeExtension(out, Extension.Dts) :
|
||||
getOutputDeclarationFileName(fileName, referencedProject.commandLine);
|
||||
getOutputDeclarationFileName(fileName, referencedProject.commandLine, !host.useCaseSensitiveFileNames());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+1
-1
@@ -1148,7 +1148,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
function readDirectory(path: string, extensions?: ReadonlyArray<string>, excludes?: ReadonlyArray<string>, includes?: ReadonlyArray<string>, depth?: number): string[] {
|
||||
return matchFiles(path, extensions, excludes, includes, useCaseSensitiveFileNames, process.cwd(), depth, getAccessibleFileSystemEntries);
|
||||
return matchFiles(path, extensions, excludes, includes, useCaseSensitiveFileNames, process.cwd(), depth, getAccessibleFileSystemEntries, realpath);
|
||||
}
|
||||
|
||||
function fileSystemEntryExists(path: string, entryKind: FileSystemEntryKind): boolean {
|
||||
|
||||
+5
-88
@@ -276,60 +276,6 @@ namespace ts {
|
||||
return getOrCreateValueFromConfigFileMap<Map<T>>(configFileMap, resolved, createMap);
|
||||
}
|
||||
|
||||
export function getOutputDeclarationFileName(inputFileName: string, configFile: ParsedCommandLine) {
|
||||
const relativePath = getRelativePathFromDirectory(rootDirOfOptions(configFile.options, configFile.options.configFilePath!), inputFileName, /*ignoreCase*/ true);
|
||||
const outputPath = resolvePath(configFile.options.declarationDir || configFile.options.outDir || getDirectoryPath(configFile.options.configFilePath!), relativePath);
|
||||
return changeExtension(outputPath, Extension.Dts);
|
||||
}
|
||||
|
||||
function getOutputJSFileName(inputFileName: string, configFile: ParsedCommandLine) {
|
||||
const relativePath = getRelativePathFromDirectory(rootDirOfOptions(configFile.options, configFile.options.configFilePath!), inputFileName, /*ignoreCase*/ true);
|
||||
const outputPath = resolvePath(configFile.options.outDir || getDirectoryPath(configFile.options.configFilePath!), relativePath);
|
||||
const newExtension = fileExtensionIs(inputFileName, Extension.Json) ? Extension.Json :
|
||||
fileExtensionIs(inputFileName, Extension.Tsx) && configFile.options.jsx === JsxEmit.Preserve ? Extension.Jsx : Extension.Js;
|
||||
return changeExtension(outputPath, newExtension);
|
||||
}
|
||||
|
||||
function getOutputFileNames(inputFileName: string, configFile: ParsedCommandLine): ReadonlyArray<string> {
|
||||
// outFile is handled elsewhere; .d.ts files don't generate outputs
|
||||
if (configFile.options.outFile || configFile.options.out || fileExtensionIs(inputFileName, Extension.Dts)) {
|
||||
return emptyArray;
|
||||
}
|
||||
|
||||
const outputs: string[] = [];
|
||||
const js = getOutputJSFileName(inputFileName, configFile);
|
||||
outputs.push(js);
|
||||
if (configFile.options.sourceMap) {
|
||||
outputs.push(`${js}.map`);
|
||||
}
|
||||
if (getEmitDeclarations(configFile.options) && !fileExtensionIs(inputFileName, Extension.Json)) {
|
||||
const dts = getOutputDeclarationFileName(inputFileName, configFile);
|
||||
outputs.push(dts);
|
||||
if (configFile.options.declarationMap) {
|
||||
outputs.push(`${dts}.map`);
|
||||
}
|
||||
}
|
||||
return outputs;
|
||||
}
|
||||
|
||||
function getOutFileOutputs(project: ParsedCommandLine, ignoreBuildInfo?: boolean): ReadonlyArray<string> {
|
||||
Debug.assert(!!project.options.outFile || !!project.options.out, "outFile must be set");
|
||||
const { jsFilePath, sourceMapFilePath, declarationFilePath, declarationMapPath, buildInfoPath } = getOutputPathsForBundle(project.options, /*forceDtsPaths*/ false);
|
||||
|
||||
let outputs: string[] | undefined = [];
|
||||
const addOutput = (path: string | undefined) => path && (outputs || (outputs = [])).push(path);
|
||||
addOutput(jsFilePath);
|
||||
addOutput(sourceMapFilePath);
|
||||
addOutput(declarationFilePath);
|
||||
addOutput(declarationMapPath);
|
||||
if (!ignoreBuildInfo) addOutput(buildInfoPath);
|
||||
return outputs || emptyArray;
|
||||
}
|
||||
|
||||
function rootDirOfOptions(opts: CompilerOptions, configFileName: string) {
|
||||
return opts.rootDir || getDirectoryPath(configFileName);
|
||||
}
|
||||
|
||||
function newer(date1: Date, date2: Date): Date {
|
||||
return date2 > date1 ? date2 : date1;
|
||||
}
|
||||
@@ -715,7 +661,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
// Collect the expected outputs of this project
|
||||
const outputs = getAllProjectOutputs(project);
|
||||
const outputs = getAllProjectOutputs(project, !host.useCaseSensitiveFileNames());
|
||||
|
||||
if (outputs.length === 0) {
|
||||
return {
|
||||
@@ -1202,7 +1148,7 @@ namespace ts {
|
||||
const status: Status.UpToDate = {
|
||||
type: UpToDateStatusType.UpToDate,
|
||||
newestDeclarationFileContentChangedTime: anyDtsChanged ? maximumDate : newestDeclarationFileContentChangedTime,
|
||||
oldestOutputFileName: outputFiles.length ? outputFiles[0].name : getFirstProjectOutput(configFile)
|
||||
oldestOutputFileName: outputFiles.length ? outputFiles[0].name : getFirstProjectOutput(configFile, !host.useCaseSensitiveFileNames())
|
||||
};
|
||||
diagnostics.removeKey(proj);
|
||||
projectStatus.setValue(proj, status);
|
||||
@@ -1295,13 +1241,13 @@ namespace ts {
|
||||
const status: Status.UpToDate = {
|
||||
type: UpToDateStatusType.UpToDate,
|
||||
newestDeclarationFileContentChangedTime: priorNewestUpdateTime,
|
||||
oldestOutputFileName: getFirstProjectOutput(proj)
|
||||
oldestOutputFileName: getFirstProjectOutput(proj, !host.useCaseSensitiveFileNames())
|
||||
};
|
||||
projectStatus.setValue(proj.options.configFilePath as ResolvedConfigFilePath, status);
|
||||
}
|
||||
|
||||
function updateOutputTimestampsWorker(proj: ParsedCommandLine, priorNewestUpdateTime: Date, verboseMessage: DiagnosticMessage, skipOutputs?: FileMap<true>) {
|
||||
const outputs = getAllProjectOutputs(proj);
|
||||
const outputs = getAllProjectOutputs(proj, !host.useCaseSensitiveFileNames());
|
||||
if (!skipOutputs || outputs.length !== skipOutputs.getSize()) {
|
||||
if (options.verbose) {
|
||||
reportStatus(verboseMessage, proj.options.configFilePath!);
|
||||
@@ -1337,7 +1283,7 @@ namespace ts {
|
||||
reportParseConfigFileDiagnostic(proj);
|
||||
continue;
|
||||
}
|
||||
const outputs = getAllProjectOutputs(parsed);
|
||||
const outputs = getAllProjectOutputs(parsed, !host.useCaseSensitiveFileNames());
|
||||
for (const output of outputs) {
|
||||
if (host.fileExists(output)) {
|
||||
filesToDelete.push(output);
|
||||
@@ -1499,35 +1445,6 @@ namespace ts {
|
||||
return combinePaths(project, "tsconfig.json") as ResolvedConfigFileName;
|
||||
}
|
||||
|
||||
export function getAllProjectOutputs(project: ParsedCommandLine): ReadonlyArray<string> {
|
||||
if (project.options.outFile || project.options.out) {
|
||||
return getOutFileOutputs(project);
|
||||
}
|
||||
else {
|
||||
const outputs: string[] = [];
|
||||
for (const inputFile of project.fileNames) {
|
||||
outputs.push(...getOutputFileNames(inputFile, project));
|
||||
}
|
||||
const buildInfoPath = getOutputPathForBuildInfo(project.options);
|
||||
if (buildInfoPath) outputs.push(buildInfoPath);
|
||||
return outputs;
|
||||
}
|
||||
}
|
||||
|
||||
function getFirstProjectOutput(project: ParsedCommandLine): string {
|
||||
if (project.options.outFile || project.options.out) {
|
||||
return first(getOutFileOutputs(project));
|
||||
}
|
||||
|
||||
for (const inputFile of project.fileNames) {
|
||||
const outputs = getOutputFileNames(inputFile, project);
|
||||
if (outputs.length) {
|
||||
return first(outputs);
|
||||
}
|
||||
}
|
||||
return Debug.fail(`project ${project.options.configFilePath} expected to have at least one output`);
|
||||
}
|
||||
|
||||
export function formatUpToDateStatus<T>(configFileName: string, status: UpToDateStatus, relName: (fileName: string) => string, formatMessage: (message: DiagnosticMessage, ...args: string[]) => T) {
|
||||
switch (status.type) {
|
||||
case UpToDateStatusType.OutOfDateWithSelf:
|
||||
|
||||
@@ -8101,7 +8101,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
/** @param path directory of the tsconfig.json */
|
||||
export function matchFiles(path: string, extensions: ReadonlyArray<string> | undefined, excludes: ReadonlyArray<string> | undefined, includes: ReadonlyArray<string> | undefined, useCaseSensitiveFileNames: boolean, currentDirectory: string, depth: number | undefined, getFileSystemEntries: (path: string) => FileSystemEntries): string[] {
|
||||
export function matchFiles(path: string, extensions: ReadonlyArray<string> | undefined, excludes: ReadonlyArray<string> | undefined, includes: ReadonlyArray<string> | undefined, useCaseSensitiveFileNames: boolean, currentDirectory: string, depth: number | undefined, getFileSystemEntries: (path: string) => FileSystemEntries, realpath: (path: string) => string): string[] {
|
||||
path = normalizePath(path);
|
||||
currentDirectory = normalizePath(currentDirectory);
|
||||
|
||||
@@ -8114,7 +8114,8 @@ namespace ts {
|
||||
// Associate an array of results with each include regex. This keeps results in order of the "include" order.
|
||||
// If there are no "includes", then just put everything in results[0].
|
||||
const results: string[][] = includeFileRegexes ? includeFileRegexes.map(() => []) : [[]];
|
||||
|
||||
const visited = createMap<true>();
|
||||
const toCanonical = createGetCanonicalFileName(useCaseSensitiveFileNames);
|
||||
for (const basePath of patterns.basePaths) {
|
||||
visitDirectory(basePath, combinePaths(currentDirectory, basePath), depth);
|
||||
}
|
||||
@@ -8122,6 +8123,9 @@ namespace ts {
|
||||
return flatten<string>(results);
|
||||
|
||||
function visitDirectory(path: string, absolutePath: string, depth: number | undefined) {
|
||||
const canonicalPath = toCanonical(realpath(absolutePath));
|
||||
if (visited.has(canonicalPath)) return;
|
||||
visited.set(canonicalPath, true);
|
||||
const { files, directories } = getFileSystemEntries(path);
|
||||
|
||||
for (const current of sort<string>(files, compareStringsCaseSensitive)) {
|
||||
|
||||
@@ -11,6 +11,7 @@ namespace ts {
|
||||
directoryExists?(path: string): boolean;
|
||||
getDirectories?(path: string): string[];
|
||||
readDirectory?(path: string, extensions?: ReadonlyArray<string>, exclude?: ReadonlyArray<string>, include?: ReadonlyArray<string>, depth?: number): string[];
|
||||
realpath?(path: string): string;
|
||||
|
||||
createDirectory?(path: string): void;
|
||||
writeFile?(path: string, data: string, writeByteOrderMark?: boolean): void;
|
||||
@@ -56,7 +57,8 @@ namespace ts {
|
||||
writeFile: host.writeFile && writeFile,
|
||||
addOrDeleteFileOrDirectory,
|
||||
addOrDeleteFile,
|
||||
clearCache
|
||||
clearCache,
|
||||
realpath: host.realpath && realpath
|
||||
};
|
||||
|
||||
function toPath(fileName: string) {
|
||||
@@ -170,7 +172,7 @@ namespace ts {
|
||||
const rootDirPath = toPath(rootDir);
|
||||
const result = tryReadDirectory(rootDir, rootDirPath);
|
||||
if (result) {
|
||||
return matchFiles(rootDir, extensions, excludes, includes, useCaseSensitiveFileNames, currentDirectory, depth, getFileSystemEntries);
|
||||
return matchFiles(rootDir, extensions, excludes, includes, useCaseSensitiveFileNames, currentDirectory, depth, getFileSystemEntries, realpath);
|
||||
}
|
||||
return host.readDirectory!(rootDir, extensions, excludes, includes, depth);
|
||||
|
||||
@@ -183,6 +185,10 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
function realpath(s: string) {
|
||||
return host.realpath ? host.realpath(s) : s;
|
||||
}
|
||||
|
||||
function addOrDeleteFileOrDirectory(fileOrDirectory: string, fileOrDirectoryPath: Path) {
|
||||
const existingResult = getCachedFileSystemEntries(fileOrDirectoryPath);
|
||||
if (existingResult) {
|
||||
|
||||
@@ -87,7 +87,7 @@ namespace fakes {
|
||||
}
|
||||
|
||||
public readDirectory(path: string, extensions?: ReadonlyArray<string>, exclude?: ReadonlyArray<string>, include?: ReadonlyArray<string>, depth?: number): string[] {
|
||||
return ts.matchFiles(path, extensions, exclude, include, this.useCaseSensitiveFileNames, this.getCurrentDirectory(), depth, path => this.getAccessibleFileSystemEntries(path));
|
||||
return ts.matchFiles(path, extensions, exclude, include, this.useCaseSensitiveFileNames, this.getCurrentDirectory(), depth, path => this.getAccessibleFileSystemEntries(path), path => this.realpath(path));
|
||||
}
|
||||
|
||||
public getAccessibleFileSystemEntries(path: string): ts.FileSystemEntries {
|
||||
|
||||
@@ -826,7 +826,7 @@ interface Array<T> {}`
|
||||
});
|
||||
}
|
||||
return { directories, files };
|
||||
});
|
||||
}, path => this.realpath(path));
|
||||
}
|
||||
|
||||
watchDirectory(directoryName: string, cb: DirectoryWatcherCallback, recursive: boolean): FileWatcher {
|
||||
|
||||
Vendored
+1
-1
@@ -10,7 +10,7 @@ interface Map<K, V> {
|
||||
|
||||
interface MapConstructor {
|
||||
new(): Map<any, any>;
|
||||
new<K, V>(entries?: ReadonlyArray<[K, V]> | null): Map<K, V>;
|
||||
new<K, V>(entries?: ReadonlyArray<readonly [K, V]> | null): Map<K, V>;
|
||||
readonly prototype: Map<any, any>;
|
||||
}
|
||||
declare var Map: MapConstructor;
|
||||
|
||||
Vendored
+1
-1
@@ -129,7 +129,7 @@ interface ReadonlyMap<K, V> {
|
||||
}
|
||||
|
||||
interface MapConstructor {
|
||||
new <K, V>(iterable: Iterable<[K, V]>): Map<K, V>;
|
||||
new <K, V>(iterable: Iterable<readonly [K, V]>): Map<K, V>;
|
||||
}
|
||||
|
||||
interface WeakMap<K extends object, V> { }
|
||||
|
||||
@@ -703,6 +703,14 @@ namespace ts.Completions {
|
||||
case SyntaxKind.PropertyAccessExpression:
|
||||
propertyAccessToConvert = parent as PropertyAccessExpression;
|
||||
node = propertyAccessToConvert.expression;
|
||||
if (node.end === contextToken.pos &&
|
||||
isCallExpression(node) &&
|
||||
node.getChildCount(sourceFile) &&
|
||||
last(node.getChildren(sourceFile)).kind !== SyntaxKind.CloseParenToken) {
|
||||
// This is likely dot from incorrectly parsed call expression and user is starting to write spread
|
||||
// eg: Math.min(./**/)
|
||||
return undefined;
|
||||
}
|
||||
break;
|
||||
case SyntaxKind.QualifiedName:
|
||||
node = (parent as QualifiedName).left;
|
||||
@@ -1129,6 +1137,9 @@ namespace ts.Completions {
|
||||
|
||||
case SyntaxKind.AsKeyword:
|
||||
return parentKind === SyntaxKind.AsExpression;
|
||||
|
||||
case SyntaxKind.ExtendsKeyword:
|
||||
return parentKind === SyntaxKind.TypeParameter;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
||||
@@ -1196,7 +1196,9 @@ namespace ts.FindAllReferences.Core {
|
||||
|
||||
// For `export { foo as bar }`, rename `foo`, but not `bar`.
|
||||
if (!isForRenameWithPrefixAndSuffixText(state.options) || alwaysGetReferences) {
|
||||
const exportKind = referenceLocation.originalKeywordKind === SyntaxKind.DefaultKeyword ? ExportKind.Default : ExportKind.Named;
|
||||
const isDefaultExport = referenceLocation.originalKeywordKind === SyntaxKind.DefaultKeyword
|
||||
|| exportSpecifier.name.originalKeywordKind === SyntaxKind.DefaultKeyword;
|
||||
const exportKind = isDefaultExport ? ExportKind.Default : ExportKind.Named;
|
||||
const exportSymbol = Debug.assertDefined(exportSpecifier.symbol);
|
||||
const exportInfo = Debug.assertDefined(getExportInfo(exportSymbol, exportKind, state.checker));
|
||||
searchForImportsOfExport(referenceLocation, exportSymbol, exportInfo, state);
|
||||
|
||||
@@ -269,7 +269,7 @@ namespace ts.FindAllReferences {
|
||||
}
|
||||
|
||||
/**
|
||||
* `import x = require("./x") or `import * as x from "./x"`.
|
||||
* `import x = require("./x")` or `import * as x from "./x"`.
|
||||
* An `export =` may be imported by this syntax, so it may be a direct import.
|
||||
* If it's not a direct import, it will be in `indirectUsers`, so we don't have to do anything here.
|
||||
*/
|
||||
|
||||
@@ -1512,5 +1512,30 @@ namespace ts {
|
||||
validateMatches(getExpected(caseSensitiveBasePath), json, caseSensitiveOrderingDiffersWithCaseHost, caseSensitiveBasePath);
|
||||
validateMatches(getExpected(caseInsensitiveBasePath), json, caseInsensitiveOrderingDiffersWithCaseHost, caseInsensitiveBasePath);
|
||||
});
|
||||
|
||||
it("when recursive symlinked directories are present", () => {
|
||||
const fs = new vfs.FileSystem(/*ignoreCase*/ true, {
|
||||
cwd: caseInsensitiveBasePath, files: {
|
||||
"c:/dev/index.ts": ""
|
||||
}
|
||||
});
|
||||
fs.mkdirpSync("c:/dev/a/b/c");
|
||||
fs.symlinkSync("c:/dev/A", "c:/dev/a/self");
|
||||
fs.symlinkSync("c:/dev/a", "c:/dev/a/b/parent");
|
||||
fs.symlinkSync("c:/dev/a", "c:/dev/a/b/c/grandparent");
|
||||
const host = new fakes.ParseConfigHost(fs);
|
||||
const json = {};
|
||||
const expected: ParsedCommandLine = {
|
||||
options: {},
|
||||
errors: [],
|
||||
fileNames: [
|
||||
"c:/dev/index.ts"
|
||||
],
|
||||
wildcardDirectories: {
|
||||
"c:/dev": WatchDirectoryFlags.Recursive
|
||||
},
|
||||
};
|
||||
validateMatches(expected, json, host, caseInsensitiveBasePath);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
namespace ts {
|
||||
describe("unittests:: tsbuild:: with resolveJsonModule option", () => {
|
||||
let projFs: vfs.FileSystem;
|
||||
const allExpectedOutputs = ["/src/tests/dist/src/index.js", "/src/tests/dist/src/index.d.ts", "/src/tests/dist/src/hello.json"];
|
||||
const allExpectedOutputs = ["/src/dist/src/index.js", "/src/dist/src/index.d.ts", "/src/dist/src/hello.json"];
|
||||
before(() => {
|
||||
projFs = loadProjectFromDisk("tests/projects/resolveJsonModuleAndComposite");
|
||||
});
|
||||
@@ -29,33 +29,53 @@ namespace ts {
|
||||
}
|
||||
|
||||
it("with resolveJsonModule and include only", () => {
|
||||
verifyProjectWithResolveJsonModule("/src/tests/tsconfig_withInclude.json", [
|
||||
verifyProjectWithResolveJsonModule("/src/tsconfig_withInclude.json", [
|
||||
Diagnostics.File_0_is_not_in_project_file_list_Projects_must_list_all_files_or_use_an_include_pattern,
|
||||
"/src/tests/src/hello.json"
|
||||
"/src/src/hello.json"
|
||||
]);
|
||||
});
|
||||
|
||||
it("with resolveJsonModule and include of *.json along with other include", () => {
|
||||
verifyProjectWithResolveJsonModule("/src/tests/tsconfig_withIncludeOfJson.json");
|
||||
verifyProjectWithResolveJsonModule("/src/tsconfig_withIncludeOfJson.json");
|
||||
});
|
||||
|
||||
it("with resolveJsonModule and include of *.json along with other include and file name matches ts file", () => {
|
||||
const fs = projFs.shadow();
|
||||
fs.rimrafSync("/src/tests/src/hello.json");
|
||||
fs.writeFileSync("/src/tests/src/index.json", JSON.stringify({ hello: "world" }));
|
||||
fs.writeFileSync("/src/tests/src/index.ts", `import hello from "./index.json"
|
||||
fs.rimrafSync("/src/src/hello.json");
|
||||
fs.writeFileSync("/src/src/index.json", JSON.stringify({ hello: "world" }));
|
||||
fs.writeFileSync("/src/src/index.ts", `import hello from "./index.json"
|
||||
|
||||
export default hello.hello`);
|
||||
const allExpectedOutputs = ["/src/tests/dist/src/index.js", "/src/tests/dist/src/index.d.ts", "/src/tests/dist/src/index.json"];
|
||||
verifyProjectWithResolveJsonModuleWithFs(fs, "/src/tests/tsconfig_withIncludeOfJson.json", allExpectedOutputs);
|
||||
const allExpectedOutputs = ["/src/dist/src/index.js", "/src/dist/src/index.d.ts", "/src/dist/src/index.json"];
|
||||
verifyProjectWithResolveJsonModuleWithFs(fs, "/src/tsconfig_withIncludeOfJson.json", allExpectedOutputs);
|
||||
});
|
||||
|
||||
it("with resolveJsonModule and files containing json file", () => {
|
||||
verifyProjectWithResolveJsonModule("/src/tests/tsconfig_withFiles.json");
|
||||
verifyProjectWithResolveJsonModule("/src/tsconfig_withFiles.json");
|
||||
});
|
||||
|
||||
it("with resolveJsonModule and include and files", () => {
|
||||
verifyProjectWithResolveJsonModule("/src/tests/tsconfig_withIncludeAndFiles.json");
|
||||
verifyProjectWithResolveJsonModule("/src/tsconfig_withIncludeAndFiles.json");
|
||||
});
|
||||
|
||||
it("with resolveJsonModule and sourceMap", () => {
|
||||
const fs = projFs.shadow();
|
||||
const configFile = "src/tsconfig_withFiles.json";
|
||||
replaceText(fs, configFile, `"composite": true,`, `"composite": true, "sourceMap": true,`);
|
||||
const host = new fakes.SolutionBuilderHost(fs);
|
||||
const builder = createSolutionBuilder(host, [configFile], { verbose: false });
|
||||
builder.buildAllProjects();
|
||||
host.assertDiagnosticMessages();
|
||||
for (const output of [...allExpectedOutputs, "/src/dist/src/index.js.map"]) {
|
||||
assert(fs.existsSync(output), `Expect file ${output} to exist`);
|
||||
}
|
||||
|
||||
const newBuilder = createSolutionBuilder(host, [configFile], { verbose: true });
|
||||
newBuilder.buildAllProjects();
|
||||
host.assertDiagnosticMessages(
|
||||
getExpectedDiagnosticForProjectsInBuild(configFile),
|
||||
[Diagnostics.Project_0_is_up_to_date_because_newest_input_1_is_older_than_oldest_output_2, configFile, "src/src/index.ts", "src/dist/src/index.js"]
|
||||
);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -4,13 +4,11 @@ tests/cases/conformance/types/specifyingTypes/typeQueries/circularTypeofWithVarO
|
||||
tests/cases/conformance/types/specifyingTypes/typeQueries/circularTypeofWithVarOrFunc.ts(5,6): error TS2456: Type alias 'typeAlias2' circularly references itself.
|
||||
tests/cases/conformance/types/specifyingTypes/typeQueries/circularTypeofWithVarOrFunc.ts(7,18): error TS2577: Return type annotation circularly references itself.
|
||||
tests/cases/conformance/types/specifyingTypes/typeQueries/circularTypeofWithVarOrFunc.ts(9,6): error TS2456: Type alias 'typeAlias3' circularly references itself.
|
||||
tests/cases/conformance/types/specifyingTypes/typeQueries/circularTypeofWithVarOrFunc.ts(18,6): error TS2456: Type alias 'R' circularly references itself.
|
||||
tests/cases/conformance/types/specifyingTypes/typeQueries/circularTypeofWithVarOrFunc.ts(19,29): error TS2577: Return type annotation circularly references itself.
|
||||
tests/cases/conformance/types/specifyingTypes/typeQueries/circularTypeofWithVarOrFunc.ts(25,6): error TS2456: Type alias 'R2' circularly references itself.
|
||||
tests/cases/conformance/types/specifyingTypes/typeQueries/circularTypeofWithVarOrFunc.ts(26,15): error TS2577: Return type annotation circularly references itself.
|
||||
tests/cases/conformance/types/specifyingTypes/typeQueries/circularTypeofWithVarOrFunc.ts(20,3): error TS2322: Type 'number' is not assignable to type 'ReturnType<(input: Input) => ReturnType<typeof mul>>'.
|
||||
tests/cases/conformance/types/specifyingTypes/typeQueries/circularTypeofWithVarOrFunc.ts(26,20): error TS2322: Type '0' is not assignable to type 'ReturnType<() => ReturnType<typeof f>>'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/types/specifyingTypes/typeQueries/circularTypeofWithVarOrFunc.ts (10 errors) ====
|
||||
==== tests/cases/conformance/types/specifyingTypes/typeQueries/circularTypeofWithVarOrFunc.ts (8 errors) ====
|
||||
type typeAlias1 = typeof varOfAliasedType1;
|
||||
~~~~~~~~~~
|
||||
!!! error TS2456: Type alias 'typeAlias1' circularly references itself.
|
||||
@@ -41,20 +39,16 @@ tests/cases/conformance/types/specifyingTypes/typeQueries/circularTypeofWithVarO
|
||||
}
|
||||
|
||||
type R = ReturnType<typeof mul>;
|
||||
~
|
||||
!!! error TS2456: Type alias 'R' circularly references itself.
|
||||
function mul(input: Input): R {
|
||||
~
|
||||
!!! error TS2577: Return type annotation circularly references itself.
|
||||
return input.a * input.b;
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2322: Type 'number' is not assignable to type 'ReturnType<(input: Input) => ReturnType<typeof mul>>'.
|
||||
}
|
||||
|
||||
// Repro from #26104
|
||||
|
||||
type R2 = ReturnType<typeof f>;
|
||||
~~
|
||||
!!! error TS2456: Type alias 'R2' circularly references itself.
|
||||
function f(): R2 { return 0; }
|
||||
~~
|
||||
!!! error TS2577: Return type annotation circularly references itself.
|
||||
~~~~~~~~~
|
||||
!!! error TS2322: Type '0' is not assignable to type 'ReturnType<() => ReturnType<typeof f>>'.
|
||||
|
||||
@@ -37,11 +37,11 @@ interface Input {
|
||||
}
|
||||
|
||||
type R = ReturnType<typeof mul>;
|
||||
>R : any
|
||||
>mul : (input: Input) => any
|
||||
>R : ReturnType<(input: Input) => ReturnType<typeof mul>>
|
||||
>mul : (input: Input) => ReturnType<typeof mul>
|
||||
|
||||
function mul(input: Input): R {
|
||||
>mul : (input: Input) => any
|
||||
>mul : (input: Input) => ReturnType<typeof mul>
|
||||
>input : Input
|
||||
|
||||
return input.a * input.b;
|
||||
@@ -57,10 +57,10 @@ function mul(input: Input): R {
|
||||
// Repro from #26104
|
||||
|
||||
type R2 = ReturnType<typeof f>;
|
||||
>R2 : any
|
||||
>f : () => any
|
||||
>R2 : ReturnType<() => ReturnType<typeof f>>
|
||||
>f : () => ReturnType<typeof f>
|
||||
|
||||
function f(): R2 { return 0; }
|
||||
>f : () => any
|
||||
>f : () => ReturnType<typeof f>
|
||||
>0 : 0
|
||||
|
||||
|
||||
+69
@@ -0,0 +1,69 @@
|
||||
//// [circularlyConstrainedMappedTypeContainingConditionalNoInfiniteInstantiationDepth.ts]
|
||||
declare class Component<P> {
|
||||
constructor(props: Readonly<P>);
|
||||
constructor(props: P, context?: any);
|
||||
readonly props: Readonly<P> & Readonly<{ children?: {} }>;
|
||||
}
|
||||
interface ComponentClass<P = {}> {
|
||||
new (props: P, context?: any): Component<P>;
|
||||
propTypes?: WeakValidationMap<P>;
|
||||
defaultProps?: Partial<P>;
|
||||
displayName?: string;
|
||||
}
|
||||
interface FunctionComponent<P = {}> {
|
||||
(props: P & { children?: {} }, context?: any): {} | null;
|
||||
propTypes?: WeakValidationMap<P>;
|
||||
defaultProps?: Partial<P>;
|
||||
displayName?: string;
|
||||
}
|
||||
|
||||
export declare const nominalTypeHack: unique symbol;
|
||||
export interface Validator<T> {
|
||||
(props: object, propName: string, componentName: string, location: string, propFullName: string): Error | null;
|
||||
[nominalTypeHack]?: T;
|
||||
}
|
||||
type WeakValidationMap<T> = {
|
||||
[K in keyof T]?: null extends T[K]
|
||||
? Validator<T[K] | null | undefined>
|
||||
: undefined extends T[K]
|
||||
? Validator<T[K] | null | undefined>
|
||||
: Validator<T[K]>
|
||||
};
|
||||
type ComponentType<P = {}> = ComponentClass<P> | FunctionComponent<P>;
|
||||
|
||||
export type Shared<
|
||||
InjectedProps,
|
||||
DecorationTargetProps extends Shared<InjectedProps, DecorationTargetProps>
|
||||
> = {
|
||||
[P in Extract<keyof InjectedProps, keyof DecorationTargetProps>]?: InjectedProps[P] extends DecorationTargetProps[P] ? DecorationTargetProps[P] : never;
|
||||
};
|
||||
|
||||
// Infers prop type from component C
|
||||
export type GetProps<C> = C extends ComponentType<infer P> ? P : never;
|
||||
|
||||
export type ConnectedComponentClass<
|
||||
C extends ComponentType<any>,
|
||||
P
|
||||
> = ComponentClass<P> & {
|
||||
WrappedComponent: C;
|
||||
};
|
||||
|
||||
export type Matching<InjectedProps, DecorationTargetProps> = {
|
||||
[P in keyof DecorationTargetProps]: P extends keyof InjectedProps
|
||||
? InjectedProps[P] extends DecorationTargetProps[P]
|
||||
? DecorationTargetProps[P]
|
||||
: InjectedProps[P]
|
||||
: DecorationTargetProps[P];
|
||||
};
|
||||
|
||||
export type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>;
|
||||
|
||||
export type InferableComponentEnhancerWithProps<TInjectedProps, TNeedsProps> =
|
||||
<C extends ComponentType<Matching<TInjectedProps, GetProps<C>>>>(
|
||||
component: C
|
||||
) => ConnectedComponentClass<C, Omit<GetProps<C>, keyof Shared<TInjectedProps, GetProps<C>>> & TNeedsProps>;
|
||||
|
||||
|
||||
//// [circularlyConstrainedMappedTypeContainingConditionalNoInfiniteInstantiationDepth.js]
|
||||
"use strict";
|
||||
exports.__esModule = true;
|
||||
+255
@@ -0,0 +1,255 @@
|
||||
=== tests/cases/compiler/circularlyConstrainedMappedTypeContainingConditionalNoInfiniteInstantiationDepth.ts ===
|
||||
declare class Component<P> {
|
||||
>Component : Symbol(Component, Decl(circularlyConstrainedMappedTypeContainingConditionalNoInfiniteInstantiationDepth.ts, 0, 0))
|
||||
>P : Symbol(P, Decl(circularlyConstrainedMappedTypeContainingConditionalNoInfiniteInstantiationDepth.ts, 0, 24))
|
||||
|
||||
constructor(props: Readonly<P>);
|
||||
>props : Symbol(props, Decl(circularlyConstrainedMappedTypeContainingConditionalNoInfiniteInstantiationDepth.ts, 1, 16))
|
||||
>Readonly : Symbol(Readonly, Decl(lib.es5.d.ts, --, --))
|
||||
>P : Symbol(P, Decl(circularlyConstrainedMappedTypeContainingConditionalNoInfiniteInstantiationDepth.ts, 0, 24))
|
||||
|
||||
constructor(props: P, context?: any);
|
||||
>props : Symbol(props, Decl(circularlyConstrainedMappedTypeContainingConditionalNoInfiniteInstantiationDepth.ts, 2, 16))
|
||||
>P : Symbol(P, Decl(circularlyConstrainedMappedTypeContainingConditionalNoInfiniteInstantiationDepth.ts, 0, 24))
|
||||
>context : Symbol(context, Decl(circularlyConstrainedMappedTypeContainingConditionalNoInfiniteInstantiationDepth.ts, 2, 25))
|
||||
|
||||
readonly props: Readonly<P> & Readonly<{ children?: {} }>;
|
||||
>props : Symbol(Component.props, Decl(circularlyConstrainedMappedTypeContainingConditionalNoInfiniteInstantiationDepth.ts, 2, 41))
|
||||
>Readonly : Symbol(Readonly, Decl(lib.es5.d.ts, --, --))
|
||||
>P : Symbol(P, Decl(circularlyConstrainedMappedTypeContainingConditionalNoInfiniteInstantiationDepth.ts, 0, 24))
|
||||
>Readonly : Symbol(Readonly, Decl(lib.es5.d.ts, --, --))
|
||||
>children : Symbol(children, Decl(circularlyConstrainedMappedTypeContainingConditionalNoInfiniteInstantiationDepth.ts, 3, 44))
|
||||
}
|
||||
interface ComponentClass<P = {}> {
|
||||
>ComponentClass : Symbol(ComponentClass, Decl(circularlyConstrainedMappedTypeContainingConditionalNoInfiniteInstantiationDepth.ts, 4, 1))
|
||||
>P : Symbol(P, Decl(circularlyConstrainedMappedTypeContainingConditionalNoInfiniteInstantiationDepth.ts, 5, 25))
|
||||
|
||||
new (props: P, context?: any): Component<P>;
|
||||
>props : Symbol(props, Decl(circularlyConstrainedMappedTypeContainingConditionalNoInfiniteInstantiationDepth.ts, 6, 9))
|
||||
>P : Symbol(P, Decl(circularlyConstrainedMappedTypeContainingConditionalNoInfiniteInstantiationDepth.ts, 5, 25))
|
||||
>context : Symbol(context, Decl(circularlyConstrainedMappedTypeContainingConditionalNoInfiniteInstantiationDepth.ts, 6, 18))
|
||||
>Component : Symbol(Component, Decl(circularlyConstrainedMappedTypeContainingConditionalNoInfiniteInstantiationDepth.ts, 0, 0))
|
||||
>P : Symbol(P, Decl(circularlyConstrainedMappedTypeContainingConditionalNoInfiniteInstantiationDepth.ts, 5, 25))
|
||||
|
||||
propTypes?: WeakValidationMap<P>;
|
||||
>propTypes : Symbol(ComponentClass.propTypes, Decl(circularlyConstrainedMappedTypeContainingConditionalNoInfiniteInstantiationDepth.ts, 6, 48))
|
||||
>WeakValidationMap : Symbol(WeakValidationMap, Decl(circularlyConstrainedMappedTypeContainingConditionalNoInfiniteInstantiationDepth.ts, 22, 1))
|
||||
>P : Symbol(P, Decl(circularlyConstrainedMappedTypeContainingConditionalNoInfiniteInstantiationDepth.ts, 5, 25))
|
||||
|
||||
defaultProps?: Partial<P>;
|
||||
>defaultProps : Symbol(ComponentClass.defaultProps, Decl(circularlyConstrainedMappedTypeContainingConditionalNoInfiniteInstantiationDepth.ts, 7, 37))
|
||||
>Partial : Symbol(Partial, Decl(lib.es5.d.ts, --, --))
|
||||
>P : Symbol(P, Decl(circularlyConstrainedMappedTypeContainingConditionalNoInfiniteInstantiationDepth.ts, 5, 25))
|
||||
|
||||
displayName?: string;
|
||||
>displayName : Symbol(ComponentClass.displayName, Decl(circularlyConstrainedMappedTypeContainingConditionalNoInfiniteInstantiationDepth.ts, 8, 30))
|
||||
}
|
||||
interface FunctionComponent<P = {}> {
|
||||
>FunctionComponent : Symbol(FunctionComponent, Decl(circularlyConstrainedMappedTypeContainingConditionalNoInfiniteInstantiationDepth.ts, 10, 1))
|
||||
>P : Symbol(P, Decl(circularlyConstrainedMappedTypeContainingConditionalNoInfiniteInstantiationDepth.ts, 11, 28))
|
||||
|
||||
(props: P & { children?: {} }, context?: any): {} | null;
|
||||
>props : Symbol(props, Decl(circularlyConstrainedMappedTypeContainingConditionalNoInfiniteInstantiationDepth.ts, 12, 5))
|
||||
>P : Symbol(P, Decl(circularlyConstrainedMappedTypeContainingConditionalNoInfiniteInstantiationDepth.ts, 11, 28))
|
||||
>children : Symbol(children, Decl(circularlyConstrainedMappedTypeContainingConditionalNoInfiniteInstantiationDepth.ts, 12, 17))
|
||||
>context : Symbol(context, Decl(circularlyConstrainedMappedTypeContainingConditionalNoInfiniteInstantiationDepth.ts, 12, 34))
|
||||
|
||||
propTypes?: WeakValidationMap<P>;
|
||||
>propTypes : Symbol(FunctionComponent.propTypes, Decl(circularlyConstrainedMappedTypeContainingConditionalNoInfiniteInstantiationDepth.ts, 12, 61))
|
||||
>WeakValidationMap : Symbol(WeakValidationMap, Decl(circularlyConstrainedMappedTypeContainingConditionalNoInfiniteInstantiationDepth.ts, 22, 1))
|
||||
>P : Symbol(P, Decl(circularlyConstrainedMappedTypeContainingConditionalNoInfiniteInstantiationDepth.ts, 11, 28))
|
||||
|
||||
defaultProps?: Partial<P>;
|
||||
>defaultProps : Symbol(FunctionComponent.defaultProps, Decl(circularlyConstrainedMappedTypeContainingConditionalNoInfiniteInstantiationDepth.ts, 13, 37))
|
||||
>Partial : Symbol(Partial, Decl(lib.es5.d.ts, --, --))
|
||||
>P : Symbol(P, Decl(circularlyConstrainedMappedTypeContainingConditionalNoInfiniteInstantiationDepth.ts, 11, 28))
|
||||
|
||||
displayName?: string;
|
||||
>displayName : Symbol(FunctionComponent.displayName, Decl(circularlyConstrainedMappedTypeContainingConditionalNoInfiniteInstantiationDepth.ts, 14, 30))
|
||||
}
|
||||
|
||||
export declare const nominalTypeHack: unique symbol;
|
||||
>nominalTypeHack : Symbol(nominalTypeHack, Decl(circularlyConstrainedMappedTypeContainingConditionalNoInfiniteInstantiationDepth.ts, 18, 20))
|
||||
|
||||
export interface Validator<T> {
|
||||
>Validator : Symbol(Validator, Decl(circularlyConstrainedMappedTypeContainingConditionalNoInfiniteInstantiationDepth.ts, 18, 52))
|
||||
>T : Symbol(T, Decl(circularlyConstrainedMappedTypeContainingConditionalNoInfiniteInstantiationDepth.ts, 19, 27))
|
||||
|
||||
(props: object, propName: string, componentName: string, location: string, propFullName: string): Error | null;
|
||||
>props : Symbol(props, Decl(circularlyConstrainedMappedTypeContainingConditionalNoInfiniteInstantiationDepth.ts, 20, 5))
|
||||
>propName : Symbol(propName, Decl(circularlyConstrainedMappedTypeContainingConditionalNoInfiniteInstantiationDepth.ts, 20, 19))
|
||||
>componentName : Symbol(componentName, Decl(circularlyConstrainedMappedTypeContainingConditionalNoInfiniteInstantiationDepth.ts, 20, 37))
|
||||
>location : Symbol(location, Decl(circularlyConstrainedMappedTypeContainingConditionalNoInfiniteInstantiationDepth.ts, 20, 60))
|
||||
>propFullName : Symbol(propFullName, Decl(circularlyConstrainedMappedTypeContainingConditionalNoInfiniteInstantiationDepth.ts, 20, 78))
|
||||
>Error : Symbol(Error, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
|
||||
|
||||
[nominalTypeHack]?: T;
|
||||
>[nominalTypeHack] : Symbol(Validator[nominalTypeHack], Decl(circularlyConstrainedMappedTypeContainingConditionalNoInfiniteInstantiationDepth.ts, 20, 115))
|
||||
>nominalTypeHack : Symbol(nominalTypeHack, Decl(circularlyConstrainedMappedTypeContainingConditionalNoInfiniteInstantiationDepth.ts, 18, 20))
|
||||
>T : Symbol(T, Decl(circularlyConstrainedMappedTypeContainingConditionalNoInfiniteInstantiationDepth.ts, 19, 27))
|
||||
}
|
||||
type WeakValidationMap<T> = {
|
||||
>WeakValidationMap : Symbol(WeakValidationMap, Decl(circularlyConstrainedMappedTypeContainingConditionalNoInfiniteInstantiationDepth.ts, 22, 1))
|
||||
>T : Symbol(T, Decl(circularlyConstrainedMappedTypeContainingConditionalNoInfiniteInstantiationDepth.ts, 23, 23))
|
||||
|
||||
[K in keyof T]?: null extends T[K]
|
||||
>K : Symbol(K, Decl(circularlyConstrainedMappedTypeContainingConditionalNoInfiniteInstantiationDepth.ts, 24, 5))
|
||||
>T : Symbol(T, Decl(circularlyConstrainedMappedTypeContainingConditionalNoInfiniteInstantiationDepth.ts, 23, 23))
|
||||
>T : Symbol(T, Decl(circularlyConstrainedMappedTypeContainingConditionalNoInfiniteInstantiationDepth.ts, 23, 23))
|
||||
>K : Symbol(K, Decl(circularlyConstrainedMappedTypeContainingConditionalNoInfiniteInstantiationDepth.ts, 24, 5))
|
||||
|
||||
? Validator<T[K] | null | undefined>
|
||||
>Validator : Symbol(Validator, Decl(circularlyConstrainedMappedTypeContainingConditionalNoInfiniteInstantiationDepth.ts, 18, 52))
|
||||
>T : Symbol(T, Decl(circularlyConstrainedMappedTypeContainingConditionalNoInfiniteInstantiationDepth.ts, 23, 23))
|
||||
>K : Symbol(K, Decl(circularlyConstrainedMappedTypeContainingConditionalNoInfiniteInstantiationDepth.ts, 24, 5))
|
||||
|
||||
: undefined extends T[K]
|
||||
>T : Symbol(T, Decl(circularlyConstrainedMappedTypeContainingConditionalNoInfiniteInstantiationDepth.ts, 23, 23))
|
||||
>K : Symbol(K, Decl(circularlyConstrainedMappedTypeContainingConditionalNoInfiniteInstantiationDepth.ts, 24, 5))
|
||||
|
||||
? Validator<T[K] | null | undefined>
|
||||
>Validator : Symbol(Validator, Decl(circularlyConstrainedMappedTypeContainingConditionalNoInfiniteInstantiationDepth.ts, 18, 52))
|
||||
>T : Symbol(T, Decl(circularlyConstrainedMappedTypeContainingConditionalNoInfiniteInstantiationDepth.ts, 23, 23))
|
||||
>K : Symbol(K, Decl(circularlyConstrainedMappedTypeContainingConditionalNoInfiniteInstantiationDepth.ts, 24, 5))
|
||||
|
||||
: Validator<T[K]>
|
||||
>Validator : Symbol(Validator, Decl(circularlyConstrainedMappedTypeContainingConditionalNoInfiniteInstantiationDepth.ts, 18, 52))
|
||||
>T : Symbol(T, Decl(circularlyConstrainedMappedTypeContainingConditionalNoInfiniteInstantiationDepth.ts, 23, 23))
|
||||
>K : Symbol(K, Decl(circularlyConstrainedMappedTypeContainingConditionalNoInfiniteInstantiationDepth.ts, 24, 5))
|
||||
|
||||
};
|
||||
type ComponentType<P = {}> = ComponentClass<P> | FunctionComponent<P>;
|
||||
>ComponentType : Symbol(ComponentType, Decl(circularlyConstrainedMappedTypeContainingConditionalNoInfiniteInstantiationDepth.ts, 29, 2))
|
||||
>P : Symbol(P, Decl(circularlyConstrainedMappedTypeContainingConditionalNoInfiniteInstantiationDepth.ts, 30, 19))
|
||||
>ComponentClass : Symbol(ComponentClass, Decl(circularlyConstrainedMappedTypeContainingConditionalNoInfiniteInstantiationDepth.ts, 4, 1))
|
||||
>P : Symbol(P, Decl(circularlyConstrainedMappedTypeContainingConditionalNoInfiniteInstantiationDepth.ts, 30, 19))
|
||||
>FunctionComponent : Symbol(FunctionComponent, Decl(circularlyConstrainedMappedTypeContainingConditionalNoInfiniteInstantiationDepth.ts, 10, 1))
|
||||
>P : Symbol(P, Decl(circularlyConstrainedMappedTypeContainingConditionalNoInfiniteInstantiationDepth.ts, 30, 19))
|
||||
|
||||
export type Shared<
|
||||
>Shared : Symbol(Shared, Decl(circularlyConstrainedMappedTypeContainingConditionalNoInfiniteInstantiationDepth.ts, 30, 70))
|
||||
|
||||
InjectedProps,
|
||||
>InjectedProps : Symbol(InjectedProps, Decl(circularlyConstrainedMappedTypeContainingConditionalNoInfiniteInstantiationDepth.ts, 32, 19))
|
||||
|
||||
DecorationTargetProps extends Shared<InjectedProps, DecorationTargetProps>
|
||||
>DecorationTargetProps : Symbol(DecorationTargetProps, Decl(circularlyConstrainedMappedTypeContainingConditionalNoInfiniteInstantiationDepth.ts, 33, 18))
|
||||
>Shared : Symbol(Shared, Decl(circularlyConstrainedMappedTypeContainingConditionalNoInfiniteInstantiationDepth.ts, 30, 70))
|
||||
>InjectedProps : Symbol(InjectedProps, Decl(circularlyConstrainedMappedTypeContainingConditionalNoInfiniteInstantiationDepth.ts, 32, 19))
|
||||
>DecorationTargetProps : Symbol(DecorationTargetProps, Decl(circularlyConstrainedMappedTypeContainingConditionalNoInfiniteInstantiationDepth.ts, 33, 18))
|
||||
|
||||
> = {
|
||||
[P in Extract<keyof InjectedProps, keyof DecorationTargetProps>]?: InjectedProps[P] extends DecorationTargetProps[P] ? DecorationTargetProps[P] : never;
|
||||
>P : Symbol(P, Decl(circularlyConstrainedMappedTypeContainingConditionalNoInfiniteInstantiationDepth.ts, 36, 9))
|
||||
>Extract : Symbol(Extract, Decl(lib.es5.d.ts, --, --))
|
||||
>InjectedProps : Symbol(InjectedProps, Decl(circularlyConstrainedMappedTypeContainingConditionalNoInfiniteInstantiationDepth.ts, 32, 19))
|
||||
>DecorationTargetProps : Symbol(DecorationTargetProps, Decl(circularlyConstrainedMappedTypeContainingConditionalNoInfiniteInstantiationDepth.ts, 33, 18))
|
||||
>InjectedProps : Symbol(InjectedProps, Decl(circularlyConstrainedMappedTypeContainingConditionalNoInfiniteInstantiationDepth.ts, 32, 19))
|
||||
>P : Symbol(P, Decl(circularlyConstrainedMappedTypeContainingConditionalNoInfiniteInstantiationDepth.ts, 36, 9))
|
||||
>DecorationTargetProps : Symbol(DecorationTargetProps, Decl(circularlyConstrainedMappedTypeContainingConditionalNoInfiniteInstantiationDepth.ts, 33, 18))
|
||||
>P : Symbol(P, Decl(circularlyConstrainedMappedTypeContainingConditionalNoInfiniteInstantiationDepth.ts, 36, 9))
|
||||
>DecorationTargetProps : Symbol(DecorationTargetProps, Decl(circularlyConstrainedMappedTypeContainingConditionalNoInfiniteInstantiationDepth.ts, 33, 18))
|
||||
>P : Symbol(P, Decl(circularlyConstrainedMappedTypeContainingConditionalNoInfiniteInstantiationDepth.ts, 36, 9))
|
||||
|
||||
};
|
||||
|
||||
// Infers prop type from component C
|
||||
export type GetProps<C> = C extends ComponentType<infer P> ? P : never;
|
||||
>GetProps : Symbol(GetProps, Decl(circularlyConstrainedMappedTypeContainingConditionalNoInfiniteInstantiationDepth.ts, 37, 6))
|
||||
>C : Symbol(C, Decl(circularlyConstrainedMappedTypeContainingConditionalNoInfiniteInstantiationDepth.ts, 40, 21))
|
||||
>C : Symbol(C, Decl(circularlyConstrainedMappedTypeContainingConditionalNoInfiniteInstantiationDepth.ts, 40, 21))
|
||||
>ComponentType : Symbol(ComponentType, Decl(circularlyConstrainedMappedTypeContainingConditionalNoInfiniteInstantiationDepth.ts, 29, 2))
|
||||
>P : Symbol(P, Decl(circularlyConstrainedMappedTypeContainingConditionalNoInfiniteInstantiationDepth.ts, 40, 55))
|
||||
>P : Symbol(P, Decl(circularlyConstrainedMappedTypeContainingConditionalNoInfiniteInstantiationDepth.ts, 40, 55))
|
||||
|
||||
export type ConnectedComponentClass<
|
||||
>ConnectedComponentClass : Symbol(ConnectedComponentClass, Decl(circularlyConstrainedMappedTypeContainingConditionalNoInfiniteInstantiationDepth.ts, 40, 71))
|
||||
|
||||
C extends ComponentType<any>,
|
||||
>C : Symbol(C, Decl(circularlyConstrainedMappedTypeContainingConditionalNoInfiniteInstantiationDepth.ts, 42, 36))
|
||||
>ComponentType : Symbol(ComponentType, Decl(circularlyConstrainedMappedTypeContainingConditionalNoInfiniteInstantiationDepth.ts, 29, 2))
|
||||
|
||||
P
|
||||
>P : Symbol(P, Decl(circularlyConstrainedMappedTypeContainingConditionalNoInfiniteInstantiationDepth.ts, 43, 33))
|
||||
|
||||
> = ComponentClass<P> & {
|
||||
>ComponentClass : Symbol(ComponentClass, Decl(circularlyConstrainedMappedTypeContainingConditionalNoInfiniteInstantiationDepth.ts, 4, 1))
|
||||
>P : Symbol(P, Decl(circularlyConstrainedMappedTypeContainingConditionalNoInfiniteInstantiationDepth.ts, 43, 33))
|
||||
|
||||
WrappedComponent: C;
|
||||
>WrappedComponent : Symbol(WrappedComponent, Decl(circularlyConstrainedMappedTypeContainingConditionalNoInfiniteInstantiationDepth.ts, 45, 25))
|
||||
>C : Symbol(C, Decl(circularlyConstrainedMappedTypeContainingConditionalNoInfiniteInstantiationDepth.ts, 42, 36))
|
||||
|
||||
};
|
||||
|
||||
export type Matching<InjectedProps, DecorationTargetProps> = {
|
||||
>Matching : Symbol(Matching, Decl(circularlyConstrainedMappedTypeContainingConditionalNoInfiniteInstantiationDepth.ts, 47, 2))
|
||||
>InjectedProps : Symbol(InjectedProps, Decl(circularlyConstrainedMappedTypeContainingConditionalNoInfiniteInstantiationDepth.ts, 49, 21))
|
||||
>DecorationTargetProps : Symbol(DecorationTargetProps, Decl(circularlyConstrainedMappedTypeContainingConditionalNoInfiniteInstantiationDepth.ts, 49, 35))
|
||||
|
||||
[P in keyof DecorationTargetProps]: P extends keyof InjectedProps
|
||||
>P : Symbol(P, Decl(circularlyConstrainedMappedTypeContainingConditionalNoInfiniteInstantiationDepth.ts, 50, 5))
|
||||
>DecorationTargetProps : Symbol(DecorationTargetProps, Decl(circularlyConstrainedMappedTypeContainingConditionalNoInfiniteInstantiationDepth.ts, 49, 35))
|
||||
>P : Symbol(P, Decl(circularlyConstrainedMappedTypeContainingConditionalNoInfiniteInstantiationDepth.ts, 50, 5))
|
||||
>InjectedProps : Symbol(InjectedProps, Decl(circularlyConstrainedMappedTypeContainingConditionalNoInfiniteInstantiationDepth.ts, 49, 21))
|
||||
|
||||
? InjectedProps[P] extends DecorationTargetProps[P]
|
||||
>InjectedProps : Symbol(InjectedProps, Decl(circularlyConstrainedMappedTypeContainingConditionalNoInfiniteInstantiationDepth.ts, 49, 21))
|
||||
>P : Symbol(P, Decl(circularlyConstrainedMappedTypeContainingConditionalNoInfiniteInstantiationDepth.ts, 50, 5))
|
||||
>DecorationTargetProps : Symbol(DecorationTargetProps, Decl(circularlyConstrainedMappedTypeContainingConditionalNoInfiniteInstantiationDepth.ts, 49, 35))
|
||||
>P : Symbol(P, Decl(circularlyConstrainedMappedTypeContainingConditionalNoInfiniteInstantiationDepth.ts, 50, 5))
|
||||
|
||||
? DecorationTargetProps[P]
|
||||
>DecorationTargetProps : Symbol(DecorationTargetProps, Decl(circularlyConstrainedMappedTypeContainingConditionalNoInfiniteInstantiationDepth.ts, 49, 35))
|
||||
>P : Symbol(P, Decl(circularlyConstrainedMappedTypeContainingConditionalNoInfiniteInstantiationDepth.ts, 50, 5))
|
||||
|
||||
: InjectedProps[P]
|
||||
>InjectedProps : Symbol(InjectedProps, Decl(circularlyConstrainedMappedTypeContainingConditionalNoInfiniteInstantiationDepth.ts, 49, 21))
|
||||
>P : Symbol(P, Decl(circularlyConstrainedMappedTypeContainingConditionalNoInfiniteInstantiationDepth.ts, 50, 5))
|
||||
|
||||
: DecorationTargetProps[P];
|
||||
>DecorationTargetProps : Symbol(DecorationTargetProps, Decl(circularlyConstrainedMappedTypeContainingConditionalNoInfiniteInstantiationDepth.ts, 49, 35))
|
||||
>P : Symbol(P, Decl(circularlyConstrainedMappedTypeContainingConditionalNoInfiniteInstantiationDepth.ts, 50, 5))
|
||||
|
||||
};
|
||||
|
||||
export type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>;
|
||||
>Omit : Symbol(Omit, Decl(circularlyConstrainedMappedTypeContainingConditionalNoInfiniteInstantiationDepth.ts, 55, 2))
|
||||
>T : Symbol(T, Decl(circularlyConstrainedMappedTypeContainingConditionalNoInfiniteInstantiationDepth.ts, 57, 17))
|
||||
>K : Symbol(K, Decl(circularlyConstrainedMappedTypeContainingConditionalNoInfiniteInstantiationDepth.ts, 57, 19))
|
||||
>T : Symbol(T, Decl(circularlyConstrainedMappedTypeContainingConditionalNoInfiniteInstantiationDepth.ts, 57, 17))
|
||||
>Pick : Symbol(Pick, Decl(lib.es5.d.ts, --, --))
|
||||
>T : Symbol(T, Decl(circularlyConstrainedMappedTypeContainingConditionalNoInfiniteInstantiationDepth.ts, 57, 17))
|
||||
>Exclude : Symbol(Exclude, Decl(lib.es5.d.ts, --, --))
|
||||
>T : Symbol(T, Decl(circularlyConstrainedMappedTypeContainingConditionalNoInfiniteInstantiationDepth.ts, 57, 17))
|
||||
>K : Symbol(K, Decl(circularlyConstrainedMappedTypeContainingConditionalNoInfiniteInstantiationDepth.ts, 57, 19))
|
||||
|
||||
export type InferableComponentEnhancerWithProps<TInjectedProps, TNeedsProps> =
|
||||
>InferableComponentEnhancerWithProps : Symbol(InferableComponentEnhancerWithProps, Decl(circularlyConstrainedMappedTypeContainingConditionalNoInfiniteInstantiationDepth.ts, 57, 70))
|
||||
>TInjectedProps : Symbol(TInjectedProps, Decl(circularlyConstrainedMappedTypeContainingConditionalNoInfiniteInstantiationDepth.ts, 59, 48))
|
||||
>TNeedsProps : Symbol(TNeedsProps, Decl(circularlyConstrainedMappedTypeContainingConditionalNoInfiniteInstantiationDepth.ts, 59, 63))
|
||||
|
||||
<C extends ComponentType<Matching<TInjectedProps, GetProps<C>>>>(
|
||||
>C : Symbol(C, Decl(circularlyConstrainedMappedTypeContainingConditionalNoInfiniteInstantiationDepth.ts, 60, 5))
|
||||
>ComponentType : Symbol(ComponentType, Decl(circularlyConstrainedMappedTypeContainingConditionalNoInfiniteInstantiationDepth.ts, 29, 2))
|
||||
>Matching : Symbol(Matching, Decl(circularlyConstrainedMappedTypeContainingConditionalNoInfiniteInstantiationDepth.ts, 47, 2))
|
||||
>TInjectedProps : Symbol(TInjectedProps, Decl(circularlyConstrainedMappedTypeContainingConditionalNoInfiniteInstantiationDepth.ts, 59, 48))
|
||||
>GetProps : Symbol(GetProps, Decl(circularlyConstrainedMappedTypeContainingConditionalNoInfiniteInstantiationDepth.ts, 37, 6))
|
||||
>C : Symbol(C, Decl(circularlyConstrainedMappedTypeContainingConditionalNoInfiniteInstantiationDepth.ts, 60, 5))
|
||||
|
||||
component: C
|
||||
>component : Symbol(component, Decl(circularlyConstrainedMappedTypeContainingConditionalNoInfiniteInstantiationDepth.ts, 60, 69))
|
||||
>C : Symbol(C, Decl(circularlyConstrainedMappedTypeContainingConditionalNoInfiniteInstantiationDepth.ts, 60, 5))
|
||||
|
||||
) => ConnectedComponentClass<C, Omit<GetProps<C>, keyof Shared<TInjectedProps, GetProps<C>>> & TNeedsProps>;
|
||||
>ConnectedComponentClass : Symbol(ConnectedComponentClass, Decl(circularlyConstrainedMappedTypeContainingConditionalNoInfiniteInstantiationDepth.ts, 40, 71))
|
||||
>C : Symbol(C, Decl(circularlyConstrainedMappedTypeContainingConditionalNoInfiniteInstantiationDepth.ts, 60, 5))
|
||||
>Omit : Symbol(Omit, Decl(circularlyConstrainedMappedTypeContainingConditionalNoInfiniteInstantiationDepth.ts, 55, 2))
|
||||
>GetProps : Symbol(GetProps, Decl(circularlyConstrainedMappedTypeContainingConditionalNoInfiniteInstantiationDepth.ts, 37, 6))
|
||||
>C : Symbol(C, Decl(circularlyConstrainedMappedTypeContainingConditionalNoInfiniteInstantiationDepth.ts, 60, 5))
|
||||
>Shared : Symbol(Shared, Decl(circularlyConstrainedMappedTypeContainingConditionalNoInfiniteInstantiationDepth.ts, 30, 70))
|
||||
>TInjectedProps : Symbol(TInjectedProps, Decl(circularlyConstrainedMappedTypeContainingConditionalNoInfiniteInstantiationDepth.ts, 59, 48))
|
||||
>GetProps : Symbol(GetProps, Decl(circularlyConstrainedMappedTypeContainingConditionalNoInfiniteInstantiationDepth.ts, 37, 6))
|
||||
>C : Symbol(C, Decl(circularlyConstrainedMappedTypeContainingConditionalNoInfiniteInstantiationDepth.ts, 60, 5))
|
||||
>TNeedsProps : Symbol(TNeedsProps, Decl(circularlyConstrainedMappedTypeContainingConditionalNoInfiniteInstantiationDepth.ts, 59, 63))
|
||||
|
||||
+126
@@ -0,0 +1,126 @@
|
||||
=== tests/cases/compiler/circularlyConstrainedMappedTypeContainingConditionalNoInfiniteInstantiationDepth.ts ===
|
||||
declare class Component<P> {
|
||||
>Component : Component<P>
|
||||
|
||||
constructor(props: Readonly<P>);
|
||||
>props : Readonly<P>
|
||||
|
||||
constructor(props: P, context?: any);
|
||||
>props : P
|
||||
>context : any
|
||||
|
||||
readonly props: Readonly<P> & Readonly<{ children?: {} }>;
|
||||
>props : Readonly<P> & Readonly<{ children?: {} | undefined; }>
|
||||
>children : {} | undefined
|
||||
}
|
||||
interface ComponentClass<P = {}> {
|
||||
new (props: P, context?: any): Component<P>;
|
||||
>props : P
|
||||
>context : any
|
||||
|
||||
propTypes?: WeakValidationMap<P>;
|
||||
>propTypes : WeakValidationMap<P> | undefined
|
||||
|
||||
defaultProps?: Partial<P>;
|
||||
>defaultProps : Partial<P> | undefined
|
||||
|
||||
displayName?: string;
|
||||
>displayName : string | undefined
|
||||
}
|
||||
interface FunctionComponent<P = {}> {
|
||||
(props: P & { children?: {} }, context?: any): {} | null;
|
||||
>props : P & { children?: {} | undefined; }
|
||||
>children : {} | undefined
|
||||
>context : any
|
||||
>null : null
|
||||
|
||||
propTypes?: WeakValidationMap<P>;
|
||||
>propTypes : WeakValidationMap<P> | undefined
|
||||
|
||||
defaultProps?: Partial<P>;
|
||||
>defaultProps : Partial<P> | undefined
|
||||
|
||||
displayName?: string;
|
||||
>displayName : string | undefined
|
||||
}
|
||||
|
||||
export declare const nominalTypeHack: unique symbol;
|
||||
>nominalTypeHack : unique symbol
|
||||
|
||||
export interface Validator<T> {
|
||||
(props: object, propName: string, componentName: string, location: string, propFullName: string): Error | null;
|
||||
>props : object
|
||||
>propName : string
|
||||
>componentName : string
|
||||
>location : string
|
||||
>propFullName : string
|
||||
>null : null
|
||||
|
||||
[nominalTypeHack]?: T;
|
||||
>[nominalTypeHack] : T | undefined
|
||||
>nominalTypeHack : unique symbol
|
||||
}
|
||||
type WeakValidationMap<T> = {
|
||||
>WeakValidationMap : WeakValidationMap<T>
|
||||
|
||||
[K in keyof T]?: null extends T[K]
|
||||
>null : null
|
||||
|
||||
? Validator<T[K] | null | undefined>
|
||||
>null : null
|
||||
|
||||
: undefined extends T[K]
|
||||
? Validator<T[K] | null | undefined>
|
||||
>null : null
|
||||
|
||||
: Validator<T[K]>
|
||||
};
|
||||
type ComponentType<P = {}> = ComponentClass<P> | FunctionComponent<P>;
|
||||
>ComponentType : ComponentType<P>
|
||||
|
||||
export type Shared<
|
||||
>Shared : Shared<InjectedProps, DecorationTargetProps>
|
||||
|
||||
InjectedProps,
|
||||
DecorationTargetProps extends Shared<InjectedProps, DecorationTargetProps>
|
||||
> = {
|
||||
[P in Extract<keyof InjectedProps, keyof DecorationTargetProps>]?: InjectedProps[P] extends DecorationTargetProps[P] ? DecorationTargetProps[P] : never;
|
||||
};
|
||||
|
||||
// Infers prop type from component C
|
||||
export type GetProps<C> = C extends ComponentType<infer P> ? P : never;
|
||||
>GetProps : GetProps<C>
|
||||
|
||||
export type ConnectedComponentClass<
|
||||
>ConnectedComponentClass : ConnectedComponentClass<C, P>
|
||||
|
||||
C extends ComponentType<any>,
|
||||
P
|
||||
> = ComponentClass<P> & {
|
||||
WrappedComponent: C;
|
||||
>WrappedComponent : C
|
||||
|
||||
};
|
||||
|
||||
export type Matching<InjectedProps, DecorationTargetProps> = {
|
||||
>Matching : Matching<InjectedProps, DecorationTargetProps>
|
||||
|
||||
[P in keyof DecorationTargetProps]: P extends keyof InjectedProps
|
||||
? InjectedProps[P] extends DecorationTargetProps[P]
|
||||
? DecorationTargetProps[P]
|
||||
: InjectedProps[P]
|
||||
: DecorationTargetProps[P];
|
||||
};
|
||||
|
||||
export type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>;
|
||||
>Omit : Pick<T, Exclude<keyof T, K>>
|
||||
|
||||
export type InferableComponentEnhancerWithProps<TInjectedProps, TNeedsProps> =
|
||||
>InferableComponentEnhancerWithProps : InferableComponentEnhancerWithProps<TInjectedProps, TNeedsProps>
|
||||
|
||||
<C extends ComponentType<Matching<TInjectedProps, GetProps<C>>>>(
|
||||
component: C
|
||||
>component : C
|
||||
|
||||
) => ConnectedComponentClass<C, Omit<GetProps<C>, keyof Shared<TInjectedProps, GetProps<C>>> & TNeedsProps>;
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
//// [mapConstructorOnReadonlyTuple.ts]
|
||||
const pairs = [['1', 1], ['2', 2]] as const
|
||||
new Map(pairs);
|
||||
|
||||
//// [mapConstructorOnReadonlyTuple.js]
|
||||
const pairs = [['1', 1], ['2', 2]];
|
||||
new Map(pairs);
|
||||
@@ -0,0 +1,8 @@
|
||||
=== tests/cases/compiler/mapConstructorOnReadonlyTuple.ts ===
|
||||
const pairs = [['1', 1], ['2', 2]] as const
|
||||
>pairs : Symbol(pairs, Decl(mapConstructorOnReadonlyTuple.ts, 0, 5))
|
||||
|
||||
new Map(pairs);
|
||||
>Map : Symbol(Map, Decl(lib.es2015.collection.d.ts, --, --), Decl(lib.es2015.collection.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --))
|
||||
>pairs : Symbol(pairs, Decl(mapConstructorOnReadonlyTuple.ts, 0, 5))
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
=== tests/cases/compiler/mapConstructorOnReadonlyTuple.ts ===
|
||||
const pairs = [['1', 1], ['2', 2]] as const
|
||||
>pairs : readonly [readonly ["1", 1], readonly ["2", 2]]
|
||||
>[['1', 1], ['2', 2]] as const : readonly [readonly ["1", 1], readonly ["2", 2]]
|
||||
>[['1', 1], ['2', 2]] : readonly [readonly ["1", 1], readonly ["2", 2]]
|
||||
>['1', 1] : readonly ["1", 1]
|
||||
>'1' : "1"
|
||||
>1 : 1
|
||||
>['2', 2] : readonly ["2", 2]
|
||||
>'2' : "2"
|
||||
>2 : 2
|
||||
|
||||
new Map(pairs);
|
||||
>new Map(pairs) : Map<"1" | "2", 1 | 2>
|
||||
>Map : MapConstructor
|
||||
>pairs : readonly [readonly ["1", 1], readonly ["2", 2]]
|
||||
|
||||
@@ -1,16 +1,13 @@
|
||||
tests/cases/compiler/recursiveResolveTypeMembers.ts(4,49): error TS2577: Return type annotation circularly references itself.
|
||||
tests/cases/compiler/recursiveResolveTypeMembers.ts(4,58): error TS2304: Cannot find name 'H'.
|
||||
tests/cases/compiler/recursiveResolveTypeMembers.ts(4,62): error TS2574: A rest element type must be an array type.
|
||||
tests/cases/compiler/recursiveResolveTypeMembers.ts(4,79): error TS2304: Cannot find name 'R'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/recursiveResolveTypeMembers.ts (4 errors) ====
|
||||
==== tests/cases/compiler/recursiveResolveTypeMembers.ts (3 errors) ====
|
||||
// Repro from #25291
|
||||
|
||||
type PromisedTuple<L extends any[], U = (...args: L) => void> =
|
||||
U extends (h: infer H, ...args: infer R) => [Promise<H>, ...PromisedTuple<R>] ? [] : []
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2577: Return type annotation circularly references itself.
|
||||
~
|
||||
!!! error TS2304: Cannot find name 'H'.
|
||||
~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
+64
@@ -0,0 +1,64 @@
|
||||
// @strict: true
|
||||
declare class Component<P> {
|
||||
constructor(props: Readonly<P>);
|
||||
constructor(props: P, context?: any);
|
||||
readonly props: Readonly<P> & Readonly<{ children?: {} }>;
|
||||
}
|
||||
interface ComponentClass<P = {}> {
|
||||
new (props: P, context?: any): Component<P>;
|
||||
propTypes?: WeakValidationMap<P>;
|
||||
defaultProps?: Partial<P>;
|
||||
displayName?: string;
|
||||
}
|
||||
interface FunctionComponent<P = {}> {
|
||||
(props: P & { children?: {} }, context?: any): {} | null;
|
||||
propTypes?: WeakValidationMap<P>;
|
||||
defaultProps?: Partial<P>;
|
||||
displayName?: string;
|
||||
}
|
||||
|
||||
export declare const nominalTypeHack: unique symbol;
|
||||
export interface Validator<T> {
|
||||
(props: object, propName: string, componentName: string, location: string, propFullName: string): Error | null;
|
||||
[nominalTypeHack]?: T;
|
||||
}
|
||||
type WeakValidationMap<T> = {
|
||||
[K in keyof T]?: null extends T[K]
|
||||
? Validator<T[K] | null | undefined>
|
||||
: undefined extends T[K]
|
||||
? Validator<T[K] | null | undefined>
|
||||
: Validator<T[K]>
|
||||
};
|
||||
type ComponentType<P = {}> = ComponentClass<P> | FunctionComponent<P>;
|
||||
|
||||
export type Shared<
|
||||
InjectedProps,
|
||||
DecorationTargetProps extends Shared<InjectedProps, DecorationTargetProps>
|
||||
> = {
|
||||
[P in Extract<keyof InjectedProps, keyof DecorationTargetProps>]?: InjectedProps[P] extends DecorationTargetProps[P] ? DecorationTargetProps[P] : never;
|
||||
};
|
||||
|
||||
// Infers prop type from component C
|
||||
export type GetProps<C> = C extends ComponentType<infer P> ? P : never;
|
||||
|
||||
export type ConnectedComponentClass<
|
||||
C extends ComponentType<any>,
|
||||
P
|
||||
> = ComponentClass<P> & {
|
||||
WrappedComponent: C;
|
||||
};
|
||||
|
||||
export type Matching<InjectedProps, DecorationTargetProps> = {
|
||||
[P in keyof DecorationTargetProps]: P extends keyof InjectedProps
|
||||
? InjectedProps[P] extends DecorationTargetProps[P]
|
||||
? DecorationTargetProps[P]
|
||||
: InjectedProps[P]
|
||||
: DecorationTargetProps[P];
|
||||
};
|
||||
|
||||
export type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>;
|
||||
|
||||
export type InferableComponentEnhancerWithProps<TInjectedProps, TNeedsProps> =
|
||||
<C extends ComponentType<Matching<TInjectedProps, GetProps<C>>>>(
|
||||
component: C
|
||||
) => ConnectedComponentClass<C, Omit<GetProps<C>, keyof Shared<TInjectedProps, GetProps<C>>> & TNeedsProps>;
|
||||
@@ -0,0 +1,4 @@
|
||||
// @target: es2015
|
||||
|
||||
const pairs = [['1', 1], ['2', 2]] as const
|
||||
new Map(pairs);
|
||||
@@ -7,4 +7,4 @@
|
||||
////var C4 = class D<T extends /*4*/>{}
|
||||
|
||||
verify.completions({ marker: ["0", "1", "2", "3"], exact: undefined });
|
||||
verify.completions({ marker: "4", exact: ["D", ...completion.globalsPlus(["C0", "C1", "C2", "C3", "C4"])] });
|
||||
verify.completions({ marker: "4", exact: ["D", "T", ...completion.globalTypes] });
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
/// <reference path='fourslash.ts'/>
|
||||
|
||||
////
|
||||
//// const [] = [Math.min(./*marker*/)]
|
||||
////
|
||||
|
||||
goTo.marker("marker");
|
||||
verify.completions({ exact: undefined });
|
||||
edit.insert(".");
|
||||
verify.completions({ exact: undefined });
|
||||
edit.insert(".");
|
||||
verify.completions({ exact: completion.globals });
|
||||
@@ -0,0 +1,18 @@
|
||||
/// <reference path='fourslash.ts' />
|
||||
|
||||
// @Filename: f.ts
|
||||
////export { [|foo|] as [|{| "isWriteAccess": true, "isDefinition": true |}default|] };
|
||||
////function /*start*/[|{| "isWriteAccess": true, "isDefinition": true |}foo|](a: number, b: number) {
|
||||
//// return a + b;
|
||||
////}
|
||||
|
||||
// @Filename: b.ts
|
||||
////import [|{| "isWriteAccess": true, "isDefinition": true |}bar|] from "./f";
|
||||
////[|bar|](1, 2);
|
||||
|
||||
verify.noErrors();
|
||||
const [ foo0, foo1, foo2, bar0, bar1 ] = test.ranges();
|
||||
const fooGroup = { definition: "function foo(a: number, b: number): number", ranges: [foo0, foo2] };
|
||||
const exportDefaultGroup = { definition: "(alias) function foo(a: number, b: number): number\nexport default", ranges: [foo1] };
|
||||
const barGroup = { definition: "(alias) function bar(a: number, b: number): number\nimport bar", ranges: [bar0, bar1]};
|
||||
verify.referenceGroups("start", [fooGroup, exportDefaultGroup, barGroup]);
|
||||
@@ -0,0 +1,15 @@
|
||||
/// <reference path='fourslash.ts' />
|
||||
|
||||
// @Filename: f.ts
|
||||
////export { [|foo|] as [|{| "isWriteAccess": true, "isDefinition": true |}foo|] }
|
||||
////function /*start*/[|{| "isWriteAccess": true, "isDefinition": true |}foo|](a: number, b: number) { }
|
||||
|
||||
// @Filename: b.ts
|
||||
////import x = require("./f");
|
||||
////x.[|foo|](1, 2);
|
||||
|
||||
verify.noErrors();
|
||||
const [ foo0, foo1, foo2, foo3 ] = test.ranges();
|
||||
const fooGroup = { definition: "function foo(a: number, b: number): void", ranges: [foo0, foo2] };
|
||||
const exportFooGroup = { definition: "(alias) function foo(a: number, b: number): void\nexport foo", ranges: [foo1, foo3] };
|
||||
verify.referenceGroups("start", [fooGroup, exportFooGroup]);
|
||||
Reference in New Issue
Block a user