mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Merge branch 'master' into fixStructuralIdentity
# Conflicts: # tests/baselines/reference/conditionalTypes1.errors.txt # tests/baselines/reference/conditionalTypes1.js # tests/baselines/reference/conditionalTypes1.symbols # tests/baselines/reference/conditionalTypes1.types # tests/cases/conformance/types/conditional/conditionalTypes1.ts
This commit is contained in:
@@ -4406,7 +4406,7 @@ namespace ts {
|
||||
type = getWidenedTypeForVariableLikeDeclaration(declaration, /*reportErrors*/ true);
|
||||
}
|
||||
else {
|
||||
Debug.fail("Unhandled declaration kind! " + (ts as any).SyntaxKind[declaration.kind]);
|
||||
Debug.fail("Unhandled declaration kind! " + Debug.showSyntaxKind(declaration));
|
||||
}
|
||||
|
||||
if (!popTypeResolution()) {
|
||||
@@ -20726,7 +20726,7 @@ namespace ts {
|
||||
case SyntaxKind.ImportSpecifier: // https://github.com/Microsoft/TypeScript/pull/7591
|
||||
return DeclarationSpaces.ExportValue;
|
||||
default:
|
||||
Debug.fail((ts as any).SyntaxKind[d.kind]);
|
||||
Debug.fail(Debug.showSyntaxKind(d));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+20
-1
@@ -1466,7 +1466,7 @@ namespace ts {
|
||||
if (value !== undefined && test(value)) return value;
|
||||
|
||||
if (value && typeof (value as any).kind === "number") {
|
||||
Debug.fail(`Invalid cast. The supplied ${(ts as any).SyntaxKind[(value as any).kind]} did not pass the test '${Debug.getFunctionName(test)}'.`);
|
||||
Debug.fail(`Invalid cast. The supplied ${Debug.showSyntaxKind(value as any as Node)} did not pass the test '${Debug.getFunctionName(test)}'.`);
|
||||
}
|
||||
else {
|
||||
Debug.fail(`Invalid cast. The supplied value did not pass the test '${Debug.getFunctionName(test)}'.`);
|
||||
@@ -2925,6 +2925,25 @@ namespace ts {
|
||||
return match ? match[1] : "";
|
||||
}
|
||||
}
|
||||
|
||||
export function showSymbol(symbol: Symbol): string {
|
||||
return `{ flags: ${showFlags(symbol.flags, (ts as any).SymbolFlags)}; declarations: ${map(symbol.declarations, showSyntaxKind)} }`;
|
||||
}
|
||||
|
||||
function showFlags(flags: number, flagsEnum: { [flag: number]: string }): string {
|
||||
const out = [];
|
||||
for (let pow = 0; pow <= 30; pow++) {
|
||||
const n = 1 << pow;
|
||||
if (flags & n) {
|
||||
out.push(flagsEnum[n]);
|
||||
}
|
||||
}
|
||||
return out.join("|");
|
||||
}
|
||||
|
||||
export function showSyntaxKind(node: Node): string {
|
||||
return (ts as any).SyntaxKind[node.kind];
|
||||
}
|
||||
}
|
||||
|
||||
/** Remove an item from an array, moving everything to its right one space left. */
|
||||
|
||||
@@ -4118,16 +4118,6 @@ namespace ts {
|
||||
[option: string]: string[] | boolean | undefined;
|
||||
}
|
||||
|
||||
export interface DiscoverTypingsInfo {
|
||||
fileNames: string[]; // The file names that belong to the same project.
|
||||
projectRootPath: string; // The path to the project root directory
|
||||
safeListPath: string; // The path used to retrieve the safe list
|
||||
packageNameToTypingLocation: Map<string>; // The map of package names to their cached typing locations
|
||||
typeAcquisition: TypeAcquisition; // Used to customize the type acquisition process
|
||||
compilerOptions: CompilerOptions; // Used as a source for typing inference
|
||||
unresolvedImports: ReadonlyArray<string>; // List of unresolved module ids from imports
|
||||
}
|
||||
|
||||
export enum ModuleKind {
|
||||
None = 0,
|
||||
CommonJS = 1,
|
||||
|
||||
@@ -63,7 +63,7 @@ namespace ts.projectSystem {
|
||||
readonly globalTypingsCacheLocation: string,
|
||||
throttleLimit: number,
|
||||
installTypingHost: server.ServerHost,
|
||||
readonly typesRegistry = createMap<void>(),
|
||||
readonly typesRegistry = createMap<MapLike<string>>(),
|
||||
log?: TI.Log) {
|
||||
super(installTypingHost, globalTypingsCacheLocation, safeList.path, customTypesMap.path, throttleLimit, log);
|
||||
}
|
||||
@@ -126,6 +126,25 @@ namespace ts.projectSystem {
|
||||
return JSON.stringify({ dependencies });
|
||||
}
|
||||
|
||||
export function createTypesRegistry(...list: string[]): Map<MapLike<string>> {
|
||||
const versionMap = {
|
||||
"latest": "1.3.0",
|
||||
"ts2.0": "1.0.0",
|
||||
"ts2.1": "1.0.0",
|
||||
"ts2.2": "1.2.0",
|
||||
"ts2.3": "1.3.0",
|
||||
"ts2.4": "1.3.0",
|
||||
"ts2.5": "1.3.0",
|
||||
"ts2.6": "1.3.0",
|
||||
"ts2.7": "1.3.0"
|
||||
};
|
||||
const map = createMap<MapLike<string>>();
|
||||
for (const l of list) {
|
||||
map.set(l, versionMap);
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
export function toExternalFile(fileName: string): protocol.ExternalFile {
|
||||
return { fileName };
|
||||
}
|
||||
@@ -6682,12 +6701,18 @@ namespace ts.projectSystem {
|
||||
},
|
||||
})
|
||||
};
|
||||
const typingsCachePackageLockJson: FileOrFolder = {
|
||||
path: `${typingsCache}/package-lock.json`,
|
||||
content: JSON.stringify({
|
||||
dependencies: {
|
||||
},
|
||||
})
|
||||
};
|
||||
|
||||
const files = [file, packageJsonInCurrentDirectory, packageJsonOfPkgcurrentdirectory, indexOfPkgcurrentdirectory, typingsCachePackageJson];
|
||||
const files = [file, packageJsonInCurrentDirectory, packageJsonOfPkgcurrentdirectory, indexOfPkgcurrentdirectory, typingsCachePackageJson, typingsCachePackageLockJson];
|
||||
const host = createServerHost(files, { currentDirectory });
|
||||
|
||||
const typesRegistry = createMap<void>();
|
||||
typesRegistry.set("pkgcurrentdirectory", void 0);
|
||||
const typesRegistry = createTypesRegistry("pkgcurrentdirectory");
|
||||
const typingsInstaller = new TestTypingsInstaller(typingsCache, /*throttleLimit*/ 5, host, typesRegistry);
|
||||
|
||||
const projectService = createProjectService(host, { typingsInstaller });
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
/// <reference path="../harness.ts" />
|
||||
/// <reference path="./tsserverProjectSystem.ts" />
|
||||
/// <reference path="../../server/typingsInstaller/typingsInstaller.ts" />
|
||||
/// <reference path="../../services/semver.ts" />
|
||||
|
||||
namespace ts.projectSystem {
|
||||
import TI = server.typingsInstaller;
|
||||
@@ -10,15 +11,7 @@ namespace ts.projectSystem {
|
||||
interface InstallerParams {
|
||||
globalTypingsCacheLocation?: string;
|
||||
throttleLimit?: number;
|
||||
typesRegistry?: Map<void>;
|
||||
}
|
||||
|
||||
function createTypesRegistry(...list: string[]): Map<void> {
|
||||
const map = createMap<void>();
|
||||
for (const l of list) {
|
||||
map.set(l, undefined);
|
||||
}
|
||||
return map;
|
||||
typesRegistry?: Map<MapLike<string>>;
|
||||
}
|
||||
|
||||
class Installer extends TestTypingsInstaller {
|
||||
@@ -50,7 +43,7 @@ namespace ts.projectSystem {
|
||||
const logs: string[] = [];
|
||||
return {
|
||||
log(message) {
|
||||
logs.push(message);
|
||||
logs.push(message);
|
||||
},
|
||||
finish() {
|
||||
return logs;
|
||||
@@ -1053,6 +1046,142 @@ namespace ts.projectSystem {
|
||||
const version2 = proj.getCachedUnresolvedImportsPerFile_TestOnly().getVersion();
|
||||
assert.notEqual(version1, version2, "set of unresolved imports should change");
|
||||
});
|
||||
|
||||
it("expired cache entry (inferred project, should install typings)", () => {
|
||||
const file1 = {
|
||||
path: "/a/b/app.js",
|
||||
content: ""
|
||||
};
|
||||
const packageJson = {
|
||||
path: "/a/b/package.json",
|
||||
content: JSON.stringify({
|
||||
name: "test",
|
||||
dependencies: {
|
||||
jquery: "^3.1.0"
|
||||
}
|
||||
})
|
||||
};
|
||||
const jquery = {
|
||||
path: "/a/data/node_modules/@types/jquery/index.d.ts",
|
||||
content: "declare const $: { x: number }"
|
||||
};
|
||||
const cacheConfig = {
|
||||
path: "/a/data/package.json",
|
||||
content: JSON.stringify({
|
||||
dependencies: {
|
||||
"types-registry": "^0.1.317"
|
||||
},
|
||||
devDependencies: {
|
||||
"@types/jquery": "^1.0.0"
|
||||
}
|
||||
})
|
||||
};
|
||||
const cacheLockConfig = {
|
||||
path: "/a/data/package-lock.json",
|
||||
content: JSON.stringify({
|
||||
dependencies: {
|
||||
"@types/jquery": {
|
||||
version: "1.0.0"
|
||||
}
|
||||
}
|
||||
})
|
||||
};
|
||||
const host = createServerHost([file1, packageJson, jquery, cacheConfig, cacheLockConfig]);
|
||||
const installer = new (class extends Installer {
|
||||
constructor() {
|
||||
super(host, { typesRegistry: createTypesRegistry("jquery") });
|
||||
}
|
||||
installWorker(_requestId: number, _args: string[], _cwd: string, cb: TI.RequestCompletedAction) {
|
||||
const installedTypings = ["@types/jquery"];
|
||||
const typingFiles = [jquery];
|
||||
executeCommand(this, host, installedTypings, typingFiles, cb);
|
||||
}
|
||||
})();
|
||||
|
||||
const projectService = createProjectService(host, { useSingleInferredProject: true, typingsInstaller: installer });
|
||||
projectService.openClientFile(file1.path);
|
||||
|
||||
checkNumberOfProjects(projectService, { inferredProjects: 1 });
|
||||
const p = projectService.inferredProjects[0];
|
||||
checkProjectActualFiles(p, [file1.path]);
|
||||
|
||||
installer.installAll(/*expectedCount*/ 1);
|
||||
|
||||
checkNumberOfProjects(projectService, { inferredProjects: 1 });
|
||||
checkProjectActualFiles(p, [file1.path, jquery.path]);
|
||||
});
|
||||
|
||||
it("non-expired cache entry (inferred project, should not install typings)", () => {
|
||||
const file1 = {
|
||||
path: "/a/b/app.js",
|
||||
content: ""
|
||||
};
|
||||
const packageJson = {
|
||||
path: "/a/b/package.json",
|
||||
content: JSON.stringify({
|
||||
name: "test",
|
||||
dependencies: {
|
||||
jquery: "^3.1.0"
|
||||
}
|
||||
})
|
||||
};
|
||||
const timestamps = {
|
||||
path: "/a/data/timestamps.json",
|
||||
content: JSON.stringify({
|
||||
entries: {
|
||||
"@types/jquery": Date.now()
|
||||
}
|
||||
})
|
||||
};
|
||||
const cacheConfig = {
|
||||
path: "/a/data/package.json",
|
||||
content: JSON.stringify({
|
||||
dependencies: {
|
||||
"types-registry": "^0.1.317"
|
||||
},
|
||||
devDependencies: {
|
||||
"@types/jquery": "^1.3.0"
|
||||
}
|
||||
})
|
||||
};
|
||||
const cacheLockConfig = {
|
||||
path: "/a/data/package-lock.json",
|
||||
content: JSON.stringify({
|
||||
dependencies: {
|
||||
"@types/jquery": {
|
||||
version: "1.3.0"
|
||||
}
|
||||
}
|
||||
})
|
||||
};
|
||||
const jquery = {
|
||||
path: "/a/data/node_modules/@types/jquery/index.d.ts",
|
||||
content: "declare const $: { x: number }"
|
||||
};
|
||||
const host = createServerHost([file1, packageJson, timestamps, cacheConfig, cacheLockConfig, jquery]);
|
||||
const installer = new (class extends Installer {
|
||||
constructor() {
|
||||
super(host, { typesRegistry: createTypesRegistry("jquery") });
|
||||
}
|
||||
installWorker(_requestId: number, _args: string[], _cwd: string, cb: TI.RequestCompletedAction) {
|
||||
const installedTypings: string[] = [];
|
||||
const typingFiles: FileOrFolder[] = [];
|
||||
executeCommand(this, host, installedTypings, typingFiles, cb);
|
||||
}
|
||||
})();
|
||||
|
||||
const projectService = createProjectService(host, { useSingleInferredProject: true, typingsInstaller: installer });
|
||||
projectService.openClientFile(file1.path);
|
||||
|
||||
checkNumberOfProjects(projectService, { inferredProjects: 1 });
|
||||
const p = projectService.inferredProjects[0];
|
||||
checkProjectActualFiles(p, [file1.path]);
|
||||
|
||||
installer.installAll(/*expectedCount*/ 0);
|
||||
|
||||
checkNumberOfProjects(projectService, { inferredProjects: 1 });
|
||||
checkProjectActualFiles(p, [file1.path]);
|
||||
});
|
||||
});
|
||||
|
||||
describe("Validate package name:", () => {
|
||||
@@ -1132,7 +1261,7 @@ namespace ts.projectSystem {
|
||||
|
||||
const host = createServerHost([app, jquery, chroma]);
|
||||
const logger = trackingLogger();
|
||||
const result = JsTyping.discoverTypings(host, logger.log, [app.path, jquery.path, chroma.path], getDirectoryPath(<Path>app.path), safeList, emptyMap, { enable: true }, emptyArray);
|
||||
const result = JsTyping.discoverTypings(host, logger.log, [app.path, jquery.path, chroma.path], getDirectoryPath(<Path>app.path), safeList, emptyMap, { enable: true }, emptyArray, emptyMap);
|
||||
const finish = logger.finish();
|
||||
assert.deepEqual(finish, [
|
||||
'Inferred typings from file names: ["jquery","chroma-js"]',
|
||||
@@ -1148,11 +1277,11 @@ namespace ts.projectSystem {
|
||||
content: ""
|
||||
};
|
||||
const host = createServerHost([f]);
|
||||
const cache = createMap<string>();
|
||||
const cache = createMap<JsTyping.CachedTyping>();
|
||||
|
||||
for (const name of JsTyping.nodeCoreModuleList) {
|
||||
const logger = trackingLogger();
|
||||
const result = JsTyping.discoverTypings(host, logger.log, [f.path], getDirectoryPath(<Path>f.path), emptySafeList, cache, { enable: true }, [name, "somename"]);
|
||||
const result = JsTyping.discoverTypings(host, logger.log, [f.path], getDirectoryPath(<Path>f.path), emptySafeList, cache, { enable: true }, [name, "somename"], emptyMap);
|
||||
assert.deepEqual(logger.finish(), [
|
||||
'Inferred typings from unresolved imports: ["node","somename"]',
|
||||
'Result: {"cachedTypingPaths":[],"newTypingNames":["node","somename"],"filesToWatch":["/a/b/bower_components","/a/b/node_modules"]}',
|
||||
@@ -1171,9 +1300,10 @@ namespace ts.projectSystem {
|
||||
content: ""
|
||||
};
|
||||
const host = createServerHost([f, node]);
|
||||
const cache = createMapFromTemplate<string>({ node: node.path });
|
||||
const cache = createMapFromTemplate<JsTyping.CachedTyping>({ node: { typingLocation: node.path, version: Semver.parse("1.3.0") } });
|
||||
const registry = createTypesRegistry("node");
|
||||
const logger = trackingLogger();
|
||||
const result = JsTyping.discoverTypings(host, logger.log, [f.path], getDirectoryPath(<Path>f.path), emptySafeList, cache, { enable: true }, ["fs", "bar"]);
|
||||
const result = JsTyping.discoverTypings(host, logger.log, [f.path], getDirectoryPath(<Path>f.path), emptySafeList, cache, { enable: true }, ["fs", "bar"], registry);
|
||||
assert.deepEqual(logger.finish(), [
|
||||
'Inferred typings from unresolved imports: ["node","bar"]',
|
||||
'Result: {"cachedTypingPaths":["/a/b/node.d.ts"],"newTypingNames":["bar"],"filesToWatch":["/a/b/bower_components","/a/b/node_modules"]}',
|
||||
@@ -1196,9 +1326,9 @@ namespace ts.projectSystem {
|
||||
content: JSON.stringify({ name: "b" }),
|
||||
};
|
||||
const host = createServerHost([app, a, b]);
|
||||
const cache = createMap<string>();
|
||||
const cache = createMap<JsTyping.CachedTyping>();
|
||||
const logger = trackingLogger();
|
||||
const result = JsTyping.discoverTypings(host, logger.log, [app.path], getDirectoryPath(<Path>app.path), emptySafeList, cache, { enable: true }, /*unresolvedImports*/ []);
|
||||
const result = JsTyping.discoverTypings(host, logger.log, [app.path], getDirectoryPath(<Path>app.path), emptySafeList, cache, { enable: true }, /*unresolvedImports*/ [], emptyMap);
|
||||
assert.deepEqual(logger.finish(), [
|
||||
'Searching for typing names in /node_modules; all files: ["/node_modules/a/package.json"]',
|
||||
' Found package names: ["a"]',
|
||||
@@ -1211,6 +1341,94 @@ namespace ts.projectSystem {
|
||||
filesToWatch: ["/bower_components", "/node_modules"],
|
||||
});
|
||||
});
|
||||
|
||||
it("should install expired typings", () => {
|
||||
const app = {
|
||||
path: "/a/app.js",
|
||||
content: ""
|
||||
};
|
||||
const cachePath = "/a/cache/";
|
||||
const commander = {
|
||||
path: cachePath + "node_modules/@types/commander/index.d.ts",
|
||||
content: "export let x: number"
|
||||
};
|
||||
const node = {
|
||||
path: cachePath + "node_modules/@types/node/index.d.ts",
|
||||
content: "export let y: number"
|
||||
};
|
||||
const host = createServerHost([app]);
|
||||
const cache = createMapFromTemplate<JsTyping.CachedTyping>({
|
||||
node: { typingLocation: node.path, version: Semver.parse("1.3.0") },
|
||||
commander: { typingLocation: commander.path, version: Semver.parse("1.0.0") }
|
||||
});
|
||||
const registry = createTypesRegistry("node", "commander");
|
||||
const logger = trackingLogger();
|
||||
const result = JsTyping.discoverTypings(host, logger.log, [app.path], getDirectoryPath(<Path>app.path), emptySafeList, cache, { enable: true }, ["http", "commander"], registry);
|
||||
assert.deepEqual(logger.finish(), [
|
||||
'Inferred typings from unresolved imports: ["node","commander"]',
|
||||
'Result: {"cachedTypingPaths":["/a/cache/node_modules/@types/node/index.d.ts"],"newTypingNames":["commander"],"filesToWatch":["/a/bower_components","/a/node_modules"]}',
|
||||
]);
|
||||
assert.deepEqual(result.cachedTypingPaths, [node.path]);
|
||||
assert.deepEqual(result.newTypingNames, ["commander"]);
|
||||
});
|
||||
|
||||
it("should install expired typings with prerelease version of tsserver", () => {
|
||||
const app = {
|
||||
path: "/a/app.js",
|
||||
content: ""
|
||||
};
|
||||
const cachePath = "/a/cache/";
|
||||
const node = {
|
||||
path: cachePath + "node_modules/@types/node/index.d.ts",
|
||||
content: "export let y: number"
|
||||
};
|
||||
const host = createServerHost([app]);
|
||||
const cache = createMapFromTemplate<JsTyping.CachedTyping>({
|
||||
node: { typingLocation: node.path, version: Semver.parse("1.0.0") }
|
||||
});
|
||||
const registry = createTypesRegistry("node");
|
||||
registry.delete(`ts${ts.versionMajorMinor}`);
|
||||
const logger = trackingLogger();
|
||||
const result = JsTyping.discoverTypings(host, logger.log, [app.path], getDirectoryPath(<Path>app.path), emptySafeList, cache, { enable: true }, ["http"], registry);
|
||||
assert.deepEqual(logger.finish(), [
|
||||
'Inferred typings from unresolved imports: ["node"]',
|
||||
'Result: {"cachedTypingPaths":[],"newTypingNames":["node"],"filesToWatch":["/a/bower_components","/a/node_modules"]}',
|
||||
]);
|
||||
assert.deepEqual(result.cachedTypingPaths, []);
|
||||
assert.deepEqual(result.newTypingNames, ["node"]);
|
||||
});
|
||||
|
||||
|
||||
it("prerelease typings are properly handled", () => {
|
||||
const app = {
|
||||
path: "/a/app.js",
|
||||
content: ""
|
||||
};
|
||||
const cachePath = "/a/cache/";
|
||||
const commander = {
|
||||
path: cachePath + "node_modules/@types/commander/index.d.ts",
|
||||
content: "export let x: number"
|
||||
};
|
||||
const node = {
|
||||
path: cachePath + "node_modules/@types/node/index.d.ts",
|
||||
content: "export let y: number"
|
||||
};
|
||||
const host = createServerHost([app]);
|
||||
const cache = createMapFromTemplate<JsTyping.CachedTyping>({
|
||||
node: { typingLocation: node.path, version: Semver.parse("1.3.0-next.0") },
|
||||
commander: { typingLocation: commander.path, version: Semver.parse("1.3.0-next.0") }
|
||||
});
|
||||
const registry = createTypesRegistry("node", "commander");
|
||||
registry.get("node")[`ts${ts.versionMajorMinor}`] = "1.3.0-next.1";
|
||||
const logger = trackingLogger();
|
||||
const result = JsTyping.discoverTypings(host, logger.log, [app.path], getDirectoryPath(<Path>app.path), emptySafeList, cache, { enable: true }, ["http", "commander"], registry);
|
||||
assert.deepEqual(logger.finish(), [
|
||||
'Inferred typings from unresolved imports: ["node","commander"]',
|
||||
'Result: {"cachedTypingPaths":[],"newTypingNames":["node","commander"],"filesToWatch":["/a/bower_components","/a/node_modules"]}',
|
||||
]);
|
||||
assert.deepEqual(result.cachedTypingPaths, []);
|
||||
assert.deepEqual(result.newTypingNames, ["node", "commander"]);
|
||||
});
|
||||
});
|
||||
|
||||
describe("telemetry events", () => {
|
||||
@@ -1273,12 +1491,22 @@ namespace ts.projectSystem {
|
||||
path: "/a/package.json",
|
||||
content: JSON.stringify({ dependencies: { commander: "1.0.0" } })
|
||||
};
|
||||
const packageLockFile = {
|
||||
path: "/a/cache/package-lock.json",
|
||||
content: JSON.stringify({
|
||||
dependencies: {
|
||||
"@types/commander": {
|
||||
version: "1.0.0"
|
||||
}
|
||||
}
|
||||
})
|
||||
};
|
||||
const cachePath = "/a/cache/";
|
||||
const commander = {
|
||||
path: cachePath + "node_modules/@types/commander/index.d.ts",
|
||||
content: "export let x: number"
|
||||
};
|
||||
const host = createServerHost([f1, packageFile]);
|
||||
const host = createServerHost([f1, packageFile, packageLockFile]);
|
||||
let beginEvent: server.BeginInstallTypes;
|
||||
let endEvent: server.EndInstallTypes;
|
||||
const installer = new (class extends Installer {
|
||||
|
||||
@@ -405,9 +405,11 @@ interface Array<T> {}`
|
||||
ensureFileOrFolder(fileOrDirectory: FileOrFolder, ignoreWatchInvokedWithTriggerAsFileCreate?: boolean) {
|
||||
if (isString(fileOrDirectory.content)) {
|
||||
const file = this.toFile(fileOrDirectory);
|
||||
Debug.assert(!this.fs.get(file.path));
|
||||
const baseFolder = this.ensureFolder(getDirectoryPath(file.fullPath));
|
||||
this.addFileOrFolderInFolder(baseFolder, file, ignoreWatchInvokedWithTriggerAsFileCreate);
|
||||
// file may already exist when updating existing type declaration file
|
||||
if (!this.fs.get(file.path)) {
|
||||
const baseFolder = this.ensureFolder(getDirectoryPath(file.fullPath));
|
||||
this.addFileOrFolderInFolder(baseFolder, file, ignoreWatchInvokedWithTriggerAsFileCreate);
|
||||
}
|
||||
}
|
||||
else if (isString(fileOrDirectory.symLink)) {
|
||||
const symLink = this.toSymLink(fileOrDirectory);
|
||||
|
||||
Vendored
+25
@@ -1338,6 +1338,31 @@ type Record<K extends string, T> = {
|
||||
[P in K]: T;
|
||||
};
|
||||
|
||||
/**
|
||||
* Exclude from T those types that are assignable to U
|
||||
*/
|
||||
type Exclude<T, U> = T extends U ? never : T;
|
||||
|
||||
/**
|
||||
* Extract from T those types that are assignable to U
|
||||
*/
|
||||
type Extract<T, U> = T extends U ? T : never;
|
||||
|
||||
/**
|
||||
* Exclude null and undefined from T
|
||||
*/
|
||||
type NonNullable<T> = T extends null | undefined ? never : T;
|
||||
|
||||
/**
|
||||
* Obtain the return type of a function type
|
||||
*/
|
||||
type ReturnType<T extends (...args: any[]) => any> = T extends (...args: any[]) => infer R ? R : any;
|
||||
|
||||
/**
|
||||
* Obtain the return type of a constructor function type
|
||||
*/
|
||||
type InstanceType<T extends new (...args: any[]) => any> = T extends new (...args: any[]) => infer R ? R : any;
|
||||
|
||||
/**
|
||||
* Marker for contextual 'this' type
|
||||
*/
|
||||
|
||||
@@ -253,7 +253,7 @@ namespace ts.server {
|
||||
private requestMap = createMap<QueuedOperation>(); // Maps operation ID to newest requestQueue entry with that ID
|
||||
/** We will lazily request the types registry on the first call to `isKnownTypesPackageName` and store it in `typesRegistryCache`. */
|
||||
private requestedRegistry: boolean;
|
||||
private typesRegistryCache: Map<void> | undefined;
|
||||
private typesRegistryCache: Map<MapLike<string>> | undefined;
|
||||
|
||||
// This number is essentially arbitrary. Processing more than one typings request
|
||||
// at a time makes sense, but having too many in the pipe results in a hang
|
||||
|
||||
+1
-1
@@ -75,7 +75,7 @@ declare namespace ts.server {
|
||||
/* @internal */
|
||||
export interface TypesRegistryResponse extends TypingInstallerResponse {
|
||||
readonly kind: EventTypesRegistry;
|
||||
readonly typesRegistry: MapLike<void>;
|
||||
readonly typesRegistry: MapLike<MapLike<string>>;
|
||||
}
|
||||
|
||||
export interface PackageInstalledResponse extends ProjectResponse {
|
||||
|
||||
@@ -41,15 +41,15 @@ namespace ts.server.typingsInstaller {
|
||||
}
|
||||
|
||||
interface TypesRegistryFile {
|
||||
entries: MapLike<void>;
|
||||
entries: MapLike<MapLike<string>>;
|
||||
}
|
||||
|
||||
function loadTypesRegistryFile(typesRegistryFilePath: string, host: InstallTypingHost, log: Log): Map<void> {
|
||||
function loadTypesRegistryFile(typesRegistryFilePath: string, host: InstallTypingHost, log: Log): Map<MapLike<string>> {
|
||||
if (!host.fileExists(typesRegistryFilePath)) {
|
||||
if (log.isEnabled()) {
|
||||
log.writeLine(`Types registry file '${typesRegistryFilePath}' does not exist`);
|
||||
}
|
||||
return createMap<void>();
|
||||
return createMap<MapLike<string>>();
|
||||
}
|
||||
try {
|
||||
const content = <TypesRegistryFile>JSON.parse(host.readFile(typesRegistryFilePath));
|
||||
@@ -59,7 +59,7 @@ namespace ts.server.typingsInstaller {
|
||||
if (log.isEnabled()) {
|
||||
log.writeLine(`Error when loading types registry file '${typesRegistryFilePath}': ${(<Error>e).message}, ${(<Error>e).stack}`);
|
||||
}
|
||||
return createMap<void>();
|
||||
return createMap<MapLike<string>>();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -77,7 +77,7 @@ namespace ts.server.typingsInstaller {
|
||||
export class NodeTypingsInstaller extends TypingsInstaller {
|
||||
private readonly nodeExecSync: ExecSync;
|
||||
private readonly npmPath: string;
|
||||
readonly typesRegistry: Map<void>;
|
||||
readonly typesRegistry: Map<MapLike<string>>;
|
||||
|
||||
private delayedInitializationError: InitializationFailedResponse | undefined;
|
||||
|
||||
@@ -141,7 +141,7 @@ namespace ts.server.typingsInstaller {
|
||||
this.closeProject(req);
|
||||
break;
|
||||
case "typesRegistry": {
|
||||
const typesRegistry: { [key: string]: void } = {};
|
||||
const typesRegistry: { [key: string]: MapLike<string> } = {};
|
||||
this.typesRegistry.forEach((value, key) => {
|
||||
typesRegistry[key] = value;
|
||||
});
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
/// <reference path="../../compiler/core.ts" />
|
||||
/// <reference path="../../compiler/moduleNameResolver.ts" />
|
||||
/// <reference path="../../services/jsTyping.ts"/>
|
||||
/// <reference path="../../services/semver.ts"/>
|
||||
/// <reference path="../types.ts"/>
|
||||
/// <reference path="../shared.ts"/>
|
||||
|
||||
@@ -9,6 +10,10 @@ namespace ts.server.typingsInstaller {
|
||||
devDependencies: MapLike<any>;
|
||||
}
|
||||
|
||||
interface NpmLock {
|
||||
dependencies: { [packageName: string]: { version: string } };
|
||||
}
|
||||
|
||||
export interface Log {
|
||||
isEnabled(): boolean;
|
||||
writeLine(text: string): void;
|
||||
@@ -42,7 +47,7 @@ namespace ts.server.typingsInstaller {
|
||||
}
|
||||
|
||||
export abstract class TypingsInstaller {
|
||||
private readonly packageNameToTypingLocation: Map<string> = createMap<string>();
|
||||
private readonly packageNameToTypingLocation: Map<JsTyping.CachedTyping> = createMap<JsTyping.CachedTyping>();
|
||||
private readonly missingTypingsSet: Map<true> = createMap<true>();
|
||||
private readonly knownCachesSet: Map<true> = createMap<true>();
|
||||
private readonly projectWatchers: Map<FileWatcher[]> = createMap<FileWatcher[]>();
|
||||
@@ -52,7 +57,7 @@ namespace ts.server.typingsInstaller {
|
||||
private installRunCount = 1;
|
||||
private inFlightRequestCount = 0;
|
||||
|
||||
abstract readonly typesRegistry: Map<void>;
|
||||
abstract readonly typesRegistry: Map<MapLike<string>>;
|
||||
|
||||
constructor(
|
||||
protected readonly installTypingHost: InstallTypingHost,
|
||||
@@ -117,7 +122,8 @@ namespace ts.server.typingsInstaller {
|
||||
this.safeList,
|
||||
this.packageNameToTypingLocation,
|
||||
req.typeAcquisition,
|
||||
req.unresolvedImports);
|
||||
req.unresolvedImports,
|
||||
this.typesRegistry);
|
||||
|
||||
if (this.log.isEnabled()) {
|
||||
this.log.writeLine(`Finished typings discovery: ${JSON.stringify(discoverTypingsResult)}`);
|
||||
@@ -156,23 +162,30 @@ namespace ts.server.typingsInstaller {
|
||||
if (this.log.isEnabled()) {
|
||||
this.log.writeLine(`Processing cache location '${cacheLocation}'`);
|
||||
}
|
||||
if (this.knownCachesSet.get(cacheLocation)) {
|
||||
if (this.knownCachesSet.has(cacheLocation)) {
|
||||
if (this.log.isEnabled()) {
|
||||
this.log.writeLine(`Cache location was already processed...`);
|
||||
}
|
||||
return;
|
||||
}
|
||||
const packageJson = combinePaths(cacheLocation, "package.json");
|
||||
const packageLockJson = combinePaths(cacheLocation, "package-lock.json");
|
||||
if (this.log.isEnabled()) {
|
||||
this.log.writeLine(`Trying to find '${packageJson}'...`);
|
||||
}
|
||||
if (this.installTypingHost.fileExists(packageJson)) {
|
||||
if (this.installTypingHost.fileExists(packageJson) && this.installTypingHost.fileExists(packageLockJson)) {
|
||||
const npmConfig = <NpmConfig>JSON.parse(this.installTypingHost.readFile(packageJson));
|
||||
const npmLock = <NpmLock>JSON.parse(this.installTypingHost.readFile(packageLockJson));
|
||||
if (this.log.isEnabled()) {
|
||||
this.log.writeLine(`Loaded content of '${packageJson}': ${JSON.stringify(npmConfig)}`);
|
||||
this.log.writeLine(`Loaded content of '${packageLockJson}'`);
|
||||
}
|
||||
if (npmConfig.devDependencies) {
|
||||
if (npmConfig.devDependencies && npmLock.dependencies) {
|
||||
for (const key in npmConfig.devDependencies) {
|
||||
if (!hasProperty(npmLock.dependencies, key)) {
|
||||
// if package in package.json but not package-lock.json, skip adding to cache so it is reinstalled on next use
|
||||
continue;
|
||||
}
|
||||
// key is @types/<package name>
|
||||
const packageName = getBaseFileName(key);
|
||||
if (!packageName) {
|
||||
@@ -184,10 +197,11 @@ namespace ts.server.typingsInstaller {
|
||||
continue;
|
||||
}
|
||||
const existingTypingFile = this.packageNameToTypingLocation.get(packageName);
|
||||
if (existingTypingFile === typingFile) {
|
||||
continue;
|
||||
}
|
||||
if (existingTypingFile) {
|
||||
if (existingTypingFile.typingLocation === typingFile) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (this.log.isEnabled()) {
|
||||
this.log.writeLine(`New typing for package ${packageName} from '${typingFile}' conflicts with existing typing file '${existingTypingFile}'`);
|
||||
}
|
||||
@@ -195,7 +209,11 @@ namespace ts.server.typingsInstaller {
|
||||
if (this.log.isEnabled()) {
|
||||
this.log.writeLine(`Adding entry into typings cache: '${packageName}' => '${typingFile}'`);
|
||||
}
|
||||
this.packageNameToTypingLocation.set(packageName, typingFile);
|
||||
const info = getProperty(npmLock.dependencies, key);
|
||||
const version = info && info.version;
|
||||
const semver = Semver.parse(version);
|
||||
const newTyping: JsTyping.CachedTyping = { typingLocation: typingFile, version: semver };
|
||||
this.packageNameToTypingLocation.set(packageName, newTyping);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -211,10 +229,6 @@ namespace ts.server.typingsInstaller {
|
||||
if (this.log.isEnabled()) this.log.writeLine(`'${typing}' is in missingTypingsSet - skipping...`);
|
||||
return false;
|
||||
}
|
||||
if (this.packageNameToTypingLocation.get(typing)) {
|
||||
if (this.log.isEnabled()) this.log.writeLine(`'${typing}' already has a typing - skipping...`);
|
||||
return false;
|
||||
}
|
||||
const validationResult = JsTyping.validatePackageName(typing);
|
||||
if (validationResult !== JsTyping.PackageNameValidationResult.Ok) {
|
||||
// add typing name to missing set so we won't process it again
|
||||
@@ -226,6 +240,10 @@ namespace ts.server.typingsInstaller {
|
||||
if (this.log.isEnabled()) this.log.writeLine(`Entry for package '${typing}' does not exist in local types registry - skipping...`);
|
||||
return false;
|
||||
}
|
||||
if (this.packageNameToTypingLocation.get(typing) && JsTyping.isTypingUpToDate(this.packageNameToTypingLocation.get(typing), this.typesRegistry.get(typing))) {
|
||||
if (this.log.isEnabled()) this.log.writeLine(`'${typing}' already has an up-to-date typing - skipping...`);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
});
|
||||
}
|
||||
@@ -294,9 +312,12 @@ namespace ts.server.typingsInstaller {
|
||||
this.missingTypingsSet.set(packageName, true);
|
||||
continue;
|
||||
}
|
||||
if (!this.packageNameToTypingLocation.has(packageName)) {
|
||||
this.packageNameToTypingLocation.set(packageName, typingFile);
|
||||
}
|
||||
|
||||
// packageName is guaranteed to exist in typesRegistry by filterTypings
|
||||
const distTags = this.typesRegistry.get(packageName);
|
||||
const newVersion = Semver.parse(distTags[`ts${ts.versionMajorMinor}`] || distTags[latestDistTag]);
|
||||
const newTyping: JsTyping.CachedTyping = { typingLocation: typingFile, version: newVersion };
|
||||
this.packageNameToTypingLocation.set(packageName, newTyping);
|
||||
installedTypingFiles.push(typingFile);
|
||||
}
|
||||
if (this.log.isEnabled()) {
|
||||
@@ -390,4 +411,6 @@ namespace ts.server.typingsInstaller {
|
||||
export function typingsName(packageName: string): string {
|
||||
return `@types/${packageName}@ts${versionMajorMinor}`;
|
||||
}
|
||||
|
||||
const latestDistTag = "latest";
|
||||
}
|
||||
@@ -712,7 +712,7 @@ namespace ts.Completions {
|
||||
function getFirstSymbolInChain(symbol: Symbol, enclosingDeclaration: Node, checker: TypeChecker): Symbol | undefined {
|
||||
const chain = checker.getAccessibleSymbolChain(symbol, enclosingDeclaration, /*meaning*/ SymbolFlags.All, /*useOnlyExternalAliasing*/ false);
|
||||
if (chain) return first(chain);
|
||||
return isModuleSymbol(symbol.parent) ? symbol : symbol.parent && getFirstSymbolInChain(symbol.parent, enclosingDeclaration, checker);
|
||||
return symbol.parent && (isModuleSymbol(symbol.parent) ? symbol : getFirstSymbolInChain(symbol.parent, enclosingDeclaration, checker));
|
||||
}
|
||||
|
||||
function isModuleSymbol(symbol: Symbol): boolean {
|
||||
|
||||
@@ -416,10 +416,16 @@ namespace ts.FindAllReferences.Core {
|
||||
}
|
||||
|
||||
// If the symbol is declared as part of a declaration like `{ type: "a" } | { type: "b" }`, use the property on the union type to get more references.
|
||||
return firstDefined(symbol.declarations, decl =>
|
||||
isTypeLiteralNode(decl.parent) && isUnionTypeNode(decl.parent.parent)
|
||||
return firstDefined(symbol.declarations, decl => {
|
||||
if (!decl.parent) {
|
||||
// Assertions for GH#21814. We should be handling SourceFile symbols in `getReferencedSymbolsForModule` instead of getting here.
|
||||
Debug.assert(decl.kind === SyntaxKind.SourceFile);
|
||||
Debug.fail(`Unexpected symbol at ${Debug.showSyntaxKind(node)}: ${Debug.showSymbol(symbol)}`);
|
||||
}
|
||||
return isTypeLiteralNode(decl.parent) && isUnionTypeNode(decl.parent.parent)
|
||||
? checker.getPropertyOfType(checker.getTypeFromTypeNode(decl.parent.parent), symbol.name)
|
||||
: undefined) || symbol;
|
||||
: undefined;
|
||||
}) || symbol;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -914,7 +920,8 @@ namespace ts.FindAllReferences.Core {
|
||||
|
||||
// At `export { x } from "foo"`, also search for the imported symbol `"foo".x`.
|
||||
if (search.comingFrom !== ImportExport.Export && exportDeclaration.moduleSpecifier && !propertyName) {
|
||||
searchForImportedSymbol(state.checker.getExportSpecifierLocalTargetSymbol(exportSpecifier), state);
|
||||
const imported = state.checker.getExportSpecifierLocalTargetSymbol(exportSpecifier);
|
||||
if (imported) searchForImportedSymbol(imported, state);
|
||||
}
|
||||
|
||||
function addRef() {
|
||||
@@ -923,7 +930,7 @@ namespace ts.FindAllReferences.Core {
|
||||
}
|
||||
|
||||
function getLocalSymbolForExportSpecifier(referenceLocation: Identifier, referenceSymbol: Symbol, exportSpecifier: ExportSpecifier, checker: TypeChecker): Symbol {
|
||||
return isExportSpecifierAlias(referenceLocation, exportSpecifier) ? checker.getExportSpecifierLocalTargetSymbol(exportSpecifier) : referenceSymbol;
|
||||
return isExportSpecifierAlias(referenceLocation, exportSpecifier) && checker.getExportSpecifierLocalTargetSymbol(exportSpecifier) || referenceSymbol;
|
||||
}
|
||||
|
||||
function isExportSpecifierAlias(referenceLocation: Identifier, exportSpecifier: ExportSpecifier): boolean {
|
||||
|
||||
@@ -517,29 +517,12 @@ namespace ts.FindAllReferences {
|
||||
const sym = useLhsSymbol ? checker.getSymbolAtLocation(cast(node.left, isPropertyAccessExpression).name) : symbol;
|
||||
// Better detection for GH#20803
|
||||
if (sym && !(checker.getMergedSymbol(sym.parent).flags & SymbolFlags.Module)) {
|
||||
Debug.fail(`Special property assignment kind does not have a module as its parent. Assignment is ${showSymbol(sym)}, parent is ${showSymbol(sym.parent)}`);
|
||||
Debug.fail(`Special property assignment kind does not have a module as its parent. Assignment is ${Debug.showSymbol(sym)}, parent is ${Debug.showSymbol(sym.parent)}`);
|
||||
}
|
||||
return sym && exportInfo(sym, kind);
|
||||
}
|
||||
}
|
||||
|
||||
function showSymbol(s: Symbol): string {
|
||||
const decls = s.declarations.map(d => (ts as any).SyntaxKind[d.kind]).join(",");
|
||||
const flags = showFlags(s.flags, (ts as any).SymbolFlags);
|
||||
return `{ declarations: ${decls}, flags: ${flags} }`;
|
||||
}
|
||||
|
||||
function showFlags(f: number, flags: any) {
|
||||
const out = [];
|
||||
for (let pow = 0; pow <= 30; pow++) {
|
||||
const n = 1 << pow;
|
||||
if (f & n) {
|
||||
out.push(flags[n]);
|
||||
}
|
||||
}
|
||||
return out.join("|");
|
||||
}
|
||||
|
||||
function getImport(): ImportedSymbol | undefined {
|
||||
const isImport = isNodeImport(node);
|
||||
if (!isImport) return undefined;
|
||||
@@ -577,17 +560,17 @@ namespace ts.FindAllReferences {
|
||||
|
||||
function getExportEqualsLocalSymbol(importedSymbol: Symbol, checker: TypeChecker): Symbol {
|
||||
if (importedSymbol.flags & SymbolFlags.Alias) {
|
||||
return checker.getImmediateAliasedSymbol(importedSymbol);
|
||||
return Debug.assertDefined(checker.getImmediateAliasedSymbol(importedSymbol));
|
||||
}
|
||||
|
||||
const decl = importedSymbol.valueDeclaration;
|
||||
if (isExportAssignment(decl)) { // `export = class {}`
|
||||
return decl.expression.symbol;
|
||||
return Debug.assertDefined(decl.expression.symbol);
|
||||
}
|
||||
else if (isBinaryExpression(decl)) { // `module.exports = class {}`
|
||||
return decl.right.symbol;
|
||||
return Debug.assertDefined(decl.right.symbol);
|
||||
}
|
||||
Debug.fail();
|
||||
return Debug.fail();
|
||||
}
|
||||
|
||||
// If a reference is a class expression, the exported node would be its parent.
|
||||
@@ -623,7 +606,9 @@ namespace ts.FindAllReferences {
|
||||
}
|
||||
|
||||
export function getExportInfo(exportSymbol: Symbol, exportKind: ExportKind, checker: TypeChecker): ExportInfo | undefined {
|
||||
const exportingModuleSymbol = checker.getMergedSymbol(exportSymbol.parent); // Need to get merged symbol in case there's an augmentation.
|
||||
const moduleSymbol = exportSymbol.parent;
|
||||
if (!moduleSymbol) return undefined; // This can happen if an `export` is not at the top-level (which is a compile error).
|
||||
const exportingModuleSymbol = checker.getMergedSymbol(moduleSymbol); // Need to get merged symbol in case there's an augmentation.
|
||||
// `export` may appear in a namespace. In that case, just rely on global search.
|
||||
return isExternalModuleSymbol(exportingModuleSymbol) ? { exportingModuleSymbol, exportKind } : undefined;
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
/// <reference path='../compiler/types.ts' />
|
||||
/// <reference path='../compiler/core.ts' />
|
||||
/// <reference path='../compiler/commandLineParser.ts' />
|
||||
/// <reference path='../services/semver.ts' />
|
||||
|
||||
/* @internal */
|
||||
namespace ts.JsTyping {
|
||||
@@ -26,6 +27,17 @@ namespace ts.JsTyping {
|
||||
typings?: string;
|
||||
}
|
||||
|
||||
export interface CachedTyping {
|
||||
typingLocation: string;
|
||||
version: Semver;
|
||||
}
|
||||
|
||||
/* @internal */
|
||||
export function isTypingUpToDate(cachedTyping: JsTyping.CachedTyping, availableTypingVersions: MapLike<string>) {
|
||||
const availableVersion = Semver.parse(getProperty(availableTypingVersions, `ts${ts.versionMajorMinor}`) || getProperty(availableTypingVersions, "latest"));
|
||||
return !availableVersion.greaterThan(cachedTyping.version);
|
||||
}
|
||||
|
||||
/* @internal */
|
||||
export const nodeCoreModuleList: ReadonlyArray<string> = [
|
||||
"buffer", "querystring", "events", "http", "cluster",
|
||||
@@ -60,7 +72,7 @@ namespace ts.JsTyping {
|
||||
* @param fileNames are the file names that belong to the same project
|
||||
* @param projectRootPath is the path to the project root directory
|
||||
* @param safeListPath is the path used to retrieve the safe list
|
||||
* @param packageNameToTypingLocation is the map of package names to their cached typing locations
|
||||
* @param packageNameToTypingLocation is the map of package names to their cached typing locations and installed versions
|
||||
* @param typeAcquisition is used to customize the typing acquisition process
|
||||
* @param compilerOptions are used as a source for typing inference
|
||||
*/
|
||||
@@ -70,9 +82,10 @@ namespace ts.JsTyping {
|
||||
fileNames: string[],
|
||||
projectRootPath: Path,
|
||||
safeList: SafeList,
|
||||
packageNameToTypingLocation: ReadonlyMap<string>,
|
||||
packageNameToTypingLocation: ReadonlyMap<CachedTyping>,
|
||||
typeAcquisition: TypeAcquisition,
|
||||
unresolvedImports: ReadonlyArray<string>):
|
||||
unresolvedImports: ReadonlyArray<string>,
|
||||
typesRegistry: ReadonlyMap<MapLike<string>>):
|
||||
{ cachedTypingPaths: string[], newTypingNames: string[], filesToWatch: string[] } {
|
||||
|
||||
if (!typeAcquisition || !typeAcquisition.enable) {
|
||||
@@ -122,9 +135,9 @@ namespace ts.JsTyping {
|
||||
addInferredTypings(module, "Inferred typings from unresolved imports");
|
||||
}
|
||||
// Add the cached typing locations for inferred typings that are already installed
|
||||
packageNameToTypingLocation.forEach((typingLocation, name) => {
|
||||
if (inferredTypings.has(name) && inferredTypings.get(name) === undefined) {
|
||||
inferredTypings.set(name, typingLocation);
|
||||
packageNameToTypingLocation.forEach((typing, name) => {
|
||||
if (inferredTypings.has(name) && inferredTypings.get(name) === undefined && isTypingUpToDate(typing, typesRegistry.get(name))) {
|
||||
inferredTypings.set(name, typing.typingLocation);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -33,8 +33,8 @@ namespace ts.refactor {
|
||||
return isExportsOrModuleExportsOrAlias(sourceFile, node as PropertyAccessExpression)
|
||||
|| isExportsOrModuleExportsOrAlias(sourceFile, (node as PropertyAccessExpression).expression);
|
||||
case SyntaxKind.VariableDeclarationList:
|
||||
const decl = (node as VariableDeclarationList).declarations[0];
|
||||
return isExportsOrModuleExportsOrAlias(sourceFile, decl.initializer);
|
||||
const decl = firstOrUndefined((node as VariableDeclarationList).declarations);
|
||||
return !!decl && isExportsOrModuleExportsOrAlias(sourceFile, decl.initializer);
|
||||
case SyntaxKind.VariableDeclaration:
|
||||
return isExportsOrModuleExportsOrAlias(sourceFile, (node as VariableDeclaration).initializer);
|
||||
default:
|
||||
|
||||
@@ -968,7 +968,7 @@ namespace ts.refactor.extractSymbol {
|
||||
}
|
||||
|
||||
if (isReadonlyArray(range.range)) {
|
||||
changeTracker.replaceNodesWithNodes(context.file, range.range, newNodes);
|
||||
changeTracker.replaceNodeRangeWithNodes(context.file, first(range.range), last(range.range), newNodes);
|
||||
}
|
||||
else {
|
||||
changeTracker.replaceNodeWithNodes(context.file, range.range, newNodes);
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
/* @internal */
|
||||
namespace ts {
|
||||
function stringToInt(str: string): number {
|
||||
const n = parseInt(str, 10);
|
||||
if (isNaN(n)) {
|
||||
throw new Error(`Error in parseInt(${JSON.stringify(str)})`);
|
||||
}
|
||||
return n;
|
||||
}
|
||||
|
||||
const isPrereleaseRegex = /^(.*)-next.\d+/;
|
||||
const prereleaseSemverRegex = /^(\d+)\.(\d+)\.0-next.(\d+)$/;
|
||||
const semverRegex = /^(\d+)\.(\d+)\.(\d+)$/;
|
||||
|
||||
export class Semver {
|
||||
static parse(semver: string): Semver {
|
||||
const isPrerelease = isPrereleaseRegex.test(semver);
|
||||
const result = Semver.tryParse(semver, isPrerelease);
|
||||
if (!result) {
|
||||
throw new Error(`Unexpected semver: ${semver} (isPrerelease: ${isPrerelease})`);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
static fromRaw({ major, minor, patch, isPrerelease }: Semver): Semver {
|
||||
return new Semver(major, minor, patch, isPrerelease);
|
||||
}
|
||||
|
||||
// This must parse the output of `versionString`.
|
||||
private static tryParse(semver: string, isPrerelease: boolean): Semver | undefined {
|
||||
// Per the semver spec <http://semver.org/#spec-item-2>:
|
||||
// "A normal version number MUST take the form X.Y.Z where X, Y, and Z are non-negative integers, and MUST NOT contain leading zeroes."
|
||||
const rgx = isPrerelease ? prereleaseSemverRegex : semverRegex;
|
||||
const match = rgx.exec(semver);
|
||||
return match ? new Semver(stringToInt(match[1]), stringToInt(match[2]), stringToInt(match[3]), isPrerelease) : undefined;
|
||||
}
|
||||
|
||||
private constructor(
|
||||
readonly major: number, readonly minor: number, readonly patch: number,
|
||||
/**
|
||||
* If true, this is `major.minor.0-next.patch`.
|
||||
* If false, this is `major.minor.patch`.
|
||||
*/
|
||||
readonly isPrerelease: boolean) { }
|
||||
|
||||
get versionString(): string {
|
||||
return this.isPrerelease ? `${this.major}.${this.minor}.0-next.${this.patch}` : `${this.major}.${this.minor}.${this.patch}`;
|
||||
}
|
||||
|
||||
equals(sem: Semver): boolean {
|
||||
return this.major === sem.major && this.minor === sem.minor && this.patch === sem.patch && this.isPrerelease === sem.isPrerelease;
|
||||
}
|
||||
|
||||
greaterThan(sem: Semver): boolean {
|
||||
return this.major > sem.major || this.major === sem.major
|
||||
&& (this.minor > sem.minor || this.minor === sem.minor
|
||||
&& (!this.isPrerelease && sem.isPrerelease || this.isPrerelease === sem.isPrerelease
|
||||
&& this.patch > sem.patch));
|
||||
}
|
||||
}
|
||||
}
|
||||
+13
-1
@@ -24,6 +24,17 @@ let debugObjectHost: { CollectGarbage(): void } = (function (this: any) { return
|
||||
|
||||
/* @internal */
|
||||
namespace ts {
|
||||
interface DiscoverTypingsInfo {
|
||||
fileNames: string[]; // The file names that belong to the same project.
|
||||
projectRootPath: string; // The path to the project root directory
|
||||
safeListPath: string; // The path used to retrieve the safe list
|
||||
packageNameToTypingLocation: Map<JsTyping.CachedTyping>; // The map of package names to their cached typing locations and installed versions
|
||||
typeAcquisition: TypeAcquisition; // Used to customize the type acquisition process
|
||||
compilerOptions: CompilerOptions; // Used as a source for typing inference
|
||||
unresolvedImports: ReadonlyArray<string>; // List of unresolved module ids from imports
|
||||
typesRegistry: ReadonlyMap<MapLike<string>>; // The map of available typings in npm to maps of TS versions to their latest supported versions
|
||||
}
|
||||
|
||||
export interface ScriptSnapshotShim {
|
||||
/** Gets a portion of the script snapshot specified by [start, end). */
|
||||
getText(start: number, end: number): string;
|
||||
@@ -1159,7 +1170,8 @@ namespace ts {
|
||||
this.safeList,
|
||||
info.packageNameToTypingLocation,
|
||||
info.typeAcquisition,
|
||||
info.unresolvedImports);
|
||||
info.unresolvedImports,
|
||||
info.typesRegistry);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
+36
-39
@@ -28,9 +28,11 @@ namespace ts.textChanges {
|
||||
}
|
||||
|
||||
export interface ConfigurableStart {
|
||||
/** True to use getStart() (NB, not getFullStart()) without adjustment. */
|
||||
useNonAdjustedStartPosition?: boolean;
|
||||
}
|
||||
export interface ConfigurableEnd {
|
||||
/** True to use getEnd() without adjustment. */
|
||||
useNonAdjustedEndPosition?: boolean;
|
||||
}
|
||||
|
||||
@@ -132,7 +134,7 @@ namespace ts.textChanges {
|
||||
|
||||
export function getAdjustedStartPosition(sourceFile: SourceFile, node: Node, options: ConfigurableStart, position: Position) {
|
||||
if (options.useNonAdjustedStartPosition) {
|
||||
return node.getFullStart();
|
||||
return node.getStart();
|
||||
}
|
||||
const fullStart = node.getFullStart();
|
||||
const start = node.getStart(sourceFile);
|
||||
@@ -280,51 +282,46 @@ namespace ts.textChanges {
|
||||
return this;
|
||||
}
|
||||
|
||||
public replaceRange(sourceFile: SourceFile, range: TextRange, newNode: Node, options: InsertNodeOptions = {}) {
|
||||
public replaceRange(sourceFile: SourceFile, range: TextRange, newNode: Node, options: ChangeNodeOptions = {}) {
|
||||
this.changes.push({ kind: ChangeKind.ReplaceWithSingleNode, sourceFile, range, options, node: newNode });
|
||||
return this;
|
||||
}
|
||||
|
||||
public replaceNode(sourceFile: SourceFile, oldNode: Node, newNode: Node, options: ChangeNodeOptions = {}) {
|
||||
const startPosition = getAdjustedStartPosition(sourceFile, oldNode, options, Position.Start);
|
||||
const endPosition = getAdjustedEndPosition(sourceFile, oldNode, options);
|
||||
return this.replaceWithSingle(sourceFile, startPosition, endPosition, newNode, options);
|
||||
const pos = getAdjustedStartPosition(sourceFile, oldNode, options, Position.Start);
|
||||
const end = getAdjustedEndPosition(sourceFile, oldNode, options);
|
||||
return this.replaceRange(sourceFile, { pos, end }, newNode, options);
|
||||
}
|
||||
|
||||
public replaceNodeRange(sourceFile: SourceFile, startNode: Node, endNode: Node, newNode: Node, options: ChangeNodeOptions = {}) {
|
||||
const startPosition = getAdjustedStartPosition(sourceFile, startNode, options, Position.Start);
|
||||
const endPosition = getAdjustedEndPosition(sourceFile, endNode, options);
|
||||
return this.replaceWithSingle(sourceFile, startPosition, endPosition, newNode, options);
|
||||
const pos = getAdjustedStartPosition(sourceFile, startNode, options, Position.Start);
|
||||
const end = getAdjustedEndPosition(sourceFile, endNode, options);
|
||||
return this.replaceRange(sourceFile, { pos, end }, newNode, options);
|
||||
}
|
||||
|
||||
private replaceWithSingle(sourceFile: SourceFile, startPosition: number, endPosition: number, newNode: Node, options: ChangeNodeOptions): this {
|
||||
this.changes.push({
|
||||
kind: ChangeKind.ReplaceWithSingleNode,
|
||||
sourceFile,
|
||||
options,
|
||||
node: newNode,
|
||||
range: { pos: startPosition, end: endPosition }
|
||||
});
|
||||
private getDefaultChangeMultipleNodesOptions(): ChangeMultipleNodesOptions {
|
||||
return {
|
||||
nodeSeparator: this.newLineCharacter,
|
||||
useNonAdjustedStartPosition: true,
|
||||
useNonAdjustedEndPosition: true,
|
||||
};
|
||||
}
|
||||
|
||||
public replaceRangeWithNodes(sourceFile: SourceFile, range: TextRange, newNodes: ReadonlyArray<Node>, options: ChangeMultipleNodesOptions = this.getDefaultChangeMultipleNodesOptions()) {
|
||||
this.changes.push({ kind: ChangeKind.ReplaceWithMultipleNodes, sourceFile, range, options, nodes: newNodes });
|
||||
return this;
|
||||
}
|
||||
|
||||
private replaceWithMultiple(sourceFile: SourceFile, startPosition: number, endPosition: number, newNodes: ReadonlyArray<Node>, options: ChangeMultipleNodesOptions): this {
|
||||
this.changes.push({
|
||||
kind: ChangeKind.ReplaceWithMultipleNodes,
|
||||
sourceFile,
|
||||
options,
|
||||
nodes: newNodes,
|
||||
range: { pos: startPosition, end: endPosition }
|
||||
});
|
||||
return this;
|
||||
public replaceNodeWithNodes(sourceFile: SourceFile, oldNode: Node, newNodes: ReadonlyArray<Node>, options: ChangeMultipleNodesOptions = this.getDefaultChangeMultipleNodesOptions()) {
|
||||
const pos = getAdjustedStartPosition(sourceFile, oldNode, options, Position.Start);
|
||||
const end = getAdjustedEndPosition(sourceFile, oldNode, options);
|
||||
return this.replaceRangeWithNodes(sourceFile, { pos, end }, newNodes, options);
|
||||
}
|
||||
|
||||
public replaceNodeWithNodes(sourceFile: SourceFile, oldNode: Node, newNodes: ReadonlyArray<Node>): void {
|
||||
this.replaceWithMultiple(sourceFile, oldNode.getStart(sourceFile), oldNode.getEnd(), newNodes, { nodeSeparator: this.newLineCharacter });
|
||||
}
|
||||
|
||||
public replaceNodesWithNodes(sourceFile: SourceFile, oldNodes: ReadonlyArray<Node>, newNodes: ReadonlyArray<Node>): void {
|
||||
this.replaceWithMultiple(sourceFile, first(oldNodes).getStart(sourceFile), last(oldNodes).getEnd(), newNodes, { nodeSeparator: this.newLineCharacter });
|
||||
public replaceNodeRangeWithNodes(sourceFile: SourceFile, startNode: Node, endNode: Node, newNodes: ReadonlyArray<Node>, options: ChangeMultipleNodesOptions = this.getDefaultChangeMultipleNodesOptions()) {
|
||||
const pos = getAdjustedStartPosition(sourceFile, startNode, options, Position.Start);
|
||||
const end = getAdjustedEndPosition(sourceFile, endNode, options);
|
||||
return this.replaceRangeWithNodes(sourceFile, { pos, end }, newNodes, options);
|
||||
}
|
||||
|
||||
private insertNodeAt(sourceFile: SourceFile, pos: number, newNode: Node, options: InsertNodeOptions = {}) {
|
||||
@@ -341,18 +338,18 @@ namespace ts.textChanges {
|
||||
}
|
||||
|
||||
public insertNodeBefore(sourceFile: SourceFile, before: Node, newNode: Node, blankLineBetween = false) {
|
||||
const startPosition = getAdjustedStartPosition(sourceFile, before, {}, Position.Start);
|
||||
return this.replaceWithSingle(sourceFile, startPosition, startPosition, newNode, this.getOptionsForInsertNodeBefore(before, blankLineBetween));
|
||||
const pos = getAdjustedStartPosition(sourceFile, before, {}, Position.Start);
|
||||
return this.replaceRange(sourceFile, { pos, end: pos }, newNode, this.getOptionsForInsertNodeBefore(before, blankLineBetween));
|
||||
}
|
||||
|
||||
public insertModifierBefore(sourceFile: SourceFile, modifier: SyntaxKind, before: Node): void {
|
||||
const pos = before.getStart(sourceFile);
|
||||
this.replaceWithSingle(sourceFile, pos, pos, createToken(modifier), { suffix: " " });
|
||||
this.replaceRange(sourceFile, { pos, end: pos }, createToken(modifier), { suffix: " " });
|
||||
}
|
||||
|
||||
public changeIdentifierToPropertyAccess(sourceFile: SourceFile, prefix: string, node: Identifier): void {
|
||||
const startPosition = getAdjustedStartPosition(sourceFile, node, {}, Position.Start);
|
||||
this.replaceWithSingle(sourceFile, startPosition, startPosition, createPropertyAccess(createIdentifier(prefix), ""), {});
|
||||
const pos = getAdjustedStartPosition(sourceFile, node, {}, Position.Start);
|
||||
this.replaceRange(sourceFile, { pos, end: pos }, createPropertyAccess(createIdentifier(prefix), ""), {});
|
||||
}
|
||||
|
||||
private getOptionsForInsertNodeBefore(before: Node, doubleNewlines: boolean): ChangeNodeOptions {
|
||||
@@ -390,8 +387,8 @@ namespace ts.textChanges {
|
||||
}
|
||||
|
||||
public insertNodeAtEndOfScope(sourceFile: SourceFile, scope: Node, newNode: Node): void {
|
||||
const startPosition = getAdjustedStartPosition(sourceFile, scope.getLastToken(), {}, Position.Start);
|
||||
this.replaceWithSingle(sourceFile, startPosition, startPosition, newNode, {
|
||||
const pos = getAdjustedStartPosition(sourceFile, scope.getLastToken(), {}, Position.Start);
|
||||
this.replaceRange(sourceFile, { pos, end: pos }, newNode, {
|
||||
prefix: isLineBreak(sourceFile.text.charCodeAt(scope.getLastToken().pos)) ? this.newLineCharacter : this.newLineCharacter + this.newLineCharacter,
|
||||
suffix: this.newLineCharacter
|
||||
});
|
||||
@@ -433,7 +430,7 @@ namespace ts.textChanges {
|
||||
}
|
||||
}
|
||||
const endPosition = getAdjustedEndPosition(sourceFile, after, {});
|
||||
return this.replaceWithSingle(sourceFile, endPosition, endPosition, newNode, this.getInsertNodeAfterOptions(after));
|
||||
return this.replaceRange(sourceFile, { pos: endPosition, end: endPosition }, newNode, this.getInsertNodeAfterOptions(after));
|
||||
}
|
||||
|
||||
private getInsertNodeAfterOptions(node: Node): InsertNodeOptions {
|
||||
|
||||
@@ -66,6 +66,7 @@
|
||||
"services.ts",
|
||||
"transform.ts",
|
||||
"transpile.ts",
|
||||
"semver.ts",
|
||||
"shims.ts",
|
||||
"signatureHelp.ts",
|
||||
"symbolDisplay.ts",
|
||||
|
||||
@@ -2374,15 +2374,6 @@ declare namespace ts {
|
||||
exclude?: string[];
|
||||
[option: string]: string[] | boolean | undefined;
|
||||
}
|
||||
interface DiscoverTypingsInfo {
|
||||
fileNames: string[];
|
||||
projectRootPath: string;
|
||||
safeListPath: string;
|
||||
packageNameToTypingLocation: Map<string>;
|
||||
typeAcquisition: TypeAcquisition;
|
||||
compilerOptions: CompilerOptions;
|
||||
unresolvedImports: ReadonlyArray<string>;
|
||||
}
|
||||
enum ModuleKind {
|
||||
None = 0,
|
||||
CommonJS = 1,
|
||||
|
||||
@@ -2374,15 +2374,6 @@ declare namespace ts {
|
||||
exclude?: string[];
|
||||
[option: string]: string[] | boolean | undefined;
|
||||
}
|
||||
interface DiscoverTypingsInfo {
|
||||
fileNames: string[];
|
||||
projectRootPath: string;
|
||||
safeListPath: string;
|
||||
packageNameToTypingLocation: Map<string>;
|
||||
typeAcquisition: TypeAcquisition;
|
||||
compilerOptions: CompilerOptions;
|
||||
unresolvedImports: ReadonlyArray<string>;
|
||||
}
|
||||
enum ModuleKind {
|
||||
None = 0,
|
||||
CommonJS = 1,
|
||||
|
||||
@@ -1,22 +1,22 @@
|
||||
tests/cases/conformance/types/conditional/conditionalTypes1.ts(16,5): error TS2322: Type 'T' is not assignable to type 'Diff<T, null | undefined>'.
|
||||
tests/cases/conformance/types/conditional/conditionalTypes1.ts(21,5): error TS2322: Type 'T' is not assignable to type 'Diff<T, null | undefined>'.
|
||||
Type 'string | undefined' is not assignable to type 'Diff<T, null | undefined>'.
|
||||
Type 'undefined' is not assignable to type 'Diff<T, null | undefined>'.
|
||||
tests/cases/conformance/types/conditional/conditionalTypes1.ts(22,9): error TS2322: Type 'T' is not assignable to type 'string'.
|
||||
tests/cases/conformance/types/conditional/conditionalTypes1.ts(12,5): error TS2322: Type 'T' is not assignable to type 'NonNullable<T>'.
|
||||
tests/cases/conformance/types/conditional/conditionalTypes1.ts(17,5): error TS2322: Type 'T' is not assignable to type 'NonNullable<T>'.
|
||||
Type 'string | undefined' is not assignable to type 'NonNullable<T>'.
|
||||
Type 'undefined' is not assignable to type 'NonNullable<T>'.
|
||||
tests/cases/conformance/types/conditional/conditionalTypes1.ts(18,9): error TS2322: Type 'T' is not assignable to type 'string'.
|
||||
Type 'string | undefined' is not assignable to type 'string'.
|
||||
Type 'undefined' is not assignable to type 'string'.
|
||||
tests/cases/conformance/types/conditional/conditionalTypes1.ts(28,5): error TS2322: Type 'Partial<T>[keyof T]' is not assignable to type 'Diff<Partial<T>[keyof T], null | undefined>'.
|
||||
Type 'T[keyof T] | undefined' is not assignable to type 'Diff<Partial<T>[keyof T], null | undefined>'.
|
||||
Type 'undefined' is not assignable to type 'Diff<Partial<T>[keyof T], null | undefined>'.
|
||||
tests/cases/conformance/types/conditional/conditionalTypes1.ts(33,5): error TS2322: Type 'T["x"]' is not assignable to type 'Diff<T["x"], null | undefined>'.
|
||||
Type 'string | undefined' is not assignable to type 'Diff<T["x"], null | undefined>'.
|
||||
Type 'undefined' is not assignable to type 'Diff<T["x"], null | undefined>'.
|
||||
tests/cases/conformance/types/conditional/conditionalTypes1.ts(34,9): error TS2322: Type 'T["x"]' is not assignable to type 'string'.
|
||||
tests/cases/conformance/types/conditional/conditionalTypes1.ts(24,5): error TS2322: Type 'Partial<T>[keyof T]' is not assignable to type 'NonNullable<Partial<T>[keyof T]>'.
|
||||
Type 'T[keyof T] | undefined' is not assignable to type 'NonNullable<Partial<T>[keyof T]>'.
|
||||
Type 'undefined' is not assignable to type 'NonNullable<Partial<T>[keyof T]>'.
|
||||
tests/cases/conformance/types/conditional/conditionalTypes1.ts(29,5): error TS2322: Type 'T["x"]' is not assignable to type 'NonNullable<T["x"]>'.
|
||||
Type 'string | undefined' is not assignable to type 'NonNullable<T["x"]>'.
|
||||
Type 'undefined' is not assignable to type 'NonNullable<T["x"]>'.
|
||||
tests/cases/conformance/types/conditional/conditionalTypes1.ts(30,9): error TS2322: Type 'T["x"]' is not assignable to type 'string'.
|
||||
Type 'string | undefined' is not assignable to type 'string'.
|
||||
Type 'undefined' is not assignable to type 'string'.
|
||||
tests/cases/conformance/types/conditional/conditionalTypes1.ts(107,5): error TS2322: Type 'Pick<T, { [K in keyof T]: T[K] extends Function ? K : never; }[keyof T]>' is not assignable to type 'T'.
|
||||
tests/cases/conformance/types/conditional/conditionalTypes1.ts(108,5): error TS2322: Type 'Pick<T, { [K in keyof T]: T[K] extends Function ? never : K; }[keyof T]>' is not assignable to type 'T'.
|
||||
tests/cases/conformance/types/conditional/conditionalTypes1.ts(110,5): error TS2322: Type 'Pick<T, { [K in keyof T]: T[K] extends Function ? never : K; }[keyof T]>' is not assignable to type 'Pick<T, { [K in keyof T]: T[K] extends Function ? K : never; }[keyof T]>'.
|
||||
tests/cases/conformance/types/conditional/conditionalTypes1.ts(103,5): error TS2322: Type 'Pick<T, { [K in keyof T]: T[K] extends Function ? K : never; }[keyof T]>' is not assignable to type 'T'.
|
||||
tests/cases/conformance/types/conditional/conditionalTypes1.ts(104,5): error TS2322: Type 'Pick<T, { [K in keyof T]: T[K] extends Function ? never : K; }[keyof T]>' is not assignable to type 'T'.
|
||||
tests/cases/conformance/types/conditional/conditionalTypes1.ts(106,5): error TS2322: Type 'Pick<T, { [K in keyof T]: T[K] extends Function ? never : K; }[keyof T]>' is not assignable to type 'Pick<T, { [K in keyof T]: T[K] extends Function ? K : never; }[keyof T]>'.
|
||||
Type '{ [K in keyof T]: T[K] extends Function ? K : never; }[keyof T]' is not assignable to type '{ [K in keyof T]: T[K] extends Function ? never : K; }[keyof T]'.
|
||||
Type 'T[keyof T] extends Function ? keyof T : never' is not assignable to type '{ [K in keyof T]: T[K] extends Function ? never : K; }[keyof T]'.
|
||||
Type 'keyof T' is not assignable to type '{ [K in keyof T]: T[K] extends Function ? never : K; }[keyof T]'.
|
||||
@@ -25,7 +25,7 @@ tests/cases/conformance/types/conditional/conditionalTypes1.ts(110,5): error TS2
|
||||
Type '{ [K in keyof T]: T[K] extends Function ? K : never; }[keyof T]' is not assignable to type 'T[keyof T] extends Function ? never : keyof T'.
|
||||
Type 'T[keyof T] extends Function ? keyof T : never' is not assignable to type 'T[keyof T] extends Function ? never : keyof T'.
|
||||
Type 'keyof T' is not assignable to type 'never'.
|
||||
tests/cases/conformance/types/conditional/conditionalTypes1.ts(112,5): error TS2322: Type 'Pick<T, { [K in keyof T]: T[K] extends Function ? K : never; }[keyof T]>' is not assignable to type 'Pick<T, { [K in keyof T]: T[K] extends Function ? never : K; }[keyof T]>'.
|
||||
tests/cases/conformance/types/conditional/conditionalTypes1.ts(108,5): error TS2322: Type 'Pick<T, { [K in keyof T]: T[K] extends Function ? K : never; }[keyof T]>' is not assignable to type 'Pick<T, { [K in keyof T]: T[K] extends Function ? never : K; }[keyof T]>'.
|
||||
Type '{ [K in keyof T]: T[K] extends Function ? never : K; }[keyof T]' is not assignable to type '{ [K in keyof T]: T[K] extends Function ? K : never; }[keyof T]'.
|
||||
Type 'T[keyof T] extends Function ? never : keyof T' is not assignable to type '{ [K in keyof T]: T[K] extends Function ? K : never; }[keyof T]'.
|
||||
Type 'keyof T' is not assignable to type '{ [K in keyof T]: T[K] extends Function ? K : never; }[keyof T]'.
|
||||
@@ -34,51 +34,47 @@ tests/cases/conformance/types/conditional/conditionalTypes1.ts(112,5): error TS2
|
||||
Type '{ [K in keyof T]: T[K] extends Function ? never : K; }[keyof T]' is not assignable to type 'T[keyof T] extends Function ? keyof T : never'.
|
||||
Type 'T[keyof T] extends Function ? never : keyof T' is not assignable to type 'T[keyof T] extends Function ? keyof T : never'.
|
||||
Type 'keyof T' is not assignable to type 'never'.
|
||||
tests/cases/conformance/types/conditional/conditionalTypes1.ts(118,5): error TS2322: Type 'keyof T' is not assignable to type '{ [K in keyof T]: T[K] extends Function ? K : never; }[keyof T]'.
|
||||
tests/cases/conformance/types/conditional/conditionalTypes1.ts(114,5): error TS2322: Type 'keyof T' is not assignable to type '{ [K in keyof T]: T[K] extends Function ? K : never; }[keyof T]'.
|
||||
Type 'keyof T' is not assignable to type 'T[keyof T] extends Function ? keyof T : never'.
|
||||
tests/cases/conformance/types/conditional/conditionalTypes1.ts(119,5): error TS2322: Type '{ [K in keyof T]: T[K] extends Function ? never : K; }[keyof T]' is not assignable to type '{ [K in keyof T]: T[K] extends Function ? K : never; }[keyof T]'.
|
||||
tests/cases/conformance/types/conditional/conditionalTypes1.ts(115,5): error TS2322: Type '{ [K in keyof T]: T[K] extends Function ? never : K; }[keyof T]' is not assignable to type '{ [K in keyof T]: T[K] extends Function ? K : never; }[keyof T]'.
|
||||
Type 'T[keyof T] extends Function ? never : keyof T' is not assignable to type '{ [K in keyof T]: T[K] extends Function ? K : never; }[keyof T]'.
|
||||
Type 'keyof T' is not assignable to type '{ [K in keyof T]: T[K] extends Function ? K : never; }[keyof T]'.
|
||||
Type 'T[keyof T] extends Function ? never : keyof T' is not assignable to type 'T[keyof T] extends Function ? keyof T : never'.
|
||||
Type '{ [K in keyof T]: T[K] extends Function ? never : K; }[keyof T]' is not assignable to type 'T[keyof T] extends Function ? keyof T : never'.
|
||||
Type 'T[keyof T] extends Function ? never : keyof T' is not assignable to type 'T[keyof T] extends Function ? keyof T : never'.
|
||||
Type 'keyof T' is not assignable to type 'never'.
|
||||
tests/cases/conformance/types/conditional/conditionalTypes1.ts(120,5): error TS2322: Type 'keyof T' is not assignable to type '{ [K in keyof T]: T[K] extends Function ? never : K; }[keyof T]'.
|
||||
tests/cases/conformance/types/conditional/conditionalTypes1.ts(116,5): error TS2322: Type 'keyof T' is not assignable to type '{ [K in keyof T]: T[K] extends Function ? never : K; }[keyof T]'.
|
||||
Type 'keyof T' is not assignable to type 'T[keyof T] extends Function ? never : keyof T'.
|
||||
tests/cases/conformance/types/conditional/conditionalTypes1.ts(121,5): error TS2322: Type '{ [K in keyof T]: T[K] extends Function ? K : never; }[keyof T]' is not assignable to type '{ [K in keyof T]: T[K] extends Function ? never : K; }[keyof T]'.
|
||||
tests/cases/conformance/types/conditional/conditionalTypes1.ts(117,5): error TS2322: Type '{ [K in keyof T]: T[K] extends Function ? K : never; }[keyof T]' is not assignable to type '{ [K in keyof T]: T[K] extends Function ? never : K; }[keyof T]'.
|
||||
Type 'T[keyof T] extends Function ? keyof T : never' is not assignable to type '{ [K in keyof T]: T[K] extends Function ? never : K; }[keyof T]'.
|
||||
Type 'keyof T' is not assignable to type '{ [K in keyof T]: T[K] extends Function ? never : K; }[keyof T]'.
|
||||
Type 'T[keyof T] extends Function ? keyof T : never' is not assignable to type 'T[keyof T] extends Function ? never : keyof T'.
|
||||
Type '{ [K in keyof T]: T[K] extends Function ? K : never; }[keyof T]' is not assignable to type 'T[keyof T] extends Function ? never : keyof T'.
|
||||
Type 'T[keyof T] extends Function ? keyof T : never' is not assignable to type 'T[keyof T] extends Function ? never : keyof T'.
|
||||
Type 'keyof T' is not assignable to type 'never'.
|
||||
tests/cases/conformance/types/conditional/conditionalTypes1.ts(138,10): error TS2540: Cannot assign to 'id' because it is a constant or a read-only property.
|
||||
tests/cases/conformance/types/conditional/conditionalTypes1.ts(139,5): error TS2542: Index signature in type 'DeepReadonlyArray<Part>' only permits reading.
|
||||
tests/cases/conformance/types/conditional/conditionalTypes1.ts(140,22): error TS2540: Cannot assign to 'id' because it is a constant or a read-only property.
|
||||
tests/cases/conformance/types/conditional/conditionalTypes1.ts(141,10): error TS2339: Property 'updatePart' does not exist on type 'DeepReadonlyObject<Part>'.
|
||||
tests/cases/conformance/types/conditional/conditionalTypes1.ts(163,5): error TS2322: Type 'ZeroOf<T>' is not assignable to type 'T'.
|
||||
tests/cases/conformance/types/conditional/conditionalTypes1.ts(134,10): error TS2540: Cannot assign to 'id' because it is a constant or a read-only property.
|
||||
tests/cases/conformance/types/conditional/conditionalTypes1.ts(135,5): error TS2542: Index signature in type 'DeepReadonlyArray<Part>' only permits reading.
|
||||
tests/cases/conformance/types/conditional/conditionalTypes1.ts(136,22): error TS2540: Cannot assign to 'id' because it is a constant or a read-only property.
|
||||
tests/cases/conformance/types/conditional/conditionalTypes1.ts(137,10): error TS2339: Property 'updatePart' does not exist on type 'DeepReadonlyObject<Part>'.
|
||||
tests/cases/conformance/types/conditional/conditionalTypes1.ts(159,5): error TS2322: Type 'ZeroOf<T>' is not assignable to type 'T'.
|
||||
Type '0 | (T extends string ? "" : false)' is not assignable to type 'T'.
|
||||
Type '0' is not assignable to type 'T'.
|
||||
Type '"" | 0' is not assignable to type 'T'.
|
||||
Type '""' is not assignable to type 'T'.
|
||||
tests/cases/conformance/types/conditional/conditionalTypes1.ts(164,5): error TS2322: Type 'T' is not assignable to type 'ZeroOf<T>'.
|
||||
tests/cases/conformance/types/conditional/conditionalTypes1.ts(160,5): error TS2322: Type 'T' is not assignable to type 'ZeroOf<T>'.
|
||||
Type 'string | number' is not assignable to type 'ZeroOf<T>'.
|
||||
Type 'string' is not assignable to type 'ZeroOf<T>'.
|
||||
tests/cases/conformance/types/conditional/conditionalTypes1.ts(254,9): error TS2403: Subsequent variable declarations must have the same type. Variable 'z' must be of type 'T1', but here has type 'Foo<T & U>'.
|
||||
tests/cases/conformance/types/conditional/conditionalTypes1.ts(279,43): error TS2322: Type 'T95<U>' is not assignable to type 'T94<U>'.
|
||||
tests/cases/conformance/types/conditional/conditionalTypes1.ts(250,9): error TS2403: Subsequent variable declarations must have the same type. Variable 'z' must be of type 'T1', but here has type 'Foo<T & U>'.
|
||||
tests/cases/conformance/types/conditional/conditionalTypes1.ts(275,43): error TS2322: Type 'T95<U>' is not assignable to type 'T94<U>'.
|
||||
Type 'boolean' is not assignable to type 'true'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/types/conditional/conditionalTypes1.ts (22 errors) ====
|
||||
type Diff<T, U> = T extends U ? never : T;
|
||||
type Filter<T, U> = T extends U ? T : never;
|
||||
type NonNullable<T> = Diff<T, null | undefined>;
|
||||
type T00 = Exclude<"a" | "b" | "c" | "d", "a" | "c" | "f">; // "b" | "d"
|
||||
type T01 = Extract<"a" | "b" | "c" | "d", "a" | "c" | "f">; // "a" | "c"
|
||||
|
||||
type T00 = Diff<"a" | "b" | "c" | "d", "a" | "c" | "f">; // "b" | "d"
|
||||
type T01 = Filter<"a" | "b" | "c" | "d", "a" | "c" | "f">; // "a" | "c"
|
||||
|
||||
type T02 = Diff<string | number | (() => void), Function>; // string | number
|
||||
type T03 = Filter<string | number | (() => void), Function>; // () => void
|
||||
type T02 = Exclude<string | number | (() => void), Function>; // string | number
|
||||
type T03 = Extract<string | number | (() => void), Function>; // () => void
|
||||
|
||||
type T04 = NonNullable<string | number | undefined>; // string | number
|
||||
type T05 = NonNullable<(() => string) | string[] | null | undefined>; // (() => string) | string[]
|
||||
@@ -87,16 +83,16 @@ tests/cases/conformance/types/conditional/conditionalTypes1.ts(279,43): error TS
|
||||
x = y;
|
||||
y = x; // Error
|
||||
~
|
||||
!!! error TS2322: Type 'T' is not assignable to type 'Diff<T, null | undefined>'.
|
||||
!!! error TS2322: Type 'T' is not assignable to type 'NonNullable<T>'.
|
||||
}
|
||||
|
||||
function f2<T extends string | undefined>(x: T, y: NonNullable<T>) {
|
||||
x = y;
|
||||
y = x; // Error
|
||||
~
|
||||
!!! error TS2322: Type 'T' is not assignable to type 'Diff<T, null | undefined>'.
|
||||
!!! error TS2322: Type 'string | undefined' is not assignable to type 'Diff<T, null | undefined>'.
|
||||
!!! error TS2322: Type 'undefined' is not assignable to type 'Diff<T, null | undefined>'.
|
||||
!!! error TS2322: Type 'T' is not assignable to type 'NonNullable<T>'.
|
||||
!!! error TS2322: Type 'string | undefined' is not assignable to type 'NonNullable<T>'.
|
||||
!!! error TS2322: Type 'undefined' is not assignable to type 'NonNullable<T>'.
|
||||
let s1: string = x; // Error
|
||||
~~
|
||||
!!! error TS2322: Type 'T' is not assignable to type 'string'.
|
||||
@@ -109,18 +105,18 @@ tests/cases/conformance/types/conditional/conditionalTypes1.ts(279,43): error TS
|
||||
x = y;
|
||||
y = x; // Error
|
||||
~
|
||||
!!! error TS2322: Type 'Partial<T>[keyof T]' is not assignable to type 'Diff<Partial<T>[keyof T], null | undefined>'.
|
||||
!!! error TS2322: Type 'T[keyof T] | undefined' is not assignable to type 'Diff<Partial<T>[keyof T], null | undefined>'.
|
||||
!!! error TS2322: Type 'undefined' is not assignable to type 'Diff<Partial<T>[keyof T], null | undefined>'.
|
||||
!!! error TS2322: Type 'Partial<T>[keyof T]' is not assignable to type 'NonNullable<Partial<T>[keyof T]>'.
|
||||
!!! error TS2322: Type 'T[keyof T] | undefined' is not assignable to type 'NonNullable<Partial<T>[keyof T]>'.
|
||||
!!! error TS2322: Type 'undefined' is not assignable to type 'NonNullable<Partial<T>[keyof T]>'.
|
||||
}
|
||||
|
||||
function f4<T extends { x: string | undefined }>(x: T["x"], y: NonNullable<T["x"]>) {
|
||||
x = y;
|
||||
y = x; // Error
|
||||
~
|
||||
!!! error TS2322: Type 'T["x"]' is not assignable to type 'Diff<T["x"], null | undefined>'.
|
||||
!!! error TS2322: Type 'string | undefined' is not assignable to type 'Diff<T["x"], null | undefined>'.
|
||||
!!! error TS2322: Type 'undefined' is not assignable to type 'Diff<T["x"], null | undefined>'.
|
||||
!!! error TS2322: Type 'T["x"]' is not assignable to type 'NonNullable<T["x"]>'.
|
||||
!!! error TS2322: Type 'string | undefined' is not assignable to type 'NonNullable<T["x"]>'.
|
||||
!!! error TS2322: Type 'undefined' is not assignable to type 'NonNullable<T["x"]>'.
|
||||
let s1: string = x; // Error
|
||||
~~
|
||||
!!! error TS2322: Type 'T["x"]' is not assignable to type 'string'.
|
||||
@@ -131,23 +127,23 @@ tests/cases/conformance/types/conditional/conditionalTypes1.ts(279,43): error TS
|
||||
|
||||
type Options = { k: "a", a: number } | { k: "b", b: string } | { k: "c", c: boolean };
|
||||
|
||||
type T10 = Diff<Options, { k: "a" | "b" }>; // { k: "c", c: boolean }
|
||||
type T11 = Filter<Options, { k: "a" | "b" }>; // { k: "a", a: number } | { k: "b", b: string }
|
||||
type T10 = Exclude<Options, { k: "a" | "b" }>; // { k: "c", c: boolean }
|
||||
type T11 = Extract<Options, { k: "a" | "b" }>; // { k: "a", a: number } | { k: "b", b: string }
|
||||
|
||||
type T12 = Diff<Options, { k: "a" } | { k: "b" }>; // { k: "c", c: boolean }
|
||||
type T13 = Filter<Options, { k: "a" } | { k: "b" }>; // { k: "a", a: number } | { k: "b", b: string }
|
||||
type T12 = Exclude<Options, { k: "a" } | { k: "b" }>; // { k: "c", c: boolean }
|
||||
type T13 = Extract<Options, { k: "a" } | { k: "b" }>; // { k: "a", a: number } | { k: "b", b: string }
|
||||
|
||||
type T14 = Diff<Options, { q: "a" }>; // Options
|
||||
type T15 = Filter<Options, { q: "a" }>; // never
|
||||
type T14 = Exclude<Options, { q: "a" }>; // Options
|
||||
type T15 = Extract<Options, { q: "a" }>; // never
|
||||
|
||||
declare function f5<T extends Options, K extends string>(p: K): Filter<T, { k: K }>;
|
||||
declare function f5<T extends Options, K extends string>(p: K): Extract<T, { k: K }>;
|
||||
let x0 = f5("a"); // { k: "a", a: number }
|
||||
|
||||
type OptionsOfKind<K extends Options["k"]> = Filter<Options, { k: K }>;
|
||||
type OptionsOfKind<K extends Options["k"]> = Extract<Options, { k: K }>;
|
||||
|
||||
type T16 = OptionsOfKind<"a" | "b">; // { k: "a", a: number } | { k: "b", b: string }
|
||||
|
||||
type Select<T, K extends keyof T, V extends T[K]> = Filter<T, { [P in K]: V }>;
|
||||
type Select<T, K extends keyof T, V extends T[K]> = Extract<T, { [P in K]: V }>;
|
||||
|
||||
type T17 = Select<Options, "k", "a" | "b">; // // { k: "a", a: number } | { k: "b", b: string }
|
||||
|
||||
|
||||
@@ -1,13 +1,9 @@
|
||||
//// [conditionalTypes1.ts]
|
||||
type Diff<T, U> = T extends U ? never : T;
|
||||
type Filter<T, U> = T extends U ? T : never;
|
||||
type NonNullable<T> = Diff<T, null | undefined>;
|
||||
type T00 = Exclude<"a" | "b" | "c" | "d", "a" | "c" | "f">; // "b" | "d"
|
||||
type T01 = Extract<"a" | "b" | "c" | "d", "a" | "c" | "f">; // "a" | "c"
|
||||
|
||||
type T00 = Diff<"a" | "b" | "c" | "d", "a" | "c" | "f">; // "b" | "d"
|
||||
type T01 = Filter<"a" | "b" | "c" | "d", "a" | "c" | "f">; // "a" | "c"
|
||||
|
||||
type T02 = Diff<string | number | (() => void), Function>; // string | number
|
||||
type T03 = Filter<string | number | (() => void), Function>; // () => void
|
||||
type T02 = Exclude<string | number | (() => void), Function>; // string | number
|
||||
type T03 = Extract<string | number | (() => void), Function>; // () => void
|
||||
|
||||
type T04 = NonNullable<string | number | undefined>; // string | number
|
||||
type T05 = NonNullable<(() => string) | string[] | null | undefined>; // (() => string) | string[]
|
||||
@@ -38,23 +34,23 @@ function f4<T extends { x: string | undefined }>(x: T["x"], y: NonNullable<T["x"
|
||||
|
||||
type Options = { k: "a", a: number } | { k: "b", b: string } | { k: "c", c: boolean };
|
||||
|
||||
type T10 = Diff<Options, { k: "a" | "b" }>; // { k: "c", c: boolean }
|
||||
type T11 = Filter<Options, { k: "a" | "b" }>; // { k: "a", a: number } | { k: "b", b: string }
|
||||
type T10 = Exclude<Options, { k: "a" | "b" }>; // { k: "c", c: boolean }
|
||||
type T11 = Extract<Options, { k: "a" | "b" }>; // { k: "a", a: number } | { k: "b", b: string }
|
||||
|
||||
type T12 = Diff<Options, { k: "a" } | { k: "b" }>; // { k: "c", c: boolean }
|
||||
type T13 = Filter<Options, { k: "a" } | { k: "b" }>; // { k: "a", a: number } | { k: "b", b: string }
|
||||
type T12 = Exclude<Options, { k: "a" } | { k: "b" }>; // { k: "c", c: boolean }
|
||||
type T13 = Extract<Options, { k: "a" } | { k: "b" }>; // { k: "a", a: number } | { k: "b", b: string }
|
||||
|
||||
type T14 = Diff<Options, { q: "a" }>; // Options
|
||||
type T15 = Filter<Options, { q: "a" }>; // never
|
||||
type T14 = Exclude<Options, { q: "a" }>; // Options
|
||||
type T15 = Extract<Options, { q: "a" }>; // never
|
||||
|
||||
declare function f5<T extends Options, K extends string>(p: K): Filter<T, { k: K }>;
|
||||
declare function f5<T extends Options, K extends string>(p: K): Extract<T, { k: K }>;
|
||||
let x0 = f5("a"); // { k: "a", a: number }
|
||||
|
||||
type OptionsOfKind<K extends Options["k"]> = Filter<Options, { k: K }>;
|
||||
type OptionsOfKind<K extends Options["k"]> = Extract<Options, { k: K }>;
|
||||
|
||||
type T16 = OptionsOfKind<"a" | "b">; // { k: "a", a: number } | { k: "b", b: string }
|
||||
|
||||
type Select<T, K extends keyof T, V extends T[K]> = Filter<T, { [P in K]: V }>;
|
||||
type Select<T, K extends keyof T, V extends T[K]> = Extract<T, { [P in K]: V }>;
|
||||
|
||||
type T17 = Select<Options, "k", "a" | "b">; // // { k: "a", a: number } | { k: "b", b: string }
|
||||
|
||||
@@ -368,13 +364,10 @@ var f45 = function (value) { return value; }; // Error
|
||||
|
||||
|
||||
//// [conditionalTypes1.d.ts]
|
||||
declare type Diff<T, U> = T extends U ? never : T;
|
||||
declare type Filter<T, U> = T extends U ? T : never;
|
||||
declare type NonNullable<T> = Diff<T, null | undefined>;
|
||||
declare type T00 = Diff<"a" | "b" | "c" | "d", "a" | "c" | "f">;
|
||||
declare type T01 = Filter<"a" | "b" | "c" | "d", "a" | "c" | "f">;
|
||||
declare type T02 = Diff<string | number | (() => void), Function>;
|
||||
declare type T03 = Filter<string | number | (() => void), Function>;
|
||||
declare type T00 = Exclude<"a" | "b" | "c" | "d", "a" | "c" | "f">;
|
||||
declare type T01 = Extract<"a" | "b" | "c" | "d", "a" | "c" | "f">;
|
||||
declare type T02 = Exclude<string | number | (() => void), Function>;
|
||||
declare type T03 = Extract<string | number | (() => void), Function>;
|
||||
declare type T04 = NonNullable<string | number | undefined>;
|
||||
declare type T05 = NonNullable<(() => string) | string[] | null | undefined>;
|
||||
declare function f1<T>(x: T, y: NonNullable<T>): void;
|
||||
@@ -393,40 +386,40 @@ declare type Options = {
|
||||
k: "c";
|
||||
c: boolean;
|
||||
};
|
||||
declare type T10 = Diff<Options, {
|
||||
declare type T10 = Exclude<Options, {
|
||||
k: "a" | "b";
|
||||
}>;
|
||||
declare type T11 = Filter<Options, {
|
||||
declare type T11 = Extract<Options, {
|
||||
k: "a" | "b";
|
||||
}>;
|
||||
declare type T12 = Diff<Options, {
|
||||
declare type T12 = Exclude<Options, {
|
||||
k: "a";
|
||||
} | {
|
||||
k: "b";
|
||||
}>;
|
||||
declare type T13 = Filter<Options, {
|
||||
declare type T13 = Extract<Options, {
|
||||
k: "a";
|
||||
} | {
|
||||
k: "b";
|
||||
}>;
|
||||
declare type T14 = Diff<Options, {
|
||||
declare type T14 = Exclude<Options, {
|
||||
q: "a";
|
||||
}>;
|
||||
declare type T15 = Filter<Options, {
|
||||
declare type T15 = Extract<Options, {
|
||||
q: "a";
|
||||
}>;
|
||||
declare function f5<T extends Options, K extends string>(p: K): Filter<T, {
|
||||
declare function f5<T extends Options, K extends string>(p: K): Extract<T, {
|
||||
k: K;
|
||||
}>;
|
||||
declare let x0: {
|
||||
k: "a";
|
||||
a: number;
|
||||
};
|
||||
declare type OptionsOfKind<K extends Options["k"]> = Filter<Options, {
|
||||
declare type OptionsOfKind<K extends Options["k"]> = Extract<Options, {
|
||||
k: K;
|
||||
}>;
|
||||
declare type T16 = OptionsOfKind<"a" | "b">;
|
||||
declare type Select<T, K extends keyof T, V extends T[K]> = Filter<T, {
|
||||
declare type Select<T, K extends keyof T, V extends T[K]> = Extract<T, {
|
||||
[P in K]: V;
|
||||
}>;
|
||||
declare type T17 = Select<Options, "k", "a" | "b">;
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,91 +1,68 @@
|
||||
=== tests/cases/conformance/types/conditional/conditionalTypes1.ts ===
|
||||
type Diff<T, U> = T extends U ? never : T;
|
||||
>Diff : Diff<T, U>
|
||||
>T : T
|
||||
>U : U
|
||||
>T : T
|
||||
>U : U
|
||||
>T : T
|
||||
|
||||
type Filter<T, U> = T extends U ? T : never;
|
||||
>Filter : Filter<T, U>
|
||||
>T : T
|
||||
>U : U
|
||||
>T : T
|
||||
>U : U
|
||||
>T : T
|
||||
|
||||
type NonNullable<T> = Diff<T, null | undefined>;
|
||||
>NonNullable : Diff<T, null | undefined>
|
||||
>T : T
|
||||
>Diff : Diff<T, U>
|
||||
>T : T
|
||||
>null : null
|
||||
|
||||
type T00 = Diff<"a" | "b" | "c" | "d", "a" | "c" | "f">; // "b" | "d"
|
||||
type T00 = Exclude<"a" | "b" | "c" | "d", "a" | "c" | "f">; // "b" | "d"
|
||||
>T00 : "b" | "d"
|
||||
>Diff : Diff<T, U>
|
||||
>Exclude : Exclude<T, U>
|
||||
|
||||
type T01 = Filter<"a" | "b" | "c" | "d", "a" | "c" | "f">; // "a" | "c"
|
||||
type T01 = Extract<"a" | "b" | "c" | "d", "a" | "c" | "f">; // "a" | "c"
|
||||
>T01 : "a" | "c"
|
||||
>Filter : Filter<T, U>
|
||||
>Extract : Extract<T, U>
|
||||
|
||||
type T02 = Diff<string | number | (() => void), Function>; // string | number
|
||||
type T02 = Exclude<string | number | (() => void), Function>; // string | number
|
||||
>T02 : string | number
|
||||
>Diff : Diff<T, U>
|
||||
>Exclude : Exclude<T, U>
|
||||
>Function : Function
|
||||
|
||||
type T03 = Filter<string | number | (() => void), Function>; // () => void
|
||||
type T03 = Extract<string | number | (() => void), Function>; // () => void
|
||||
>T03 : () => void
|
||||
>Filter : Filter<T, U>
|
||||
>Extract : Extract<T, U>
|
||||
>Function : Function
|
||||
|
||||
type T04 = NonNullable<string | number | undefined>; // string | number
|
||||
>T04 : string | number
|
||||
>NonNullable : Diff<T, null | undefined>
|
||||
>NonNullable : NonNullable<T>
|
||||
|
||||
type T05 = NonNullable<(() => string) | string[] | null | undefined>; // (() => string) | string[]
|
||||
>T05 : (() => string) | string[]
|
||||
>NonNullable : Diff<T, null | undefined>
|
||||
>NonNullable : NonNullable<T>
|
||||
>null : null
|
||||
|
||||
function f1<T>(x: T, y: NonNullable<T>) {
|
||||
>f1 : <T>(x: T, y: Diff<T, null | undefined>) => void
|
||||
>f1 : <T>(x: T, y: NonNullable<T>) => void
|
||||
>T : T
|
||||
>x : T
|
||||
>T : T
|
||||
>y : Diff<T, null | undefined>
|
||||
>NonNullable : Diff<T, null | undefined>
|
||||
>y : NonNullable<T>
|
||||
>NonNullable : NonNullable<T>
|
||||
>T : T
|
||||
|
||||
x = y;
|
||||
>x = y : Diff<T, null | undefined>
|
||||
>x = y : NonNullable<T>
|
||||
>x : T
|
||||
>y : Diff<T, null | undefined>
|
||||
>y : NonNullable<T>
|
||||
|
||||
y = x; // Error
|
||||
>y = x : T
|
||||
>y : Diff<T, null | undefined>
|
||||
>y : NonNullable<T>
|
||||
>x : T
|
||||
}
|
||||
|
||||
function f2<T extends string | undefined>(x: T, y: NonNullable<T>) {
|
||||
>f2 : <T extends string | undefined>(x: T, y: Diff<T, null | undefined>) => void
|
||||
>f2 : <T extends string | undefined>(x: T, y: NonNullable<T>) => void
|
||||
>T : T
|
||||
>x : T
|
||||
>T : T
|
||||
>y : Diff<T, null | undefined>
|
||||
>NonNullable : Diff<T, null | undefined>
|
||||
>y : NonNullable<T>
|
||||
>NonNullable : NonNullable<T>
|
||||
>T : T
|
||||
|
||||
x = y;
|
||||
>x = y : Diff<T, null | undefined>
|
||||
>x = y : NonNullable<T>
|
||||
>x : T
|
||||
>y : Diff<T, null | undefined>
|
||||
>y : NonNullable<T>
|
||||
|
||||
y = x; // Error
|
||||
>y = x : T
|
||||
>y : Diff<T, null | undefined>
|
||||
>y : NonNullable<T>
|
||||
>x : T
|
||||
|
||||
let s1: string = x; // Error
|
||||
@@ -94,51 +71,51 @@ function f2<T extends string | undefined>(x: T, y: NonNullable<T>) {
|
||||
|
||||
let s2: string = y;
|
||||
>s2 : string
|
||||
>y : Diff<T, null | undefined>
|
||||
>y : NonNullable<T>
|
||||
}
|
||||
|
||||
function f3<T>(x: Partial<T>[keyof T], y: NonNullable<Partial<T>[keyof T]>) {
|
||||
>f3 : <T>(x: Partial<T>[keyof T], y: Diff<Partial<T>[keyof T], null | undefined>) => void
|
||||
>f3 : <T>(x: Partial<T>[keyof T], y: NonNullable<Partial<T>[keyof T]>) => void
|
||||
>T : T
|
||||
>x : Partial<T>[keyof T]
|
||||
>Partial : Partial<T>
|
||||
>T : T
|
||||
>T : T
|
||||
>y : Diff<Partial<T>[keyof T], null | undefined>
|
||||
>NonNullable : Diff<T, null | undefined>
|
||||
>y : NonNullable<Partial<T>[keyof T]>
|
||||
>NonNullable : NonNullable<T>
|
||||
>Partial : Partial<T>
|
||||
>T : T
|
||||
>T : T
|
||||
|
||||
x = y;
|
||||
>x = y : Diff<Partial<T>[keyof T], null | undefined>
|
||||
>x = y : NonNullable<Partial<T>[keyof T]>
|
||||
>x : Partial<T>[keyof T]
|
||||
>y : Diff<Partial<T>[keyof T], null | undefined>
|
||||
>y : NonNullable<Partial<T>[keyof T]>
|
||||
|
||||
y = x; // Error
|
||||
>y = x : Partial<T>[keyof T]
|
||||
>y : Diff<Partial<T>[keyof T], null | undefined>
|
||||
>y : NonNullable<Partial<T>[keyof T]>
|
||||
>x : Partial<T>[keyof T]
|
||||
}
|
||||
|
||||
function f4<T extends { x: string | undefined }>(x: T["x"], y: NonNullable<T["x"]>) {
|
||||
>f4 : <T extends { x: string | undefined; }>(x: T["x"], y: Diff<T["x"], null | undefined>) => void
|
||||
>f4 : <T extends { x: string | undefined; }>(x: T["x"], y: NonNullable<T["x"]>) => void
|
||||
>T : T
|
||||
>x : string | undefined
|
||||
>x : T["x"]
|
||||
>T : T
|
||||
>y : Diff<T["x"], null | undefined>
|
||||
>NonNullable : Diff<T, null | undefined>
|
||||
>y : NonNullable<T["x"]>
|
||||
>NonNullable : NonNullable<T>
|
||||
>T : T
|
||||
|
||||
x = y;
|
||||
>x = y : Diff<T["x"], null | undefined>
|
||||
>x = y : NonNullable<T["x"]>
|
||||
>x : T["x"]
|
||||
>y : Diff<T["x"], null | undefined>
|
||||
>y : NonNullable<T["x"]>
|
||||
|
||||
y = x; // Error
|
||||
>y = x : T["x"]
|
||||
>y : Diff<T["x"], null | undefined>
|
||||
>y : NonNullable<T["x"]>
|
||||
>x : T["x"]
|
||||
|
||||
let s1: string = x; // Error
|
||||
@@ -147,7 +124,7 @@ function f4<T extends { x: string | undefined }>(x: T["x"], y: NonNullable<T["x"
|
||||
|
||||
let s2: string = y;
|
||||
>s2 : string
|
||||
>y : Diff<T["x"], null | undefined>
|
||||
>y : NonNullable<T["x"]>
|
||||
}
|
||||
|
||||
type Options = { k: "a", a: number } | { k: "b", b: string } | { k: "c", c: boolean };
|
||||
@@ -159,52 +136,52 @@ type Options = { k: "a", a: number } | { k: "b", b: string } | { k: "c", c: bool
|
||||
>k : "c"
|
||||
>c : boolean
|
||||
|
||||
type T10 = Diff<Options, { k: "a" | "b" }>; // { k: "c", c: boolean }
|
||||
type T10 = Exclude<Options, { k: "a" | "b" }>; // { k: "c", c: boolean }
|
||||
>T10 : { k: "c"; c: boolean; }
|
||||
>Diff : Diff<T, U>
|
||||
>Exclude : Exclude<T, U>
|
||||
>Options : Options
|
||||
>k : "a" | "b"
|
||||
|
||||
type T11 = Filter<Options, { k: "a" | "b" }>; // { k: "a", a: number } | { k: "b", b: string }
|
||||
type T11 = Extract<Options, { k: "a" | "b" }>; // { k: "a", a: number } | { k: "b", b: string }
|
||||
>T11 : { k: "a"; a: number; } | { k: "b"; b: string; }
|
||||
>Filter : Filter<T, U>
|
||||
>Extract : Extract<T, U>
|
||||
>Options : Options
|
||||
>k : "a" | "b"
|
||||
|
||||
type T12 = Diff<Options, { k: "a" } | { k: "b" }>; // { k: "c", c: boolean }
|
||||
type T12 = Exclude<Options, { k: "a" } | { k: "b" }>; // { k: "c", c: boolean }
|
||||
>T12 : { k: "c"; c: boolean; }
|
||||
>Diff : Diff<T, U>
|
||||
>Exclude : Exclude<T, U>
|
||||
>Options : Options
|
||||
>k : "a"
|
||||
>k : "b"
|
||||
|
||||
type T13 = Filter<Options, { k: "a" } | { k: "b" }>; // { k: "a", a: number } | { k: "b", b: string }
|
||||
type T13 = Extract<Options, { k: "a" } | { k: "b" }>; // { k: "a", a: number } | { k: "b", b: string }
|
||||
>T13 : { k: "a"; a: number; } | { k: "b"; b: string; }
|
||||
>Filter : Filter<T, U>
|
||||
>Extract : Extract<T, U>
|
||||
>Options : Options
|
||||
>k : "a"
|
||||
>k : "b"
|
||||
|
||||
type T14 = Diff<Options, { q: "a" }>; // Options
|
||||
type T14 = Exclude<Options, { q: "a" }>; // Options
|
||||
>T14 : Options
|
||||
>Diff : Diff<T, U>
|
||||
>Exclude : Exclude<T, U>
|
||||
>Options : Options
|
||||
>q : "a"
|
||||
|
||||
type T15 = Filter<Options, { q: "a" }>; // never
|
||||
type T15 = Extract<Options, { q: "a" }>; // never
|
||||
>T15 : never
|
||||
>Filter : Filter<T, U>
|
||||
>Extract : Extract<T, U>
|
||||
>Options : Options
|
||||
>q : "a"
|
||||
|
||||
declare function f5<T extends Options, K extends string>(p: K): Filter<T, { k: K }>;
|
||||
>f5 : <T extends Options, K extends string>(p: K) => Filter<T, { k: K; }>
|
||||
declare function f5<T extends Options, K extends string>(p: K): Extract<T, { k: K }>;
|
||||
>f5 : <T extends Options, K extends string>(p: K) => Extract<T, { k: K; }>
|
||||
>T : T
|
||||
>Options : Options
|
||||
>K : K
|
||||
>p : K
|
||||
>K : K
|
||||
>Filter : Filter<T, U>
|
||||
>Extract : Extract<T, U>
|
||||
>T : T
|
||||
>k : K
|
||||
>K : K
|
||||
@@ -212,31 +189,31 @@ declare function f5<T extends Options, K extends string>(p: K): Filter<T, { k: K
|
||||
let x0 = f5("a"); // { k: "a", a: number }
|
||||
>x0 : { k: "a"; a: number; }
|
||||
>f5("a") : { k: "a"; a: number; }
|
||||
>f5 : <T extends Options, K extends string>(p: K) => Filter<T, { k: K; }>
|
||||
>f5 : <T extends Options, K extends string>(p: K) => Extract<T, { k: K; }>
|
||||
>"a" : "a"
|
||||
|
||||
type OptionsOfKind<K extends Options["k"]> = Filter<Options, { k: K }>;
|
||||
>OptionsOfKind : Filter<{ k: "a"; a: number; }, { k: K; }> | Filter<{ k: "b"; b: string; }, { k: K; }> | Filter<{ k: "c"; c: boolean; }, { k: K; }>
|
||||
type OptionsOfKind<K extends Options["k"]> = Extract<Options, { k: K }>;
|
||||
>OptionsOfKind : Extract<{ k: "a"; a: number; }, { k: K; }> | Extract<{ k: "b"; b: string; }, { k: K; }> | Extract<{ k: "c"; c: boolean; }, { k: K; }>
|
||||
>K : K
|
||||
>Options : Options
|
||||
>Filter : Filter<T, U>
|
||||
>Extract : Extract<T, U>
|
||||
>Options : Options
|
||||
>k : K
|
||||
>K : K
|
||||
|
||||
type T16 = OptionsOfKind<"a" | "b">; // { k: "a", a: number } | { k: "b", b: string }
|
||||
>T16 : { k: "a"; a: number; } | { k: "b"; b: string; }
|
||||
>OptionsOfKind : Filter<{ k: "a"; a: number; }, { k: K; }> | Filter<{ k: "b"; b: string; }, { k: K; }> | Filter<{ k: "c"; c: boolean; }, { k: K; }>
|
||||
>OptionsOfKind : Extract<{ k: "a"; a: number; }, { k: K; }> | Extract<{ k: "b"; b: string; }, { k: K; }> | Extract<{ k: "c"; c: boolean; }, { k: K; }>
|
||||
|
||||
type Select<T, K extends keyof T, V extends T[K]> = Filter<T, { [P in K]: V }>;
|
||||
>Select : Filter<T, { [P in K]: V; }>
|
||||
type Select<T, K extends keyof T, V extends T[K]> = Extract<T, { [P in K]: V }>;
|
||||
>Select : Extract<T, { [P in K]: V; }>
|
||||
>T : T
|
||||
>K : K
|
||||
>T : T
|
||||
>V : V
|
||||
>T : T
|
||||
>K : K
|
||||
>Filter : Filter<T, U>
|
||||
>Extract : Extract<T, U>
|
||||
>T : T
|
||||
>P : P
|
||||
>K : K
|
||||
@@ -244,7 +221,7 @@ type Select<T, K extends keyof T, V extends T[K]> = Filter<T, { [P in K]: V }>;
|
||||
|
||||
type T17 = Select<Options, "k", "a" | "b">; // // { k: "a", a: number } | { k: "b", b: string }
|
||||
>T17 : { k: "a"; a: number; } | { k: "b"; b: string; }
|
||||
>Select : Filter<T, { [P in K]: V; }>
|
||||
>Select : Extract<T, { [P in K]: V; }>
|
||||
>Options : Options
|
||||
|
||||
type TypeName<T> =
|
||||
|
||||
@@ -1,21 +1,26 @@
|
||||
tests/cases/conformance/types/conditional/inferTypes1.ts(34,23): error TS2344: Type 'string' does not satisfy the constraint 'Function'.
|
||||
tests/cases/conformance/types/conditional/inferTypes1.ts(43,25): error TS2344: Type '(x: string, y: string) => number' does not satisfy the constraint '(x: any) => any'.
|
||||
tests/cases/conformance/types/conditional/inferTypes1.ts(44,25): error TS2344: Type 'Function' does not satisfy the constraint '(x: any) => any'.
|
||||
tests/cases/conformance/types/conditional/inferTypes1.ts(31,23): error TS2344: Type 'string' does not satisfy the constraint '(...args: any[]) => any'.
|
||||
tests/cases/conformance/types/conditional/inferTypes1.ts(32,23): error TS2344: Type 'Function' does not satisfy the constraint '(...args: any[]) => any'.
|
||||
Type 'Function' provides no match for the signature '(...args: any[]): any'.
|
||||
tests/cases/conformance/types/conditional/inferTypes1.ts(37,25): error TS2344: Type 'string' does not satisfy the constraint 'new (...args: any[]) => any'.
|
||||
tests/cases/conformance/types/conditional/inferTypes1.ts(38,25): error TS2344: Type 'Function' does not satisfy the constraint 'new (...args: any[]) => any'.
|
||||
Type 'Function' provides no match for the signature 'new (...args: any[]): any'.
|
||||
tests/cases/conformance/types/conditional/inferTypes1.ts(46,25): error TS2344: Type '(x: string, y: string) => number' does not satisfy the constraint '(x: any) => any'.
|
||||
tests/cases/conformance/types/conditional/inferTypes1.ts(47,25): error TS2344: Type 'Function' does not satisfy the constraint '(x: any) => any'.
|
||||
Type 'Function' provides no match for the signature '(x: any): any'.
|
||||
tests/cases/conformance/types/conditional/inferTypes1.ts(70,12): error TS1338: 'infer' declarations are only permitted in the 'extends' clause of a conditional type.
|
||||
tests/cases/conformance/types/conditional/inferTypes1.ts(71,15): error TS1338: 'infer' declarations are only permitted in the 'extends' clause of a conditional type.
|
||||
tests/cases/conformance/types/conditional/inferTypes1.ts(71,41): error TS1338: 'infer' declarations are only permitted in the 'extends' clause of a conditional type.
|
||||
tests/cases/conformance/types/conditional/inferTypes1.ts(71,51): error TS1338: 'infer' declarations are only permitted in the 'extends' clause of a conditional type.
|
||||
tests/cases/conformance/types/conditional/inferTypes1.ts(72,15): error TS2304: Cannot find name 'U'.
|
||||
tests/cases/conformance/types/conditional/inferTypes1.ts(72,15): error TS4081: Exported type alias 'T62' has or is using private name 'U'.
|
||||
tests/cases/conformance/types/conditional/inferTypes1.ts(72,43): error TS2304: Cannot find name 'U'.
|
||||
tests/cases/conformance/types/conditional/inferTypes1.ts(72,43): error TS4081: Exported type alias 'T62' has or is using private name 'U'.
|
||||
tests/cases/conformance/types/conditional/inferTypes1.ts(78,44): error TS2344: Type 'U' does not satisfy the constraint 'string'.
|
||||
tests/cases/conformance/types/conditional/inferTypes1.ts(73,12): error TS1338: 'infer' declarations are only permitted in the 'extends' clause of a conditional type.
|
||||
tests/cases/conformance/types/conditional/inferTypes1.ts(74,15): error TS1338: 'infer' declarations are only permitted in the 'extends' clause of a conditional type.
|
||||
tests/cases/conformance/types/conditional/inferTypes1.ts(74,41): error TS1338: 'infer' declarations are only permitted in the 'extends' clause of a conditional type.
|
||||
tests/cases/conformance/types/conditional/inferTypes1.ts(74,51): error TS1338: 'infer' declarations are only permitted in the 'extends' clause of a conditional type.
|
||||
tests/cases/conformance/types/conditional/inferTypes1.ts(75,15): error TS2304: Cannot find name 'U'.
|
||||
tests/cases/conformance/types/conditional/inferTypes1.ts(75,15): error TS4081: Exported type alias 'T62' has or is using private name 'U'.
|
||||
tests/cases/conformance/types/conditional/inferTypes1.ts(75,43): error TS2304: Cannot find name 'U'.
|
||||
tests/cases/conformance/types/conditional/inferTypes1.ts(75,43): error TS4081: Exported type alias 'T62' has or is using private name 'U'.
|
||||
tests/cases/conformance/types/conditional/inferTypes1.ts(81,44): error TS2344: Type 'U' does not satisfy the constraint 'string'.
|
||||
Type 'number' is not assignable to type 'string'.
|
||||
tests/cases/conformance/types/conditional/inferTypes1.ts(131,40): error TS2322: Type 'T' is not assignable to type 'string'.
|
||||
tests/cases/conformance/types/conditional/inferTypes1.ts(134,40): error TS2322: Type 'T' is not assignable to type 'string'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/types/conditional/inferTypes1.ts (13 errors) ====
|
||||
==== tests/cases/conformance/types/conditional/inferTypes1.ts (16 errors) ====
|
||||
type Unpacked<T> =
|
||||
T extends (infer U)[] ? U :
|
||||
T extends (...args: any[]) => infer U ? U :
|
||||
@@ -30,8 +35,6 @@ tests/cases/conformance/types/conditional/inferTypes1.ts(131,40): error TS2322:
|
||||
type T05 = Unpacked<any>; // any
|
||||
type T06 = Unpacked<never>; // never
|
||||
|
||||
type ReturnType<T extends Function> = T extends ((...args: any[]) => infer R) | (new (...args: any[]) => infer R) ? R : any;
|
||||
|
||||
function f1(s: string) {
|
||||
return { a: 1, b: s };
|
||||
}
|
||||
@@ -46,13 +49,26 @@ tests/cases/conformance/types/conditional/inferTypes1.ts(131,40): error TS2322:
|
||||
type T12 = ReturnType<(<T>() => T)>; // {}
|
||||
type T13 = ReturnType<(<T extends U, U extends number[]>() => T)>; // number[]
|
||||
type T14 = ReturnType<typeof f1>; // { a: number, b: string }
|
||||
type T15 = ReturnType<typeof C>; // C
|
||||
type T16 = ReturnType<any>; // any
|
||||
type T17 = ReturnType<never>; // any
|
||||
type T18 = ReturnType<string>; // Error
|
||||
type T15 = ReturnType<any>; // any
|
||||
type T16 = ReturnType<never>; // any
|
||||
type T17 = ReturnType<string>; // Error
|
||||
~~~~~~
|
||||
!!! error TS2344: Type 'string' does not satisfy the constraint 'Function'.
|
||||
type T19 = ReturnType<Function>; // any
|
||||
!!! error TS2344: Type 'string' does not satisfy the constraint '(...args: any[]) => any'.
|
||||
type T18 = ReturnType<Function>; // Error
|
||||
~~~~~~~~
|
||||
!!! error TS2344: Type 'Function' does not satisfy the constraint '(...args: any[]) => any'.
|
||||
!!! error TS2344: Type 'Function' provides no match for the signature '(...args: any[]): any'.
|
||||
|
||||
type U10 = InstanceType<typeof C>; // C
|
||||
type U11 = InstanceType<any>; // any
|
||||
type U12 = InstanceType<never>; // any
|
||||
type U13 = InstanceType<string>; // Error
|
||||
~~~~~~
|
||||
!!! error TS2344: Type 'string' does not satisfy the constraint 'new (...args: any[]) => any'.
|
||||
type U14 = InstanceType<Function>; // Error
|
||||
~~~~~~~~
|
||||
!!! error TS2344: Type 'Function' does not satisfy the constraint 'new (...args: any[]) => any'.
|
||||
!!! error TS2344: Type 'Function' provides no match for the signature 'new (...args: any[]): any'.
|
||||
|
||||
type ArgumentType<T extends (x: any) => any> = T extends (a: infer A) => any ? A : any;
|
||||
|
||||
|
||||
@@ -13,8 +13,6 @@ type T04 = Unpacked<Unpacked<Promise<string>[]>>; // string
|
||||
type T05 = Unpacked<any>; // any
|
||||
type T06 = Unpacked<never>; // never
|
||||
|
||||
type ReturnType<T extends Function> = T extends ((...args: any[]) => infer R) | (new (...args: any[]) => infer R) ? R : any;
|
||||
|
||||
function f1(s: string) {
|
||||
return { a: 1, b: s };
|
||||
}
|
||||
@@ -29,11 +27,16 @@ type T11 = ReturnType<(s: string) => void>; // void
|
||||
type T12 = ReturnType<(<T>() => T)>; // {}
|
||||
type T13 = ReturnType<(<T extends U, U extends number[]>() => T)>; // number[]
|
||||
type T14 = ReturnType<typeof f1>; // { a: number, b: string }
|
||||
type T15 = ReturnType<typeof C>; // C
|
||||
type T16 = ReturnType<any>; // any
|
||||
type T17 = ReturnType<never>; // any
|
||||
type T18 = ReturnType<string>; // Error
|
||||
type T19 = ReturnType<Function>; // any
|
||||
type T15 = ReturnType<any>; // any
|
||||
type T16 = ReturnType<never>; // any
|
||||
type T17 = ReturnType<string>; // Error
|
||||
type T18 = ReturnType<Function>; // Error
|
||||
|
||||
type U10 = InstanceType<typeof C>; // C
|
||||
type U11 = InstanceType<any>; // any
|
||||
type U12 = InstanceType<never>; // any
|
||||
type U13 = InstanceType<string>; // Error
|
||||
type U14 = InstanceType<Function>; // Error
|
||||
|
||||
type ArgumentType<T extends (x: any) => any> = T extends (a: infer A) => any ? A : any;
|
||||
|
||||
|
||||
@@ -54,518 +54,524 @@ type T06 = Unpacked<never>; // never
|
||||
>T06 : Symbol(T06, Decl(inferTypes1.ts, 11, 25))
|
||||
>Unpacked : Symbol(Unpacked, Decl(inferTypes1.ts, 0, 0))
|
||||
|
||||
type ReturnType<T extends Function> = T extends ((...args: any[]) => infer R) | (new (...args: any[]) => infer R) ? R : any;
|
||||
>ReturnType : Symbol(ReturnType, Decl(inferTypes1.ts, 12, 27))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 14, 16))
|
||||
>Function : Symbol(Function, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 14, 16))
|
||||
>args : Symbol(args, Decl(inferTypes1.ts, 14, 50))
|
||||
>R : Symbol(R, Decl(inferTypes1.ts, 14, 74), Decl(inferTypes1.ts, 14, 110))
|
||||
>args : Symbol(args, Decl(inferTypes1.ts, 14, 86))
|
||||
>R : Symbol(R, Decl(inferTypes1.ts, 14, 74), Decl(inferTypes1.ts, 14, 110))
|
||||
>R : Symbol(R, Decl(inferTypes1.ts, 14, 74), Decl(inferTypes1.ts, 14, 110))
|
||||
|
||||
function f1(s: string) {
|
||||
>f1 : Symbol(f1, Decl(inferTypes1.ts, 14, 124))
|
||||
>s : Symbol(s, Decl(inferTypes1.ts, 16, 12))
|
||||
>f1 : Symbol(f1, Decl(inferTypes1.ts, 12, 27))
|
||||
>s : Symbol(s, Decl(inferTypes1.ts, 14, 12))
|
||||
|
||||
return { a: 1, b: s };
|
||||
>a : Symbol(a, Decl(inferTypes1.ts, 17, 12))
|
||||
>b : Symbol(b, Decl(inferTypes1.ts, 17, 18))
|
||||
>s : Symbol(s, Decl(inferTypes1.ts, 16, 12))
|
||||
>a : Symbol(a, Decl(inferTypes1.ts, 15, 12))
|
||||
>b : Symbol(b, Decl(inferTypes1.ts, 15, 18))
|
||||
>s : Symbol(s, Decl(inferTypes1.ts, 14, 12))
|
||||
}
|
||||
|
||||
class C {
|
||||
>C : Symbol(C, Decl(inferTypes1.ts, 18, 1))
|
||||
>C : Symbol(C, Decl(inferTypes1.ts, 16, 1))
|
||||
|
||||
x = 0;
|
||||
>x : Symbol(C.x, Decl(inferTypes1.ts, 20, 9))
|
||||
>x : Symbol(C.x, Decl(inferTypes1.ts, 18, 9))
|
||||
|
||||
y = 0;
|
||||
>y : Symbol(C.y, Decl(inferTypes1.ts, 21, 10))
|
||||
>y : Symbol(C.y, Decl(inferTypes1.ts, 19, 10))
|
||||
}
|
||||
|
||||
type T10 = ReturnType<() => string>; // string
|
||||
>T10 : Symbol(T10, Decl(inferTypes1.ts, 23, 1))
|
||||
>ReturnType : Symbol(ReturnType, Decl(inferTypes1.ts, 12, 27))
|
||||
>T10 : Symbol(T10, Decl(inferTypes1.ts, 21, 1))
|
||||
>ReturnType : Symbol(ReturnType, Decl(lib.d.ts, --, --))
|
||||
|
||||
type T11 = ReturnType<(s: string) => void>; // void
|
||||
>T11 : Symbol(T11, Decl(inferTypes1.ts, 25, 36))
|
||||
>ReturnType : Symbol(ReturnType, Decl(inferTypes1.ts, 12, 27))
|
||||
>s : Symbol(s, Decl(inferTypes1.ts, 26, 23))
|
||||
>T11 : Symbol(T11, Decl(inferTypes1.ts, 23, 36))
|
||||
>ReturnType : Symbol(ReturnType, Decl(lib.d.ts, --, --))
|
||||
>s : Symbol(s, Decl(inferTypes1.ts, 24, 23))
|
||||
|
||||
type T12 = ReturnType<(<T>() => T)>; // {}
|
||||
>T12 : Symbol(T12, Decl(inferTypes1.ts, 26, 43))
|
||||
>ReturnType : Symbol(ReturnType, Decl(inferTypes1.ts, 12, 27))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 27, 24))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 27, 24))
|
||||
>T12 : Symbol(T12, Decl(inferTypes1.ts, 24, 43))
|
||||
>ReturnType : Symbol(ReturnType, Decl(lib.d.ts, --, --))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 25, 24))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 25, 24))
|
||||
|
||||
type T13 = ReturnType<(<T extends U, U extends number[]>() => T)>; // number[]
|
||||
>T13 : Symbol(T13, Decl(inferTypes1.ts, 27, 36))
|
||||
>ReturnType : Symbol(ReturnType, Decl(inferTypes1.ts, 12, 27))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 28, 24))
|
||||
>U : Symbol(U, Decl(inferTypes1.ts, 28, 36))
|
||||
>U : Symbol(U, Decl(inferTypes1.ts, 28, 36))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 28, 24))
|
||||
>T13 : Symbol(T13, Decl(inferTypes1.ts, 25, 36))
|
||||
>ReturnType : Symbol(ReturnType, Decl(lib.d.ts, --, --))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 26, 24))
|
||||
>U : Symbol(U, Decl(inferTypes1.ts, 26, 36))
|
||||
>U : Symbol(U, Decl(inferTypes1.ts, 26, 36))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 26, 24))
|
||||
|
||||
type T14 = ReturnType<typeof f1>; // { a: number, b: string }
|
||||
>T14 : Symbol(T14, Decl(inferTypes1.ts, 28, 66))
|
||||
>ReturnType : Symbol(ReturnType, Decl(inferTypes1.ts, 12, 27))
|
||||
>f1 : Symbol(f1, Decl(inferTypes1.ts, 14, 124))
|
||||
>T14 : Symbol(T14, Decl(inferTypes1.ts, 26, 66))
|
||||
>ReturnType : Symbol(ReturnType, Decl(lib.d.ts, --, --))
|
||||
>f1 : Symbol(f1, Decl(inferTypes1.ts, 12, 27))
|
||||
|
||||
type T15 = ReturnType<typeof C>; // C
|
||||
>T15 : Symbol(T15, Decl(inferTypes1.ts, 29, 33))
|
||||
>ReturnType : Symbol(ReturnType, Decl(inferTypes1.ts, 12, 27))
|
||||
>C : Symbol(C, Decl(inferTypes1.ts, 18, 1))
|
||||
type T15 = ReturnType<any>; // any
|
||||
>T15 : Symbol(T15, Decl(inferTypes1.ts, 27, 33))
|
||||
>ReturnType : Symbol(ReturnType, Decl(lib.d.ts, --, --))
|
||||
|
||||
type T16 = ReturnType<any>; // any
|
||||
>T16 : Symbol(T16, Decl(inferTypes1.ts, 30, 32))
|
||||
>ReturnType : Symbol(ReturnType, Decl(inferTypes1.ts, 12, 27))
|
||||
type T16 = ReturnType<never>; // any
|
||||
>T16 : Symbol(T16, Decl(inferTypes1.ts, 28, 27))
|
||||
>ReturnType : Symbol(ReturnType, Decl(lib.d.ts, --, --))
|
||||
|
||||
type T17 = ReturnType<never>; // any
|
||||
>T17 : Symbol(T17, Decl(inferTypes1.ts, 31, 27))
|
||||
>ReturnType : Symbol(ReturnType, Decl(inferTypes1.ts, 12, 27))
|
||||
type T17 = ReturnType<string>; // Error
|
||||
>T17 : Symbol(T17, Decl(inferTypes1.ts, 29, 29))
|
||||
>ReturnType : Symbol(ReturnType, Decl(lib.d.ts, --, --))
|
||||
|
||||
type T18 = ReturnType<string>; // Error
|
||||
>T18 : Symbol(T18, Decl(inferTypes1.ts, 32, 29))
|
||||
>ReturnType : Symbol(ReturnType, Decl(inferTypes1.ts, 12, 27))
|
||||
type T18 = ReturnType<Function>; // Error
|
||||
>T18 : Symbol(T18, Decl(inferTypes1.ts, 30, 30))
|
||||
>ReturnType : Symbol(ReturnType, Decl(lib.d.ts, --, --))
|
||||
>Function : Symbol(Function, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
|
||||
|
||||
type T19 = ReturnType<Function>; // any
|
||||
>T19 : Symbol(T19, Decl(inferTypes1.ts, 33, 30))
|
||||
>ReturnType : Symbol(ReturnType, Decl(inferTypes1.ts, 12, 27))
|
||||
type U10 = InstanceType<typeof C>; // C
|
||||
>U10 : Symbol(U10, Decl(inferTypes1.ts, 31, 32))
|
||||
>InstanceType : Symbol(InstanceType, Decl(lib.d.ts, --, --))
|
||||
>C : Symbol(C, Decl(inferTypes1.ts, 16, 1))
|
||||
|
||||
type U11 = InstanceType<any>; // any
|
||||
>U11 : Symbol(U11, Decl(inferTypes1.ts, 33, 34))
|
||||
>InstanceType : Symbol(InstanceType, Decl(lib.d.ts, --, --))
|
||||
|
||||
type U12 = InstanceType<never>; // any
|
||||
>U12 : Symbol(U12, Decl(inferTypes1.ts, 34, 29))
|
||||
>InstanceType : Symbol(InstanceType, Decl(lib.d.ts, --, --))
|
||||
|
||||
type U13 = InstanceType<string>; // Error
|
||||
>U13 : Symbol(U13, Decl(inferTypes1.ts, 35, 31))
|
||||
>InstanceType : Symbol(InstanceType, Decl(lib.d.ts, --, --))
|
||||
|
||||
type U14 = InstanceType<Function>; // Error
|
||||
>U14 : Symbol(U14, Decl(inferTypes1.ts, 36, 32))
|
||||
>InstanceType : Symbol(InstanceType, Decl(lib.d.ts, --, --))
|
||||
>Function : Symbol(Function, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
|
||||
|
||||
type ArgumentType<T extends (x: any) => any> = T extends (a: infer A) => any ? A : any;
|
||||
>ArgumentType : Symbol(ArgumentType, Decl(inferTypes1.ts, 34, 32))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 36, 18))
|
||||
>x : Symbol(x, Decl(inferTypes1.ts, 36, 29))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 36, 18))
|
||||
>a : Symbol(a, Decl(inferTypes1.ts, 36, 58))
|
||||
>A : Symbol(A, Decl(inferTypes1.ts, 36, 66))
|
||||
>A : Symbol(A, Decl(inferTypes1.ts, 36, 66))
|
||||
>ArgumentType : Symbol(ArgumentType, Decl(inferTypes1.ts, 37, 34))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 39, 18))
|
||||
>x : Symbol(x, Decl(inferTypes1.ts, 39, 29))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 39, 18))
|
||||
>a : Symbol(a, Decl(inferTypes1.ts, 39, 58))
|
||||
>A : Symbol(A, Decl(inferTypes1.ts, 39, 66))
|
||||
>A : Symbol(A, Decl(inferTypes1.ts, 39, 66))
|
||||
|
||||
type T20 = ArgumentType<() => void>; // never
|
||||
>T20 : Symbol(T20, Decl(inferTypes1.ts, 36, 87))
|
||||
>ArgumentType : Symbol(ArgumentType, Decl(inferTypes1.ts, 34, 32))
|
||||
>T20 : Symbol(T20, Decl(inferTypes1.ts, 39, 87))
|
||||
>ArgumentType : Symbol(ArgumentType, Decl(inferTypes1.ts, 37, 34))
|
||||
|
||||
type T21 = ArgumentType<(x: string) => number>; // string
|
||||
>T21 : Symbol(T21, Decl(inferTypes1.ts, 38, 36))
|
||||
>ArgumentType : Symbol(ArgumentType, Decl(inferTypes1.ts, 34, 32))
|
||||
>x : Symbol(x, Decl(inferTypes1.ts, 39, 25))
|
||||
>T21 : Symbol(T21, Decl(inferTypes1.ts, 41, 36))
|
||||
>ArgumentType : Symbol(ArgumentType, Decl(inferTypes1.ts, 37, 34))
|
||||
>x : Symbol(x, Decl(inferTypes1.ts, 42, 25))
|
||||
|
||||
type T22 = ArgumentType<(x?: string) => number>; // string | undefined
|
||||
>T22 : Symbol(T22, Decl(inferTypes1.ts, 39, 47))
|
||||
>ArgumentType : Symbol(ArgumentType, Decl(inferTypes1.ts, 34, 32))
|
||||
>x : Symbol(x, Decl(inferTypes1.ts, 40, 25))
|
||||
>T22 : Symbol(T22, Decl(inferTypes1.ts, 42, 47))
|
||||
>ArgumentType : Symbol(ArgumentType, Decl(inferTypes1.ts, 37, 34))
|
||||
>x : Symbol(x, Decl(inferTypes1.ts, 43, 25))
|
||||
|
||||
type T23 = ArgumentType<(...args: string[]) => number>; // string
|
||||
>T23 : Symbol(T23, Decl(inferTypes1.ts, 40, 48))
|
||||
>ArgumentType : Symbol(ArgumentType, Decl(inferTypes1.ts, 34, 32))
|
||||
>args : Symbol(args, Decl(inferTypes1.ts, 41, 25))
|
||||
>T23 : Symbol(T23, Decl(inferTypes1.ts, 43, 48))
|
||||
>ArgumentType : Symbol(ArgumentType, Decl(inferTypes1.ts, 37, 34))
|
||||
>args : Symbol(args, Decl(inferTypes1.ts, 44, 25))
|
||||
|
||||
type T24 = ArgumentType<(x: string, y: string) => number>; // Error
|
||||
>T24 : Symbol(T24, Decl(inferTypes1.ts, 41, 55))
|
||||
>ArgumentType : Symbol(ArgumentType, Decl(inferTypes1.ts, 34, 32))
|
||||
>x : Symbol(x, Decl(inferTypes1.ts, 42, 25))
|
||||
>y : Symbol(y, Decl(inferTypes1.ts, 42, 35))
|
||||
>T24 : Symbol(T24, Decl(inferTypes1.ts, 44, 55))
|
||||
>ArgumentType : Symbol(ArgumentType, Decl(inferTypes1.ts, 37, 34))
|
||||
>x : Symbol(x, Decl(inferTypes1.ts, 45, 25))
|
||||
>y : Symbol(y, Decl(inferTypes1.ts, 45, 35))
|
||||
|
||||
type T25 = ArgumentType<Function>; // Error
|
||||
>T25 : Symbol(T25, Decl(inferTypes1.ts, 42, 58))
|
||||
>ArgumentType : Symbol(ArgumentType, Decl(inferTypes1.ts, 34, 32))
|
||||
>T25 : Symbol(T25, Decl(inferTypes1.ts, 45, 58))
|
||||
>ArgumentType : Symbol(ArgumentType, Decl(inferTypes1.ts, 37, 34))
|
||||
>Function : Symbol(Function, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
|
||||
|
||||
type T26 = ArgumentType<any>; // any
|
||||
>T26 : Symbol(T26, Decl(inferTypes1.ts, 43, 34))
|
||||
>ArgumentType : Symbol(ArgumentType, Decl(inferTypes1.ts, 34, 32))
|
||||
>T26 : Symbol(T26, Decl(inferTypes1.ts, 46, 34))
|
||||
>ArgumentType : Symbol(ArgumentType, Decl(inferTypes1.ts, 37, 34))
|
||||
|
||||
type T27 = ArgumentType<never>; // any
|
||||
>T27 : Symbol(T27, Decl(inferTypes1.ts, 44, 29))
|
||||
>ArgumentType : Symbol(ArgumentType, Decl(inferTypes1.ts, 34, 32))
|
||||
>T27 : Symbol(T27, Decl(inferTypes1.ts, 47, 29))
|
||||
>ArgumentType : Symbol(ArgumentType, Decl(inferTypes1.ts, 37, 34))
|
||||
|
||||
type X1<T extends { x: any, y: any }> = T extends { x: infer X, y: infer Y } ? [X, Y] : any;
|
||||
>X1 : Symbol(X1, Decl(inferTypes1.ts, 45, 31))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 47, 8))
|
||||
>x : Symbol(x, Decl(inferTypes1.ts, 47, 19))
|
||||
>y : Symbol(y, Decl(inferTypes1.ts, 47, 27))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 47, 8))
|
||||
>x : Symbol(x, Decl(inferTypes1.ts, 47, 51))
|
||||
>X : Symbol(X, Decl(inferTypes1.ts, 47, 60))
|
||||
>y : Symbol(y, Decl(inferTypes1.ts, 47, 63))
|
||||
>Y : Symbol(Y, Decl(inferTypes1.ts, 47, 72))
|
||||
>X : Symbol(X, Decl(inferTypes1.ts, 47, 60))
|
||||
>Y : Symbol(Y, Decl(inferTypes1.ts, 47, 72))
|
||||
>X1 : Symbol(X1, Decl(inferTypes1.ts, 48, 31))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 50, 8))
|
||||
>x : Symbol(x, Decl(inferTypes1.ts, 50, 19))
|
||||
>y : Symbol(y, Decl(inferTypes1.ts, 50, 27))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 50, 8))
|
||||
>x : Symbol(x, Decl(inferTypes1.ts, 50, 51))
|
||||
>X : Symbol(X, Decl(inferTypes1.ts, 50, 60))
|
||||
>y : Symbol(y, Decl(inferTypes1.ts, 50, 63))
|
||||
>Y : Symbol(Y, Decl(inferTypes1.ts, 50, 72))
|
||||
>X : Symbol(X, Decl(inferTypes1.ts, 50, 60))
|
||||
>Y : Symbol(Y, Decl(inferTypes1.ts, 50, 72))
|
||||
|
||||
type T30 = X1<{ x: any, y: any }>; // [any, any]
|
||||
>T30 : Symbol(T30, Decl(inferTypes1.ts, 47, 92))
|
||||
>X1 : Symbol(X1, Decl(inferTypes1.ts, 45, 31))
|
||||
>x : Symbol(x, Decl(inferTypes1.ts, 49, 15))
|
||||
>y : Symbol(y, Decl(inferTypes1.ts, 49, 23))
|
||||
>T30 : Symbol(T30, Decl(inferTypes1.ts, 50, 92))
|
||||
>X1 : Symbol(X1, Decl(inferTypes1.ts, 48, 31))
|
||||
>x : Symbol(x, Decl(inferTypes1.ts, 52, 15))
|
||||
>y : Symbol(y, Decl(inferTypes1.ts, 52, 23))
|
||||
|
||||
type T31 = X1<{ x: number, y: string }>; // [number, string]
|
||||
>T31 : Symbol(T31, Decl(inferTypes1.ts, 49, 34))
|
||||
>X1 : Symbol(X1, Decl(inferTypes1.ts, 45, 31))
|
||||
>x : Symbol(x, Decl(inferTypes1.ts, 50, 15))
|
||||
>y : Symbol(y, Decl(inferTypes1.ts, 50, 26))
|
||||
>T31 : Symbol(T31, Decl(inferTypes1.ts, 52, 34))
|
||||
>X1 : Symbol(X1, Decl(inferTypes1.ts, 48, 31))
|
||||
>x : Symbol(x, Decl(inferTypes1.ts, 53, 15))
|
||||
>y : Symbol(y, Decl(inferTypes1.ts, 53, 26))
|
||||
|
||||
type T32 = X1<{ x: number, y: string, z: boolean }>; // [number, string]
|
||||
>T32 : Symbol(T32, Decl(inferTypes1.ts, 50, 40))
|
||||
>X1 : Symbol(X1, Decl(inferTypes1.ts, 45, 31))
|
||||
>x : Symbol(x, Decl(inferTypes1.ts, 51, 15))
|
||||
>y : Symbol(y, Decl(inferTypes1.ts, 51, 26))
|
||||
>z : Symbol(z, Decl(inferTypes1.ts, 51, 37))
|
||||
>T32 : Symbol(T32, Decl(inferTypes1.ts, 53, 40))
|
||||
>X1 : Symbol(X1, Decl(inferTypes1.ts, 48, 31))
|
||||
>x : Symbol(x, Decl(inferTypes1.ts, 54, 15))
|
||||
>y : Symbol(y, Decl(inferTypes1.ts, 54, 26))
|
||||
>z : Symbol(z, Decl(inferTypes1.ts, 54, 37))
|
||||
|
||||
type X2<T> = T extends { a: infer U, b: infer U } ? U : never;
|
||||
>X2 : Symbol(X2, Decl(inferTypes1.ts, 51, 52))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 53, 8))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 53, 8))
|
||||
>a : Symbol(a, Decl(inferTypes1.ts, 53, 24))
|
||||
>U : Symbol(U, Decl(inferTypes1.ts, 53, 33), Decl(inferTypes1.ts, 53, 45))
|
||||
>b : Symbol(b, Decl(inferTypes1.ts, 53, 36))
|
||||
>U : Symbol(U, Decl(inferTypes1.ts, 53, 33), Decl(inferTypes1.ts, 53, 45))
|
||||
>U : Symbol(U, Decl(inferTypes1.ts, 53, 33), Decl(inferTypes1.ts, 53, 45))
|
||||
>X2 : Symbol(X2, Decl(inferTypes1.ts, 54, 52))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 56, 8))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 56, 8))
|
||||
>a : Symbol(a, Decl(inferTypes1.ts, 56, 24))
|
||||
>U : Symbol(U, Decl(inferTypes1.ts, 56, 33), Decl(inferTypes1.ts, 56, 45))
|
||||
>b : Symbol(b, Decl(inferTypes1.ts, 56, 36))
|
||||
>U : Symbol(U, Decl(inferTypes1.ts, 56, 33), Decl(inferTypes1.ts, 56, 45))
|
||||
>U : Symbol(U, Decl(inferTypes1.ts, 56, 33), Decl(inferTypes1.ts, 56, 45))
|
||||
|
||||
type T40 = X2<{}>; // never
|
||||
>T40 : Symbol(T40, Decl(inferTypes1.ts, 53, 62))
|
||||
>X2 : Symbol(X2, Decl(inferTypes1.ts, 51, 52))
|
||||
>T40 : Symbol(T40, Decl(inferTypes1.ts, 56, 62))
|
||||
>X2 : Symbol(X2, Decl(inferTypes1.ts, 54, 52))
|
||||
|
||||
type T41 = X2<{ a: string }>; // never
|
||||
>T41 : Symbol(T41, Decl(inferTypes1.ts, 55, 18))
|
||||
>X2 : Symbol(X2, Decl(inferTypes1.ts, 51, 52))
|
||||
>a : Symbol(a, Decl(inferTypes1.ts, 56, 15))
|
||||
>T41 : Symbol(T41, Decl(inferTypes1.ts, 58, 18))
|
||||
>X2 : Symbol(X2, Decl(inferTypes1.ts, 54, 52))
|
||||
>a : Symbol(a, Decl(inferTypes1.ts, 59, 15))
|
||||
|
||||
type T42 = X2<{ a: string, b: string }>; // string
|
||||
>T42 : Symbol(T42, Decl(inferTypes1.ts, 56, 29))
|
||||
>X2 : Symbol(X2, Decl(inferTypes1.ts, 51, 52))
|
||||
>a : Symbol(a, Decl(inferTypes1.ts, 57, 15))
|
||||
>b : Symbol(b, Decl(inferTypes1.ts, 57, 26))
|
||||
>T42 : Symbol(T42, Decl(inferTypes1.ts, 59, 29))
|
||||
>X2 : Symbol(X2, Decl(inferTypes1.ts, 54, 52))
|
||||
>a : Symbol(a, Decl(inferTypes1.ts, 60, 15))
|
||||
>b : Symbol(b, Decl(inferTypes1.ts, 60, 26))
|
||||
|
||||
type T43 = X2<{ a: number, b: string }>; // string | number
|
||||
>T43 : Symbol(T43, Decl(inferTypes1.ts, 57, 40))
|
||||
>X2 : Symbol(X2, Decl(inferTypes1.ts, 51, 52))
|
||||
>a : Symbol(a, Decl(inferTypes1.ts, 58, 15))
|
||||
>b : Symbol(b, Decl(inferTypes1.ts, 58, 26))
|
||||
>T43 : Symbol(T43, Decl(inferTypes1.ts, 60, 40))
|
||||
>X2 : Symbol(X2, Decl(inferTypes1.ts, 54, 52))
|
||||
>a : Symbol(a, Decl(inferTypes1.ts, 61, 15))
|
||||
>b : Symbol(b, Decl(inferTypes1.ts, 61, 26))
|
||||
|
||||
type T44 = X2<{ a: number, b: string, c: boolean }>; // string | number
|
||||
>T44 : Symbol(T44, Decl(inferTypes1.ts, 58, 40))
|
||||
>X2 : Symbol(X2, Decl(inferTypes1.ts, 51, 52))
|
||||
>a : Symbol(a, Decl(inferTypes1.ts, 59, 15))
|
||||
>b : Symbol(b, Decl(inferTypes1.ts, 59, 26))
|
||||
>c : Symbol(c, Decl(inferTypes1.ts, 59, 37))
|
||||
>T44 : Symbol(T44, Decl(inferTypes1.ts, 61, 40))
|
||||
>X2 : Symbol(X2, Decl(inferTypes1.ts, 54, 52))
|
||||
>a : Symbol(a, Decl(inferTypes1.ts, 62, 15))
|
||||
>b : Symbol(b, Decl(inferTypes1.ts, 62, 26))
|
||||
>c : Symbol(c, Decl(inferTypes1.ts, 62, 37))
|
||||
|
||||
type X3<T> = T extends { a: (x: infer U) => void, b: (x: infer U) => void } ? U : never;
|
||||
>X3 : Symbol(X3, Decl(inferTypes1.ts, 59, 52))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 61, 8))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 61, 8))
|
||||
>a : Symbol(a, Decl(inferTypes1.ts, 61, 24))
|
||||
>x : Symbol(x, Decl(inferTypes1.ts, 61, 29))
|
||||
>U : Symbol(U, Decl(inferTypes1.ts, 61, 37), Decl(inferTypes1.ts, 61, 62))
|
||||
>b : Symbol(b, Decl(inferTypes1.ts, 61, 49))
|
||||
>x : Symbol(x, Decl(inferTypes1.ts, 61, 54))
|
||||
>U : Symbol(U, Decl(inferTypes1.ts, 61, 37), Decl(inferTypes1.ts, 61, 62))
|
||||
>U : Symbol(U, Decl(inferTypes1.ts, 61, 37), Decl(inferTypes1.ts, 61, 62))
|
||||
>X3 : Symbol(X3, Decl(inferTypes1.ts, 62, 52))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 64, 8))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 64, 8))
|
||||
>a : Symbol(a, Decl(inferTypes1.ts, 64, 24))
|
||||
>x : Symbol(x, Decl(inferTypes1.ts, 64, 29))
|
||||
>U : Symbol(U, Decl(inferTypes1.ts, 64, 37), Decl(inferTypes1.ts, 64, 62))
|
||||
>b : Symbol(b, Decl(inferTypes1.ts, 64, 49))
|
||||
>x : Symbol(x, Decl(inferTypes1.ts, 64, 54))
|
||||
>U : Symbol(U, Decl(inferTypes1.ts, 64, 37), Decl(inferTypes1.ts, 64, 62))
|
||||
>U : Symbol(U, Decl(inferTypes1.ts, 64, 37), Decl(inferTypes1.ts, 64, 62))
|
||||
|
||||
type T50 = X3<{}>; // never
|
||||
>T50 : Symbol(T50, Decl(inferTypes1.ts, 61, 88))
|
||||
>X3 : Symbol(X3, Decl(inferTypes1.ts, 59, 52))
|
||||
>T50 : Symbol(T50, Decl(inferTypes1.ts, 64, 88))
|
||||
>X3 : Symbol(X3, Decl(inferTypes1.ts, 62, 52))
|
||||
|
||||
type T51 = X3<{ a: (x: string) => void }>; // never
|
||||
>T51 : Symbol(T51, Decl(inferTypes1.ts, 63, 18))
|
||||
>X3 : Symbol(X3, Decl(inferTypes1.ts, 59, 52))
|
||||
>a : Symbol(a, Decl(inferTypes1.ts, 64, 15))
|
||||
>x : Symbol(x, Decl(inferTypes1.ts, 64, 20))
|
||||
|
||||
type T52 = X3<{ a: (x: string) => void, b: (x: string) => void }>; // string
|
||||
>T52 : Symbol(T52, Decl(inferTypes1.ts, 64, 42))
|
||||
>X3 : Symbol(X3, Decl(inferTypes1.ts, 59, 52))
|
||||
>a : Symbol(a, Decl(inferTypes1.ts, 65, 15))
|
||||
>x : Symbol(x, Decl(inferTypes1.ts, 65, 20))
|
||||
>b : Symbol(b, Decl(inferTypes1.ts, 65, 39))
|
||||
>x : Symbol(x, Decl(inferTypes1.ts, 65, 44))
|
||||
|
||||
type T53 = X3<{ a: (x: number) => void, b: (x: string) => void }>; // string & number
|
||||
>T53 : Symbol(T53, Decl(inferTypes1.ts, 65, 66))
|
||||
>X3 : Symbol(X3, Decl(inferTypes1.ts, 59, 52))
|
||||
>a : Symbol(a, Decl(inferTypes1.ts, 66, 15))
|
||||
>x : Symbol(x, Decl(inferTypes1.ts, 66, 20))
|
||||
>b : Symbol(b, Decl(inferTypes1.ts, 66, 39))
|
||||
>x : Symbol(x, Decl(inferTypes1.ts, 66, 44))
|
||||
|
||||
type T54 = X3<{ a: (x: number) => void, b: () => void }>; // number
|
||||
>T54 : Symbol(T54, Decl(inferTypes1.ts, 66, 66))
|
||||
>X3 : Symbol(X3, Decl(inferTypes1.ts, 59, 52))
|
||||
>T51 : Symbol(T51, Decl(inferTypes1.ts, 66, 18))
|
||||
>X3 : Symbol(X3, Decl(inferTypes1.ts, 62, 52))
|
||||
>a : Symbol(a, Decl(inferTypes1.ts, 67, 15))
|
||||
>x : Symbol(x, Decl(inferTypes1.ts, 67, 20))
|
||||
>b : Symbol(b, Decl(inferTypes1.ts, 67, 39))
|
||||
|
||||
type T52 = X3<{ a: (x: string) => void, b: (x: string) => void }>; // string
|
||||
>T52 : Symbol(T52, Decl(inferTypes1.ts, 67, 42))
|
||||
>X3 : Symbol(X3, Decl(inferTypes1.ts, 62, 52))
|
||||
>a : Symbol(a, Decl(inferTypes1.ts, 68, 15))
|
||||
>x : Symbol(x, Decl(inferTypes1.ts, 68, 20))
|
||||
>b : Symbol(b, Decl(inferTypes1.ts, 68, 39))
|
||||
>x : Symbol(x, Decl(inferTypes1.ts, 68, 44))
|
||||
|
||||
type T53 = X3<{ a: (x: number) => void, b: (x: string) => void }>; // string & number
|
||||
>T53 : Symbol(T53, Decl(inferTypes1.ts, 68, 66))
|
||||
>X3 : Symbol(X3, Decl(inferTypes1.ts, 62, 52))
|
||||
>a : Symbol(a, Decl(inferTypes1.ts, 69, 15))
|
||||
>x : Symbol(x, Decl(inferTypes1.ts, 69, 20))
|
||||
>b : Symbol(b, Decl(inferTypes1.ts, 69, 39))
|
||||
>x : Symbol(x, Decl(inferTypes1.ts, 69, 44))
|
||||
|
||||
type T54 = X3<{ a: (x: number) => void, b: () => void }>; // number
|
||||
>T54 : Symbol(T54, Decl(inferTypes1.ts, 69, 66))
|
||||
>X3 : Symbol(X3, Decl(inferTypes1.ts, 62, 52))
|
||||
>a : Symbol(a, Decl(inferTypes1.ts, 70, 15))
|
||||
>x : Symbol(x, Decl(inferTypes1.ts, 70, 20))
|
||||
>b : Symbol(b, Decl(inferTypes1.ts, 70, 39))
|
||||
|
||||
type T60 = infer U; // Error
|
||||
>T60 : Symbol(T60, Decl(inferTypes1.ts, 67, 57))
|
||||
>U : Symbol(U, Decl(inferTypes1.ts, 69, 16))
|
||||
>T60 : Symbol(T60, Decl(inferTypes1.ts, 70, 57))
|
||||
>U : Symbol(U, Decl(inferTypes1.ts, 72, 16))
|
||||
|
||||
type T61<T> = infer A extends infer B ? infer C : infer D; // Error
|
||||
>T61 : Symbol(T61, Decl(inferTypes1.ts, 69, 19))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 70, 9))
|
||||
>A : Symbol(A, Decl(inferTypes1.ts, 70, 19))
|
||||
>B : Symbol(B, Decl(inferTypes1.ts, 70, 35))
|
||||
>C : Symbol(C, Decl(inferTypes1.ts, 70, 45))
|
||||
>D : Symbol(D, Decl(inferTypes1.ts, 70, 55))
|
||||
>T61 : Symbol(T61, Decl(inferTypes1.ts, 72, 19))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 73, 9))
|
||||
>A : Symbol(A, Decl(inferTypes1.ts, 73, 19))
|
||||
>B : Symbol(B, Decl(inferTypes1.ts, 73, 35))
|
||||
>C : Symbol(C, Decl(inferTypes1.ts, 73, 45))
|
||||
>D : Symbol(D, Decl(inferTypes1.ts, 73, 55))
|
||||
|
||||
type T62<T> = U extends (infer U)[] ? U : U; // Error
|
||||
>T62 : Symbol(T62, Decl(inferTypes1.ts, 70, 58))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 71, 9))
|
||||
>U : Symbol(U, Decl(inferTypes1.ts, 71, 30))
|
||||
>U : Symbol(U, Decl(inferTypes1.ts, 71, 30))
|
||||
>T62 : Symbol(T62, Decl(inferTypes1.ts, 73, 58))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 74, 9))
|
||||
>U : Symbol(U, Decl(inferTypes1.ts, 74, 30))
|
||||
>U : Symbol(U, Decl(inferTypes1.ts, 74, 30))
|
||||
|
||||
type T70<T extends string> = { x: T };
|
||||
>T70 : Symbol(T70, Decl(inferTypes1.ts, 71, 44))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 73, 9))
|
||||
>x : Symbol(x, Decl(inferTypes1.ts, 73, 30))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 73, 9))
|
||||
>T70 : Symbol(T70, Decl(inferTypes1.ts, 74, 44))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 76, 9))
|
||||
>x : Symbol(x, Decl(inferTypes1.ts, 76, 30))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 76, 9))
|
||||
|
||||
type T71<T> = T extends T70<infer U> ? T70<U> : never;
|
||||
>T71 : Symbol(T71, Decl(inferTypes1.ts, 73, 38))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 74, 9))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 74, 9))
|
||||
>T70 : Symbol(T70, Decl(inferTypes1.ts, 71, 44))
|
||||
>U : Symbol(U, Decl(inferTypes1.ts, 74, 33))
|
||||
>T70 : Symbol(T70, Decl(inferTypes1.ts, 71, 44))
|
||||
>U : Symbol(U, Decl(inferTypes1.ts, 74, 33))
|
||||
>T71 : Symbol(T71, Decl(inferTypes1.ts, 76, 38))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 77, 9))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 77, 9))
|
||||
>T70 : Symbol(T70, Decl(inferTypes1.ts, 74, 44))
|
||||
>U : Symbol(U, Decl(inferTypes1.ts, 77, 33))
|
||||
>T70 : Symbol(T70, Decl(inferTypes1.ts, 74, 44))
|
||||
>U : Symbol(U, Decl(inferTypes1.ts, 77, 33))
|
||||
|
||||
type T72<T extends number> = { y: T };
|
||||
>T72 : Symbol(T72, Decl(inferTypes1.ts, 74, 54))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 76, 9))
|
||||
>y : Symbol(y, Decl(inferTypes1.ts, 76, 30))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 76, 9))
|
||||
>T72 : Symbol(T72, Decl(inferTypes1.ts, 77, 54))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 79, 9))
|
||||
>y : Symbol(y, Decl(inferTypes1.ts, 79, 30))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 79, 9))
|
||||
|
||||
type T73<T> = T extends T72<infer U> ? T70<U> : never; // Error
|
||||
>T73 : Symbol(T73, Decl(inferTypes1.ts, 76, 38))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 77, 9))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 77, 9))
|
||||
>T72 : Symbol(T72, Decl(inferTypes1.ts, 74, 54))
|
||||
>U : Symbol(U, Decl(inferTypes1.ts, 77, 33))
|
||||
>T70 : Symbol(T70, Decl(inferTypes1.ts, 71, 44))
|
||||
>U : Symbol(U, Decl(inferTypes1.ts, 77, 33))
|
||||
>T73 : Symbol(T73, Decl(inferTypes1.ts, 79, 38))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 80, 9))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 80, 9))
|
||||
>T72 : Symbol(T72, Decl(inferTypes1.ts, 77, 54))
|
||||
>U : Symbol(U, Decl(inferTypes1.ts, 80, 33))
|
||||
>T70 : Symbol(T70, Decl(inferTypes1.ts, 74, 44))
|
||||
>U : Symbol(U, Decl(inferTypes1.ts, 80, 33))
|
||||
|
||||
type T74<T extends number, U extends string> = { x: T, y: U };
|
||||
>T74 : Symbol(T74, Decl(inferTypes1.ts, 77, 54))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 79, 9))
|
||||
>U : Symbol(U, Decl(inferTypes1.ts, 79, 26))
|
||||
>x : Symbol(x, Decl(inferTypes1.ts, 79, 48))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 79, 9))
|
||||
>y : Symbol(y, Decl(inferTypes1.ts, 79, 54))
|
||||
>U : Symbol(U, Decl(inferTypes1.ts, 79, 26))
|
||||
>T74 : Symbol(T74, Decl(inferTypes1.ts, 80, 54))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 82, 9))
|
||||
>U : Symbol(U, Decl(inferTypes1.ts, 82, 26))
|
||||
>x : Symbol(x, Decl(inferTypes1.ts, 82, 48))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 82, 9))
|
||||
>y : Symbol(y, Decl(inferTypes1.ts, 82, 54))
|
||||
>U : Symbol(U, Decl(inferTypes1.ts, 82, 26))
|
||||
|
||||
type T75<T> = T extends T74<infer U, infer U> ? T70<U> | T72<U> | T74<U, U> : never;
|
||||
>T75 : Symbol(T75, Decl(inferTypes1.ts, 79, 62))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 80, 9))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 80, 9))
|
||||
>T74 : Symbol(T74, Decl(inferTypes1.ts, 77, 54))
|
||||
>U : Symbol(U, Decl(inferTypes1.ts, 80, 33), Decl(inferTypes1.ts, 80, 42))
|
||||
>U : Symbol(U, Decl(inferTypes1.ts, 80, 33), Decl(inferTypes1.ts, 80, 42))
|
||||
>T70 : Symbol(T70, Decl(inferTypes1.ts, 71, 44))
|
||||
>U : Symbol(U, Decl(inferTypes1.ts, 80, 33), Decl(inferTypes1.ts, 80, 42))
|
||||
>T72 : Symbol(T72, Decl(inferTypes1.ts, 74, 54))
|
||||
>U : Symbol(U, Decl(inferTypes1.ts, 80, 33), Decl(inferTypes1.ts, 80, 42))
|
||||
>T74 : Symbol(T74, Decl(inferTypes1.ts, 77, 54))
|
||||
>U : Symbol(U, Decl(inferTypes1.ts, 80, 33), Decl(inferTypes1.ts, 80, 42))
|
||||
>U : Symbol(U, Decl(inferTypes1.ts, 80, 33), Decl(inferTypes1.ts, 80, 42))
|
||||
>T75 : Symbol(T75, Decl(inferTypes1.ts, 82, 62))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 83, 9))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 83, 9))
|
||||
>T74 : Symbol(T74, Decl(inferTypes1.ts, 80, 54))
|
||||
>U : Symbol(U, Decl(inferTypes1.ts, 83, 33), Decl(inferTypes1.ts, 83, 42))
|
||||
>U : Symbol(U, Decl(inferTypes1.ts, 83, 33), Decl(inferTypes1.ts, 83, 42))
|
||||
>T70 : Symbol(T70, Decl(inferTypes1.ts, 74, 44))
|
||||
>U : Symbol(U, Decl(inferTypes1.ts, 83, 33), Decl(inferTypes1.ts, 83, 42))
|
||||
>T72 : Symbol(T72, Decl(inferTypes1.ts, 77, 54))
|
||||
>U : Symbol(U, Decl(inferTypes1.ts, 83, 33), Decl(inferTypes1.ts, 83, 42))
|
||||
>T74 : Symbol(T74, Decl(inferTypes1.ts, 80, 54))
|
||||
>U : Symbol(U, Decl(inferTypes1.ts, 83, 33), Decl(inferTypes1.ts, 83, 42))
|
||||
>U : Symbol(U, Decl(inferTypes1.ts, 83, 33), Decl(inferTypes1.ts, 83, 42))
|
||||
|
||||
type T76<T extends T[], U extends T> = { x: T };
|
||||
>T76 : Symbol(T76, Decl(inferTypes1.ts, 80, 84))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 82, 9))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 82, 9))
|
||||
>U : Symbol(U, Decl(inferTypes1.ts, 82, 23))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 82, 9))
|
||||
>x : Symbol(x, Decl(inferTypes1.ts, 82, 40))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 82, 9))
|
||||
>T76 : Symbol(T76, Decl(inferTypes1.ts, 83, 84))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 85, 9))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 85, 9))
|
||||
>U : Symbol(U, Decl(inferTypes1.ts, 85, 23))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 85, 9))
|
||||
>x : Symbol(x, Decl(inferTypes1.ts, 85, 40))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 85, 9))
|
||||
|
||||
type T77<T> = T extends T76<infer X, infer Y> ? T76<X, Y> : never;
|
||||
>T77 : Symbol(T77, Decl(inferTypes1.ts, 82, 48))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 83, 9))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 83, 9))
|
||||
>T76 : Symbol(T76, Decl(inferTypes1.ts, 80, 84))
|
||||
>X : Symbol(X, Decl(inferTypes1.ts, 83, 33))
|
||||
>Y : Symbol(Y, Decl(inferTypes1.ts, 83, 42))
|
||||
>T76 : Symbol(T76, Decl(inferTypes1.ts, 80, 84))
|
||||
>X : Symbol(X, Decl(inferTypes1.ts, 83, 33))
|
||||
>Y : Symbol(Y, Decl(inferTypes1.ts, 83, 42))
|
||||
>T77 : Symbol(T77, Decl(inferTypes1.ts, 85, 48))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 86, 9))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 86, 9))
|
||||
>T76 : Symbol(T76, Decl(inferTypes1.ts, 83, 84))
|
||||
>X : Symbol(X, Decl(inferTypes1.ts, 86, 33))
|
||||
>Y : Symbol(Y, Decl(inferTypes1.ts, 86, 42))
|
||||
>T76 : Symbol(T76, Decl(inferTypes1.ts, 83, 84))
|
||||
>X : Symbol(X, Decl(inferTypes1.ts, 86, 33))
|
||||
>Y : Symbol(Y, Decl(inferTypes1.ts, 86, 42))
|
||||
|
||||
type T78<T> = T extends T76<infer X, infer X> ? T76<X, X> : never;
|
||||
>T78 : Symbol(T78, Decl(inferTypes1.ts, 83, 66))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 84, 9))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 84, 9))
|
||||
>T76 : Symbol(T76, Decl(inferTypes1.ts, 80, 84))
|
||||
>X : Symbol(X, Decl(inferTypes1.ts, 84, 33), Decl(inferTypes1.ts, 84, 42))
|
||||
>X : Symbol(X, Decl(inferTypes1.ts, 84, 33), Decl(inferTypes1.ts, 84, 42))
|
||||
>T76 : Symbol(T76, Decl(inferTypes1.ts, 80, 84))
|
||||
>X : Symbol(X, Decl(inferTypes1.ts, 84, 33), Decl(inferTypes1.ts, 84, 42))
|
||||
>X : Symbol(X, Decl(inferTypes1.ts, 84, 33), Decl(inferTypes1.ts, 84, 42))
|
||||
>T78 : Symbol(T78, Decl(inferTypes1.ts, 86, 66))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 87, 9))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 87, 9))
|
||||
>T76 : Symbol(T76, Decl(inferTypes1.ts, 83, 84))
|
||||
>X : Symbol(X, Decl(inferTypes1.ts, 87, 33), Decl(inferTypes1.ts, 87, 42))
|
||||
>X : Symbol(X, Decl(inferTypes1.ts, 87, 33), Decl(inferTypes1.ts, 87, 42))
|
||||
>T76 : Symbol(T76, Decl(inferTypes1.ts, 83, 84))
|
||||
>X : Symbol(X, Decl(inferTypes1.ts, 87, 33), Decl(inferTypes1.ts, 87, 42))
|
||||
>X : Symbol(X, Decl(inferTypes1.ts, 87, 33), Decl(inferTypes1.ts, 87, 42))
|
||||
|
||||
// Example from #21496
|
||||
|
||||
type JsonifiedObject<T extends object> = { [K in keyof T]: Jsonified<T[K]> };
|
||||
>JsonifiedObject : Symbol(JsonifiedObject, Decl(inferTypes1.ts, 84, 66))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 88, 21))
|
||||
>K : Symbol(K, Decl(inferTypes1.ts, 88, 44))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 88, 21))
|
||||
>Jsonified : Symbol(Jsonified, Decl(inferTypes1.ts, 88, 77))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 88, 21))
|
||||
>K : Symbol(K, Decl(inferTypes1.ts, 88, 44))
|
||||
>JsonifiedObject : Symbol(JsonifiedObject, Decl(inferTypes1.ts, 87, 66))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 91, 21))
|
||||
>K : Symbol(K, Decl(inferTypes1.ts, 91, 44))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 91, 21))
|
||||
>Jsonified : Symbol(Jsonified, Decl(inferTypes1.ts, 91, 77))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 91, 21))
|
||||
>K : Symbol(K, Decl(inferTypes1.ts, 91, 44))
|
||||
|
||||
type Jsonified<T> =
|
||||
>Jsonified : Symbol(Jsonified, Decl(inferTypes1.ts, 88, 77))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 90, 15))
|
||||
>Jsonified : Symbol(Jsonified, Decl(inferTypes1.ts, 91, 77))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 93, 15))
|
||||
|
||||
T extends string | number | boolean | null ? T
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 90, 15))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 90, 15))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 93, 15))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 93, 15))
|
||||
|
||||
: T extends undefined | Function ? never // undefined and functions are removed
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 90, 15))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 93, 15))
|
||||
>Function : Symbol(Function, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
|
||||
|
||||
: T extends { toJSON(): infer R } ? R // toJSON is called if it exists (e.g. Date)
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 90, 15))
|
||||
>toJSON : Symbol(toJSON, Decl(inferTypes1.ts, 93, 17))
|
||||
>R : Symbol(R, Decl(inferTypes1.ts, 93, 33))
|
||||
>R : Symbol(R, Decl(inferTypes1.ts, 93, 33))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 93, 15))
|
||||
>toJSON : Symbol(toJSON, Decl(inferTypes1.ts, 96, 17))
|
||||
>R : Symbol(R, Decl(inferTypes1.ts, 96, 33))
|
||||
>R : Symbol(R, Decl(inferTypes1.ts, 96, 33))
|
||||
|
||||
: T extends object ? JsonifiedObject<T>
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 90, 15))
|
||||
>JsonifiedObject : Symbol(JsonifiedObject, Decl(inferTypes1.ts, 84, 66))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 90, 15))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 93, 15))
|
||||
>JsonifiedObject : Symbol(JsonifiedObject, Decl(inferTypes1.ts, 87, 66))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 93, 15))
|
||||
|
||||
: "what is this";
|
||||
|
||||
type Example = {
|
||||
>Example : Symbol(Example, Decl(inferTypes1.ts, 95, 21))
|
||||
>Example : Symbol(Example, Decl(inferTypes1.ts, 98, 21))
|
||||
|
||||
str: "literalstring",
|
||||
>str : Symbol(str, Decl(inferTypes1.ts, 97, 16))
|
||||
>str : Symbol(str, Decl(inferTypes1.ts, 100, 16))
|
||||
|
||||
fn: () => void,
|
||||
>fn : Symbol(fn, Decl(inferTypes1.ts, 98, 25))
|
||||
>fn : Symbol(fn, Decl(inferTypes1.ts, 101, 25))
|
||||
|
||||
date: Date,
|
||||
>date : Symbol(date, Decl(inferTypes1.ts, 99, 19))
|
||||
>date : Symbol(date, Decl(inferTypes1.ts, 102, 19))
|
||||
>Date : Symbol(Date, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
|
||||
|
||||
customClass: MyClass,
|
||||
>customClass : Symbol(customClass, Decl(inferTypes1.ts, 100, 15))
|
||||
>MyClass : Symbol(MyClass, Decl(inferTypes1.ts, 107, 1))
|
||||
>customClass : Symbol(customClass, Decl(inferTypes1.ts, 103, 15))
|
||||
>MyClass : Symbol(MyClass, Decl(inferTypes1.ts, 110, 1))
|
||||
|
||||
obj: {
|
||||
>obj : Symbol(obj, Decl(inferTypes1.ts, 101, 25))
|
||||
>obj : Symbol(obj, Decl(inferTypes1.ts, 104, 25))
|
||||
|
||||
prop: "property",
|
||||
>prop : Symbol(prop, Decl(inferTypes1.ts, 102, 10))
|
||||
>prop : Symbol(prop, Decl(inferTypes1.ts, 105, 10))
|
||||
|
||||
clz: MyClass,
|
||||
>clz : Symbol(clz, Decl(inferTypes1.ts, 103, 25))
|
||||
>MyClass : Symbol(MyClass, Decl(inferTypes1.ts, 107, 1))
|
||||
>clz : Symbol(clz, Decl(inferTypes1.ts, 106, 25))
|
||||
>MyClass : Symbol(MyClass, Decl(inferTypes1.ts, 110, 1))
|
||||
|
||||
nested: { attr: Date }
|
||||
>nested : Symbol(nested, Decl(inferTypes1.ts, 104, 21))
|
||||
>attr : Symbol(attr, Decl(inferTypes1.ts, 105, 17))
|
||||
>nested : Symbol(nested, Decl(inferTypes1.ts, 107, 21))
|
||||
>attr : Symbol(attr, Decl(inferTypes1.ts, 108, 17))
|
||||
>Date : Symbol(Date, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
|
||||
|
||||
},
|
||||
}
|
||||
|
||||
declare class MyClass {
|
||||
>MyClass : Symbol(MyClass, Decl(inferTypes1.ts, 107, 1))
|
||||
>MyClass : Symbol(MyClass, Decl(inferTypes1.ts, 110, 1))
|
||||
|
||||
toJSON(): "correct";
|
||||
>toJSON : Symbol(MyClass.toJSON, Decl(inferTypes1.ts, 109, 23))
|
||||
>toJSON : Symbol(MyClass.toJSON, Decl(inferTypes1.ts, 112, 23))
|
||||
}
|
||||
|
||||
type JsonifiedExample = Jsonified<Example>;
|
||||
>JsonifiedExample : Symbol(JsonifiedExample, Decl(inferTypes1.ts, 111, 1))
|
||||
>Jsonified : Symbol(Jsonified, Decl(inferTypes1.ts, 88, 77))
|
||||
>Example : Symbol(Example, Decl(inferTypes1.ts, 95, 21))
|
||||
>JsonifiedExample : Symbol(JsonifiedExample, Decl(inferTypes1.ts, 114, 1))
|
||||
>Jsonified : Symbol(Jsonified, Decl(inferTypes1.ts, 91, 77))
|
||||
>Example : Symbol(Example, Decl(inferTypes1.ts, 98, 21))
|
||||
|
||||
declare let ex: JsonifiedExample;
|
||||
>ex : Symbol(ex, Decl(inferTypes1.ts, 114, 11))
|
||||
>JsonifiedExample : Symbol(JsonifiedExample, Decl(inferTypes1.ts, 111, 1))
|
||||
>ex : Symbol(ex, Decl(inferTypes1.ts, 117, 11))
|
||||
>JsonifiedExample : Symbol(JsonifiedExample, Decl(inferTypes1.ts, 114, 1))
|
||||
|
||||
const z1: "correct" = ex.customClass;
|
||||
>z1 : Symbol(z1, Decl(inferTypes1.ts, 115, 5))
|
||||
>ex.customClass : Symbol(customClass, Decl(inferTypes1.ts, 100, 15))
|
||||
>ex : Symbol(ex, Decl(inferTypes1.ts, 114, 11))
|
||||
>customClass : Symbol(customClass, Decl(inferTypes1.ts, 100, 15))
|
||||
>z1 : Symbol(z1, Decl(inferTypes1.ts, 118, 5))
|
||||
>ex.customClass : Symbol(customClass, Decl(inferTypes1.ts, 103, 15))
|
||||
>ex : Symbol(ex, Decl(inferTypes1.ts, 117, 11))
|
||||
>customClass : Symbol(customClass, Decl(inferTypes1.ts, 103, 15))
|
||||
|
||||
const z2: string = ex.obj.nested.attr;
|
||||
>z2 : Symbol(z2, Decl(inferTypes1.ts, 116, 5))
|
||||
>ex.obj.nested.attr : Symbol(attr, Decl(inferTypes1.ts, 105, 17))
|
||||
>ex.obj.nested : Symbol(nested, Decl(inferTypes1.ts, 104, 21))
|
||||
>ex.obj : Symbol(obj, Decl(inferTypes1.ts, 101, 25))
|
||||
>ex : Symbol(ex, Decl(inferTypes1.ts, 114, 11))
|
||||
>obj : Symbol(obj, Decl(inferTypes1.ts, 101, 25))
|
||||
>nested : Symbol(nested, Decl(inferTypes1.ts, 104, 21))
|
||||
>attr : Symbol(attr, Decl(inferTypes1.ts, 105, 17))
|
||||
>z2 : Symbol(z2, Decl(inferTypes1.ts, 119, 5))
|
||||
>ex.obj.nested.attr : Symbol(attr, Decl(inferTypes1.ts, 108, 17))
|
||||
>ex.obj.nested : Symbol(nested, Decl(inferTypes1.ts, 107, 21))
|
||||
>ex.obj : Symbol(obj, Decl(inferTypes1.ts, 104, 25))
|
||||
>ex : Symbol(ex, Decl(inferTypes1.ts, 117, 11))
|
||||
>obj : Symbol(obj, Decl(inferTypes1.ts, 104, 25))
|
||||
>nested : Symbol(nested, Decl(inferTypes1.ts, 107, 21))
|
||||
>attr : Symbol(attr, Decl(inferTypes1.ts, 108, 17))
|
||||
|
||||
// Repros from #21631
|
||||
|
||||
type A1<T, U extends A1<any, any>> = [T, U];
|
||||
>A1 : Symbol(A1, Decl(inferTypes1.ts, 116, 38))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 120, 8))
|
||||
>U : Symbol(U, Decl(inferTypes1.ts, 120, 10))
|
||||
>A1 : Symbol(A1, Decl(inferTypes1.ts, 116, 38))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 120, 8))
|
||||
>U : Symbol(U, Decl(inferTypes1.ts, 120, 10))
|
||||
>A1 : Symbol(A1, Decl(inferTypes1.ts, 119, 38))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 123, 8))
|
||||
>U : Symbol(U, Decl(inferTypes1.ts, 123, 10))
|
||||
>A1 : Symbol(A1, Decl(inferTypes1.ts, 119, 38))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 123, 8))
|
||||
>U : Symbol(U, Decl(inferTypes1.ts, 123, 10))
|
||||
|
||||
type B1<S> = S extends A1<infer T, infer U> ? [T, U] : never;
|
||||
>B1 : Symbol(B1, Decl(inferTypes1.ts, 120, 44))
|
||||
>S : Symbol(S, Decl(inferTypes1.ts, 121, 8))
|
||||
>S : Symbol(S, Decl(inferTypes1.ts, 121, 8))
|
||||
>A1 : Symbol(A1, Decl(inferTypes1.ts, 116, 38))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 121, 31))
|
||||
>U : Symbol(U, Decl(inferTypes1.ts, 121, 40))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 121, 31))
|
||||
>U : Symbol(U, Decl(inferTypes1.ts, 121, 40))
|
||||
>B1 : Symbol(B1, Decl(inferTypes1.ts, 123, 44))
|
||||
>S : Symbol(S, Decl(inferTypes1.ts, 124, 8))
|
||||
>S : Symbol(S, Decl(inferTypes1.ts, 124, 8))
|
||||
>A1 : Symbol(A1, Decl(inferTypes1.ts, 119, 38))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 124, 31))
|
||||
>U : Symbol(U, Decl(inferTypes1.ts, 124, 40))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 124, 31))
|
||||
>U : Symbol(U, Decl(inferTypes1.ts, 124, 40))
|
||||
|
||||
type A2<T, U extends void> = [T, U];
|
||||
>A2 : Symbol(A2, Decl(inferTypes1.ts, 121, 61))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 123, 8))
|
||||
>U : Symbol(U, Decl(inferTypes1.ts, 123, 10))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 123, 8))
|
||||
>U : Symbol(U, Decl(inferTypes1.ts, 123, 10))
|
||||
>A2 : Symbol(A2, Decl(inferTypes1.ts, 124, 61))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 126, 8))
|
||||
>U : Symbol(U, Decl(inferTypes1.ts, 126, 10))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 126, 8))
|
||||
>U : Symbol(U, Decl(inferTypes1.ts, 126, 10))
|
||||
|
||||
type B2<S> = S extends A2<infer T, infer U> ? [T, U] : never;
|
||||
>B2 : Symbol(B2, Decl(inferTypes1.ts, 123, 36))
|
||||
>S : Symbol(S, Decl(inferTypes1.ts, 124, 8))
|
||||
>S : Symbol(S, Decl(inferTypes1.ts, 124, 8))
|
||||
>A2 : Symbol(A2, Decl(inferTypes1.ts, 121, 61))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 124, 31))
|
||||
>U : Symbol(U, Decl(inferTypes1.ts, 124, 40))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 124, 31))
|
||||
>U : Symbol(U, Decl(inferTypes1.ts, 124, 40))
|
||||
>B2 : Symbol(B2, Decl(inferTypes1.ts, 126, 36))
|
||||
>S : Symbol(S, Decl(inferTypes1.ts, 127, 8))
|
||||
>S : Symbol(S, Decl(inferTypes1.ts, 127, 8))
|
||||
>A2 : Symbol(A2, Decl(inferTypes1.ts, 124, 61))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 127, 31))
|
||||
>U : Symbol(U, Decl(inferTypes1.ts, 127, 40))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 127, 31))
|
||||
>U : Symbol(U, Decl(inferTypes1.ts, 127, 40))
|
||||
|
||||
type C2<S, U extends void> = S extends A2<infer T, U> ? [T, U] : never;
|
||||
>C2 : Symbol(C2, Decl(inferTypes1.ts, 124, 61))
|
||||
>S : Symbol(S, Decl(inferTypes1.ts, 125, 8))
|
||||
>U : Symbol(U, Decl(inferTypes1.ts, 125, 10))
|
||||
>S : Symbol(S, Decl(inferTypes1.ts, 125, 8))
|
||||
>A2 : Symbol(A2, Decl(inferTypes1.ts, 121, 61))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 125, 47))
|
||||
>U : Symbol(U, Decl(inferTypes1.ts, 125, 10))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 125, 47))
|
||||
>U : Symbol(U, Decl(inferTypes1.ts, 125, 10))
|
||||
>C2 : Symbol(C2, Decl(inferTypes1.ts, 127, 61))
|
||||
>S : Symbol(S, Decl(inferTypes1.ts, 128, 8))
|
||||
>U : Symbol(U, Decl(inferTypes1.ts, 128, 10))
|
||||
>S : Symbol(S, Decl(inferTypes1.ts, 128, 8))
|
||||
>A2 : Symbol(A2, Decl(inferTypes1.ts, 124, 61))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 128, 47))
|
||||
>U : Symbol(U, Decl(inferTypes1.ts, 128, 10))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 128, 47))
|
||||
>U : Symbol(U, Decl(inferTypes1.ts, 128, 10))
|
||||
|
||||
// Repro from #21735
|
||||
|
||||
type A<T> = T extends string ? { [P in T]: void; } : T;
|
||||
>A : Symbol(A, Decl(inferTypes1.ts, 125, 71))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 129, 7))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 129, 7))
|
||||
>P : Symbol(P, Decl(inferTypes1.ts, 129, 34))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 129, 7))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 129, 7))
|
||||
>A : Symbol(A, Decl(inferTypes1.ts, 128, 71))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 132, 7))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 132, 7))
|
||||
>P : Symbol(P, Decl(inferTypes1.ts, 132, 34))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 132, 7))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 132, 7))
|
||||
|
||||
type B<T> = string extends T ? { [P in T]: void; } : T; // Error
|
||||
>B : Symbol(B, Decl(inferTypes1.ts, 129, 55))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 130, 7))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 130, 7))
|
||||
>P : Symbol(P, Decl(inferTypes1.ts, 130, 34))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 130, 7))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 130, 7))
|
||||
>B : Symbol(B, Decl(inferTypes1.ts, 132, 55))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 133, 7))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 133, 7))
|
||||
>P : Symbol(P, Decl(inferTypes1.ts, 133, 34))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 133, 7))
|
||||
>T : Symbol(T, Decl(inferTypes1.ts, 133, 7))
|
||||
|
||||
|
||||
@@ -54,17 +54,6 @@ type T06 = Unpacked<never>; // never
|
||||
>T06 : never
|
||||
>Unpacked : Unpacked<T>
|
||||
|
||||
type ReturnType<T extends Function> = T extends ((...args: any[]) => infer R) | (new (...args: any[]) => infer R) ? R : any;
|
||||
>ReturnType : ReturnType<T>
|
||||
>T : T
|
||||
>Function : Function
|
||||
>T : T
|
||||
>args : any[]
|
||||
>R : R
|
||||
>args : any[]
|
||||
>R : R
|
||||
>R : R
|
||||
|
||||
function f1(s: string) {
|
||||
>f1 : (s: string) => { a: number; b: string; }
|
||||
>s : string
|
||||
@@ -117,26 +106,43 @@ type T14 = ReturnType<typeof f1>; // { a: number, b: string }
|
||||
>ReturnType : ReturnType<T>
|
||||
>f1 : (s: string) => { a: number; b: string; }
|
||||
|
||||
type T15 = ReturnType<typeof C>; // C
|
||||
>T15 : C
|
||||
type T15 = ReturnType<any>; // any
|
||||
>T15 : any
|
||||
>ReturnType : ReturnType<T>
|
||||
>C : typeof C
|
||||
|
||||
type T16 = ReturnType<any>; // any
|
||||
type T16 = ReturnType<never>; // any
|
||||
>T16 : any
|
||||
>ReturnType : ReturnType<T>
|
||||
|
||||
type T17 = ReturnType<never>; // any
|
||||
type T17 = ReturnType<string>; // Error
|
||||
>T17 : any
|
||||
>ReturnType : ReturnType<T>
|
||||
|
||||
type T18 = ReturnType<string>; // Error
|
||||
type T18 = ReturnType<Function>; // Error
|
||||
>T18 : any
|
||||
>ReturnType : ReturnType<T>
|
||||
>Function : Function
|
||||
|
||||
type T19 = ReturnType<Function>; // any
|
||||
>T19 : any
|
||||
>ReturnType : ReturnType<T>
|
||||
type U10 = InstanceType<typeof C>; // C
|
||||
>U10 : C
|
||||
>InstanceType : InstanceType<T>
|
||||
>C : typeof C
|
||||
|
||||
type U11 = InstanceType<any>; // any
|
||||
>U11 : any
|
||||
>InstanceType : InstanceType<T>
|
||||
|
||||
type U12 = InstanceType<never>; // any
|
||||
>U12 : any
|
||||
>InstanceType : InstanceType<T>
|
||||
|
||||
type U13 = InstanceType<string>; // Error
|
||||
>U13 : any
|
||||
>InstanceType : InstanceType<T>
|
||||
|
||||
type U14 = InstanceType<Function>; // Error
|
||||
>U14 : any
|
||||
>InstanceType : InstanceType<T>
|
||||
>Function : Function
|
||||
|
||||
type ArgumentType<T extends (x: any) => any> = T extends (a: infer A) => any ? A : any;
|
||||
|
||||
@@ -9,4 +9,8 @@ var z = 3; // comment 4
|
||||
|
||||
===MODIFIED===
|
||||
|
||||
var x = 1;var z = 3; // comment 4
|
||||
var x = 1; // some comment - 1
|
||||
/**
|
||||
* comment 2
|
||||
*/
|
||||
var z = 3; // comment 4
|
||||
|
||||
@@ -9,5 +9,9 @@ var z = 3; // comment 4
|
||||
|
||||
===MODIFIED===
|
||||
|
||||
var x = 1; // comment 3
|
||||
var x = 1; // some comment - 1
|
||||
/**
|
||||
* comment 2
|
||||
*/
|
||||
// comment 3
|
||||
var z = 3; // comment 4
|
||||
|
||||
@@ -11,5 +11,7 @@ var a = 4; // comment 7
|
||||
===MODIFIED===
|
||||
|
||||
// comment 1
|
||||
var x = 1;// comment 6
|
||||
var x = 1; // comment 2
|
||||
// comment 3
|
||||
// comment 6
|
||||
var a = 4; // comment 7
|
||||
|
||||
@@ -11,6 +11,8 @@ var a = 4; // comment 7
|
||||
===MODIFIED===
|
||||
|
||||
// comment 1
|
||||
var x = 1; // comment 5
|
||||
var x = 1; // comment 2
|
||||
// comment 3
|
||||
// comment 5
|
||||
// comment 6
|
||||
var a = 4; // comment 7
|
||||
|
||||
@@ -10,7 +10,9 @@ var a = 4; // comment 7
|
||||
===MODIFIED===
|
||||
|
||||
// comment 1
|
||||
var x = 1;
|
||||
var x = 1; // comment 2
|
||||
// comment 3
|
||||
|
||||
public class class1 implements interface1
|
||||
{
|
||||
property1: boolean;
|
||||
|
||||
@@ -10,7 +10,9 @@ var a = 4; // comment 7
|
||||
===MODIFIED===
|
||||
|
||||
// comment 1
|
||||
var x = 1;public class class1 implements interface1
|
||||
var x = 1; // comment 2
|
||||
// comment 3
|
||||
public class class1 implements interface1
|
||||
{
|
||||
property1: boolean;
|
||||
} // comment 4
|
||||
|
||||
@@ -8,6 +8,8 @@ var z = 3; // comment 5
|
||||
// comment 6
|
||||
var a = 4; // comment 7
|
||||
===MODIFIED===
|
||||
|
||||
// comment 1
|
||||
public class class1 implements interface1
|
||||
{
|
||||
property1: boolean;
|
||||
|
||||
@@ -10,7 +10,9 @@ var a = 4; // comment 7
|
||||
===MODIFIED===
|
||||
|
||||
// comment 1
|
||||
var x = 1;
|
||||
var x = 1; // comment 2
|
||||
// comment 3
|
||||
|
||||
public class class1 implements interface1
|
||||
{
|
||||
property1: boolean;
|
||||
|
||||
@@ -10,7 +10,9 @@ var a = 4; // comment 7
|
||||
===MODIFIED===
|
||||
|
||||
// comment 1
|
||||
var x = 1;public class class1 implements interface1
|
||||
var x = 1; // comment 2
|
||||
// comment 3
|
||||
public class class1 implements interface1
|
||||
{
|
||||
property1: boolean;
|
||||
} // comment 5
|
||||
|
||||
@@ -1,15 +1,11 @@
|
||||
// @strict: true
|
||||
// @declaration: true
|
||||
|
||||
type Diff<T, U> = T extends U ? never : T;
|
||||
type Filter<T, U> = T extends U ? T : never;
|
||||
type NonNullable<T> = Diff<T, null | undefined>;
|
||||
type T00 = Exclude<"a" | "b" | "c" | "d", "a" | "c" | "f">; // "b" | "d"
|
||||
type T01 = Extract<"a" | "b" | "c" | "d", "a" | "c" | "f">; // "a" | "c"
|
||||
|
||||
type T00 = Diff<"a" | "b" | "c" | "d", "a" | "c" | "f">; // "b" | "d"
|
||||
type T01 = Filter<"a" | "b" | "c" | "d", "a" | "c" | "f">; // "a" | "c"
|
||||
|
||||
type T02 = Diff<string | number | (() => void), Function>; // string | number
|
||||
type T03 = Filter<string | number | (() => void), Function>; // () => void
|
||||
type T02 = Exclude<string | number | (() => void), Function>; // string | number
|
||||
type T03 = Extract<string | number | (() => void), Function>; // () => void
|
||||
|
||||
type T04 = NonNullable<string | number | undefined>; // string | number
|
||||
type T05 = NonNullable<(() => string) | string[] | null | undefined>; // (() => string) | string[]
|
||||
@@ -40,23 +36,23 @@ function f4<T extends { x: string | undefined }>(x: T["x"], y: NonNullable<T["x"
|
||||
|
||||
type Options = { k: "a", a: number } | { k: "b", b: string } | { k: "c", c: boolean };
|
||||
|
||||
type T10 = Diff<Options, { k: "a" | "b" }>; // { k: "c", c: boolean }
|
||||
type T11 = Filter<Options, { k: "a" | "b" }>; // { k: "a", a: number } | { k: "b", b: string }
|
||||
type T10 = Exclude<Options, { k: "a" | "b" }>; // { k: "c", c: boolean }
|
||||
type T11 = Extract<Options, { k: "a" | "b" }>; // { k: "a", a: number } | { k: "b", b: string }
|
||||
|
||||
type T12 = Diff<Options, { k: "a" } | { k: "b" }>; // { k: "c", c: boolean }
|
||||
type T13 = Filter<Options, { k: "a" } | { k: "b" }>; // { k: "a", a: number } | { k: "b", b: string }
|
||||
type T12 = Exclude<Options, { k: "a" } | { k: "b" }>; // { k: "c", c: boolean }
|
||||
type T13 = Extract<Options, { k: "a" } | { k: "b" }>; // { k: "a", a: number } | { k: "b", b: string }
|
||||
|
||||
type T14 = Diff<Options, { q: "a" }>; // Options
|
||||
type T15 = Filter<Options, { q: "a" }>; // never
|
||||
type T14 = Exclude<Options, { q: "a" }>; // Options
|
||||
type T15 = Extract<Options, { q: "a" }>; // never
|
||||
|
||||
declare function f5<T extends Options, K extends string>(p: K): Filter<T, { k: K }>;
|
||||
declare function f5<T extends Options, K extends string>(p: K): Extract<T, { k: K }>;
|
||||
let x0 = f5("a"); // { k: "a", a: number }
|
||||
|
||||
type OptionsOfKind<K extends Options["k"]> = Filter<Options, { k: K }>;
|
||||
type OptionsOfKind<K extends Options["k"]> = Extract<Options, { k: K }>;
|
||||
|
||||
type T16 = OptionsOfKind<"a" | "b">; // { k: "a", a: number } | { k: "b", b: string }
|
||||
|
||||
type Select<T, K extends keyof T, V extends T[K]> = Filter<T, { [P in K]: V }>;
|
||||
type Select<T, K extends keyof T, V extends T[K]> = Extract<T, { [P in K]: V }>;
|
||||
|
||||
type T17 = Select<Options, "k", "a" | "b">; // // { k: "a", a: number } | { k: "b", b: string }
|
||||
|
||||
|
||||
@@ -15,8 +15,6 @@ type T04 = Unpacked<Unpacked<Promise<string>[]>>; // string
|
||||
type T05 = Unpacked<any>; // any
|
||||
type T06 = Unpacked<never>; // never
|
||||
|
||||
type ReturnType<T extends Function> = T extends ((...args: any[]) => infer R) | (new (...args: any[]) => infer R) ? R : any;
|
||||
|
||||
function f1(s: string) {
|
||||
return { a: 1, b: s };
|
||||
}
|
||||
@@ -31,11 +29,16 @@ type T11 = ReturnType<(s: string) => void>; // void
|
||||
type T12 = ReturnType<(<T>() => T)>; // {}
|
||||
type T13 = ReturnType<(<T extends U, U extends number[]>() => T)>; // number[]
|
||||
type T14 = ReturnType<typeof f1>; // { a: number, b: string }
|
||||
type T15 = ReturnType<typeof C>; // C
|
||||
type T16 = ReturnType<any>; // any
|
||||
type T17 = ReturnType<never>; // any
|
||||
type T18 = ReturnType<string>; // Error
|
||||
type T19 = ReturnType<Function>; // any
|
||||
type T15 = ReturnType<any>; // any
|
||||
type T16 = ReturnType<never>; // any
|
||||
type T17 = ReturnType<string>; // Error
|
||||
type T18 = ReturnType<Function>; // Error
|
||||
|
||||
type U10 = InstanceType<typeof C>; // C
|
||||
type U11 = InstanceType<any>; // any
|
||||
type U12 = InstanceType<never>; // any
|
||||
type U13 = InstanceType<string>; // Error
|
||||
type U14 = InstanceType<Function>; // Error
|
||||
|
||||
type ArgumentType<T extends (x: any) => any> = T extends (a: infer A) => any ? A : any;
|
||||
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
/// <reference path="fourslash.ts" />
|
||||
|
||||
////function f() {
|
||||
//// class C {}
|
||||
//// return (c: C) => void;
|
||||
////}
|
||||
////f()(new /**/);
|
||||
|
||||
goTo.marker("");
|
||||
verify.not.completionListContains("C"); // Not accessible
|
||||
@@ -0,0 +1,8 @@
|
||||
/// <reference path="fourslash.ts" />
|
||||
|
||||
////{
|
||||
//// export const [|{| "isWriteAccess": true, "isDefinition": true |}x|] = 0;
|
||||
//// [|x|];
|
||||
////}
|
||||
|
||||
verify.singleReferenceGroup("const x: 0");
|
||||
@@ -0,0 +1,6 @@
|
||||
/// <reference path='fourslash.ts' />
|
||||
|
||||
// @Filename: /a.ts
|
||||
////export { [|{| "isWriteAccess": true, "isDefinition": true |}x|] };
|
||||
|
||||
verify.singleReferenceGroup("import x");
|
||||
@@ -0,0 +1,6 @@
|
||||
/// <reference path='fourslash.ts' />
|
||||
|
||||
// @Filename: /a.ts
|
||||
////export { [|{| "isWriteAccess": true, "isDefinition": true |}x|] } from "nonsense";
|
||||
|
||||
verify.singleReferenceGroup("import x");
|
||||
@@ -0,0 +1,9 @@
|
||||
/// <reference path='fourslash.ts' />
|
||||
|
||||
// @allowJs: true
|
||||
|
||||
// @Filename: /a.js
|
||||
////c[|o|]nst;
|
||||
////require("x");
|
||||
|
||||
goTo.eachRange(() => verify.not.refactorAvailable("Convert to ES6 module"));
|
||||
Reference in New Issue
Block a user